예제 #1
0
  /**
   * 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());
    }
  }
예제 #2
0
  /**
   * Set call hold
   *
   * @param state State
   * @throws ServerApiException
   */
  public void setCallHold(boolean state) throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Set call hold to " + state);
    }

    // Check permission
    ServerApiUtils.testPermission();

    // Test core availability
    ServerApiUtils.testCore();

    // Update call manager
    Core.getInstance().getImsModule().getCallManager().setCallHold(state);
  }
예제 #3
0
  /**
   * Get current geoloc sharing session from its session ID
   *
   * @param id Session ID
   * @return Session
   * @throws ServerApiException
   */
  public IGeolocSharingSession getGeolocSharingSession(String id) throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Get geoloc sharing session " + id);
    }

    // Check permission
    ServerApiUtils.testPermission();

    // Test core availability
    ServerApiUtils.testCore();

    // Return a session instance
    return geolocSharingSessions.get(id);
  }
예제 #4
0
  /**
   * Initiate a geoloc sharing session
   *
   * @param contact Contact
   * @param geoloc Geoloc info
   * @return Geoloc sharing session
   * @throws ServerApiException
   */
  public IGeolocSharingSession initiateGeolocSharing(String contact, GeolocPush geoloc)
      throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Initiate a geoloc sharing session with " + contact);
    }

    // Check permission
    ServerApiUtils.testPermission();

    // Test IMS connection
    ServerApiUtils.testIms();

    try {
      // Create a geoloc content
      String msgId = ChatUtils.generateMessageId();
      String geolocDoc =
          ChatUtils.buildGeolocDocument(geoloc, ImsModule.IMS_USER_PROFILE.getPublicUri(), msgId);
      MmContent content =
          new GeolocContent("geoloc.xml", geolocDoc.getBytes().length, geolocDoc.getBytes());

      // Initiate a sharing session
      GeolocTransferSession session =
          Core.getInstance()
              .getRichcallService()
              .initiateGeolocSharingSession(contact, content, geoloc);

      // Update rich call
      RichCall.getInstance()
          .addCall(
              contact,
              session.getSessionID(),
              RichCallData.EVENT_OUTGOING,
              session.getContent(),
              RichCallData.STATUS_STARTED);

      // Update rich messaging history
      GeolocMessage geolocMsg = new GeolocMessage(null, contact, geoloc, false);
      RichMessaging.getInstance().addOutgoingGeoloc(geolocMsg);

      // Add session in the list
      GeolocSharingSession sessionApi = new GeolocSharingSession(session);
      addGeolocSharingSession(sessionApi);
      return sessionApi;
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Unexpected error", e);
      }
      throw new ServerApiException(e.getMessage());
    }
  }
예제 #5
0
  /**
   * Initiate an image sharing session
   *
   * @param contact Contact
   * @param file Image file
   * @param thumbnail Thumbnail option
   * @throws ServerApiException
   */
  public IImageSharingSession initiateImageSharing(String contact, String file, boolean thumbnail)
      throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Initiate an image sharing session with " + contact);
    }

    // Check permission
    ServerApiUtils.testPermission();

    // Test IMS connection
    ServerApiUtils.testIms();

    try {
      // Create an image content
      FileDescription desc = FileFactory.getFactory().getFileDescription(file);
      MmContent content = ContentManager.createMmContentFromUrl(file, desc.getSize());

      // Initiate a sharing session
      ImageTransferSession session =
          Core.getInstance()
              .getRichcallService()
              .initiateImageSharingSession(contact, content, thumbnail);

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

      // Add session in the list
      ImageSharingSession sessionApi = new ImageSharingSession(session);
      addImageSharingSession(sessionApi);
      return sessionApi;
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Unexpected error", e);
      }
      throw new ServerApiException(e.getMessage());
    }
  }
예제 #6
0
  /**
   * Get the remote phone number involved in the current call
   *
   * @return Phone number or null if there is no call in progress
   * @throws ServerApiException
   */
  public String getRemotePhoneNumber() throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Get remote phone number");
    }

    // Check permission
    ServerApiUtils.testPermission();

    // Test core availability
    ServerApiUtils.testCore();

    try {
      return Core.getInstance().getImsModule().getCallManager().getRemoteParty();
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Unexpected error", e);
      }
      throw new ServerApiException(e.getMessage());
    }
  }
예제 #7
0
  /**
   * Initiate a live video sharing session
   *
   * @param contact Contact
   * @param player Media player
   * @throws ServerApiException
   */
  public IVideoSharingSession initiateLiveVideoSharing(String contact, IVideoPlayer player)
      throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Initiate a live video session with " + contact);
    }

    // Check permission
    ServerApiUtils.testPermission();

    // Test IMS connection
    ServerApiUtils.testIms();

    try {
      // Initiate a new session
      VideoStreamingSession session =
          Core.getInstance().getRichcallService().initiateLiveVideoSharingSession(contact, player);

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

      // Add session in the list
      VideoSharingSession sessionApi = new VideoSharingSession(session);
      addVideoSharingSession(sessionApi);
      return sessionApi;
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Unexpected error", e);
      }
      throw new ServerApiException(e.getMessage());
    }
  }
예제 #8
0
 /**
  * Get vodafone account mapped with the specific number.
  *
  * @param number The number to be mapped to vodafone account.
  * @return The vodafone account.
  * @throws ServerApiException
  */
 public String getNumberViaVfAccount(String number) throws ServerApiException {
   ServerApiUtils.testPermission();
   ServerApiUtils.testCore();
   return PhoneUtils.getNumberViaVfAccount(number);
 }