use of org.awesomeapp.messenger.service.IChatSession in project Zom-Android by zom.
the class ImUrlActivity method sendOtrInBand.
private void sendOtrInBand(String username, long providerId, long accountId) {
try {
IImConnection conn = ((ImApp) getApplication()).getConnection(providerId, accountId);
if (conn == null)
// can't send without a connection
return;
mChatSessionManager = conn.getChatSessionManager();
IChatSession session = getChatSession(username);
if (mSendText != null)
session.sendMessage(mSendText, false);
else if (mSendUri != null) {
try {
String offerId = UUID.randomUUID().toString();
// Log.i(TAG, "mSendUrl " +mSendUrl);
Uri vfsUri = null;
if (SecureMediaStore.isVfsUri(mSendUri)) {
vfsUri = mSendUri;
boolean sent = session.offerData(offerId, vfsUri.toString(), mSendType);
if (sent)
return;
} else {
InputStream is = getContentResolver().openInputStream(mSendUri);
String fileName = mSendUri.getLastPathSegment();
FileInfo importInfo = SystemServices.getFileInfoFromURI(this, mSendUri);
if (!TextUtils.isEmpty(importInfo.type)) {
if (importInfo.type.startsWith("image"))
vfsUri = SecureMediaStore.resizeAndImportImage(this, session.getId() + "", mSendUri, importInfo.type);
else
vfsUri = SecureMediaStore.importContent(session.getId() + "", fileName, is);
boolean sent = session.offerData(offerId, vfsUri.toString(), importInfo.type);
if (sent)
return;
}
}
} catch (Exception e) {
Log.e(TAG, "error sending external file", e);
}
Toast.makeText(this, R.string.unable_to_securely_share_this_file, Toast.LENGTH_LONG).show();
}
} catch (RemoteException e) {
Log.e(TAG, "Error sending data", e);
}
}
use of org.awesomeapp.messenger.service.IChatSession in project Zom-Android by zom.
the class ImUrlActivity method openChat.
private void openChat(long provider, long account) {
try {
IChatSessionManager manager = mConn.getChatSessionManager();
IChatSession session = manager.getChatSession(mToAddress);
if (session == null) {
session = manager.createChatSession(mToAddress, false);
}
Uri data = ContentUris.withAppendedId(Imps.Chats.CONTENT_URI, session.getId());
Intent intent = new Intent(Intent.ACTION_VIEW, data);
intent.putExtra(ImServiceConstants.EXTRA_INTENT_FROM_ADDRESS, mToAddress);
intent.putExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, provider);
intent.putExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, account);
intent.addCategory(ImApp.IMPS_CATEGORY);
startActivity(intent);
} catch (RemoteException e) {
// Ouch! Service died! We'll just disappear.
Log.w("ImUrlActivity", "Connection disappeared!");
}
}
use of org.awesomeapp.messenger.service.IChatSession in project Zom-Android by zom.
the class ConversationView method inviteContacts.
public void inviteContacts(ArrayList<String> invitees) {
if (mConn == null)
return;
try {
IChatSessionManager manager = mConn.getChatSessionManager();
IChatSession session = manager.getChatSession(mRemoteAddress);
for (String invitee : invitees) session.inviteContact(invitee);
} catch (Exception e) {
Log.e(ImApp.LOG_TAG, "error inviting contacts to group", e);
}
}
use of org.awesomeapp.messenger.service.IChatSession in project Zom-Android by zom.
the class ConversationView method createChatSession.
private IChatSession createChatSession() {
try {
if (mConn != null) {
IChatSessionManager sessionMgr = mConn.getChatSessionManager();
if (sessionMgr != null) {
String remoteAddress = mRemoteAddress;
IChatSession session = null;
if (mContactType == Imps.Contacts.TYPE_GROUP) {
// Contact contactGroup = new Contact(new XmppAddress(mRemoteAddress),mRemoteNickname,Imps.Contacts.TYPE_GROUP);
session = sessionMgr.createMultiUserChatSession(mRemoteAddress, mRemoteNickname, null, false);
// new ChatSessionInitTask(((ImApp)mActivity.getApplication()),mProviderId, mAccountId, Imps.Contacts.TYPE_GROUP)
// .executeOnExecutor(ImApp.sThreadPoolExecutor,contactGroup);
} else {
remoteAddress = Address.stripResource(mRemoteAddress);
session = sessionMgr.createChatSession(remoteAddress, false);
}
return session;
}
}
} catch (Exception e) {
// mHandler.showServiceErrorAlert(e.getLocalizedMessage());
LogCleaner.error(ImApp.LOG_TAG, "issue getting chat session", e);
}
return null;
}
use of org.awesomeapp.messenger.service.IChatSession in project Zom-Android by zom.
the class GroupDisplayActivity method changeGroupSubject.
private void changeGroupSubject(String subject) {
try {
IChatSession session = mConn.getChatSessionManager().getChatSession(mAddress);
session.setGroupChatSubject(subject);
} catch (Exception e) {
}
}
Aggregations