Esempio n. 1
0
 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);
   }
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
  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);
        }
      }
    }
  }
Esempio n. 4
0
  public int updateUserPresence(Presence newPresence) {
    try {
      mConnection.updateUserPresenceAsync(newPresence);
    } catch (ImException e) {
      return e.getImError().getCode();
    }

    return ImErrorInfo.NO_ERROR;
  }
Esempio n. 5
0
  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);
  }
Esempio n. 6
0
 public Presence getUserPresence() {
   return mConnection.getUserPresence();
 }
Esempio n. 7
0
 public Contact getLoginUser() {
   return mConnection.getLoginUser();
 }
Esempio n. 8
0
 void suspend() {
   mConnectionState = ImConnection.SUSPENDING;
   mConnection.suspend();
 }
Esempio n. 9
0
 public void logout() {
   mConnectionState = ImConnection.LOGGING_OUT;
   mConnection.logoutAsync();
 }
Esempio n. 10
0
 @Override
 public void setProxy(String type, String host, int port) throws RemoteException {
   mConnection.setProxy(type, host, port);
 }
Esempio n. 11
0
 @Override
 public void sendHeartbeat() throws RemoteException {
   mConnection.sendHeartbeat();
 }
Esempio n. 12
0
 public void networkTypeChanged() {
   mConnection.networkTypeChanged();
 }
Esempio n. 13
0
 public int[] getSupportedPresenceStatus() {
   return mConnection.getSupportedPresenceStatus();
 }