Пример #1
0
  /**
   * Returns the state of the geoloc sharing
   *
   * @return State
   * @throws RemoteException
   */
  public int getState() throws RemoteException {
    try {
      GeolocTransferSession session = mRichcallService.getGeolocTransferSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getState().toInt();
      }
      if (session.isGeolocTransferred()) {
        return State.TRANSFERRED.toInt();
      }
      SipDialogPath dialogPath = session.getDialogPath();
      if (dialogPath != null && dialogPath.isSessionEstablished()) {
        return State.STARTED.toInt();

      } else if (session.isInitiatedByRemote()) {
        if (session.isSessionAccepted()) {
          return State.ACCEPTING.toInt();
        }
        return State.INVITED.toInt();
      }
      return State.INITIATING.toInt();

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }
Пример #2
0
 @Override
 public void onInvitationReceived(ContactId contact, long timestamp) {
   synchronized (mLock) {
     mPersistentStorage.addIncomingGeolocSharing(
         contact, State.INVITED, ReasonCode.UNSPECIFIED, timestamp);
     mBroadcaster.broadcastInvitation(mSharingId);
   }
 }
Пример #3
0
  /**
   * Returns the local timestamp of when the geoloc sharing was initiated for outgoing geoloc
   * sharing or the local timestamp of when the geoloc sharing invitation was received for incoming
   * geoloc sharings.
   *
   * @return long
   * @throws RemoteException
   */
  public long getTimestamp() throws RemoteException {
    try {
      GeolocTransferSession session = mRichcallService.getGeolocTransferSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getTimestamp();
      }
      return session.getTimestamp();

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }
Пример #4
0
  /**
   * Returns the reason code of the state of the geoloc sharing
   *
   * @return ReasonCode
   * @throws RemoteException
   */
  public int getReasonCode() throws RemoteException {
    try {
      GeolocTransferSession session = mRichcallService.getGeolocTransferSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getReasonCode().toInt();
      }
      return ReasonCode.UNSPECIFIED.toInt();

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }
Пример #5
0
 @Override
 public void onContentTransferred(ContactId contact, Geoloc geoloc, boolean initiatedByRemote) {
   if (sLogger.isActivated()) {
     sLogger.debug("Geoloc transferred.");
   }
   synchronized (mLock) {
     mGeolocSharingService.removeGeolocSharing(mSharingId);
     if (initiatedByRemote) {
       if (RichCallHistory.getInstance().setGeolocSharingTransferred(mSharingId, geoloc)) {
         mBroadcaster.broadcastStateChanged(
             contact, mSharingId, State.TRANSFERRED, ReasonCode.UNSPECIFIED);
       }
     } else {
       if (mPersistentStorage.setStateAndReasonCode(State.TRANSFERRED, ReasonCode.UNSPECIFIED)) {
         mBroadcaster.broadcastStateChanged(
             contact, mSharingId, State.TRANSFERRED, ReasonCode.UNSPECIFIED);
       }
     }
   }
 }
Пример #6
0
  /**
   * Returns the direction of the sharing (incoming or outgoing)
   *
   * @return Direction
   * @throws RemoteException
   * @see Direction
   */
  public int getDirection() throws RemoteException {
    try {
      GeolocTransferSession session = mRichcallService.getGeolocTransferSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getDirection().toInt();
      }
      if (session.isInitiatedByRemote()) {
        return Direction.INCOMING.toInt();
      }
      return Direction.OUTGOING.toInt();

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }
Пример #7
0
 @Override
 public void onSessionAborted(ContactId contact, TerminationReason reason) {
   if (sLogger.isActivated()) {
     sLogger.debug(
         new StringBuilder("Session aborted; reason=").append(reason).append(".").toString());
   }
   synchronized (mLock) {
     mGeolocSharingService.removeGeolocSharing(mSharingId);
     switch (reason) {
       case TERMINATION_BY_TIMEOUT:
       case TERMINATION_BY_SYSTEM:
         setStateAndReasonCode(contact, State.ABORTED, ReasonCode.ABORTED_BY_SYSTEM);
         break;
       case TERMINATION_BY_CONNECTION_LOST:
         setStateAndReasonCode(contact, State.FAILED, ReasonCode.FAILED_SHARING);
         break;
       case TERMINATION_BY_USER:
         setStateAndReasonCode(contact, State.ABORTED, ReasonCode.ABORTED_BY_USER);
         break;
       case TERMINATION_BY_REMOTE:
         /*
          * TODO : Fix sending of SIP BYE by sender once transfer is completed and media
          * session is closed. Then this check of state can be removed. Also need to
          * check if it is storing and broadcasting right state and reasoncode.
          */
         if (State.TRANSFERRED != mPersistentStorage.getState()) {
           setStateAndReasonCode(contact, State.ABORTED, ReasonCode.ABORTED_BY_REMOTE);
         }
         break;
       default:
         throw new IllegalArgumentException(
             new StringBuilder("Unknown reason ; sessionAbortedReason=")
                 .append(reason)
                 .append("!")
                 .toString());
     }
   }
 }
Пример #8
0
 private void setStateAndReasonCode(ContactId contact, State state, ReasonCode reasonCode) {
   if (mPersistentStorage.setStateAndReasonCode(state, reasonCode)) {
     mBroadcaster.broadcastStateChanged(contact, mSharingId, state, reasonCode);
   }
 }