Esempio n. 1
0
  @Override
  public HTMLNode getHTMLText() {
    HTMLNode alertNode = new HTMLNode("div");
    alertNode.addChild(
        "p",
        l10n(
            "header",
            new String[] {"from", "composed", "sent", "received"},
            new String[] {
              sourceNodeName,
              DateFormat.getInstance().format(new Date(composedTime)),
              DateFormat.getInstance().format(new Date(sentTime)),
              DateFormat.getInstance().format(new Date(receivedTime))
            }));
    String[] lines = messageText.split("\n");
    for (int i = 0, c = lines.length; i < c; i++) {
      alertNode.addChild("#", lines[i]);
      if (i != lines.length - 1) alertNode.addChild("br");
    }

    DarknetPeerNode pn = (DarknetPeerNode) peerRef.get();
    if (pn != null)
      alertNode
          .addChild("p")
          .addChild("a", "href", "/send_n2ntm/?peernode_hashcode=" + pn.hashCode(), l10n("reply"));
    return alertNode;
  }
Esempio n. 2
0
 @Override
 public boolean isValid() {
   DarknetPeerNode pn = (DarknetPeerNode) peerRef.get();
   if (pn != null) {
     sourceNodeName = pn.getName();
     sourcePeer = pn.getPeer().toString();
   }
   return true;
 }
Esempio n. 3
0
 /**
  * Adds the node reference in the resources as a friend to the node this plugin is loaded.
  *
  * @return the corresponding PeerAdditionReturnCode indicating whether the bridge was added
  *     successfully as a friend
  */
 private PeerAdditionReturnCodes addFriendBridge() {
   SimpleFieldSet bridgeNodeFS;
   try {
     bridgeNodeFS = nodeRefHelper.getBridgeNodeRefFS();
   } catch (IOException e) {
     Logger.error(this, "IO Exception while parsing bridge reference resource file");
     return PeerAdditionReturnCodes.INTERNAL_ERROR;
   }
   PeerNode pn;
   try {
     pn = node.createNewDarknetNode(bridgeNodeFS, FRIEND_TRUST.HIGH, FRIEND_VISIBILITY.NO);
     ((DarknetPeerNode) pn).setPrivateDarknetCommentNote("Master Bridge");
   } catch (FSParseException e) {
     return PeerAdditionReturnCodes.CANT_PARSE;
   } catch (PeerParseException e) {
     return PeerAdditionReturnCodes.CANT_PARSE;
   } catch (ReferenceSignatureVerificationException e) {
     return PeerAdditionReturnCodes.INVALID_SIGNATURE;
   } catch (Throwable t) {
     Logger.error(this, "Internal error adding reference :" + t.getMessage(), t);
     return PeerAdditionReturnCodes.INTERNAL_ERROR;
   }
   if (Arrays.equals(pn.getPubKeyHash(), node.getDarknetPubKeyHash())) {
     Logger.warning(this, "The bridge  node reference file belongs to this node.");
     return PeerAdditionReturnCodes.TRY_TO_ADD_SELF;
   }
   if (!node.addPeerConnection(pn)) {
     return PeerAdditionReturnCodes.ALREADY_IN_REFERENCE;
   }
   return PeerAdditionReturnCodes.OK;
 }
Esempio n. 4
0
 public N2NTMUserAlert(
     DarknetPeerNode sourcePeerNode,
     String message,
     int fileNumber,
     long composedTime,
     long sentTime,
     long receivedTime) {
   super(true, null, null, null, null, UserAlert.MINOR, true, null, true, null);
   this.messageText = message;
   this.fileNumber = fileNumber;
   this.composedTime = composedTime;
   this.sentTime = sentTime;
   this.receivedTime = receivedTime;
   peerRef = sourcePeerNode.getWeakRef();
   sourceNodeName = sourcePeerNode.getName();
   sourcePeer = sourcePeerNode.getPeer().toString();
 }
 public DownloadFeedUserAlert(
     DarknetPeerNode sourcePeerNode,
     String description,
     int fileNumber,
     FreenetURI uri,
     long composed,
     long sent,
     long received) {
   super(true, null, null, null, null, UserAlert.MINOR, true, null, true, null);
   this.description = description;
   this.uri = uri;
   this.fileNumber = fileNumber;
   this.composed = composed;
   this.sent = sent;
   this.received = received;
   peerRef = sourcePeerNode.getWeakRef();
   sourceNodeName = sourcePeerNode.getName();
 }
 @Override
 public void onDismiss() {
   DarknetPeerNode pn = (DarknetPeerNode) peerRef.get();
   if (pn != null) pn.deleteExtraPeerDataFile(fileNumber);
 }
 @Override
 public boolean isValid() {
   DarknetPeerNode pn = (DarknetPeerNode) peerRef.get();
   if (pn != null) sourceNodeName = pn.getName();
   return true;
 }