コード例 #1
0
  @Override
  public String getShortestUniqueName(Identity identity) {
    // We must not synchronize anything according to the specification of this function (to prevent
    // deadlocks)
    String nickname = mShortestUniqueNicknameCache.get(identity.getID());

    if (nickname == null) nickname = identity.getFreetalkAddress();

    return nickname;
  }
コード例 #2
0
  /**
   * Not synchronized, the involved identity might be deleted during the query - which is not really
   * a problem.
   */
  public List<WoTTrust> getReceivedTrusts(Identity trustee) throws Exception {
    List<WoTTrust> result = new ArrayList<WoTTrust>();

    SimpleFieldSet request = new SimpleFieldSet(true);
    request.putOverwrite("Message", "GetTrusters");
    request.putOverwrite("Context", "");
    request.putOverwrite("Identity", trustee.getID());
    try {
      SimpleFieldSet answer = sendFCPMessageBlocking(request, null, "Identities").params;
      for (int idx = 0; ; idx++) {
        String id = answer.get("Identity" + idx);
        if (id == null
            || id.equals("")) /* TODO: Figure out whether the second condition is necessary */
          break;
        try {
          final WoTTrust trust =
              new WoTTrust(
                  getIdentity(id),
                  trustee,
                  (byte) Integer.parseInt(answer.get("Value" + idx)),
                  answer.get("Comment" + idx));
          mWoTCache.putTrust(trust);
          result.add(trust);
        } catch (NoSuchIdentityException e) {
        } catch (InvalidParameterException e) {
        }
      }
    } catch (PluginNotFoundException e) {
      throw new WoTDisconnectedException();
    }
    return result;
  }
コード例 #3
0
  /**
   * Not synchronized, the involved identities might be deleted during the query - which is not
   * really a problem.
   */
  private String getProperty(OwnIdentity truster, Identity target, String property)
      throws Exception {
    SimpleFieldSet sfs = new SimpleFieldSet(true);
    sfs.putOverwrite("Message", "GetIdentity");
    sfs.putOverwrite("Truster", truster.getID());
    sfs.putOverwrite("Identity", target.getID());

    return sendFCPMessageBlocking(sfs, null, "Identity").params.get(property);
  }
コード例 #4
0
  /**
   * Not synchronized, the involved identity might be deleted during the query - which is not really
   * a problem.
   */
  public int getReceivedTrustsCount(Identity trustee) throws Exception {
    SimpleFieldSet request = new SimpleFieldSet(true);
    request.putOverwrite("Message", "GetTrustersCount");
    request.putOverwrite("Identity", trustee.getID());
    request.putOverwrite("Context", Freetalk.WOT_CONTEXT);

    try {
      SimpleFieldSet answer = sendFCPMessageBlocking(request, null, "TrustersCount").params;
      return Integer.parseInt(answer.get("Value"));
    } catch (PluginNotFoundException e) {
      throw new WoTDisconnectedException();
    }
  }