/**
   * Remove a SIP session from the list
   *
   * @param sessionId Session ID
   */
  protected static void removeSipSession(String sessionId) {
    if (logger.isActivated()) {
      logger.debug("Remove a multimedia session from the list (size=" + sipSessions.size() + ")");
    }

    sipSessions.remove(sessionId);
  }
Esempio n. 2
0
  /**
   * Add an geoloc sharing session in the list
   *
   * @param session Geoloc sharing session
   */
  protected static void addGeolocSharingSession(GeolocSharingImpl session) {
    if (logger.isActivated()) {
      logger.debug("Add a geoloc sharing session in the list (size=" + gshSessions.size() + ")");
    }

    gshSessions.put(session.getSharingId(), session);
  }
 /**
  * Add a video sharing session in the list
  *
  * @param session Video sharing session
  */
 protected static void addVideoSharingSession(VideoSharingSession session) {
   if (logger.isActivated()) {
     logger.debug(
         "Add a video sharing session in the list (size=" + videoSharingSessions.size() + ")");
   }
   videoSharingSessions.put(session.getSessionID(), session);
 }
Esempio n. 4
0
  /**
   * Constructor
   *
   * @param parent IMS service
   * @param invite Initial INVITE request
   */
  public TerminatingOne2OneChatSession(ImsService parent, SipRequest invite) {
    super(parent, PhoneUtils.extractNumberFromUri(SipUtils.getAssertedIdentity(invite)));

    // Set first message
    InstantMessage firstMsg = ChatUtils.getFirstMessage(invite);
    setFirstMesssage(firstMsg);

    // Create dialog path
    createTerminatingDialogPath(invite);

    // Set contribution ID
    String id = ChatUtils.getContributionId(invite);
    setContributionID(id);
    if (RcsSettings.getInstance().isCPMSupported()) {
      if (logger.isActivated()) {
        logger.info("TerminatingFOne2OneSession1  CPMS");
      }
      setConversationID(ChatUtils.getCoversationId(invite));
      setInReplyID(ChatUtils.getInReplyId(invite));
    }

    if (logger.isActivated()) {
      logger.info("TerminatingOne2OneChatSession From: " + ChatUtils.getFromAias(invite));
      logger.info("TerminatingOne2OneChatSession Display name: " + this.getRemoteDisplayName());
    }
    setRemoteDisplayName(this.getRemoteDisplayName());
  }
Esempio n. 5
0
 /** Core layer has been terminated */
 public void handleCoreLayerStopped() {
   // Display a notification
   if (logger.isActivated()) {
     logger.debug("Handle event core terminated");
   }
   addRcsServiceNotification(false, getString(R.string.rcs_core_stopped));
 }
Esempio n. 6
0
  /** Stop core */
  public synchronized void stopCore() {
    if (Core.getInstance() == null) {
      // Already stopped
      return;
    }

    if (logger.isActivated()) {
      logger.debug("Stop RCS core service");
    }

    // Update GSMA client API
    GsmaUtils.setClientActivationState(getApplicationContext(), false);

    // Send service intent
    Intent intent = new Intent(ClientApiIntents.SERVICE_STATUS);
    intent.putExtra("status", ClientApiIntents.SERVICE_STATUS_STOPPING);
    getApplicationContext().sendBroadcast(intent);

    // Terminate the core in background
    Core.terminateCore();

    // Close CPU manager
    cpuManager.close();

    // Send service intent
    intent = new Intent(ClientApiIntents.SERVICE_STATUS);
    intent.putExtra("status", ClientApiIntents.SERVICE_STATUS_STOPPED);
    getApplicationContext().sendBroadcast(intent);

    if (logger.isActivated()) {
      logger.info("RCS core service stopped with success");
    }
  }
Esempio n. 7
0
  /**
   * Receive a new geoloc sharing invitation
   *
   * @param session Geoloc sharing session
   */
  public void receiveGeolocSharingInvitation(GeolocTransferSession session) {
    if (logger.isActivated()) {
      logger.info("Receive geoloc sharing invitation from " + session.getRemoteContact());
    }

    // Extract number from contact
    String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact());

    // Add session in the list
    GeolocSharingImpl sessionApi = new GeolocSharingImpl(session);
    GeolocSharingServiceImpl.addGeolocSharingSession(sessionApi);

    // Broadcast intent related to the received invitation
    Intent intent = new Intent(GeolocSharingIntent.ACTION_NEW_INVITATION);
    intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
    intent.putExtra(GeolocSharingIntent.EXTRA_CONTACT, number);
    intent.putExtra(GeolocSharingIntent.EXTRA_DISPLAY_NAME, session.getRemoteDisplayName());
    intent.putExtra(GeolocSharingIntent.EXTRA_SHARING_ID, session.getSessionID());
    AndroidFactory.getApplicationContext().sendBroadcast(intent);

    // Notify geoloc sharing invitation listeners
    synchronized (lock) {
      final int N = listeners.beginBroadcast();
      for (int i = 0; i < N; i++) {
        try {
          listeners.getBroadcastItem(i).onNewGeolocSharing(session.getSessionID());
        } catch (Exception e) {
          if (logger.isActivated()) {
            logger.error("Can't notify listener", e);
          }
        }
      }
      listeners.finishBroadcast();
    }
  }
  /**
   * Receive a new video sharing invitation
   *
   * @param session Video sharing session
   */
  public void receiveVideoSharingInvitation(VideoStreamingSession session) {
    if (logger.isActivated()) {
      logger.info("Receive video sharing invitation from " + session.getRemoteContact());
    }

    // Extract number from contact
    String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact());
    VideoContent content = (VideoContent) session.getContent();

    // Update rich call history
    RichCall.getInstance()
        .addCall(
            number,
            session.getSessionID(),
            RichCallData.EVENT_INCOMING,
            content,
            RichCallData.STATUS_STARTED);

    // Add session in the list
    VideoSharingSession sessionApi = new VideoSharingSession(session);
    addVideoSharingSession(sessionApi);

    // Broadcast intent related to the received invitation
    Intent intent = new Intent(RichCallApiIntents.VIDEO_SHARING_INVITATION);
    intent.putExtra("contact", number);
    intent.putExtra("contactDisplayname", session.getRemoteDisplayName());
    intent.putExtra("sessionId", session.getSessionID());
    intent.putExtra("videotype", content.getEncoding());
    intent.putExtra("videowidth", content.getWidth());
    intent.putExtra("videoheight", content.getHeight());
    AndroidFactory.getApplicationContext().sendBroadcast(intent);
  }
  /**
   * Returns a current video sharing from its unique ID
   *
   * @return Video sharing or null if not found
   * @throws ServerApiException
   */
  public IVideoSharing getVideoSharing(String sharingId) throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Get video sharing session " + sharingId);
    }

    return videoSharingSessions.get(sharingId);
  }
  /**
   * Receive a new geoloc sharing invitation
   *
   * @param session Geoloc sharing session
   */
  public void receiveGeolocSharingInvitation(GeolocTransferSession session) {
    if (logger.isActivated()) {
      logger.info("Receive geoloc sharing invitation from " + session.getRemoteContact());
    }

    // Extract number from contact
    String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact());

    // Update rich call history
    RichCall.getInstance()
        .addCall(
            number,
            session.getSessionID(),
            RichCallData.EVENT_INCOMING,
            session.getContent(),
            RichCallData.STATUS_STARTED);

    // Add session in the list
    GeolocSharingSession sessionApi = new GeolocSharingSession(session);
    addGeolocSharingSession(sessionApi);

    // Broadcast intent related to the received invitation
    Intent intent = new Intent(RichCallApiIntents.GEOLOC_SHARING_INVITATION);
    intent.putExtra("contact", number);
    intent.putExtra("contactDisplayname", session.getRemoteDisplayName());
    intent.putExtra("sessionId", session.getSessionID());
    AndroidFactory.getApplicationContext().sendBroadcast(intent);
  }
 /**
  * Add an image sharing session in the list
  *
  * @param session Image sharing session
  */
 protected static void addImageSharingSession(ImageSharingSession session) {
   if (logger.isActivated()) {
     logger.debug(
         "Add an image sharing session in the list (size=" + imageSharingSessions.size() + ")");
   }
   imageSharingSessions.put(session.getSessionID(), session);
 }
  /**
   * Data transfer error
   *
   * @param error Error
   */
  public void msrpTransferError(String error) {
    if (isInterrupted()) {
      return;
    }

    if (logger.isActivated()) {
      logger.info("Data transfer error: " + error);
    }

    // Close the media session
    closeMediaSession();

    // Terminate session
    terminateSession();

    // Remove the current session
    getImsService().removeSession(this);

    // Notify listeners
    if (!isInterrupted()) {
      for (int j = 0; j < getListeners().size(); j++) {
        ((FileSharingSessionListener) getListeners().get(j))
            .handleTransferError(
                new FileSharingError(FileSharingError.MEDIA_TRANSFER_FAILED, error));
      }
    }
  }
  /**
   * Get list of current image sharing sessions with a contact
   *
   * @param contact Contact
   * @return List of sessions
   * @throws ServerApiException
   */
  public List<IBinder> getImageSharingSessionsWith(String contact) throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Get image sharing sessions with " + contact);
    }

    // Check permission
    ServerApiUtils.testPermission();

    // Test core availability
    ServerApiUtils.testCore();

    try {
      Vector<ContentSharingSession> list =
          Core.getInstance().getRichcallService().getCShSessions(contact);
      ArrayList<IBinder> result = new ArrayList<IBinder>(list.size());
      for (int i = 0; i < list.size(); i++) {
        ContentSharingSession session = list.elementAt(i);
        IImageSharingSession sessionApi = imageSharingSessions.get(session.getSessionID());
        if (sessionApi != null) {
          result.add(sessionApi.asBinder());
        }
      }
      return result;
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Unexpected error", e);
      }
      throw new ServerApiException(e.getMessage());
    }
  }
Esempio n. 14
0
  /**
   * Returns a current geoloc sharing from its unique ID
   *
   * @return Geoloc sharing
   * @throws ServerApiException
   */
  public IGeolocSharing getGeolocSharing(String sharingId) throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Get geoloc sharing session " + sharingId);
    }

    return gshSessions.get(sharingId);
  }
  /**
   * Sends a message in pager mode to a contact and for a given service. The message may be any type
   * of content. The parameter contact supports the following formats: MSISDN in national or
   * international format, SIP address, SIP-URI or Tel-URI. If the format of the contact is not
   * supported an exception is thrown.
   *
   * @param serviceId Service ID
   * @param contact Contact
   * @param content Message content
   * @return Returns true if sent successfully else returns false
   * @throws ServerApiException
   */
  public boolean sendMessage(String serviceId, String contact, byte[] content)
      throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Send instant message to " + contact);
    }

    // Test IMS connection
    ServerApiUtils.testIms();

    try {
      // Send instant message
      String featureTag =
          FeatureTags.FEATURE_RCSE
              + "=\""
              + FeatureTags.FEATURE_RCSE_EXTENSION
              + "."
              + serviceId
              + "\"";
      return Core.getInstance().getSipService().sendInstantMessage(contact, featureTag, content);
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Unexpected error", e);
      }
      throw new ServerApiException(e.getMessage());
    }
  }
  /**
   * Add a SIP session in the list
   *
   * @param session SIP session
   */
  protected static void addSipSession(MultimediaSessionImpl session) {
    if (logger.isActivated()) {
      logger.debug("Add a multimedia session in the list (size=" + sipSessions.size() + ")");
    }

    sipSessions.put(session.getSessionId(), session);
  }
  /**
   * Returns a current session from its unique session ID
   *
   * @return Multimedia session or null if not found
   * @throws ServerApiException
   */
  public IMultimediaSession getSession(String sessionId) throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Get multimedia session " + sessionId);
    }

    return sipSessions.get(sessionId);
  }
  /** Close API */
  public void close() {
    // Clear list of sessions
    videoSharingSessions.clear();

    if (logger.isActivated()) {
      logger.info("Video sharing service API is closed");
    }
  }
  /**
   * Registers an video sharing invitation listener
   *
   * @param listener New video sharing listener
   * @throws ServerApiException
   */
  public void addNewVideoSharingListener(INewVideoSharingListener listener)
      throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Add an video sharing invitation listener");
    }

    listeners.register(listener);
  }
Esempio n. 20
0
  /** Close API */
  public void close() {
    // Clear list of sessions
    gshSessions.clear();

    if (logger.isActivated()) {
      logger.info("Geoloc sharing service API is closed");
    }
  }
  /** Close API */
  public void close() {
    // Clear list of sessions
    sipSessions.clear();

    if (logger.isActivated()) {
      logger.info("Multimedia session service API is closed");
    }
  }
 /** Close the MSRP session */
 private void closeMsrpSession() {
   if (msrpMgr != null) {
     msrpMgr.closeSession();
   }
   if (logger.isActivated()) {
     logger.debug("MSRP session has been closed");
   }
 }
Esempio n. 23
0
  /**
   * Remove an geoloc sharing session from the list
   *
   * @param sessionId Session ID
   */
  protected static void removeGeolocSharingSession(String sessionId) {
    if (logger.isActivated()) {
      logger.debug(
          "Remove a geoloc sharing session from the list (size=" + gshSessions.size() + ")");
    }

    gshSessions.remove(sessionId);
  }
Esempio n. 24
0
  /**
   * New SIP instant message received
   *
   * @param intent Resolved intent
   */
  public void handleSipInstantMessageReceived(Intent intent) {
    if (logger.isActivated()) {
      logger.debug("Handle event receive SIP instant message");
    }

    // Broadcast the message
    sipApi.receiveSipInstantMessage(intent);
  }
Esempio n. 25
0
  /**
   * New one-to-one chat session invitation
   *
   * @param session Chat session
   */
  public void handleOneOneChatSessionInvitation(TerminatingOne2OneChatSession session) {
    if (logger.isActivated()) {
      logger.debug("Handle event receive 1-1 chat session invitation");
    }

    // Broadcast the invitation
    messagingApi.receiveOneOneChatInvitation(session);
  }
Esempio n. 26
0
  /** Handle "try registration" event */
  public void handleTryDeregister() {
    if (logger.isActivated()) {
      logger.debug("Handle event try deregistration");
    }

    // Display a notification
    addRcsServiceNotification(false, getString(R.string.rcs_core_ims_try_disconnect));
  }
Esempio n. 27
0
  /**
   * Unregisters a geoloc sharing invitation listener
   *
   * @param listener New geoloc sharing listener
   * @throws ServerApiException
   */
  public void removeNewGeolocSharingListener(INewGeolocSharingListener listener)
      throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Remove a geoloc sharing invitation listener");
    }

    listeners.unregister(listener);
  }
Esempio n. 28
0
  /**
   * New message delivery status
   *
   * @param contact Contact
   * @param msgId Message ID
   * @param status Delivery status
   * @param date The server date for delivery status
   */
  public void handleMessageDeliveryStatus(String contact, String msgId, String status, long date) {
    if (logger.isActivated()) {
      logger.debug("Handle message delivery status");
    }

    // Notify listeners
    messagingApi.handleMessageDeliveryStatus(contact, msgId, status, date);
  }
Esempio n. 29
0
  /**
   * New ad-hoc group chat session invitation
   *
   * @param session Chat session
   */
  public void handleAdhocGroupChatSessionInvitation(TerminatingAdhocGroupChatSession session) {
    if (logger.isActivated()) {
      logger.debug("Handle event receive ad-hoc group chat session invitation");
    }

    // Broadcast the invitation
    messagingApi.receiveGroupChatInvitation(session);
  }
Esempio n. 30
0
  /**
   * New SIP session invitation
   *
   * @param intent Resolved intent
   * @param session SIP session
   */
  public void handleSipSessionInvitation(Intent intent, GenericSipSession session) {
    if (logger.isActivated()) {
      logger.debug("Handle event receive SIP session invitation");
    }

    // Broadcast the invitation
    sipApi.receiveSipSessionInvitation(intent, session);
  }