示例#1
0
  /**
   * Initiate a pre-recorded video sharing session
   *
   * @param contact Remote contact
   * @param content Video content to share
   * @param player Media player
   * @return CSh session
   * @throws CoreException
   */
  public VideoStreamingSession initiatePreRecordedVideoSharingSession(
      String contact, VideoContent content, IMediaPlayer player) throws CoreException {
    if (logger.isActivated()) {
      logger.info(
          "Initiate a pre-recorded video sharing session with contact "
              + contact
              + ", file "
              + content.toString());
    }

    // Test if call is established
    if (!getImsModule().getCallManager().isCallConnected()) {
      if (logger.isActivated()) {
        logger.debug("Rich call not established: cancel the initiation");
      }
      throw new CoreException("Call not established");
    }

    // Reject if there are already 2 bidirectional sessions with a given contact
    boolean rejectInvitation = false;
    Vector<ContentSharingSession> currentSessions = getCShSessions();
    if (currentSessions.size() >= 2) {
      // Already a bidirectional session
      if (logger.isActivated()) {
        logger.debug("Max sessions reached");
      }
      rejectInvitation = true;
    } else if (currentSessions.size() == 1) {
      ContentSharingSession currentSession = currentSessions.elementAt(0);
      if (!(currentSession instanceof TerminatingVideoStreamingSession)) {
        // Originating session already used
        if (logger.isActivated()) {
          logger.debug("Max originating sessions reached");
        }
        rejectInvitation = true;
      } else if (!PhoneUtils.compareNumbers(contact, currentSession.getRemoteContact())) {
        // Not the same contact
        if (logger.isActivated()) {
          logger.debug("Only bidirectional session with same contact authorized");
        }
        rejectInvitation = true;
      }
    }
    if (rejectInvitation) {
      if (logger.isActivated()) {
        logger.debug("The max number of sharing sessions is achieved: cancel the initiation");
      }
      throw new CoreException("Max content sharing sessions achieved");
    }

    // Create a new session
    OriginatingPreRecordedVideoStreamingSession session =
        new OriginatingPreRecordedVideoStreamingSession(
            this, player, content, PhoneUtils.formatNumberToSipUri(contact));

    // Start the session
    session.startSession();
    return session;
  }
示例#2
0
  /**
   * Receive an image sharing invitation
   *
   * @param invite Initial invite
   */
  public void receiveImageSharingInvitation(SipRequest invite) {
    if (logger.isActivated()) {
      logger.info("Receive an image sharing session invitation");
    }

    // Test if call is established
    if (!getImsModule().getCallManager().isCallConnected()) {
      if (logger.isActivated()) {
        logger.debug("Rich call not established: reject the invitation");
      }
      sendErrorResponse(invite, 606);
      return;
    }

    // Reject if there are already 2 bidirectional sessions with a given contact
    boolean rejectInvitation = false;
    String contact = SipUtils.getAssertedIdentity(invite);
    Vector<ContentSharingSession> currentSessions = getCShSessions();
    if (currentSessions.size() >= 2) {
      // Already a bidirectional session
      if (logger.isActivated()) {
        logger.debug("Max sessions reached");
      }
      rejectInvitation = true;
    } else if (currentSessions.size() == 1) {
      ContentSharingSession currentSession = currentSessions.elementAt(0);
      if (currentSession instanceof TerminatingImageTransferSession) {
        // Terminating session already used
        if (logger.isActivated()) {
          logger.debug("Max terminating sessions reached");
        }
        rejectInvitation = true;
      } else if (!PhoneUtils.compareNumbers(contact, currentSession.getRemoteContact())) {
        // Not the same contact
        if (logger.isActivated()) {
          logger.debug("Only bidirectional session with same contact authorized");
        }
        rejectInvitation = true;
      }
    }
    if (rejectInvitation) {
      if (logger.isActivated()) {
        logger.debug("The max number of sharing sessions is achieved: reject the invitation");
      }
      sendErrorResponse(invite, 486);
      return;
    }

    // Create a new session
    ImageTransferSession session = new TerminatingImageTransferSession(this, invite);

    // Start the session
    session.startSession();

    // Notify listener
    getImsModule().getCore().getListener().handleContentSharingTransferInvitation(session);
  }
示例#3
0
 /** M: add for MSRPoTLS @{ */
 protected String getCurrentProtocol() {
   if (logger.isActivated()) {
     logger.debug("getCurrentProtocol entry");
   }
   String protocol = getImsService().getImsModule().getCurrentNetworkInterface().getMsrpProtocol();
   if (logger.isActivated()) {
     logger.debug("getCurrentProtocol exit, protocol: " + protocol);
   }
   return protocol;
 }
示例#4
0
 /** Abort all pending sessions */
 public void abortAllSessions() {
   if (logger.isActivated()) {
     logger.debug("Abort all pending sessions");
   }
   for (Enumeration<ImsServiceSession> e = getSessions(); e.hasMoreElements(); ) {
     ImsServiceSession session = (ImsServiceSession) e.nextElement();
     if (logger.isActivated()) {
       logger.debug("Abort pending session " + session.getSessionID());
     }
     session.abortSession();
   }
 }
示例#5
0
  /** Interrupt session */
  public void interruptSession() {
    if (logger.isActivated()) {
      logger.info("ABC Interrupt the session");
    }

    try {
      // Unblock semaphore
      synchronized (waitUserAnswer) {
        waitUserAnswer.notifyAll();
      }

      if (!isSessionInterrupted()) {
        if (logger.isActivated()) {
          logger.info("ABC Interrupt the session1");
        }
        // Interrupt thread
        sessionInterrupted = true;
        interrupt();
      }
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Can't interrupt the session correctly", e);
      }
    }
    if (logger.isActivated()) {
      logger.debug("Session has been interrupted");
    }
  }
 /**
  * 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);
 }
  /**
   * 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);
  }
示例#8
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");
    }
  }
示例#9
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));
 }
示例#10
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);
 }
  /**
   * 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);
  }
  /** Background processing */
  public void run() {
    try {
      if (logger.isActivated()) {
        logger.info("Rejoin an existing group chat session");
      }

      // Set setup mode
      String localSetup = createSetupOffer();
      if (logger.isActivated()) {
        logger.debug("Local setup attribute is " + localSetup);
      }

      // Set local port
      int localMsrpPort;
      if ("active".equals(localSetup)) {
        localMsrpPort = 9; // See RFC4145, Page 4
      } else {
        localMsrpPort = getMsrpMgr().getLocalMsrpPort();
      }

      // Build SDP part
      String ipAddress = getDialogPath().getSipStack().getLocalIpAddress();
      String sdp =
          SdpUtils.buildGroupChatSDP(
              ipAddress,
              localMsrpPort,
              getMsrpMgr().getLocalSocketProtocol(),
              getAcceptTypes(),
              getWrappedTypes(),
              localSetup,
              getMsrpMgr().getLocalMsrpPath(),
              SdpUtils.DIRECTION_SENDRECV);

      // Set the local SDP part in the dialog path
      getDialogPath().setLocalContent(sdp);

      // Create an INVITE request
      if (logger.isActivated()) {
        logger.info("Send INVITE");
      }
      SipRequest invite = createInviteRequest(sdp);

      // Set the Authorization header
      getAuthenticationAgent().setAuthorizationHeader(invite);

      // Set initial request in the dialog path
      getDialogPath().setInvite(invite);

      // Send INVITE request
      sendInvite(invite);
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Session initiation has failed", e);
      }

      // Unexpected error
      handleError(new ChatError(ChatError.UNEXPECTED_EXCEPTION, e.getMessage()));
    }
  }
示例#14
0
  /**
   * A new file transfer invitation has been received
   *
   * @param session File transfer session
   * @param isGroup is group file transfer
   */
  public void handleFileTransferInvitation(FileSharingSession session, boolean isGroup) {
    if (logger.isActivated()) {
      logger.debug("Handle event file transfer invitation");
    }

    // Broadcast the invitation
    messagingApi.receiveFileTransferInvitation(session, isGroup);
  }
示例#15
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);
  }
 /** Close the MSRP session */
 private void closeMsrpSession() {
   if (msrpMgr != null) {
     msrpMgr.closeSession();
   }
   if (logger.isActivated()) {
     logger.debug("MSRP session has been closed");
   }
 }
示例#17
0
  /**
   * New content sharing transfer invitation
   *
   * @param session Content sharing transfer invitation
   */
  public void handleContentSharingTransferInvitation(GeolocTransferSession session) {
    if (logger.isActivated()) {
      logger.debug("Handle event content sharing transfer invitation");
    }

    // Broadcast the invitation
    richcallApi.receiveGeolocSharingInvitation(session);
  }
示例#18
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));
  }
示例#19
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);
  }
示例#20
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);
  }
示例#21
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);
  }
示例#22
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);
  }
示例#23
0
 /**
  * New IP call invitation
  *
  * @param session IP call session
  */
 @Override
 public void handleIPCallInvitation(IPCallStreamingSession session) {
   if (logger.isActivated()) {
     logger.debug("Handle event IP call invitation");
   }
   // Broadcast the invitation
   ipcallApi.receiveIPCallInvitation(session);
 }
示例#24
0
  /**
   * New content sharing streaming invitation
   *
   * @param session CSh session
   */
  public void handleContentSharingStreamingInvitation(VideoStreamingSession session) {
    if (logger.isActivated()) {
      logger.debug("Handle event content sharing streaming invitation");
    }

    // Broadcast the invitation
    richcallApi.receiveVideoSharingInvitation(session);
  }
示例#25
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);
  }
  /**
   * Send INVITE message
   *
   * @param invite SIP INVITE
   * @throws SipException
   */
  @Override
  /** M: Modified to resolve the 403 error issue.@{ */
  protected void sendInvite(SipRequest invite) throws SipException {
    /** @} */
    // Send INVITE request
    SipTransactionContext ctx =
        getImsService().getImsModule().getSipManager().sendSipMessageAndWait(invite);

    // Wait response
    ctx.waitResponse(getResponseTimeout());

    // Analyze the received response
    if (ctx.isSipResponse()) {
      // A response has been received
      if (ctx.getStatusCode() == 200) {
        // 200 OK
        handle200OK(ctx.getSipResponse());
      } else if (ctx.getStatusCode() == 407) {
        // 407 Proxy Authentication Required
        handle407Authentication(ctx.getSipResponse());
      } else if (ctx.getStatusCode() == 422) {
        // 422 Session Interval Too Small
        handle422SessionTooSmall(ctx.getSipResponse());
      } else if (ctx.getStatusCode() == 603) {
        // 603 Invitation declined
        handleError(
            new FileSharingError(
                FileSharingError.SESSION_INITIATION_DECLINED, ctx.getReasonPhrase()));
      } else if (ctx.getStatusCode() == 487) {
        // 487 Invitation cancelled
        handleError(
            new FileSharingError(
                FileSharingError.SESSION_INITIATION_CANCELLED, ctx.getReasonPhrase()));
      }
      /** M: Modified to resolve the 403 error issue.@{ */
      else if (ctx.getStatusCode() == 403) {
        handle403Forbidden(invite);
      }
      /** @} */
      else {
        // Other error response
        handleError(
            new FileSharingError(
                FileSharingError.SESSION_INITIATION_FAILED,
                ctx.getStatusCode() + " " + ctx.getReasonPhrase()));
      }
    } else {
      if (logger.isActivated()) {
        logger.debug("No response received for INVITE");
      }
      /**
       * M:ALPS00507513. ADDED to reslove issue of wrong prompt in case of file transfer timeout@{
       */
      // No response received: timeout
      handleError(new FileSharingError(FileSharingError.SESSION_INITIATION_TIMEOUT));
      /** @}* */
    }
  }
示例#27
0
  /**
   * User terms notification
   *
   * @param remote Remote server
   * @param id Request ID
   * @param subject Subject
   * @param text Text
   * @param btnLabel Label of OK button
   */
  public void handleUserNotification(
      String remote, String id, String subject, String text, String okButtonLabel) {
    if (logger.isActivated()) {
      logger.debug("Handle event user terms notification");
    }

    // Notify listeners
    termsApi.receiveUserNotification(remote, id, subject, text, okButtonLabel);
  }
示例#28
0
  /** SIM has changed */
  public void handleSimHasChanged() {
    if (logger.isActivated()) {
      logger.debug("Handle SIM has changed");
    }

    // Restart the RCS service
    LauncherUtils.stopRcsService(getApplicationContext());
    LauncherUtils.launchRcsService(getApplicationContext(), true, false);
  }
 /**
  * Remove an image sharing session from the list
  *
  * @param sessionId Session ID
  */
 protected static void removeImageSharingSession(String sessionId) {
   if (logger.isActivated()) {
     logger.debug(
         "Remove an image sharing session from the list (size="
             + imageSharingSessions.size()
             + ")");
   }
   imageSharingSessions.remove(sessionId);
 }
 /**
  * Remove a video sharing session from the list
  *
  * @param sessionId Session ID
  */
 protected static void removeVideoSharingSession(String sessionId) {
   if (logger.isActivated()) {
     logger.debug(
         "Remove a video sharing session from the list (size="
             + videoSharingSessions.size()
             + ")");
   }
   videoSharingSessions.remove(sessionId);
 }