コード例 #1
0
ファイル: ImApp.java プロジェクト: Kensan/Gibberbot
 public void onConnectionCreated(IImConnection conn) throws RemoteException {
   long providerId = conn.getProviderId();
   synchronized (mConnections) {
     if (!mConnections.containsKey(providerId)) {
       mConnections.put(providerId, conn);
       conn.registerConnectionListener(mConnectionListener);
     }
   }
   broadcastConnEvent(EVENT_CONNECTION_CREATED, providerId, null);
 }
コード例 #2
0
ファイル: ImApp.java プロジェクト: Kensan/Gibberbot
    @Override
    public void onSelfPresenceUpdated(IImConnection connection) {
      if (Log.isLoggable(LOG_TAG, Log.DEBUG)) log("onUserPresenceUpdated");

      try {
        long providerId = connection.getProviderId();
        broadcastConnEvent(EVENT_USER_PRESENCE_UPDATED, providerId, null);
      } catch (RemoteException e) {
        Log.e(LOG_TAG, "onUserPresenceUpdated", e);
      }
    }
コード例 #3
0
ファイル: ImApp.java プロジェクト: Kensan/Gibberbot
 @Override
 public void onUpdateSelfPresenceError(IImConnection connection, ImErrorInfo error) {
   if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
     log("onUpdateUserPresenceError(" + error + ")");
   }
   try {
     long providerId = connection.getProviderId();
     broadcastConnEvent(EVENT_UPDATE_USER_PRESENCE_ERROR, providerId, error);
   } catch (RemoteException e) {
     Log.e(LOG_TAG, "onUpdateUserPresenceError", e);
   }
 }
コード例 #4
0
 public void setConnection(IImConnection conn) {
   mConn = conn;
   try {
     mPresence = conn.getUserPresence();
     mProviderId = conn.getProviderId();
   } catch (RemoteException e) {
     mHandler.showServiceErrorAlert();
   }
   if (mPresence == null) {
     mPresence = new Presence();
   }
   updateView();
 }
コード例 #5
0
ファイル: ImApp.java プロジェクト: Kensan/Gibberbot
    @Override
    public void onConnectionStateChange(IImConnection conn, int state, ImErrorInfo error) {
      if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
        log("onConnectionStateChange(" + state + ", " + error + ")");
      }

      try {
        int what = -1;
        long providerId = conn.getProviderId();
        switch (state) {
          case ImConnection.LOGGED_IN:
            what = EVENT_CONNECTION_LOGGED_IN;
            break;

          case ImConnection.LOGGING_IN:
            what = EVENT_CONNECTION_LOGGING_IN;
            break;

          case ImConnection.LOGGING_OUT:
            what = EVENT_CONNECTION_LOGGING_OUT;
            // MIRON - remove only if disconnected!
            //                    synchronized (mConnections) {
            //                        mConnections.remove(providerId);
            //                    }
            break;

          case ImConnection.DISCONNECTED:
            what = EVENT_CONNECTION_DISCONNECTED;
            synchronized (mConnections) {
              mConnections.remove(providerId);
            }
            // stop the service if there isn't an active connection anymore.
            stopImServiceIfInactive();
            break;

          case ImConnection.SUSPENDED:
            what = EVENT_CONNECTION_SUSPENDED;
            break;
        }
        if (what != -1) {
          broadcastConnEvent(what, providerId, error);
        }
      } catch (RemoteException e) {
        Log.e(LOG_TAG, "onConnectionStateChange", e);
      }
    }
コード例 #6
0
ファイル: ImApp.java プロジェクト: Kensan/Gibberbot
 private void fetchActiveConnections() {
   try {
     // register the listener before fetch so that we won't miss any connection.
     mImService.addConnectionCreatedListener(mConnCreationListener);
     synchronized (mConnections) {
       for (IBinder binder : (List<IBinder>) mImService.getActiveConnections()) {
         IImConnection conn = IImConnection.Stub.asInterface(binder);
         long providerId = conn.getProviderId();
         if (!mConnections.containsKey(providerId)) {
           mConnections.put(providerId, conn);
           conn.registerConnectionListener(mConnectionListener);
         }
       }
     }
   } catch (RemoteException e) {
     Log.e(LOG_TAG, "fetching active connections", e);
   }
 }