use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.
the class ContactsListFragment method archiveContact.
private static void archiveContact(Activity activity, String address, int contactType, long providerId, long accountId) {
try {
IImConnection mConn;
ImApp app = ((ImApp) activity.getApplication());
mConn = app.getConnection(providerId, accountId);
// then delete the contact from our list
IContactListManager manager = mConn.getContactListManager();
int res = manager.archiveContact(address, contactType, true);
if (res != ImErrorInfo.NO_ERROR) {
// mHandler.showAlert(R.string.error,
// ErrorResUtils.getErrorRes(getResources(), res, address));
}
} catch (RemoteException re) {
}
}
use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.
the class AddContactAsyncTask method addToContactList.
private int addToContactList(String address, String otrFingperint, String nickname) {
int res = -1;
try {
IImConnection conn = mApp.getConnection(mProviderId, mAccountId);
if (conn == null)
conn = mApp.createConnection(mProviderId, mAccountId);
IContactList list = getContactList(conn);
if (list != null) {
res = list.addContact(address, nickname);
if (res != ImErrorInfo.NO_ERROR) {
// what to do here?
}
if (!TextUtils.isEmpty(otrFingperint)) {
OtrAndroidKeyManagerImpl.getInstance(mApp).verifyUser(address, otrFingperint);
}
}
} catch (RemoteException re) {
Log.e(ImApp.LOG_TAG, "error adding contact", re);
}
return res;
}
use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.
the class AccountActivity method signOut.
void signOut(long providerId, long accountId) {
try {
IImConnection conn = mApp.getConnection(providerId, accountId);
if (conn != null) {
conn.logout();
} else {
// Normally, we can always get the connection when user chose to
// sign out. However, if the application crash unexpectedly, the
// status will never be updated. Clear the status in this case
// to make it recoverable from the crash.
ContentValues values = new ContentValues(2);
values.put(Imps.AccountStatusColumns.PRESENCE_STATUS, Imps.CommonPresenceColumns.OFFLINE);
values.put(Imps.AccountStatusColumns.CONNECTION_STATUS, Imps.ConnectionStatus.OFFLINE);
String where = Imps.AccountStatusColumns.ACCOUNT + "=?";
getContentResolver().update(Imps.AccountStatus.CONTENT_URI, values, where, new String[] { Long.toString(accountId) });
}
} catch (RemoteException ex) {
Log.e(ImApp.LOG_TAG, "signout: caught ", ex);
} finally {
// Toast.makeText(this,
// getString(R.string.signed_out_prompt, this.mEditUserAccount.getText()),
// Toast.LENGTH_SHORT).show();
isSignedIn = false;
// mBtnSignIn.setText(getString(R.string.sign_in));
// mBtnSignIn.setBackgroundResource(R.drawable.btn_green);
}
}
use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.
the class ContactListFilterView method setContactNickname.
private void setContactNickname(int aPosition) {
Cursor cursor = (Cursor) mFilterList.getItemAtPosition(aPosition);
final IImConnection conn = getConnection(cursor);
final String address = cursor.getString(cursor.getColumnIndexOrThrow(Imps.Contacts.USERNAME));
final String nickname = cursor.getString(cursor.getColumnIndexOrThrow(Imps.Contacts.NICKNAME));
final View view = LayoutInflater.from(mContext).inflate(R.layout.alert_dialog_contact_nickname, null);
((TextView) view.findViewById(R.id.contact_address_textview)).setText(address);
((EditText) view.findViewById(R.id.contact_nickname_edittext)).setText(nickname);
new AlertDialog.Builder(mContext).setTitle(mContext.getString(R.string.menu_contact_nickname, nickname)).setView(view).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
final String newNickname = ((EditText) view.findViewById(R.id.contact_nickname_edittext)).getText().toString();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
setContactNickname(address, newNickname, conn);
}
}, 500);
}
}).setNegativeButton(R.string.cancel, null).show();
}
use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.
the class ContactListFilterView method blockContact.
void blockContact(Cursor c) {
final IImConnection conn = getConnection(c);
String nickname = c.getString(c.getColumnIndexOrThrow(Imps.Contacts.NICKNAME));
final String address = c.getString(c.getColumnIndexOrThrow(Imps.Contacts.USERNAME));
DialogInterface.OnClickListener confirmListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
try {
IContactListManager manager = conn.getContactListManager();
int res = -1;
if (manager.isBlocked(address))
res = manager.unBlockContact(address);
else {
res = manager.blockContact(address);
if (res != ImErrorInfo.NO_ERROR) {
mHandler.showAlert(R.string.error, ErrorResUtils.getErrorRes(getResources(), res, address));
}
}
} catch (RemoteException e) {
mHandler.showServiceErrorAlert(e.getLocalizedMessage());
LogCleaner.error(ImApp.LOG_TAG, "remote error", e);
}
}
};
Resources r = getResources();
new AlertDialog.Builder(mContext).setTitle(R.string.confirm).setMessage(r.getString(R.string.confirm_block_contact, nickname)).setPositiveButton(R.string.yes, // default button
confirmListener).setNegativeButton(R.string.no, null).setCancelable(false).show();
}
Aggregations