@Override
 protected void onHandleIntent(final Intent intent) {
   final Core core = Core.getInstance();
   if (core == null || !core.isStarted()) {
     /* Stack is not started, don't process this intent */
     if (sLogger.isActivated()) {
       sLogger.warn("Stack is not running, do not process the delivery expiration intent!");
     }
     return;
   }
   InstantMessagingService imService = core.getImService();
   final DeliveryExpirationManager deliveryExpirarationManager =
       imService.getDeliveryExpirationManager();
   imService.scheduleImOperation(
       new Runnable() {
         @Override
         public void run() {
           String action = intent.getAction();
           try {
             if (DeliveryExpirationManager.ACTION_CHAT_MESSAGE_DELIVERY_TIMEOUT.equals(action)) {
               deliveryExpirarationManager.onChatMessageDeliveryExpirationReceived(intent);
             } else if (DeliveryExpirationManager.ACTION_FILE_TRANSFER_DELIVERY_TIMEOUT.equals(
                 action)) {
               deliveryExpirarationManager.onFileTransferDeliveryExpirationReceived(intent);
             }
           } catch (RuntimeException e) {
             /*
              * Normally we are not allowed to catch runtime exceptions as these are genuine
              * bugs which should be handled/fixed within the code. However the cases when we
              * are executing operations on a thread unhandling such exceptions will
              * eventually lead to exit the system and thus can bring the whole system down,
              * which is not intended.
              */
             sLogger.error(
                 new StringBuilder(
                         "Unable to handle one to one delivery expiration event for intent action : ")
                     .append(action)
                     .toString(),
                 e);
           }
         }
       });
 }
示例#2
0
 /** Remove session */
 public void removeSession() {
   Core.getInstance().getImService().removeSession(this);
 }
示例#3
0
 /** Start session */
 public void startSession() {
   Core.getInstance().getImService().addSession(this);
   start();
 }