use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.
the class ConversationView method blockContact.
public void blockContact() {
// TODO: unify with codes in ContactListView
DialogInterface.OnClickListener confirmListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
try {
checkConnection();
mConn = mApp.getConnection(mProviderId, mAccountId);
IContactListManager manager = mConn.getContactListManager();
manager.blockContact(Address.stripResource(mRemoteAddress));
// mNewChatActivity.finish();
} catch (Exception e) {
mHandler.showServiceErrorAlert(e.getLocalizedMessage());
LogCleaner.error(ImApp.LOG_TAG, "send message error", e);
}
}
};
Resources r = mActivity.getResources();
// The positive button is deliberately set as no so that
// the no is the default value
new AlertDialog.Builder(mContext).setTitle(R.string.confirm).setMessage(r.getString(R.string.confirm_block_contact, mRemoteNickname)).setPositiveButton(R.string.yes, // default button
confirmListener).setNegativeButton(R.string.no, null).setCancelable(false).show();
}
use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.
the class ConversationView method registerChatListener.
void registerChatListener() {
if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
log("registerChatListener " + mLastChatId);
}
try {
checkConnection();
if (getChatSession() != null) {
getChatSession().registerChatListener(mChatListener);
}
if (mConn != null) {
IContactListManager listMgr = mConn.getContactListManager();
listMgr.registerContactListListener(mContactListListener);
listMgr.registerSubscriptionListener(mSubscriptionListener);
}
} catch (Exception e) {
Log.w(ImApp.LOG_TAG, "<ChatView> registerChatListener fail:" + e.getMessage());
}
}
use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.
the class ConversationView method declineSubscription.
void declineSubscription() {
if (mConn != null) {
try {
IContactListManager manager = mConn.getContactListManager();
manager.declineSubscription(new Contact(new XmppAddress(mRemoteAddress), mRemoteNickname, Imps.Contacts.TYPE_NORMAL));
} catch (RemoteException e) {
// mHandler.showServiceErrorAlert(e.getLocalizedMessage());
LogCleaner.error(ImApp.LOG_TAG, "decline sub error", e);
}
}
}
use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.
the class ConversationView method setSelected.
public void setSelected(boolean isSelected) {
mIsSelected = isSelected;
if (mIsSelected) {
// bindChat(mLastChatId);
startListening();
updateWarningView();
mComposeMessage.requestFocus();
userActionDetected();
updateGroupTitle();
try {
mApp.dismissChatNotification(mProviderId, XmppAddress.stripResource(mRemoteAddress));
mCurrentChatSession.markAsRead();
} catch (Exception e) {
}
try {
if (mConn == null)
if (!checkConnection())
return;
if (mConn == null)
return;
IContactListManager manager = mConn.getContactListManager();
Contact contact = manager.getContactByAddress(mRemoteAddress);
if (contact != null) {
if (contact.getPresence() != null) {
mLastSeen = contact.getPresence().getLastSeen();
if (mLastSeen != null)
mActivity.updateLastSeen(mLastSeen);
}
if (!TextUtils.isEmpty(contact.getForwardingAddress())) {
showContactMoved(contact);
}
}
if ((mLastSessionStatus == null || mLastSessionStatus == SessionStatus.PLAINTEXT)) {
boolean otrPolicyAuto = getOtrPolicy() == OtrPolicy.OPPORTUNISTIC || getOtrPolicy() == OtrPolicy.OTRL_POLICY_ALWAYS;
if (mCurrentChatSession == null)
mCurrentChatSession = getChatSession();
if (mCurrentChatSession == null)
return;
IOtrChatSession otrChatSession = mCurrentChatSession.getDefaultOtrChatSession();
if (otrChatSession != null && (!isGroupChat())) {
String remoteJID = otrChatSession.getRemoteUserId();
boolean doOtr = (remoteJID != null && (remoteJID.toLowerCase().contains("chatsecure") || remoteJID.toLowerCase().contains("zom")));
if (!doOtr)
doOtr = OtrAndroidKeyManagerImpl.getInstance(mActivity).hasRemoteFingerprint(remoteJID);
if (// if set to auto, and is chatsecure, then start encryption
otrPolicyAuto && doOtr) {
// automatically attempt to turn on OTR after 1 second
mHandler.postDelayed(new Runnable() {
public void run() {
setOTRState(true);
scheduleRequery(DEFAULT_QUERY_INTERVAL);
}
}, 100);
}
}
}
} catch (RemoteException re) {
}
} else {
stopListening();
sendTypingStatus(false);
}
}
use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.
the class ConversationView method approveSubscription.
void approveSubscription() {
if (mConn != null) {
try {
IContactListManager manager = mConn.getContactListManager();
manager.approveSubscription(new Contact(new XmppAddress(mRemoteAddress), mRemoteNickname, Imps.Contacts.TYPE_NORMAL));
} catch (RemoteException e) {
// mHandler.showServiceErrorAlert(e.getLocalizedMessage());
LogCleaner.error(ImApp.LOG_TAG, "approve sub error", e);
}
}
}
Aggregations