Exemplo 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();
  }
Exemplo n.º 2
0
 public boolean isBlocked(String address) {
   try {
     return mAdaptee.isBlocked(address);
   } catch (ImException e) {
     Log.e(TAG, e.getMessage());
     return false;
   }
 }
Exemplo n.º 3
0
  public int blockContact(String address) {
    try {
      mAdaptee.blockContactAsync(address);
    } catch (ImException e) {
      return e.getImError().getCode();
    }

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

    return ImErrorInfo.NO_ERROR;
  }
Exemplo 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;
  }
Exemplo 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;
   }
 }
Exemplo 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;
  }
Exemplo 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);
    }
  }
Exemplo n.º 9
0
 public Contact createTemporaryContact(String address) {
   Contact c = mAdaptee.createTemporaryContact(address);
   insertTemporary(c);
   return c;
 }
Exemplo n.º 10
0
 public int getState() {
   return mAdaptee.getState();
 }
Exemplo n.º 11
0
 public void loadContactLists() {
   if (mAdaptee.getState() == ContactListManager.LISTS_NOT_LOADED) {
     clearValidatedContactsAndLists();
     mAdaptee.loadContactListsAsync();
   }
 }
Exemplo n.º 12
0
 public void declineSubscription(String address) {
   mAdaptee.declineSubscriptionRequest(address);
 }
Exemplo n.º 13
0
 public void approveSubscription(String address) {
   mAdaptee.approveSubscriptionRequest(address);
 }