Search in sources :

Example 6 with IImConnection

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

the class ContactListItem method declineSubscription.

void declineSubscription() {
    ImApp app = ((ImApp) ((Activity) getContext()).getApplication());
    IImConnection mConn = app.getConnection(mHolder.mProviderId, mHolder.mAccountId);
    if (mConn != null) {
        try {
            IContactListManager manager = mConn.getContactListManager();
            manager.declineSubscription(new Contact(new XmppAddress(address), nickname, Imps.Contacts.TYPE_NORMAL));
            app.dismissChatNotification(mHolder.mProviderId, address);
            manager.removeContact(address);
        } catch (RemoteException e) {
            // mHandler.showServiceErrorAlert(e.getLocalizedMessage());
            LogCleaner.error(ImApp.LOG_TAG, "decline sub error", e);
        }
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) Activity(android.app.Activity) ImApp(org.awesomeapp.messenger.ImApp) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) Contact(org.awesomeapp.messenger.model.Contact)

Example 7 with IImConnection

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

the class ContactListItem method approveSubscription.

/*
    private String queryGroupMembers(ContentResolver resolver, long groupId) {
        String[] projection = { Imps.GroupMembers.NICKNAME };
        Uri uri = ContentUris.withAppendedId(Imps.GroupMembers.CONTENT_URI, groupId);
        Cursor c = resolver.query(uri, projection, null, null, null);
        StringBuilder buf = new StringBuilder();
        if (c != null) {
            while (c.moveToNext()) {
                buf.append(c.getString(0));
                                                Imps.Avatars.DATA
                if (!c.isLast()) {
                    buf.append(',');
                }
            }
        }
        c.close();

        return buf.toString();
    }*/
void approveSubscription() {
    ImApp app = ((ImApp) ((Activity) getContext()).getApplication());
    IImConnection mConn = app.getConnection(mHolder.mProviderId, mHolder.mAccountId);
    if (mConn != null) {
        try {
            IContactListManager manager = mConn.getContactListManager();
            manager.approveSubscription(new Contact(new XmppAddress(address), nickname, Imps.Contacts.TYPE_NORMAL));
        } catch (RemoteException e) {
            // mHandler.showServiceErrorAlert(e.getLocalizedMessage());
            LogCleaner.error(ImApp.LOG_TAG, "approve sub error", e);
        }
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) Activity(android.app.Activity) ImApp(org.awesomeapp.messenger.ImApp) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) Contact(org.awesomeapp.messenger.model.Contact)

Example 8 with IImConnection

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

the class ContactsListFragment method unarchiveContact.

private static void unarchiveContact(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, false);
        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) ImApp(org.awesomeapp.messenger.ImApp) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) Paint(android.graphics.Paint)

Example 9 with IImConnection

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

the class ContactsListFragment method deleteContact.

private static void deleteContact(Activity activity, long itemId, String address, long providerId, long accountId) {
    try {
        IImConnection mConn;
        ImApp app = ((ImApp) activity.getApplication());
        mConn = app.getConnection(providerId, accountId);
        // first leave, delete an existing chat session
        IChatSessionManager sessionMgr = mConn.getChatSessionManager();
        if (sessionMgr != null) {
            IChatSession session = sessionMgr.getChatSession(Address.stripResource(address));
        }
        // then delete the contact from our list
        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) IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) ImApp(org.awesomeapp.messenger.ImApp) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession) Paint(android.graphics.Paint)

Example 10 with IImConnection

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

the class ConversationListItem method getEncryptionState.

private void getEncryptionState(long providerId, long accountId, String address, ConversationViewHolder holder) {
    try {
        ImApp app = ((ImApp) ((Activity) getContext()).getApplication());
        IImConnection conn = app.getConnection(providerId, accountId);
        if (conn == null || conn.getChatSessionManager() == null)
            return;
        IChatSession chatSession = conn.getChatSessionManager().getChatSession(address);
        if (chatSession != null) {
            if (chatSession.isEncrypted()) {
                holder.mStatusIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_encrypted_grey));
                holder.mStatusIcon.setVisibility(View.VISIBLE);
            }
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
// mCurrentChatSession.getOtrChatSession();
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) Activity(android.app.Activity) ImApp(org.awesomeapp.messenger.ImApp) IChatSession(org.awesomeapp.messenger.service.IChatSession)

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