diff --git a/htroot/MessageSend_p.html b/htroot/MessageSend_p.html index 43b76927f..a719c0acd 100644 --- a/htroot/MessageSend_p.html +++ b/htroot/MessageSend_p.html @@ -7,48 +7,48 @@ #%env/templates/header.template%# #(mode)# - +

Send message

- #(permission)# - -

You cannot send a message to #[peerName]#.
- The peer does not respond. It was now removed from the peer-list. -

- :: - -

The peer #[peerName]# is alive and responded:

-

#[response]# - You are allowed to send me a message ≤ #[messagesize]# kb and an - attachment ≤ #[attachmentsize]#. -

+ #(permission)# + +

You cannot send a message to #[peerName]#.
+ The peer does not respond. It was now removed from the peer-list. +

+ :: + +

The peer #[peerName]# is alive and responded:

+

#[response]# + You are allowed to send me a message ≤ #[messagesize]# kb and an + attachment ≤ #[attachmentsize]#. +

-
+
- Your Message -
-
- -
-
- -
-
- -
-
- -

- You can use Wiki Code here. -

-
-
+ Your Message +
+
+ +
+
+ +
+
+ +
+
+ +

+ You can use Wiki Code here. +

+
+
-
+ ::

@@ -57,19 +57,19 @@

#(/permission)# :: - +

Preview message

#(permission)#

You cannot send a message to #[peerName]#.
- The peer does not respond. It was now removed from the peer-list. + The peer does not respond. It was now removed from the peer-list.

::

The peer #[peerName]# is alive and responded:

#[response]# - You are allowed to send me a message ≤ #[messagesize]# kb and an - attachment ≤ #[attachmentsize]#. + You are allowed to send me a message ≤ #[messagesize]# kb and an + attachment ≤ #[attachmentsize]#.

The message has not been sent yet!

@@ -91,24 +91,24 @@
- Your Message -
-
- -
-
- -
-
- -
-
- -

- You can use Wiki Code here. -

-
-
+ Your Message +
+
+ +
+
+ +
+
+ +
+
+ +

+ You can use Wiki Code here. +

+
+
@@ -124,16 +124,16 @@

#(/permission)# :: - +

Send message

#(status)# - +

Your message has been sent. The target peer responded:

#[response]#

- + :: - +

The target peer is alive but did not receive your message. Sorry.

Here is a copy of your message, so you can copy it to save it for further attempts: @@ -142,12 +142,12 @@ #[message]#

#(/status)# - + :: - -

You cannot call this page directly. Instead, use a link on the Network page.

+ +

You cannot call this page directly. Instead, use a link on the Network page.

#(/mode)# - + #%env/templates/footer.template%# diff --git a/htroot/MessageSend_p.java b/htroot/MessageSend_p.java index f7dd92d55..4dba48dee 100644 --- a/htroot/MessageSend_p.java +++ b/htroot/MessageSend_p.java @@ -60,7 +60,7 @@ public class MessageSend_p { final serverObjects prop = new serverObjects(); if ((post == null) || (post.get("hash","").isEmpty())) { - prop.put("mode", "2"); + prop.put("mode", "3"); return prop; } @@ -78,52 +78,58 @@ public class MessageSend_p { // open an editor page for the message // first ask if the other peer is online, and also what kind of document it accepts Seed seed = sb.peers.getConnected(ASCII.getBytes(hash)); - for(String ip: seed.getIPs()) { - final Map result = Protocol.permissionMessage(seed.getPublicAddress(ip), hash); - //System.out.println("DEBUG: permission request result = " + result.toString()); - String peerName; - Seed targetPeer = null; - if (hash.equals(sb.peers.mySeed().hash)) { - peerName = sb.peers.mySeed().get(Seed.NAME,"nameless"); - } else { - targetPeer = sb.peers.getConnected(hash); - if (targetPeer == null) - peerName = "nameless"; - else - peerName = targetPeer.get(Seed.NAME,"nameless"); - } - - prop.putXML("mode_permission_peerName", peerName); - final String response = (result == null) ? null : result.get("response"); - if (response == null || result == null) { - // we don't have permission or other peer does not exist - prop.put("mode_permission", "0"); - if (targetPeer != null) { - sb.peers.peerActions.interfaceDeparture(targetPeer, ip); + if (seed != null) { + for (String ip : seed.getIPs()) { + final Map result = Protocol.permissionMessage(seed.getPublicAddress(ip), hash); + //System.out.println("DEBUG: permission request result = " + result.toString()); + String peerName; + Seed targetPeer = null; + if (hash.equals(sb.peers.mySeed().hash)) { + peerName = sb.peers.mySeed().get(Seed.NAME, "nameless"); + } else { + targetPeer = sb.peers.getConnected(hash); + if (targetPeer == null) { + peerName = "nameless"; + } else { + peerName = targetPeer.get(Seed.NAME, "nameless"); + } } - } else { - prop.put("mode_permission", "1"); - - // write input form - try { - final int messagesize = Integer.parseInt(result.get("messagesize")); - final int attachmentsize = Integer.parseInt(result.get("attachmentsize")); - - prop.putXML("mode_permission_response", response); - prop.put("mode_permission_messagesize", messagesize); - prop.put("mode_permission_attachmentsize", attachmentsize); - prop.putXML("mode_permission_subject", subject); - prop.putXML("mode_permission_message", message); - prop.putHTML("mode_permission_hash", hash); - if (post.containsKey("preview")) { - prop.putWiki(sb.peers.mySeed().getPublicAddress(ip), "mode_permission_previewmessage", message); + + prop.putXML("mode_permission_peerName", peerName); + final String response = (result == null) ? null : result.get("response"); + if (response == null || result == null) { + // we don't have permission or other peer does not exist + prop.put("mode_permission", "0"); + if (targetPeer != null) { + sb.peers.peerActions.interfaceDeparture(targetPeer, ip); + } + } else { + prop.put("mode_permission", "1"); + + // write input form + try { + final int messagesize = Integer.parseInt(result.get("messagesize")); + final int attachmentsize = Integer.parseInt(result.get("attachmentsize")); + + prop.putXML("mode_permission_response", response); + prop.put("mode_permission_messagesize", messagesize); + prop.put("mode_permission_attachmentsize", attachmentsize); + prop.putXML("mode_permission_subject", subject); + prop.putXML("mode_permission_message", message); + prop.putHTML("mode_permission_hash", hash); + if (post.containsKey("preview")) { + prop.putWiki(sb.peers.mySeed().getPublicAddress(ip), "mode_permission_previewmessage", message); + } + + } catch (final NumberFormatException e) { + // "unresolved pattern", the remote peer is alive but had an exception + prop.put("mode_permission", "2"); } - - } catch (final NumberFormatException e) { - // "unresolved pattern", the remote peer is alive but had an exception - prop.put("mode_permission", "2"); } } + } else { // seed == null + prop.put("mode_permission", "0"); + prop.putXML("mode_permission_peerName", "a passive peer"); } } else { prop.put("mode", "2"); @@ -140,7 +146,7 @@ public class MessageSend_p { SeedDB seedDB = sb.peers; // prepare request final String salt = crypt.randomSalt(); - + // send request final Map parts = Protocol.basicRequestParts(Switchboard.getSwitchboard(), hash, salt); parts.put("process", UTF8.StringBody("post"));