Author: nextgens
Date: 2007-02-09 10:44:12 +0000 (Fri, 09 Feb 2007)
New Revision: 11705

Modified:
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
Cleanup the N2NM code ... the synchronization changes need testing

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2007-02-09 10:34:25 UTC 
(rev 11704)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2007-02-09 10:44:12 UTC 
(rev 11705)
@@ -2697,17 +2697,7 @@
                } else if(extraPeerDataType == 
Node.EXTRA_PEER_DATA_TYPE_QUEUED_TO_SEND_N2NTM) {
                        boolean sendSuccess = false;
                        if(isConnected()) {
-                               String source_nodename = null;
-                               String target_nodename = null;
                                String text = null;
-                               try {
-                                       source_nodename = new 
String(Base64.decode(fs.get("source_nodename")));
-                                       target_nodename = new 
String(Base64.decode(fs.get("target_nodename")));
-                                       text = new 
String(Base64.decode(fs.get("text")));
-                               } catch (IllegalBase64Exception e) {
-                                       Logger.error(this, "Bad Base64 encoding 
when decoding a N2NTM SimpleFieldSet", e);
-                                       return false;
-                               }
                                Message n2ntm;
                                if(fs.get("extraPeerDataType") != null) {
                                        fs.removeValue("extraPeerDataType");
@@ -2715,27 +2705,25 @@
                                if(fs.get("senderFileNumber") != null) {
                                        fs.removeValue("senderFileNumber");
                                }
-                               fs.put("senderFileNumber", 
Integer.toString(fileNumber));
+                               fs.put("senderFileNumber", 
String.valueOf(fileNumber));
                                if(fs.get("sentTime") != null) {
                                        fs.removeValue("sentTime");
                                }
                                fs.put("sentTime", 
Long.toString(System.currentTimeMillis()));
-                               if(Version.buildNumber() < 1000) {  // 
FIXME/TODO: This test shouldn't be needed eventually
-                                       n2ntm = 
DMT.createNodeToNodeTextMessage(Node.N2N_TEXT_MESSAGE_TYPE_USERALERT, 
node.getMyName(), getName(), text);
-                               } else {
-                                       try {
-                                               n2ntm = 
DMT.createNodeToNodeMessage(Node.N2N_TEXT_MESSAGE_TYPE_USERALERT, 
fs.toString().getBytes("UTF-8"));
-                                       } catch (UnsupportedEncodingException 
e) {
-                                               Logger.error(this, 
"UnsupportedEncodingException processing extraPeerDataType 
("+extraPeerDataTypeString+") in file "+extraPeerDataFile.getPath(), e);
-                                               return false;
-                                       }
+                               
+                               try {
+                                       n2ntm = 
DMT.createNodeToNodeMessage(Node.N2N_TEXT_MESSAGE_TYPE_USERALERT, 
fs.toString().getBytes("UTF-8"));
+                               } catch (UnsupportedEncodingException e) {
+                                       Logger.error(this, 
"UnsupportedEncodingException processing extraPeerDataType 
("+extraPeerDataTypeString+") in file "+extraPeerDataFile.getPath(), e);
+                                       return false;
                                }
+
                                try {
-                                       node.usm.send(this, n2ntm, null);
-                                       Logger.normal(this, "Sent queued 
("+fileNumber+") N2NTM to '"+getName()+"': "+text);
-                                       sendSuccess = true;
                                        
synchronized(queuedToSendN2NTMExtraPeerDataFileNumbers) {
-                                               
queuedToSendN2NTMExtraPeerDataFileNumbers.remove(new Integer(fileNumber));
+                                               node.usm.send(this, n2ntm, 
null);
+                                               Logger.normal(this, "Sent 
queued ("+fileNumber+") N2NTM to '"+getName()+"': "+text);
+                                               sendSuccess = true;
+                                               
queuedToSendN2NTMExtraPeerDataFileNumbers.remove(Integer.valueOf(fileNumber));
                                        }
                                        deleteExtraPeerDataFile(fileNumber);
                                } catch (NotConnectedException e) {
@@ -2743,10 +2731,10 @@
                                }
                        }
                        if(!sendSuccess) {
-                               fs.put("extraPeerDataType", 
Integer.toString(extraPeerDataType));
-                               fs.removeValue("sentTime");
                                
synchronized(queuedToSendN2NTMExtraPeerDataFileNumbers) {
-                                       
queuedToSendN2NTMExtraPeerDataFileNumbers.add(new Integer(fileNumber));
+                                       fs.put("extraPeerDataType", 
Integer.toString(extraPeerDataType));
+                                       fs.removeValue("sentTime");
+                                       
queuedToSendN2NTMExtraPeerDataFileNumbers.add(Integer.valueOf(fileNumber));
                                }
                        }
                        return true;


Reply via email to