Esempio n. 1
0
  public ContactListManagerAdapter(ImConnectionAdapter conn) {
    mAdaptee = conn.getAdaptee().getContactListManager();
    mConn = conn;
    mContext = conn.getContext();
    mResolver = mContext.getContentResolver();

    mContactListListenerAdapter = new ContactListListenerAdapter();
    mSubscriptionListenerAdapter = new SubscriptionRequestListenerAdapter();
    mContactLists = new HashMap<Address, ContactListAdapter>();
    mTemporaryContacts = new HashMap<String, Contact>();
    mValidatedContacts = new HashSet<String>();
    mValidatedContactLists = new HashSet<String>();
    mValidatedBlockedContacts = new HashSet<String>();

    mAdaptee.addContactListListener(mContactListListenerAdapter);
    mAdaptee.setSubscriptionRequestListener(mSubscriptionListenerAdapter);

    mAccountId = mConn.getAccountId();
    mProviderId = mConn.getProviderId();

    Uri.Builder builder = Imps.Avatars.CONTENT_URI_AVATARS_BY.buildUpon();
    ContentUris.appendId(builder, mProviderId);
    ContentUris.appendId(builder, mAccountId);

    mAvatarUrl = builder.build();

    builder = Imps.Contacts.CONTENT_URI_CONTACTS_BY.buildUpon();
    ContentUris.appendId(builder, mProviderId);
    ContentUris.appendId(builder, mAccountId);

    mContactUrl = builder.build();
  }
Esempio n. 2
0
 public boolean isBlocked(String address) {
   try {
     return mAdaptee.isBlocked(address);
   } catch (ImException e) {
     Log.e(TAG, e.getMessage());
     return false;
   }
 }
Esempio n. 3
0
  public int blockContact(String address) {
    try {
      mAdaptee.blockContactAsync(address);
    } catch (ImException e) {
      return e.getImError().getCode();
    }

    return ImErrorInfo.NO_ERROR;
  }
Esempio n. 4
0
  public int deleteContactList(String name) {
    try {
      mAdaptee.deleteContactListAsync(name);
    } catch (ImException e) {
      return e.getImError().getCode();
    }

    return ImErrorInfo.NO_ERROR;
  }
Esempio n. 5
0
  public int createContactList(String name, List<Contact> contacts) {
    try {
      mAdaptee.createContactListAsync(name, contacts);
    } catch (ImException e) {
      return e.getImError().getCode();
    }

    return ImErrorInfo.NO_ERROR;
  }
Esempio n. 6
0
 public Contact getContactByAddress(String address) {
   Contact c = mAdaptee.getContact(address);
   if (c == null) {
     synchronized (mTemporaryContacts) {
       return mTemporaryContacts.get(address);
     }
   } else {
     return c;
   }
 }
Esempio n. 7
0
  public int unBlockContact(String address) {
    try {
      mAdaptee.unblockContactAsync(address);
    } catch (ImException e) {
      Log.e(TAG, e.getMessage());
      return e.getImError().getCode();
    }

    return ImErrorInfo.NO_ERROR;
  }
Esempio n. 8
0
  void deleteContactFromDataBase(Contact contact, ContactList list) {
    String selection = Imps.Contacts.USERNAME + "=? AND " + Imps.Contacts.CONTACTLIST + "=?";
    long listId = getContactListAdapter(list.getAddress()).getDataBaseId();
    String username = contact.getAddress().getFullName();
    String[] selectionArgs = {username, Long.toString(listId)};

    mResolver.delete(mContactUrl, selection, selectionArgs);

    // clear the history message if the contact doesn't exist in any list
    // anymore.
    if (mAdaptee.getContact(contact.getAddress()) == null) {
      clearHistoryMessages(username);
    }
  }
Esempio n. 9
0
 public Contact createTemporaryContact(String address) {
   Contact c = mAdaptee.createTemporaryContact(address);
   insertTemporary(c);
   return c;
 }
Esempio n. 10
0
 public int getState() {
   return mAdaptee.getState();
 }
Esempio n. 11
0
 public void loadContactLists() {
   if (mAdaptee.getState() == ContactListManager.LISTS_NOT_LOADED) {
     clearValidatedContactsAndLists();
     mAdaptee.loadContactListsAsync();
   }
 }
Esempio n. 12
0
 public void declineSubscription(String address) {
   mAdaptee.declineSubscriptionRequest(address);
 }
Esempio n. 13
0
 public void approveSubscription(String address) {
   mAdaptee.approveSubscriptionRequest(address);
 }