Search in sources :

Example 6 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress in project Zom-Android by zom.

the class ChatSessionManagerAdapter method createMultiUserChatSession.

public IChatSession createMultiUserChatSession(String roomAddress, String subject, String nickname, boolean isNewChat) {
    ChatGroupManager groupMan = mConnection.getAdaptee().getChatGroupManager();
    try {
        if (roomAddress.endsWith("@")) {
            String confServer = groupMan.getDefaultGroupChatService();
            if (confServer != null)
                roomAddress += confServer;
        }
        // TODO hard coding XMPP for now
        Address address = new XmppAddress(roomAddress);
        groupMan.createChatGroupAsync(roomAddress, subject, nickname);
        ChatGroup chatGroup = groupMan.getChatGroup(address);
        if (chatGroup != null && mConnection.getState() == ImConnection.LOGGED_IN) {
            ChatSession session = getChatSessionManager().createChatSession(chatGroup, isNewChat);
            ChatSessionAdapter adapter = getChatSessionAdapter(session, isNewChat);
            groupMan.loadMembers(chatGroup);
            return adapter;
        } else {
            return null;
        }
    } catch (Exception e) {
        Log.e(ImApp.LOG_TAG, "unable to join group chat" + e.getMessage());
        return null;
    }
}
Also used : Address(org.awesomeapp.messenger.model.Address) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) ChatGroup(org.awesomeapp.messenger.model.ChatGroup) IChatSession(org.awesomeapp.messenger.service.IChatSession) ChatSession(org.awesomeapp.messenger.model.ChatSession) RemoteException(android.os.RemoteException) ChatGroupManager(org.awesomeapp.messenger.model.ChatGroupManager)

Example 7 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress in project Zom-Android by zom.

the class AddContactActivity method setupActions.

private void setupActions() {
    View btnInviteSms = findViewById(R.id.btnInviteSMS);
    btnInviteSms.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImApp app = ((ImApp) getApplication());
            String nickname = app.getDefaultNickname();
            if (nickname == null)
                nickname = new XmppAddress(app.getDefaultUsername()).getUser();
            String inviteString = OnboardingManager.generateInviteMessage(AddContactActivity.this, nickname, app.getDefaultUsername(), app.getDefaultOtrKey());
            OnboardingManager.inviteSMSContact(AddContactActivity.this, null, inviteString);
        }
    });
    View btnInviteShare = findViewById(R.id.btnInviteShare);
    btnInviteShare.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ImApp app = ((ImApp) getApplication());
            String nickname = app.getDefaultNickname();
            if (nickname == null)
                nickname = new XmppAddress(app.getDefaultUsername()).getUser();
            String inviteString = OnboardingManager.generateInviteMessage(AddContactActivity.this, nickname, app.getDefaultUsername(), app.getDefaultOtrKey());
            OnboardingManager.inviteShare(AddContactActivity.this, inviteString);
        }
    });
    View btnInviteQR = findViewById(R.id.btnInviteScan);
    btnInviteQR.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (hasCameraPermission()) {
                ImApp app = ((ImApp) getApplication());
                try {
                    String xmppLink = OnboardingManager.generateXmppLink(app.getDefaultUsername(), app.getDefaultOtrKey());
                    OnboardingManager.inviteScan(AddContactActivity.this, xmppLink);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    });
}
Also used : XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) ImApp(org.awesomeapp.messenger.ImApp) IOException(java.io.IOException) View(android.view.View) TextView(android.widget.TextView)

Example 8 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress 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 9 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress 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 10 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress in project Zom-Android by zom.

the class ContactDisplayActivity method startChat.

public void startChat() {
    if (mConn == null)
        return;
    try {
        IChatSessionManager manager = mConn.getChatSessionManager();
        if (manager != null) {
            IChatSession session = manager.getChatSession(mUsername);
            if (session == null) {
                new ChatSessionInitTask(((ImApp) getApplication()), mProviderId, mAccountId, Imps.Contacts.TYPE_NORMAL, false) {

                    @Override
                    protected void onPostExecute(Long chatId) {
                        super.onPostExecute(chatId);
                        if (mContactId == -1) {
                            Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
                            intent.putExtra("id", chatId);
                            startActivity(intent);
                            finish();
                        }
                    }
                }.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(mUsername)));
            // Toast.makeText(this, getString(R.string.message_waiting_for_friend), Toast.LENGTH_LONG).show();
            } else {
                Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
                intent.putExtra("id", session.getId());
                startActivity(intent);
                finish();
            }
        }
    } catch (RemoteException re) {
    }
    if (mContactId != -1) {
        Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
        intent.putExtra("id", mContactId);
        startActivity(intent);
        finish();
    }
}
Also used : IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) ChatSessionInitTask(org.awesomeapp.messenger.tasks.ChatSessionInitTask) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) Intent(android.content.Intent) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession) Contact(org.awesomeapp.messenger.model.Contact)

Aggregations

XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)17 Contact (org.awesomeapp.messenger.model.Contact)10 RemoteException (android.os.RemoteException)8 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)5 Intent (android.content.Intent)4 IChatSession (org.awesomeapp.messenger.service.IChatSession)4 ChatSessionInitTask (org.awesomeapp.messenger.tasks.ChatSessionInitTask)4 ImApp (org.awesomeapp.messenger.ImApp)3 Activity (android.app.Activity)2 DecoderException (org.apache.commons.codec.DecoderException)2 Address (org.awesomeapp.messenger.model.Address)2 ChatSession (org.awesomeapp.messenger.model.ChatSession)2 IChatSessionManager (org.awesomeapp.messenger.service.IChatSessionManager)2 IImConnection (org.awesomeapp.messenger.service.IImConnection)2 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 View (android.view.View)1 TextView (android.widget.TextView)1 IOException (java.io.IOException)1