Search in sources :

Example 11 with IImConnection

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();
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) ContentValues(android.content.ContentValues) RemoteException(android.os.RemoteException)

Example 12 with IImConnection

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) {
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException)

Example 13 with IImConnection

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) {
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) Activity(android.app.Activity) ImApp(org.awesomeapp.messenger.ImApp) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException)

Example 14 with IImConnection

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);
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) Imps(org.awesomeapp.messenger.provider.Imps) ImApp(org.awesomeapp.messenger.ImApp) Cursor(android.database.Cursor) RemoteException(android.os.RemoteException)

Example 15 with IImConnection

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);
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) ContentValues(android.content.ContentValues) RemoteException(android.os.RemoteException)

Aggregations

IImConnection (org.awesomeapp.messenger.service.IImConnection)25 RemoteException (android.os.RemoteException)21 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)9 ImApp (org.awesomeapp.messenger.ImApp)8 Activity (android.app.Activity)4 ContentValues (android.content.ContentValues)4 DialogInterface (android.content.DialogInterface)4 Cursor (android.database.Cursor)3 Paint (android.graphics.Paint)3 Uri (android.net.Uri)3 View (android.view.View)3 TextView (android.widget.TextView)3 IChatSession (org.awesomeapp.messenger.service.IChatSession)3 AlertDialog (android.app.AlertDialog)2 Resources (android.content.res.Resources)2 SearchView (android.support.v7.widget.SearchView)2 Contact (org.awesomeapp.messenger.model.Contact)2 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)2 Imps (org.awesomeapp.messenger.provider.Imps)2 IChatSessionManager (org.awesomeapp.messenger.service.IChatSessionManager)2