예제 #1
0
  public boolean offerData(String offerId, String url, String type) {
    if (mConnection.getState() == ImConnection.SUSPENDED) {
      // TODO send later
      return false;
    }

    HashMap<String, String> headers = null;
    if (type != null) {
      headers = new HashMap<>();
      headers.put("Mime-Type", type);
    }

    try {
      Address localUser = mConnection.getLoginUser().getAddress();

      if (mChatSession.getParticipant() instanceof Contact) {

        Address remoteUser = new XmppAddress(getDefaultOtrChatSession().getRemoteUserId());
        mDataHandler.offerData(offerId, localUser, remoteUser, url, headers);
      } else if (mChatSession.getParticipant() instanceof ChatGroup) {
        ChatGroup group = (ChatGroup) mChatSession.getParticipant();

        for (Contact member : group.getMembers()) {
          mDataHandler.offerData(offerId, localUser, member.getAddress(), url, headers);
        }
      }

      return true;
    } catch (Exception ioe) {
      Log.w(ImApp.LOG_TAG, "unable to offer data", ioe);
      return false;
    }
  }
예제 #2
0
  @Override
  public void setIncomingFileResponse(String transferForm, boolean acceptThis, boolean acceptAll) {

    mAcceptTransfer = acceptThis;
    mAcceptAllTransfer = acceptAll;
    mWaitingForResponse = false;

    mDataHandler.acceptTransfer(mLastFileUrl, transferForm);
  }
예제 #3
0
  private void initOtrChatSession(ImEntity participant) {
    try {
      if (mConnection != null) {
        mDataHandler = new OtrDataHandler(mChatSession);
        mDataHandlerListener = new DataHandlerListenerImpl();
        mDataHandler.setDataListener(mDataHandlerListener);

        OtrChatManager cm = service.getOtrChatManager();
        cm.addOtrEngineListener(mListenerAdapter);
        mChatSession.setMessageListener(new OtrChatListener(cm, mListenerAdapter));

        if (participant instanceof Contact) {
          String key = participant.getAddress().getAddress();
          if (!mOtrChatSessions.containsKey(key)) {
            OtrChatSessionAdapter adapter =
                new OtrChatSessionAdapter(
                    mConnection.getLoginUser().getAddress().getAddress(), participant, cm);
            mOtrChatSessions.put(key, adapter);
          }
        } else if (participant instanceof ChatGroup) {
          ChatGroup group = (ChatGroup) mChatSession.getParticipant();

          for (Contact contact : group.getMembers()) {
            String key = contact.getAddress().getAddress();
            if (!mOtrChatSessions.containsKey(key)) {
              OtrChatSessionAdapter adapter =
                  new OtrChatSessionAdapter(
                      mConnection.getLoginUser().getAddress().getAddress(), contact, cm);
              mOtrChatSessions.put(key, adapter);
            }
          }
        }

        mDataHandler.setChatId(getId());
      }
    } catch (NullPointerException npe) {
      Log.e(ImApp.LOG_TAG, "error init OTR session", npe);
    }
  }
예제 #4
0
  @Override
  public void setDataListener(IDataListener dataListener) throws RemoteException {

    mDataListener = dataListener;
    mDataHandler.setDataListener(mDataListener);
  }