Search in sources :

Example 11 with Contact

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

the class ChatSessionAdapter method getNickName.

String getNickName(String username) {
    ImEntity participant = mChatSession.getParticipant();
    if (mIsGroupChat) {
        ChatGroup group = (ChatGroup) participant;
        /**
         *            List<Contact> members = group.getMembers();
         *            for (Contact c : members) {
         *                if (username.equals(c.getAddress().getAddress())) {
         *
         *                    return c.getAddress().getResource();
         *
         *                }
         *            }*
         */
        Contact groupMember = group.getMember(username);
        if (groupMember != null) {
            return groupMember.getAddress().getAddress();
        } else {
            // not found, impossible
            String[] parts = username.split("/");
            return parts[parts.length - 1];
        }
    } else {
        return ((Contact) participant).getName();
    }
}
Also used : ImEntity(org.awesomeapp.messenger.model.ImEntity) ChatGroup(org.awesomeapp.messenger.model.ChatGroup) Contact(org.awesomeapp.messenger.model.Contact)

Example 12 with Contact

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

the class ChatSessionAdapter method getParticipants.

public String[] getParticipants() {
    if (mIsGroupChat) {
        Contact self = mConnection.getLoginUser();
        ChatGroup group = (ChatGroup) mChatSession.getParticipant();
        List<Contact> members = group.getMembers();
        String[] result = new String[members.size() - 1];
        int index = 0;
        for (Contact c : members) {
            if (!c.equals(self)) {
                result[index++] = c.getAddress().getAddress();
            }
        }
        return result;
    } else {
        return new String[] { mChatSession.getParticipant().getAddress().getAddress() };
    }
}
Also used : ChatGroup(org.awesomeapp.messenger.model.ChatGroup) Contact(org.awesomeapp.messenger.model.Contact)

Example 13 with Contact

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

the class ChatSessionAdapter method onConvertToGroupChatSuccess.

void onConvertToGroupChatSuccess(ChatGroup group) {
    Contact oldParticipant = (Contact) mChatSession.getParticipant();
    String oldAddress = getAddress();
    // mChatSession.setParticipant(group);
    mChatSessionManager.updateChatSession(oldAddress, this);
    Uri oldChatUri = mChatURI;
    Uri oldMessageUri = mMessageURI;
    init(group, false);
    // copyHistoryMessages(oldParticipant);
    mContentResolver.delete(oldMessageUri, NON_CHAT_MESSAGE_SELECTION, null);
    mContentResolver.delete(oldChatUri, null, null);
    mListenerAdapter.notifyChatSessionConverted();
    mConvertingToGroupChat = false;
}
Also used : Uri(android.net.Uri) Contact(org.awesomeapp.messenger.model.Contact)

Example 14 with Contact

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

the class ChatSessionAdapter method init.

private void init(ChatGroup group, boolean isNewSession) {
    mIsGroupChat = true;
    mNickname = group.getName();
    mContactId = insertOrUpdateGroupContactInDb(group);
    group.addMemberListener(mListenerAdapter);
    mChatSession.setMessageListener(mListenerAdapter);
    try {
        mChatURI = ContentUris.withAppendedId(Imps.Chats.CONTENT_URI, mContactId);
        mChatSessionManager.getChatGroupManager().joinChatGroupAsync(group.getAddress(), group.getName());
        mMessageURI = Imps.Messages.getContentUriByThreadId(mContactId);
        if (isNewSession)
            insertOrUpdateChat("");
        for (Contact c : group.getMembers()) {
            mContactStatusMap.put(c.getName(), c.getPresence().getStatus());
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) XmppStringprepException(org.jxmpp.stringprep.XmppStringprepException) RemoteException(android.os.RemoteException) Contact(org.awesomeapp.messenger.model.Contact)

Example 15 with Contact

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

the class ContactListAdapter method getContacts.

public String[] getContacts() {
    Collection<Contact> contacts = mAdaptee.getContacts();
    String[] contactArray = new String[contacts.size()];
    int i = 0;
    for (Contact contact : contacts) contactArray[i++] = contact.getAddress().getAddress();
    return contactArray;
}
Also used : Contact(org.awesomeapp.messenger.model.Contact)

Aggregations

Contact (org.awesomeapp.messenger.model.Contact)33 RemoteException (android.os.RemoteException)11 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)10 Presence (org.awesomeapp.messenger.model.Presence)6 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)6 Intent (android.content.Intent)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 ImException (org.awesomeapp.messenger.model.ImException)5 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)5 ContentValues (android.content.ContentValues)4 Uri (android.net.Uri)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 KeyManagementException (java.security.KeyManagementException)4 KeyStoreException (java.security.KeyStoreException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 CertificateException (java.security.cert.CertificateException)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)4 ContactList (org.awesomeapp.messenger.model.ContactList)4 IChatSession (org.awesomeapp.messenger.service.IChatSession)4