コード例 #1
0
  private void importIdentity(
      boolean ownIdentity,
      String identityID,
      String requestURI,
      String insertURI,
      String nickname) {
    synchronized (mFreetalk.getTaskManager()) {
      synchronized (db.lock()) {
        try {
          Logger.normal(this, "Importing identity from WoT: " + requestURI);
          final WoTIdentity id =
              ownIdentity
                  ? new WoTOwnIdentity(
                      identityID, new FreenetURI(requestURI), new FreenetURI(insertURI), nickname)
                  : new WoTIdentity(identityID, new FreenetURI(requestURI), nickname);

          id.initializeTransient(mFreetalk);
          id.storeWithoutCommit();

          onNewIdentityAdded(id);

          if (ownIdentity) onNewOwnIdentityAdded((WoTOwnIdentity) id);

          id.checkedCommit(this);
        } catch (Exception e) {
          Persistent.checkedRollbackAndThrow(db, this, new RuntimeException(e));
        }
      }
    }
  }
コード例 #2
0
  public synchronized WoTOwnIdentity createOwnIdentity(
      String newNickname,
      boolean publishesTrustList,
      boolean publishesIntroductionPuzzles,
      boolean autoSubscribeToNewBoards,
      boolean displayImages,
      FreenetURI newRequestURI,
      FreenetURI newInsertURI)
      throws Exception {
    Logger.normal(this, "Creating new own identity via FCP, nickname: " + newNickname);

    SimpleFieldSet params = new SimpleFieldSet(true);
    params.putOverwrite("Message", "CreateIdentity");
    params.putOverwrite("Nickname", newNickname);
    params.putOverwrite("PublishTrustList", publishesTrustList ? "true" : "false");
    params.putOverwrite(
        "PublishIntroductionPuzzles",
        publishesTrustList && publishesIntroductionPuzzles ? "true" : "false");
    params.putOverwrite("Context", Freetalk.WOT_CONTEXT);
    params.putOverwrite("RequestURI", newRequestURI.toString());
    params.putOverwrite("InsertURI", newInsertURI.toString());
    PluginTalkerBlocking.Result result = sendFCPMessageBlocking(params, null, "IdentityCreated");

    /* We take the URIs which were returned by the WoT plugin instead of the requested ones because this allows the identity to work
     * even if the WoT plugin ignores our requested URIs: If we just stored the URIs we requested, we would store an identity with
     * wrong URIs which would result in the identity not being useable. */
    WoTOwnIdentity identity =
        new WoTOwnIdentity(
            result.params.get("ID"),
            new FreenetURI(result.params.get("RequestURI")),
            new FreenetURI(result.params.get("InsertURI")),
            newNickname,
            autoSubscribeToNewBoards,
            displayImages);

    identity.initializeTransient(mFreetalk);

    Logger.normal(this, "Created WoTOwnidentity via FCP, now storing... " + identity);

    synchronized (mFreetalk.getTaskManager()) {
      synchronized (db.lock()) {
        try {
          identity.storeWithoutCommit();
          onNewOwnIdentityAdded(identity);
          identity.checkedCommit(this);
          Logger.normal(this, "Stored new WoTOwnIdentity " + identity);
        } catch (RuntimeException e) {
          Persistent.checkedRollback(db, this, e);
        }
      }
    }

    return identity;
  }
コード例 #3
0
  public synchronized WoTOwnIdentity createOwnIdentity(
      String newNickname,
      boolean publishesTrustList,
      boolean publishesIntroductionPuzzles,
      boolean autoSubscribeToNewBoards,
      boolean displayImages)
      throws Exception {

    Logger.normal(this, "Creating new own identity via FCP, nickname: " + newNickname);

    SimpleFieldSet params = new SimpleFieldSet(true);
    params.putOverwrite("Message", "CreateIdentity");
    params.putOverwrite("Nickname", newNickname);
    params.putOverwrite("PublishTrustList", publishesTrustList ? "true" : "false");
    params.putOverwrite(
        "PublishIntroductionPuzzles", publishesIntroductionPuzzles ? "true" : "false");
    params.putOverwrite("Context", Freetalk.WOT_CONTEXT);
    PluginTalkerBlocking.Result result = sendFCPMessageBlocking(params, null, "IdentityCreated");

    WoTOwnIdentity identity =
        new WoTOwnIdentity(
            result.params.get("ID"),
            new FreenetURI(result.params.get("RequestURI")),
            new FreenetURI(result.params.get("InsertURI")),
            newNickname,
            autoSubscribeToNewBoards,
            displayImages);

    identity.initializeTransient(mFreetalk);

    Logger.normal(this, "Created WoTOwnidentity via FCP, now storing... " + identity);

    synchronized (mFreetalk.getTaskManager()) { // Required by onNewOwnidentityAdded
      synchronized (db.lock()) {
        try {
          identity.initializeTransient(mFreetalk);
          identity.storeWithoutCommit();
          onNewOwnIdentityAdded(identity);
          identity.checkedCommit(this);
          Logger.normal(this, "Stored new WoTOwnIdentity " + identity);

        } catch (RuntimeException e) {
          Persistent.checkedRollbackAndThrow(db, this, e);
        }
      }
    }

    return identity;
  }