public ImConnectionAdapter(long providerId, ImConnection connection, RemoteImService service) {
   mProviderId = providerId;
   mConnection = connection;
   mService = service;
   mConnectionListener = new ConnectionListenerAdapter();
   mConnection.addConnectionListener(mConnectionListener);
   if ((connection.getCapability() & ImConnection.CAPABILITY_GROUP_CHAT) != 0) {
     mGroupManager = mConnection.getChatGroupManager();
     mInvitationListener = new InvitationListenerAdapter();
     mGroupManager.setInvitationListener(mInvitationListener);
   }
 }
 public void login(long accountId, boolean autoLoadContacts, boolean retry) {
   mAccountId = accountId;
   mAutoLoadContacts = autoLoadContacts;
   mConnectionState = ImConnection.LOGGING_IN;
   mChatSessionManager = new ChatSessionManagerAdapter(this);
   mContactListManager = new ContactListManagerAdapter(this);
   mConnection.loginAsync(mAccountId, mProviderId, retry);
 }
  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);
        }
      }
    }
  }
  public int updateUserPresence(Presence newPresence) {
    try {
      mConnection.updateUserPresenceAsync(newPresence);
    } catch (ImException e) {
      return e.getImError().getCode();
    }

    return ImErrorInfo.NO_ERROR;
  }
  void saveSessionCookie(ContentResolver cr) {
    HashMap<String, String> cookies = mConnection.getSessionContext();

    int i = 0;
    ContentValues[] valuesList = new ContentValues[cookies.size()];

    for (Map.Entry<String, String> entry : cookies.entrySet()) {
      ContentValues values = new ContentValues(2);

      values.put(Imps.SessionCookies.NAME, entry.getKey());
      values.put(Imps.SessionCookies.VALUE, entry.getValue());

      valuesList[i++] = values;
    }

    cr.bulkInsert(getSessionCookiesUri(), valuesList);
  }
 public Presence getUserPresence() {
   return mConnection.getUserPresence();
 }
 public Contact getLoginUser() {
   return mConnection.getLoginUser();
 }
 void suspend() {
   mConnectionState = ImConnection.SUSPENDING;
   mConnection.suspend();
 }
 public void logout() {
   mConnectionState = ImConnection.LOGGING_OUT;
   mConnection.logoutAsync();
 }
Example #10
0
 @Override
 public void setProxy(String type, String host, int port) throws RemoteException {
   mConnection.setProxy(type, host, port);
 }
Example #11
0
 @Override
 public void sendHeartbeat() throws RemoteException {
   mConnection.sendHeartbeat();
 }
Example #12
0
 public void networkTypeChanged() {
   mConnection.networkTypeChanged();
 }
Example #13
0
 public int[] getSupportedPresenceStatus() {
   return mConnection.getSupportedPresenceStatus();
 }