use of org.awesomeapp.messenger.service.IChatSession in project Zom-Android by zom.
the class SmpResponseActivity method respondSmp.
private void respondSmp(String sid, String answer) {
ImApp app = (ImApp) getApplication();
IOtrChatSession iOtrSession;
try {
IChatSession chatSession = app.getChatSession(mProviderId, -1, Address.stripResource(sid));
iOtrSession = chatSession.getDefaultOtrChatSession();
if (iOtrSession == null) {
OtrDebugLogger.log("no session in progress for provider " + mProviderId);
return;
}
iOtrSession.respondSmpVerification(answer);
} catch (RemoteException e) {
OtrDebugLogger.log("could not respond to SMP", e);
}
}
use of org.awesomeapp.messenger.service.IChatSession 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.IChatSession 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.IChatSession 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.IChatSession in project Zom-Android by zom.
the class MainActivity method startGroupChat.
public void startGroupChat(String room, String server, String nickname, final ArrayList<String> invitees, IImConnection conn) {
mLastConnGroup = conn;
new AsyncTask<String, Long, String>() {
private ProgressDialog dialog;
@Override
protected void onPreExecute() {
dialog = new ProgressDialog(MainActivity.this);
dialog.setMessage(getString(R.string.connecting_to_group_chat_));
dialog.setCancelable(true);
dialog.show();
}
@Override
protected String doInBackground(String... params) {
String subject = params[0];
String chatRoom = "group" + UUID.randomUUID().toString().substring(0, 8);
String server = params[1];
try {
IChatSessionManager manager = mLastConnGroup.getChatSessionManager();
String roomAddress = (chatRoom + '@' + server).toLowerCase(Locale.US);
String nickname = params[2];
IChatSession session = manager.getChatSession(roomAddress);
if (session == null) {
session = manager.createMultiUserChatSession(roomAddress, subject, nickname, true);
if (session != null) {
mRequestedChatId = session.getId();
publishProgress(mRequestedChatId);
} else {
return getString(R.string.unable_to_create_or_join_group_chat);
}
} else {
mRequestedChatId = session.getId();
publishProgress(mRequestedChatId);
}
if (invitees != null && invitees.size() > 0) {
// wait a second for the server to sort itself out
try {
Thread.sleep(100);
} catch (Exception e) {
}
for (String invitee : invitees) session.inviteContact(invitee);
}
return null;
} catch (RemoteException e) {
return e.toString();
}
}
@Override
protected void onProgressUpdate(Long... showChatId) {
showChat(showChatId[0]);
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
if (dialog.isShowing()) {
dialog.dismiss();
}
if (result != null) {
// mHandler.showServiceErrorAlert(result);
}
}
}.executeOnExecutor(ImApp.sThreadPoolExecutor, room, server, nickname);
}
Aggregations