use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.
the class SignoutActivity method signOut.
private 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.AccountStatus.PRESENCE_STATUS, Imps.Presence.OFFLINE);
values.put(Imps.AccountStatus.CONNECTION_STATUS, Imps.ConnectionStatus.OFFLINE);
String where = Imps.AccountStatus.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 {
// finish();
// Toast.makeText(this, getString(R.string.signed_out_prompt), Toast.LENGTH_LONG).show();
}
}
use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.
the class ContactDisplayActivity method doDeleteContact.
void doDeleteContact() {
try {
IImConnection mConn;
mConn = ((ImApp) getApplication()).getConnection(mProviderId, mAccountId);
IContactListManager manager = mConn.getContactListManager();
int res = manager.removeContact(mUsername);
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 ContactListItem method deleteContact.
void deleteContact() {
try {
IImConnection mConn;
ImApp app = ((ImApp) ((Activity) getContext()).getApplication());
mConn = app.getConnection(mHolder.mProviderId, mHolder.mAccountId);
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.IImConnection in project Zom-Android by zom.
the class AccountListItem method runBindTask.
private void runBindTask(final Resources r, final int providerId, final int accountId, final String nickname, final String activeUserName, final int dbConnectionStatus, final String presenceString) {
String mProviderNameText;
String mSecondRowText;
try {
Cursor pCursor = mResolver.query(Imps.ProviderSettings.CONTENT_URI, new String[] { Imps.ProviderSettings.NAME, Imps.ProviderSettings.VALUE }, Imps.ProviderSettings.PROVIDER + "=?", new String[] { Long.toString(providerId) }, null);
Imps.ProviderSettings.QueryMap settings = new Imps.ProviderSettings.QueryMap(pCursor, mResolver, providerId, false, /* keep updated */
mHandler);
String userDomain = settings.getDomain();
int connectionStatus = dbConnectionStatus;
IImConnection conn = ((ImApp) mActivity.getApplication()).getConnection(providerId, accountId);
if (conn == null) {
connectionStatus = ImConnection.DISCONNECTED;
} else {
try {
connectionStatus = conn.getState();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (mShowLongName)
// + '@' + userDomain;
mProviderNameText = activeUserName;
else
mProviderNameText = nickname;
switch(connectionStatus) {
case ImConnection.LOGGING_IN:
mSecondRowText = r.getString(R.string.signing_in_wait);
mIsSignedIn = true;
break;
case ImConnection.SUSPENDING:
case ImConnection.SUSPENDED:
mSecondRowText = r.getString(R.string.error_suspended_connection);
mIsSignedIn = true;
break;
case ImConnection.LOGGED_IN:
mIsSignedIn = true;
mSecondRowText = computeSecondRowText(presenceString, r, settings, true);
break;
case ImConnection.LOGGING_OUT:
mIsSignedIn = false;
mSecondRowText = r.getString(R.string.signing_out_wait);
break;
default:
mIsSignedIn = false;
mSecondRowText = computeSecondRowText(presenceString, r, settings, true);
break;
}
settings.close();
pCursor.close();
applyView(mProviderNameText, mIsSignedIn, mSecondRowText);
} catch (NullPointerException npe) {
Log.d(ImApp.LOG_TAG, "null on QueryMap (this shouldn't happen anymore, but just in case)", npe);
}
}
use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.
the class AccountViewFragment 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(AccountStatusColumns.PRESENCE_STATUS, CommonPresenceColumns.OFFLINE);
values.put(AccountStatusColumns.CONNECTION_STATUS, Imps.ConnectionStatus.OFFLINE);
String where = AccountStatusColumns.ACCOUNT + "=?";
getActivity().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);
}
}
Aggregations