Search in sources :

Example 11 with ImApp

use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.

the class SimpleAlertHandler method registerForBroadcastEvents.

public void registerForBroadcastEvents() {
    ImApp app = (ImApp) mActivity.getApplication();
    app.registerForBroadcastEvent(ImApp.EVENT_CONNECTION_DISCONNECTED, this);
}
Also used : ImApp(org.awesomeapp.messenger.ImApp)

Example 12 with ImApp

use of org.awesomeapp.messenger.ImApp 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);
    }
}
Also used : IOtrChatSession(org.awesomeapp.messenger.crypto.IOtrChatSession) ImApp(org.awesomeapp.messenger.ImApp) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession)

Example 13 with ImApp

use of org.awesomeapp.messenger.ImApp 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 ImApp

use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.

the class AccountAdapter method runBindTask.

private void runBindTask(final Activity context, final List<AccountInfo> accountInfoList) {
    final Resources resources = context.getResources();
    final ContentResolver resolver = context.getContentResolver();
    final ImApp mApp = (ImApp) context.getApplication();
    // if called multiple times
    if (mBindTask != null)
        mBindTask.cancel(false);
    // 
    mBindTask = new AsyncTask<Void, Void, List<AccountSetting>>() {

        @Override
        protected List<AccountSetting> doInBackground(Void... params) {
            List<AccountSetting> accountSettingList = new ArrayList<AccountSetting>();
            for (AccountInfo ai : accountInfoList) {
                accountSettingList.add(getAccountSettings(ai));
            }
            return accountSettingList;
        }

        private AccountSetting getAccountSettings(AccountInfo ai) {
            AccountSetting as = new AccountSetting();
            Cursor pCursor = resolver.query(Imps.ProviderSettings.CONTENT_URI, new String[] { Imps.ProviderSettings.NAME, Imps.ProviderSettings.VALUE }, Imps.ProviderSettings.PROVIDER + "=?", new String[] { Long.toString(ai.providerId) }, null);
            if (pCursor != null) {
                Imps.ProviderSettings.QueryMap settings = new Imps.ProviderSettings.QueryMap(pCursor, resolver, ai.providerId, false, null);
                as.connectionStatus = ai.dbConnectionStatus;
                as.activeUserName = ai.activeUserName;
                as.domain = settings.getDomain();
                as.host = settings.getServer();
                as.port = settings.getPort();
                /**
                 *                    IImConnection conn = mApp.getConnection(ai.providerId,settings.get);
                 *                    if (conn == null) {
                 *                        as.connectionStatus = ImConnection.DISCONNECTED;
                 *                    } else {
                 *                        try {
                 *                            as.connectionStatus = conn.getState();
                 *                        } catch (RemoteException e) {
                 *                            // TODO Auto-generated catch block
                 *                            e.printStackTrace();
                 *                        }
                 *                    }
                 */
                settings.close();
            }
            return as;
        }

        @Override
        protected void onPostExecute(List<AccountSetting> result) {
            // store
            mBindTask = null;
            // swap
            AccountAdapter.super.swapCursor(mStashCursor);
            if (mListener != null)
                mListener.onPopulate();
        }
    };
    mBindTask.execute();
}
Also used : Imps(org.awesomeapp.messenger.provider.Imps) ImApp(org.awesomeapp.messenger.ImApp) Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver) ArrayList(java.util.ArrayList) List(java.util.List) Resources(android.content.res.Resources)

Example 15 with ImApp

use of org.awesomeapp.messenger.ImApp 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)

Aggregations

ImApp (org.awesomeapp.messenger.ImApp)21 RemoteException (android.os.RemoteException)10 IImConnection (org.awesomeapp.messenger.service.IImConnection)8 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)6 IOException (java.io.IOException)5 Activity (android.app.Activity)4 Intent (android.content.Intent)4 View (android.view.View)4 Cursor (android.database.Cursor)3 Paint (android.graphics.Paint)3 TextView (android.widget.TextView)3 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)3 IChatSession (org.awesomeapp.messenger.service.IChatSession)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 CropImageView (com.theartofdev.edmodo.cropper.CropImageView)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Contact (org.awesomeapp.messenger.model.Contact)2 Imps (org.awesomeapp.messenger.provider.Imps)2 AddContactAsyncTask (org.awesomeapp.messenger.tasks.AddContactAsyncTask)2 AlertDialog (android.app.AlertDialog)1