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(); }
private void handleInvitation(long id, boolean accept) { if (mGroupManager == null) { return; } ContentResolver cr = mService.getContentResolver(); Cursor c = cr.query( ContentUris.withAppendedId(Imps.Invitation.CONTENT_URI, id), null, null, null, null); if (c == null) { return; } if (c.moveToFirst()) { String inviteId = c.getString(c.getColumnIndexOrThrow(Imps.Invitation.INVITE_ID)); int status; if (accept) { mGroupManager.acceptInvitationAsync(inviteId); status = Imps.Invitation.STATUS_ACCEPTED; } else { mGroupManager.rejectInvitationAsync(inviteId); status = Imps.Invitation.STATUS_REJECTED; } // TODO c.updateInt(c.getColumnIndexOrThrow(Imps.Invitation.STATUS), status); // c.commitUpdates(); } c.close(); }
void reestablishSession() { mConnectionState = ImConnection.LOGGING_IN; ContentResolver cr = mService.getContentResolver(); if ((mConnection.getCapability() & ImConnection.CAPABILITY_SESSION_REESTABLISHMENT) != 0) { HashMap<String, String> cookie = querySessionCookie(cr); if (cookie != null) { Log.d(TAG, "re-establish session"); try { mConnection.reestablishSessionAsync(cookie); } catch (IllegalArgumentException e) { Log.e(TAG, "Invalid session cookie, probably modified by others."); clearSessionCookie(cr); } } } }
void updateAccountStatusInDb() { Presence p = getUserPresence(); int presenceStatus = Imps.Presence.OFFLINE; int connectionStatus = convertConnStateForDb(mConnectionState); if (p != null) { presenceStatus = ContactListManagerAdapter.convertPresenceStatus(p); } ContentResolver cr = mService.getContentResolver(); Uri uri = Imps.AccountStatus.CONTENT_URI; ContentValues values = new ContentValues(); values.put(Imps.AccountStatus.ACCOUNT, mAccountId); values.put(Imps.AccountStatus.PRESENCE_STATUS, presenceStatus); values.put(Imps.AccountStatus.CONNECTION_STATUS, connectionStatus); cr.insert(uri, values); }