use of org.awesomeapp.messenger.service.IChatSessionManager in project Zom-Android by zom.
the class ContactsListFragment method deleteContact.
private static void deleteContact(Activity activity, long itemId, String address, long providerId, long accountId) {
try {
IImConnection mConn;
ImApp app = ((ImApp) activity.getApplication());
mConn = app.getConnection(providerId, accountId);
// first leave, delete an existing chat session
IChatSessionManager sessionMgr = mConn.getChatSessionManager();
if (sessionMgr != null) {
IChatSession session = sessionMgr.getChatSession(Address.stripResource(address));
}
// then delete the contact from our list
IContactListManager manager = mConn.getContactListManager();
int res = manager.removeContact(address);
if (res != ImErrorInfo.NO_ERROR) {
// mHandler.showAlert(R.string.error,
// ErrorResUtils.getErrorRes(getResources(), res, address));
}
} catch (RemoteException re) {
}
}
use of org.awesomeapp.messenger.service.IChatSessionManager in project Zom-Android by zom.
the class ContactDisplayActivity method startChat.
public void startChat() {
if (mConn == null)
return;
try {
IChatSessionManager manager = mConn.getChatSessionManager();
if (manager != null) {
IChatSession session = manager.getChatSession(mUsername);
if (session == null) {
new ChatSessionInitTask(((ImApp) getApplication()), mProviderId, mAccountId, Imps.Contacts.TYPE_NORMAL, false) {
@Override
protected void onPostExecute(Long chatId) {
super.onPostExecute(chatId);
if (mContactId == -1) {
Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
intent.putExtra("id", chatId);
startActivity(intent);
finish();
}
}
}.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(mUsername)));
// Toast.makeText(this, getString(R.string.message_waiting_for_friend), Toast.LENGTH_LONG).show();
} else {
Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
intent.putExtra("id", session.getId());
startActivity(intent);
finish();
}
}
} catch (RemoteException re) {
}
if (mContactId != -1) {
Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
intent.putExtra("id", mContactId);
startActivity(intent);
finish();
}
}
use of org.awesomeapp.messenger.service.IChatSessionManager in project Zom-Android by zom.
the class ContactDisplayActivity method initSmp.
private void initSmp(String question, String answer) {
try {
IChatSessionManager manager = mConn.getChatSessionManager();
IChatSession session = manager.getChatSession(mUsername);
IOtrChatSession iOtrSession = session.getDefaultOtrChatSession();
iOtrSession.initSmpVerification(question, answer);
} catch (RemoteException e) {
Log.e(ImApp.LOG_TAG, "error init SMP", e);
}
}
use of org.awesomeapp.messenger.service.IChatSessionManager in project Zom-Android by zom.
the class GroupDisplayActivity method inviteContacts.
public void inviteContacts(ArrayList<String> invitees) {
if (mConn == null)
return;
try {
IChatSessionManager manager = mConn.getChatSessionManager();
IChatSession session = manager.getChatSession(mAddress);
for (String invitee : invitees) {
session.inviteContact(invitee);
GroupMemberDisplay member = new GroupMemberDisplay();
XmppAddress address = new XmppAddress(invitee);
member.username = address.getBareAddress();
member.nickname = address.getUser();
try {
member.avatar = DatabaseUtils.getAvatarFromAddress(getContentResolver(), member.username, ImApp.SMALL_AVATAR_WIDTH, ImApp.SMALL_AVATAR_HEIGHT);
} catch (DecoderException e) {
e.printStackTrace();
}
mMembers.add(member);
}
mRecyclerView.getAdapter().notifyDataSetChanged();
} catch (Exception e) {
Log.e(ImApp.LOG_TAG, "error inviting contacts to group", e);
}
}
use of org.awesomeapp.messenger.service.IChatSessionManager in project Zom-Android by zom.
the class ImApp method getChatSession.
public IChatSession getChatSession(long providerId, long accountId, String remoteAddress) {
IImConnection conn = getConnection(providerId, accountId);
IChatSessionManager chatSessionManager = null;
if (conn != null) {
try {
chatSessionManager = conn.getChatSessionManager();
} catch (RemoteException e) {
Log.e(LOG_TAG, "error in getting ChatSessionManager", e);
}
}
if (chatSessionManager != null) {
try {
return chatSessionManager.getChatSession(remoteAddress);
} catch (RemoteException e) {
Log.e(LOG_TAG, "error in getting ChatSession", e);
}
}
return null;
}
Aggregations