zerofile-svn Mailing List for ZeroFile
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(51) |
Dec
(26) |
|---|
|
From: <kar...@us...> - 2007-12-13 15:06:32
|
Revision: 86
http://zerofile.svn.sourceforge.net/zerofile/?rev=86&view=rev
Author: karl-bengtsson
Date: 2007-12-13 07:06:29 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
Updated status messages for file transfer
Modified Paths:
--------------
trunk/src/HttpServer.java
Modified: trunk/src/HttpServer.java
===================================================================
--- trunk/src/HttpServer.java 2007-12-13 14:51:29 UTC (rev 85)
+++ trunk/src/HttpServer.java 2007-12-13 15:06:29 UTC (rev 86)
@@ -109,9 +109,9 @@
}
return null;
}
- public void printDoneMsg(String fileName)
+ public void printStatusMsg(String msg)
{
- _session.printTextToChatWindow("File \"" + fileName + "\" transferred successfully!");
+ _session.printTextToChatWindow(msg);
}
}
@@ -214,10 +214,11 @@
// Send the entity body.
if (fileExists)
{
+ _httpServer.printStatusMsg("Sending \"" + requestedFile.getName() + "\"...");
sendBytes(fis, output) ;
fis.close();
_httpServer.removeFile(requestedFile);
- _httpServer.printDoneMsg(requestedFile.getName());
+ _httpServer.printStatusMsg("File \"" + requestedFile.getName() + "\" transferred successfully!");
}
else
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-13 14:51:31
|
Revision: 85
http://zerofile.svn.sourceforge.net/zerofile/?rev=85&view=rev
Author: karl-bengtsson
Date: 2007-12-13 06:51:29 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
More status text updates on file transfer
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 14:47:19 UTC (rev 84)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 14:51:29 UTC (rev 85)
@@ -147,6 +147,7 @@
String fileName = urlToFile.substring(urlToFile.lastIndexOf("/")+1).replace("%20"," ");
if (ZeroFileSettings.getCheckBox().equals("true"))
{
+ _chatWindow.printText("Now downloading file \"" + fileName + "\" from chat partner");
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
_chatWindow.printText("Downloaded file \""+ fileName + "\" from chat partner");
}
@@ -154,6 +155,7 @@
{
if (JOptionPane.showConfirmDialog(null, _chatPartner.toString() + "is sending you the file \""+fileName+"\". Do you wish to accept this file transfer?","Ta emot?", JOptionPane.YES_NO_OPTION) == 0)
{
+ _chatWindow.printText("Now downloading file \"" + fileName + "\" from chat partner");
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
_chatWindow.printText("Downloaded file \""+ fileName + "\" from chat partner");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-13 14:47:21
|
Revision: 84
http://zerofile.svn.sourceforge.net/zerofile/?rev=84&view=rev
Author: karl-bengtsson
Date: 2007-12-13 06:47:19 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
bugfix for problems with sending files containing whitespace in file names
Modified Paths:
--------------
trunk/src/HttpServer.java
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFile.java
Modified: trunk/src/HttpServer.java
===================================================================
--- trunk/src/HttpServer.java 2007-12-13 14:17:44 UTC (rev 83)
+++ trunk/src/HttpServer.java 2007-12-13 14:47:19 UTC (rev 84)
@@ -160,7 +160,7 @@
if(temp.equals("GET"))
{
String fileName = s.nextToken();
- fileName = fileName.replaceFirst("/","");
+ fileName = fileName.replaceFirst("/","").replace("%20"," ");
FileInputStream fis = null ;
boolean fileExists = false;
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 14:17:44 UTC (rev 83)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 14:47:19 UTC (rev 84)
@@ -62,7 +62,7 @@
String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body>";
fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
- fileTransferStanza += "http://"+InetAddress.getLocalHost().getHostAddress()+":"+_httpServer.getPort()+"/"+filnamn+"</url></x></message>";
+ fileTransferStanza += "http://"+InetAddress.getLocalHost().getHostAddress()+":"+_httpServer.getPort()+"/"+filnamn.replace(" ", "%20")+"</url></x></message>";
_toRemoteHost.print(fileTransferStanza);
_toRemoteHost.flush();
}
@@ -144,7 +144,7 @@
if (stanza.contains("<x xmlns=\"jabber:x:oob\">"))
{
String urlToFile = XMPPDOMParser.getUrlFromFileTransferStanza(stanza);
- String fileName = urlToFile.substring(urlToFile.lastIndexOf("/")+1);
+ String fileName = urlToFile.substring(urlToFile.lastIndexOf("/")+1).replace("%20"," ");
if (ZeroFileSettings.getCheckBox().equals("true"))
{
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-12-13 14:17:44 UTC (rev 83)
+++ trunk/src/ZeroFile.java 2007-12-13 14:47:19 UTC (rev 84)
@@ -62,9 +62,9 @@
{
String localFileName;
if (!ZeroFileSettings.getDownloadFolder().equals(""))
- localFileName = ZeroFileSettings.getDownloadFolder() +"/"+ address.substring(lastSlashIndex + 1);
+ localFileName = ZeroFileSettings.getDownloadFolder() +"/"+ address.substring(lastSlashIndex + 1).replace("%20"," ");
else
- localFileName = System.getProperty("user.home") +"/"+ address.substring(lastSlashIndex + 1);
+ localFileName = System.getProperty("user.home") +"/"+ address.substring(lastSlashIndex + 1).replace("%20"," ");
URL url = new URL(address);
out = new BufferedOutputStream(
new FileOutputStream(localFileName));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-13 14:17:57
|
Revision: 83
http://zerofile.svn.sourceforge.net/zerofile/?rev=83&view=rev
Author: karl-bengtsson
Date: 2007-12-13 06:17:44 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
fancy chatwindow autoscroll
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFileChatWindow.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 14:10:21 UTC (rev 82)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 14:17:44 UTC (rev 83)
@@ -152,7 +152,7 @@
}
else
{
- if (JOptionPane.showConfirmDialog(null, "Ta emot?", _chatPartner.toString() + "is sending you the file \""+fileName+"\". Do you wish to accept this file transfer?", JOptionPane.YES_NO_OPTION) == 0)
+ if (JOptionPane.showConfirmDialog(null, _chatPartner.toString() + "is sending you the file \""+fileName+"\". Do you wish to accept this file transfer?","Ta emot?", JOptionPane.YES_NO_OPTION) == 0)
{
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
_chatWindow.printText("Downloaded file \""+ fileName + "\" from chat partner");
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-12-13 14:10:21 UTC (rev 82)
+++ trunk/src/ZeroFileChatWindow.java 2007-12-13 14:17:44 UTC (rev 83)
@@ -32,6 +32,7 @@
public void printText(String s)
{
_chatTextArea.append(s+"\n");
+ _chatTextArea.setCaretPosition(_chatTextArea.getDocument().getLength());
}
public void sendMessage(String str)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-13 14:10:18
|
Revision: 82
http://zerofile.svn.sourceforge.net/zerofile/?rev=82&view=rev
Author: karl-bengtsson
Date: 2007-12-13 06:10:21 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
uppsnyggad fildelning
Modified Paths:
--------------
trunk/src/HttpServer.java
trunk/src/XMPPDOMParser.java
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFileChatWindow.java
Modified: trunk/src/HttpServer.java
===================================================================
--- trunk/src/HttpServer.java 2007-12-13 13:57:51 UTC (rev 81)
+++ trunk/src/HttpServer.java 2007-12-13 14:10:21 UTC (rev 82)
@@ -75,6 +75,8 @@
public void removeFile(File filen)
{
_files.remove(filen);
+ if (_files.size() == 0)
+ stop();
}
public int getPort()
{
@@ -107,9 +109,9 @@
}
return null;
}
- public void printDoneMsg()
+ public void printDoneMsg(String fileName)
{
- _session.printTextToChatWindow("File transferred successfully!");
+ _session.printTextToChatWindow("File \"" + fileName + "\" transferred successfully!");
}
}
@@ -215,7 +217,7 @@
sendBytes(fis, output) ;
fis.close();
_httpServer.removeFile(requestedFile);
- _httpServer.printDoneMsg();
+ _httpServer.printDoneMsg(requestedFile.getName());
}
else
{
Modified: trunk/src/XMPPDOMParser.java
===================================================================
--- trunk/src/XMPPDOMParser.java 2007-12-13 13:57:51 UTC (rev 81)
+++ trunk/src/XMPPDOMParser.java 2007-12-13 14:10:21 UTC (rev 82)
@@ -69,7 +69,6 @@
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document d = factory.newDocumentBuilder().parse(new InputSource(new StringReader(stanza)));
return d.getElementsByTagName("url").item(0).getTextContent();
- //return d.getAttributes().getNamedItem("from").toString();
}
catch (Exception e)
{
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 13:57:51 UTC (rev 81)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 14:10:21 UTC (rev 82)
@@ -1,7 +1,5 @@
import java.io.*;
import java.net.*;
-import java.nio.*;
-import java.nio.charset.*;
import javax.swing.*;
@@ -18,8 +16,6 @@
private PrintWriter _toRemoteHost;
private ZeroFileChatWindow _chatWindow;
private XMPPLinkLocalHost _chatPartner;
- private Charset charset = Charset.forName("UTF-8");
- private CharsetEncoder encoder = charset.newEncoder();
private HttpServer _httpServer = new HttpServer(this);
private Thread _remoteHostReadingThread = new Thread() {
@@ -101,7 +97,6 @@
private void RecievedStanza(String stanza)
{
- System.out.println(stanza);
if (stanza.contains("<?xml"))
// Stanza is a handshake
{
@@ -148,17 +143,19 @@
{
if (stanza.contains("<x xmlns=\"jabber:x:oob\">"))
{
+ String urlToFile = XMPPDOMParser.getUrlFromFileTransferStanza(stanza);
+ String fileName = urlToFile.substring(urlToFile.lastIndexOf("/")+1);
if (ZeroFileSettings.getCheckBox().equals("true"))
{
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
- _chatWindow.printText("Downloaded file from chat partner");
+ _chatWindow.printText("Downloaded file \""+ fileName + "\" from chat partner");
}
else
{
- if (JOptionPane.showConfirmDialog(null, "Ta emot?", "Ta emot fil?", JOptionPane.YES_NO_OPTION) == 0)
+ if (JOptionPane.showConfirmDialog(null, "Ta emot?", _chatPartner.toString() + "is sending you the file \""+fileName+"\". Do you wish to accept this file transfer?", JOptionPane.YES_NO_OPTION) == 0)
{
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
- _chatWindow.printText("Downloaded file from chat partner");
+ _chatWindow.printText("Downloaded file \""+ fileName + "\" from chat partner");
}
}
}
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-12-13 13:57:51 UTC (rev 81)
+++ trunk/src/ZeroFileChatWindow.java 2007-12-13 14:10:21 UTC (rev 82)
@@ -1,5 +1,6 @@
import java.awt.*;
import java.awt.event.*;
+import java.io.File;
import javax.swing.*;
@@ -81,7 +82,9 @@
JFileChooser _fileChooser= new JFileChooser();
_fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
_fileChooser.showOpenDialog(null);
- _session.offerFileTransfer(_fileChooser.getSelectedFile().toString());
+ File offeredFile = _fileChooser.getSelectedFile();
+ _session.offerFileTransfer(offeredFile.toString());
+ printText("Offered file \"" + offeredFile.getName() + "\" to chat partner");
}
}
);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-13 13:57:46
|
Revision: 81
http://zerofile.svn.sourceforge.net/zerofile/?rev=81&view=rev
Author: karl-bengtsson
Date: 2007-12-13 05:57:51 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
thrown out old code
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 13:49:41 UTC (rev 80)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 13:57:51 UTC (rev 81)
@@ -67,8 +67,7 @@
fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
fileTransferStanza += "http://"+InetAddress.getLocalHost().getHostAddress()+":"+_httpServer.getPort()+"/"+filnamn+"</url></x></message>";
- ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(fileTransferStanza));
- _toRemoteHost.print(bbuf.asCharBuffer().toString());
+ _toRemoteHost.print(fileTransferStanza);
_toRemoteHost.flush();
}
catch (Exception e)
@@ -85,7 +84,7 @@
{
_s = new Socket(hostToChatWith.getHost(),hostToChatWith.getPort());
_toRemoteHost = new PrintWriter(_s.getOutputStream());
- _fromRemoteHost = new InputStreamReader(_s.getInputStream(),"UTF-8");
+ _fromRemoteHost = new InputStreamReader(_s.getInputStream());
_remoteHostReadingThread.start();
sendHandshake();
}
@@ -211,8 +210,7 @@
try
{
String messageStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body>"+m+"</body></message>";
- ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(messageStanza));
- _toRemoteHost.print(bbuf.asCharBuffer().toString());
+ _toRemoteHost.print(messageStanza);
_toRemoteHost.flush();
}
catch (Exception e)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-13 13:49:36
|
Revision: 80
http://zerofile.svn.sourceforge.net/zerofile/?rev=80&view=rev
Author: karl-bengtsson
Date: 2007-12-13 05:49:41 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
bugfix
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 13:47:52 UTC (rev 79)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 13:49:41 UTC (rev 80)
@@ -68,7 +68,7 @@
fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
fileTransferStanza += "http://"+InetAddress.getLocalHost().getHostAddress()+":"+_httpServer.getPort()+"/"+filnamn+"</url></x></message>";
ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(fileTransferStanza));
- _toRemoteHost.print(bbuf.toString());
+ _toRemoteHost.print(bbuf.asCharBuffer().toString());
_toRemoteHost.flush();
}
catch (Exception e)
@@ -212,7 +212,7 @@
{
String messageStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body>"+m+"</body></message>";
ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(messageStanza));
- _toRemoteHost.print(bbuf.toString());
+ _toRemoteHost.print(bbuf.asCharBuffer().toString());
_toRemoteHost.flush();
}
catch (Exception e)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-13 13:47:50
|
Revision: 79
http://zerofile.svn.sourceforge.net/zerofile/?rev=79&view=rev
Author: karl-bengtsson
Date: 2007-12-13 05:47:52 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
bugfix
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 13:42:14 UTC (rev 78)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 13:47:52 UTC (rev 79)
@@ -68,7 +68,7 @@
fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
fileTransferStanza += "http://"+InetAddress.getLocalHost().getHostAddress()+":"+_httpServer.getPort()+"/"+filnamn+"</url></x></message>";
ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(fileTransferStanza));
- _toRemoteHost.print(bbuf);
+ _toRemoteHost.print(bbuf.toString());
_toRemoteHost.flush();
}
catch (Exception e)
@@ -102,6 +102,7 @@
private void RecievedStanza(String stanza)
{
+ System.out.println(stanza);
if (stanza.contains("<?xml"))
// Stanza is a handshake
{
@@ -211,7 +212,7 @@
{
String messageStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body>"+m+"</body></message>";
ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(messageStanza));
- _toRemoteHost.print(bbuf);
+ _toRemoteHost.print(bbuf.toString());
_toRemoteHost.flush();
}
catch (Exception e)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-13 13:42:16
|
Revision: 78
http://zerofile.svn.sourceforge.net/zerofile/?rev=78&view=rev
Author: karl-bengtsson
Date: 2007-12-13 05:42:14 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
maybe support for swedish characters
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFile.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 11:30:42 UTC (rev 77)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 13:42:14 UTC (rev 78)
@@ -1,5 +1,8 @@
import java.io.*;
import java.net.*;
+import java.nio.*;
+import java.nio.charset.*;
+
import javax.swing.*;
/*
@@ -15,6 +18,8 @@
private PrintWriter _toRemoteHost;
private ZeroFileChatWindow _chatWindow;
private XMPPLinkLocalHost _chatPartner;
+ private Charset charset = Charset.forName("UTF-8");
+ private CharsetEncoder encoder = charset.newEncoder();
private HttpServer _httpServer = new HttpServer(this);
private Thread _remoteHostReadingThread = new Thread() {
@@ -62,8 +67,8 @@
fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
fileTransferStanza += "http://"+InetAddress.getLocalHost().getHostAddress()+":"+_httpServer.getPort()+"/"+filnamn+"</url></x></message>";
- System.out.println(fileTransferStanza);
- _toRemoteHost.print(fileTransferStanza);
+ ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(fileTransferStanza));
+ _toRemoteHost.print(bbuf);
_toRemoteHost.flush();
}
catch (Exception e)
@@ -80,7 +85,7 @@
{
_s = new Socket(hostToChatWith.getHost(),hostToChatWith.getPort());
_toRemoteHost = new PrintWriter(_s.getOutputStream());
- _fromRemoteHost = new InputStreamReader(_s.getInputStream());
+ _fromRemoteHost = new InputStreamReader(_s.getInputStream(),"UTF-8");
_remoteHostReadingThread.start();
sendHandshake();
}
@@ -202,9 +207,17 @@
public void sendMessage(String m)
{
- String messageStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body>"+m+"</body></message>";
- _toRemoteHost.print(messageStanza);
- _toRemoteHost.flush();
+ try
+ {
+ String messageStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body>"+m+"</body></message>";
+ ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(messageStanza));
+ _toRemoteHost.print(bbuf);
+ _toRemoteHost.flush();
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
}
public void disconnect()
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-12-13 11:30:42 UTC (rev 77)
+++ trunk/src/ZeroFile.java 2007-12-13 13:42:14 UTC (rev 78)
@@ -7,7 +7,6 @@
* @throws IOException
*/
public static void main(String[] args) throws IOException {
- System.out.println(InetAddress.getLocalHost().getHostAddress());
System.out.println(
new java.io.OutputStreamWriter(
new java.io.ByteArrayOutputStream()).getEncoding()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-13 11:30:40
|
Revision: 77
http://zerofile.svn.sourceforge.net/zerofile/?rev=77&view=rev
Author: karl-bengtsson
Date: 2007-12-13 03:30:42 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
File transfer ftw, w00t
Modified Paths:
--------------
trunk/src/HttpServer.java
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFile.java
Modified: trunk/src/HttpServer.java
===================================================================
--- trunk/src/HttpServer.java 2007-12-05 07:25:07 UTC (rev 76)
+++ trunk/src/HttpServer.java 2007-12-13 11:30:42 UTC (rev 77)
@@ -1,14 +1,14 @@
import java.net.*;
import java.io.*;
import java.util.*;
-import java.lang.*;
public class HttpServer {
private int _portNr;
- private List<File> _files;
+ private ArrayList<File> _files = new ArrayList<File>();
private XMPPLinkLocalChatSession _session;
private Boolean _running = false;
private ServerSocket _serverSocket;
+ private HttpServer _httpServer = this;
private Thread _httpListenerThread = new Thread()
{
public void run()
@@ -21,7 +21,7 @@
System.out.println("New connection accepted " + connection.getInetAddress() + ":" + connection.getPort());
try
{
- httpRequestHandler request = new httpRequestHandler(connection);
+ httpRequestHandler request = new httpRequestHandler(_httpServer,connection);
// Create a new thread to process the request.
Thread thread = new Thread(request);
@@ -49,6 +49,7 @@
_portNr = _serverSocket.getLocalPort();
System.out.println("httpServer starting running on port " + _portNr);
_httpListenerThread.start();
+ _running = true;
}
catch (Exception e)
{
@@ -67,7 +68,7 @@
}
public void addFile(File filen)
{
- //_files.add(filen); TODO N\x8Ctt buggar h\x8Ar
+ _files.add(filen);
if (!_running)
start();
}
@@ -83,6 +84,33 @@
{
return _running;
}
+ public ArrayList<File> getFiles()
+ {
+ return _files;
+ }
+ public Boolean servesFile(String fileName)
+ {
+ for (int i = 0; i<_files.size(); i++)
+ {
+ if (_files.get(i).getName().equals(fileName))
+ return true;
+ }
+ return false;
+ }
+
+ public File getFile(String fileName)
+ {
+ for (int i = 0; i<_files.size(); i++)
+ {
+ if (_files.get(i).getName().equals(fileName))
+ return _files.get(i);
+ }
+ return null;
+ }
+ public void printDoneMsg()
+ {
+ _session.printTextToChatWindow("File transferred successfully!");
+ }
}
class httpRequestHandler implements Runnable
@@ -92,14 +120,16 @@
InputStream input;
OutputStream output;
BufferedReader br;
+ HttpServer _httpServer;
// Constructor
- public httpRequestHandler(Socket socket) throws Exception
+ public httpRequestHandler(HttpServer httpServer,Socket socket) throws Exception
{
this.socket = socket;
this.input = socket.getInputStream();
this.output = socket.getOutputStream();
this.br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ this._httpServer = httpServer;
}
public void run()
@@ -128,19 +158,17 @@
if(temp.equals("GET"))
{
String fileName = s.nextToken();
- fileName = "." + fileName ;
+ fileName = fileName.replaceFirst("/","");
- // Open the requested file.
FileInputStream fis = null ;
- boolean fileExists = true ;
- try
+ boolean fileExists = false;
+ File requestedFile = null;
+ if (_httpServer.servesFile(fileName))
{
- fis = new FileInputStream( fileName ) ;
+ requestedFile = _httpServer.getFile(fileName);
+ fis = new FileInputStream(requestedFile.getPath()) ;
+ fileExists = true;
}
- catch ( FileNotFoundException e )
- {
- fileExists = false ;
- }
// Construct the response message.
String serverLine = "Server: ZeroFile embedded http server/1.0" + CRLF;
@@ -150,7 +178,6 @@
String contentLengthLine = "error";
if ( fileExists )
{
- System.out.println("hittade fil");
statusLine = "HTTP/1.0 200 OK" + CRLF ;
contentTypeLine = "Content-type: " + contentType( fileName ) + CRLF ;
contentLengthLine = "Content-Length: "
@@ -159,7 +186,6 @@
}
else
{
- System.out.println("hittade inte fil");
statusLine = "HTTP/1.0 404 Not Found" + CRLF ;
contentTypeLine = "Content-Type: text/html" + CRLF ;
entityBody = "<HTML>"
@@ -188,6 +214,8 @@
{
sendBytes(fis, output) ;
fis.close();
+ _httpServer.removeFile(requestedFile);
+ _httpServer.printDoneMsg();
}
else
{
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-05 07:25:07 UTC (rev 76)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 11:30:42 UTC (rev 77)
@@ -52,16 +52,24 @@
public void offerFileTransfer(String localFileNameAndPath)
{
- File filen = new File(localFileNameAndPath);
- _httpServer.addFile(filen);
- long sizeOfFile = filen.length();
- String filnamn = filen.getName();
- String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body>";
- fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
- fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
- fileTransferStanza += "http://10.100.46.243:5297/25E8656B83FBA3A2/"+filnamn+"</url></x></message>";
- _toRemoteHost.print(fileTransferStanza);
- _toRemoteHost.flush();
+ try
+ {
+ File filen = new File(localFileNameAndPath);
+ _httpServer.addFile(filen);
+ long sizeOfFile = filen.length();
+ String filnamn = filen.getName();
+ String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body>";
+ fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
+ fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
+ fileTransferStanza += "http://"+InetAddress.getLocalHost().getHostAddress()+":"+_httpServer.getPort()+"/"+filnamn+"</url></x></message>";
+ System.out.println(fileTransferStanza);
+ _toRemoteHost.print(fileTransferStanza);
+ _toRemoteHost.flush();
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
}
public XMPPLinkLocalChatSession(XMPPLinkLocalHost hostToChatWith)
@@ -147,10 +155,6 @@
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
_chatWindow.printText("Downloaded file from chat partner");
}
- else
- {
- // Skicka "jag vill inte ha din j\x8Avla fil-meddelande"
- }
}
}
}
@@ -191,6 +195,11 @@
}
}
+ public void printTextToChatWindow(String txt)
+ {
+ _chatWindow.printText(txt);
+ }
+
public void sendMessage(String m)
{
String messageStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body>"+m+"</body></message>";
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-12-05 07:25:07 UTC (rev 76)
+++ trunk/src/ZeroFile.java 2007-12-13 11:30:42 UTC (rev 77)
@@ -7,6 +7,7 @@
* @throws IOException
*/
public static void main(String[] args) throws IOException {
+ System.out.println(InetAddress.getLocalHost().getHostAddress());
System.out.println(
new java.io.OutputStreamWriter(
new java.io.ByteArrayOutputStream()).getEncoding()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-05 07:25:06
|
Revision: 76
http://zerofile.svn.sourceforge.net/zerofile/?rev=76&view=rev
Author: karl-bengtsson
Date: 2007-12-04 23:25:07 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
The embedded HTTP server now returns a working 404 error when any file is requested. The server actually works and respects HTTP 1.0 (sort of). We now need to make it serve the files we've elected to share.
Modified Paths:
--------------
trunk/src/HttpServer.java
Modified: trunk/src/HttpServer.java
===================================================================
--- trunk/src/HttpServer.java 2007-12-04 16:26:31 UTC (rev 75)
+++ trunk/src/HttpServer.java 2007-12-05 07:25:07 UTC (rev 76)
@@ -9,46 +9,47 @@
private XMPPLinkLocalChatSession _session;
private Boolean _running = false;
private ServerSocket _serverSocket;
- private Thread _httpListenerThread;
- public void start()
+ private Thread _httpListenerThread = new Thread()
{
- try
+ public void run()
{
- _serverSocket = new ServerSocket();
- _portNr = _serverSocket.getLocalPort();
- System.out.println("httpServer starting running on port " + _portNr);
- _httpListenerThread = new Thread()
- {
- public void run()
+ try
{
- try
+ while(true)
{
- while(true)
+ Socket connection = _serverSocket.accept();
+ System.out.println("New connection accepted " + connection.getInetAddress() + ":" + connection.getPort());
+ try
{
- Socket connection = _serverSocket.accept();
- System.out.println("New connection accepted " + connection.getInetAddress() + ":" + connection.getPort());
- try
- {
- httpRequestHandler request = new httpRequestHandler(connection);
- // Create a new thread to process the request.
- Thread thread = new Thread(request);
+ httpRequestHandler request = new httpRequestHandler(connection);
+ // Create a new thread to process the request.
+ Thread thread = new Thread(request);
- // Start the thread.
- thread.start();
- }
- catch(Exception e)
- {
- System.out.println(e);
- }
+ // Start the thread.
+ thread.start();
}
+ catch(Exception e)
+ {
+ System.out.println(e);
+ }
}
- catch (Exception e)
- {
- System.out.println(e);
- }
}
- };
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
}
+ };
+
+ public void start()
+ {
+ try
+ {
+ _serverSocket = new ServerSocket(0);
+ _portNr = _serverSocket.getLocalPort();
+ System.out.println("httpServer starting running on port " + _portNr);
+ _httpListenerThread.start();
+ }
catch (Exception e)
{
System.out.println(e);
@@ -115,7 +116,7 @@
private void processRequest() throws Exception
{
- while(true)
+ while (true)
{
String headerLine = br.readLine();
System.out.println(headerLine);
@@ -142,13 +143,14 @@
}
// Construct the response message.
- String serverLine = "Server: ZeroFile embedded http server";
+ String serverLine = "Server: ZeroFile embedded http server/1.0" + CRLF;
String statusLine = null;
String contentTypeLine = null;
String entityBody = null;
String contentLengthLine = "error";
if ( fileExists )
{
+ System.out.println("hittade fil");
statusLine = "HTTP/1.0 200 OK" + CRLF ;
contentTypeLine = "Content-type: " + contentType( fileName ) + CRLF ;
contentLengthLine = "Content-Length: "
@@ -157,13 +159,13 @@
}
else
{
+ System.out.println("hittade inte fil");
statusLine = "HTTP/1.0 404 Not Found" + CRLF ;
- contentTypeLine = "text/html" ;
+ contentTypeLine = "Content-Type: text/html" + CRLF ;
entityBody = "<HTML>"
+ "<HEAD><TITLE>404 Not Found</TITLE></HEAD>"
- + "<BODY>404 Not Found"
- + "<br>usage:http://www.snaip.com:4444/"
- + "fileName.html</BODY></HTML>" ;
+ + "<BODY>404 Not Found</BODY></HTML>" ;
+ contentLengthLine = "Content-Length: " + entityBody.length() + CRLF;
}
// Send the status line.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 16:26:44
|
Revision: 75
http://zerofile.svn.sourceforge.net/zerofile/?rev=75&view=rev
Author: karl-bengtsson
Date: 2007-12-04 08:26:31 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
blandade tester
Modified Paths:
--------------
trunk/src/HttpServer.java
Modified: trunk/src/HttpServer.java
===================================================================
--- trunk/src/HttpServer.java 2007-12-04 15:46:53 UTC (rev 74)
+++ trunk/src/HttpServer.java 2007-12-04 16:26:31 UTC (rev 75)
@@ -5,30 +5,74 @@
public class HttpServer {
private int _portNr;
- private File[] _files;
+ private List<File> _files;
private XMPPLinkLocalChatSession _session;
- private Boolean _running;
+ private Boolean _running = false;
+ private ServerSocket _serverSocket;
+ private Thread _httpListenerThread;
public void start()
{
- _running = true;
+ try
+ {
+ _serverSocket = new ServerSocket();
+ _portNr = _serverSocket.getLocalPort();
+ System.out.println("httpServer starting running on port " + _portNr);
+ _httpListenerThread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ while(true)
+ {
+ Socket connection = _serverSocket.accept();
+ System.out.println("New connection accepted " + connection.getInetAddress() + ":" + connection.getPort());
+ try
+ {
+ httpRequestHandler request = new httpRequestHandler(connection);
+ // Create a new thread to process the request.
+ Thread thread = new Thread(request);
+
+ // Start the thread.
+ thread.start();
+ }
+ catch(Exception e)
+ {
+ System.out.println(e);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
}
+
public void stop()
{
+ _httpListenerThread.interrupt();
_running = false;
}
HttpServer(XMPPLinkLocalChatSession session)
{
_session = session;
- if (!_running)
- start();
}
public void addFile(File filen)
{
-
+ //_files.add(filen); TODO N\x8Ctt buggar h\x8Ar
+ if (!_running)
+ start();
}
public void removeFile(File filen)
{
-
+ _files.remove(filen);
}
public int getPort()
{
@@ -39,3 +83,145 @@
return _running;
}
}
+
+class httpRequestHandler implements Runnable
+{
+ final static String CRLF = "\r\n";
+ Socket socket;
+ InputStream input;
+ OutputStream output;
+ BufferedReader br;
+
+ // Constructor
+ public httpRequestHandler(Socket socket) throws Exception
+ {
+ this.socket = socket;
+ this.input = socket.getInputStream();
+ this.output = socket.getOutputStream();
+ this.br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ }
+
+ public void run()
+ {
+ try
+ {
+ processRequest();
+ }
+ catch(Exception e)
+ {
+ System.out.println(e);
+ }
+ }
+
+ private void processRequest() throws Exception
+ {
+ while(true)
+ {
+ String headerLine = br.readLine();
+ System.out.println(headerLine);
+ if(headerLine.equals(CRLF) || headerLine.equals("")) break;
+
+ StringTokenizer s = new StringTokenizer(headerLine);
+ String temp = s.nextToken();
+
+ if(temp.equals("GET"))
+ {
+ String fileName = s.nextToken();
+ fileName = "." + fileName ;
+
+ // Open the requested file.
+ FileInputStream fis = null ;
+ boolean fileExists = true ;
+ try
+ {
+ fis = new FileInputStream( fileName ) ;
+ }
+ catch ( FileNotFoundException e )
+ {
+ fileExists = false ;
+ }
+
+ // Construct the response message.
+ String serverLine = "Server: ZeroFile embedded http server";
+ String statusLine = null;
+ String contentTypeLine = null;
+ String entityBody = null;
+ String contentLengthLine = "error";
+ if ( fileExists )
+ {
+ statusLine = "HTTP/1.0 200 OK" + CRLF ;
+ contentTypeLine = "Content-type: " + contentType( fileName ) + CRLF ;
+ contentLengthLine = "Content-Length: "
+ + (new Integer(fis.available())).toString()
+ + CRLF;
+ }
+ else
+ {
+ statusLine = "HTTP/1.0 404 Not Found" + CRLF ;
+ contentTypeLine = "text/html" ;
+ entityBody = "<HTML>"
+ + "<HEAD><TITLE>404 Not Found</TITLE></HEAD>"
+ + "<BODY>404 Not Found"
+ + "<br>usage:http://www.snaip.com:4444/"
+ + "fileName.html</BODY></HTML>" ;
+ }
+
+ // Send the status line.
+ output.write(statusLine.getBytes());
+
+ // Send the server line.
+ output.write(serverLine.getBytes());
+
+ // Send the content type line.
+ output.write(contentTypeLine.getBytes());
+
+ // Send the Content-Length
+ output.write(contentLengthLine.getBytes());
+
+ // Send a blank line to indicate the end of the header lines.
+ output.write(CRLF.getBytes());
+
+ // Send the entity body.
+ if (fileExists)
+ {
+ sendBytes(fis, output) ;
+ fis.close();
+ }
+ else
+ {
+ output.write(entityBody.getBytes());
+ }
+ }
+ }
+
+ try
+ {
+ output.close();
+ br.close();
+ socket.close();
+ }
+ catch(Exception e) {}
+ }
+
+ private static void sendBytes(FileInputStream fis, OutputStream os) throws Exception
+ {
+ // Construct a 1K buffer to hold bytes on their way to the socket.
+ byte[] buffer = new byte[1024] ;
+ int bytes = 0 ;
+
+ // Copy requested file into the socket's output stream.
+ while ((bytes = fis.read(buffer)) != -1 )
+ {
+ os.write(buffer, 0, bytes);
+ }
+ }
+
+ private static String contentType(String fileName)
+ {
+ if (fileName.endsWith(".htm") || fileName.endsWith(".html"))
+ {
+ return "text/html";
+ }
+ return "";
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 15:46:48
|
Revision: 74
http://zerofile.svn.sourceforge.net/zerofile/?rev=74&view=rev
Author: karl-bengtsson
Date: 2007-12-04 07:46:53 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
added skeleton http server without any functionality
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Added Paths:
-----------
trunk/src/HttpServer.java
Added: trunk/src/HttpServer.java
===================================================================
--- trunk/src/HttpServer.java (rev 0)
+++ trunk/src/HttpServer.java 2007-12-04 15:46:53 UTC (rev 74)
@@ -0,0 +1,41 @@
+import java.net.*;
+import java.io.*;
+import java.util.*;
+import java.lang.*;
+
+public class HttpServer {
+ private int _portNr;
+ private File[] _files;
+ private XMPPLinkLocalChatSession _session;
+ private Boolean _running;
+ public void start()
+ {
+ _running = true;
+ }
+ public void stop()
+ {
+ _running = false;
+ }
+ HttpServer(XMPPLinkLocalChatSession session)
+ {
+ _session = session;
+ if (!_running)
+ start();
+ }
+ public void addFile(File filen)
+ {
+
+ }
+ public void removeFile(File filen)
+ {
+
+ }
+ public int getPort()
+ {
+ return _portNr;
+ }
+ public Boolean isRunnin()
+ {
+ return _running;
+ }
+}
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 15:32:18 UTC (rev 73)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 15:46:53 UTC (rev 74)
@@ -15,6 +15,7 @@
private PrintWriter _toRemoteHost;
private ZeroFileChatWindow _chatWindow;
private XMPPLinkLocalHost _chatPartner;
+ private HttpServer _httpServer = new HttpServer(this);
private Thread _remoteHostReadingThread = new Thread() {
public void run() {
@@ -52,6 +53,7 @@
public void offerFileTransfer(String localFileNameAndPath)
{
File filen = new File(localFileNameAndPath);
+ _httpServer.addFile(filen);
long sizeOfFile = filen.length();
String filnamn = filen.getName();
String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body>";
@@ -176,6 +178,7 @@
public XMPPLinkLocalChatSession(Socket s)
{
_s = s;
+
try
{
_fromRemoteHost = new InputStreamReader(_s.getInputStream());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 15:32:19
|
Revision: 73
http://zerofile.svn.sourceforge.net/zerofile/?rev=73&view=rev
Author: karl-bengtsson
Date: 2007-12-04 07:32:18 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
We can now offer files workingly. sort of.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 15:19:07 UTC (rev 72)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 15:32:18 UTC (rev 73)
@@ -54,7 +54,7 @@
File filen = new File(localFileNameAndPath);
long sizeOfFile = filen.length();
String filnamn = filen.getName();
- String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body></message>";
+ String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body>";
fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
fileTransferStanza += "http://10.100.46.243:5297/25E8656B83FBA3A2/"+filnamn+"</url></x></message>";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 15:19:08
|
Revision: 72
http://zerofile.svn.sourceforge.net/zerofile/?rev=72&view=rev
Author: karl-bengtsson
Date: 2007-12-04 07:19:07 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
now we try to send the file transfer stanza
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:52:16 UTC (rev 71)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 15:19:07 UTC (rev 72)
@@ -51,22 +51,15 @@
public void offerFileTransfer(String localFileNameAndPath)
{
- System.out.println(localFileNameAndPath);
- int lastSlashIndex = localFileNameAndPath.lastIndexOf('/');
- if (!(lastSlashIndex >= 0 && lastSlashIndex < localFileNameAndPath.length() - 1))
- {
- System.out.println("blaaargh, felaktigt filnamn");
- }
- else
- {
- File filen = new File(localFileNameAndPath);
- long sizeOfFile = filen.length();
- String filnamn = localFileNameAndPath.substring(lastSlashIndex + 1);
- String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body></message>";
- fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
- fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
- fileTransferStanza += "http://10.100.46.243:5297/25E8656B83FBA3A2/"+filnamn+"</url></x></message>";
- }
+ File filen = new File(localFileNameAndPath);
+ long sizeOfFile = filen.length();
+ String filnamn = filen.getName();
+ String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body></message>";
+ fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
+ fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
+ fileTransferStanza += "http://10.100.46.243:5297/25E8656B83FBA3A2/"+filnamn+"</url></x></message>";
+ _toRemoteHost.print(fileTransferStanza);
+ _toRemoteHost.flush();
}
public XMPPLinkLocalChatSession(XMPPLinkLocalHost hostToChatWith)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 14:52:14
|
Revision: 71
http://zerofile.svn.sourceforge.net/zerofile/?rev=71&view=rev
Author: karl-bengtsson
Date: 2007-12-04 06:52:16 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
test2
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:50:49 UTC (rev 70)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:52:16 UTC (rev 71)
@@ -51,6 +51,7 @@
public void offerFileTransfer(String localFileNameAndPath)
{
+ System.out.println(localFileNameAndPath);
int lastSlashIndex = localFileNameAndPath.lastIndexOf('/');
if (!(lastSlashIndex >= 0 && lastSlashIndex < localFileNameAndPath.length() - 1))
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 14:50:44
|
Revision: 70
http://zerofile.svn.sourceforge.net/zerofile/?rev=70&view=rev
Author: karl-bengtsson
Date: 2007-12-04 06:50:49 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
buggfix
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:50:04 UTC (rev 69)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:50:49 UTC (rev 70)
@@ -64,7 +64,7 @@
String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body></message>";
fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
- fileTransferStanza += "http://10.100.46.243:5297/25E8656B83FBA3A2/"+localFileNameAndPath+"</url></x></message>";
+ fileTransferStanza += "http://10.100.46.243:5297/25E8656B83FBA3A2/"+filnamn+"</url></x></message>";
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 14:50:01
|
Revision: 69
http://zerofile.svn.sourceforge.net/zerofile/?rev=69&view=rev
Author: karl-bengtsson
Date: 2007-12-04 06:50:04 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Test av file sending stanza grejjer
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFileChatWindow.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:31:19 UTC (rev 68)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:50:04 UTC (rev 69)
@@ -49,6 +49,25 @@
}
}
+ public void offerFileTransfer(String localFileNameAndPath)
+ {
+ int lastSlashIndex = localFileNameAndPath.lastIndexOf('/');
+ if (!(lastSlashIndex >= 0 && lastSlashIndex < localFileNameAndPath.length() - 1))
+ {
+ System.out.println("blaaargh, felaktigt filnamn");
+ }
+ else
+ {
+ File filen = new File(localFileNameAndPath);
+ long sizeOfFile = filen.length();
+ String filnamn = localFileNameAndPath.substring(lastSlashIndex + 1);
+ String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body></message>";
+ fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
+ fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
+ fileTransferStanza += "http://10.100.46.243:5297/25E8656B83FBA3A2/"+localFileNameAndPath+"</url></x></message>";
+ }
+ }
+
public XMPPLinkLocalChatSession(XMPPLinkLocalHost hostToChatWith)
{
_chatPartner = hostToChatWith;
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-12-04 14:31:19 UTC (rev 68)
+++ trunk/src/ZeroFileChatWindow.java 2007-12-04 14:50:04 UTC (rev 69)
@@ -13,6 +13,7 @@
private JPanel _bottomPanel;
private JTextField _entryTextField;
private JButton _sendButton;
+ private JButton _sendFileButton;
private XMPPLinkLocalChatSession _session;
public ZeroFileChatWindow(XMPPLinkLocalChatSession sess)
@@ -53,6 +54,7 @@
_bottomPanel.setLayout(new GridLayout(1,0,1,1));
_entryTextField = new JTextField();
_sendButton = new JButton("Send");
+ _sendFileButton = new JButton("Send file...");
_bottomPanel.add(_entryTextField);
_entryTextField.addKeyListener(
new KeyListener()
@@ -72,6 +74,17 @@
}
});
_bottomPanel.add(_sendButton);
+ _bottomPanel.add(_sendFileButton);
+ _sendFileButton.addActionListener(
+ new ActionListener(){
+ public void actionPerformed(ActionEvent sendButtonPress){
+ JFileChooser _fileChooser= new JFileChooser();
+ _fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ _fileChooser.showOpenDialog(null);
+ _session.offerFileTransfer(_fileChooser.getSelectedFile().toString());
+ }
+ }
+ );
_chatWindowFrame.setVisible(true);
_sendButton.addActionListener(
new ActionListener(){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 14:31:15
|
Revision: 68
http://zerofile.svn.sourceforge.net/zerofile/?rev=68&view=rev
Author: karl-bengtsson
Date: 2007-12-04 06:31:19 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
buggfix
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFile.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:25:40 UTC (rev 67)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:31:19 UTC (rev 68)
@@ -127,7 +127,7 @@
}
else
{
- if (JOptionPane.showConfirmDialog(null, "Ta emot?", "Ta emot fil?", JOptionPane.YES_NO_OPTION) == 1)
+ if (JOptionPane.showConfirmDialog(null, "Ta emot?", "Ta emot fil?", JOptionPane.YES_NO_OPTION) == 0)
{
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
_chatWindow.printText("Downloaded file from chat partner");
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-12-04 14:25:40 UTC (rev 67)
+++ trunk/src/ZeroFile.java 2007-12-04 14:31:19 UTC (rev 68)
@@ -78,7 +78,6 @@
out.write(buffer, 0, numRead);
numWritten += numRead;
}
- System.out.println(localFileName + "\t" + numWritten);
}
catch (Exception exception)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 14:25:37
|
Revision: 67
http://zerofile.svn.sourceforge.net/zerofile/?rev=67&view=rev
Author: karl-bengtsson
Date: 2007-12-04 06:25:40 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
We can now recieve files offered by iChat. Great success! Jagshemash!
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:11:48 UTC (rev 66)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:25:40 UTC (rev 67)
@@ -120,7 +120,6 @@
{
if (stanza.contains("<x xmlns=\"jabber:x:oob\">"))
{
- System.out.println(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
if (ZeroFileSettings.getCheckBox().equals("true"))
{
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
@@ -133,6 +132,10 @@
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
_chatWindow.printText("Downloaded file from chat partner");
}
+ else
+ {
+ // Skicka "jag vill inte ha din j\x8Avla fil-meddelande"
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 14:13:12
|
Revision: 66
http://zerofile.svn.sourceforge.net/zerofile/?rev=66&view=rev
Author: karl-bengtsson
Date: 2007-12-04 06:11:48 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Tjosan.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:00:29 UTC (rev 65)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:11:48 UTC (rev 66)
@@ -1,5 +1,6 @@
import java.io.*;
import java.net.*;
+import javax.swing.*;
/*
* Class for handling chat sessions.
@@ -123,12 +124,15 @@
if (ZeroFileSettings.getCheckBox().equals("true"))
{
ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
- _chatWindow.printText("Downloading file from chat partner");
+ _chatWindow.printText("Downloaded file from chat partner");
}
else
{
- ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
- _chatWindow.printText("Downloading file from chat partner");
+ if (JOptionPane.showConfirmDialog(null, "Ta emot?", "Ta emot fil?", JOptionPane.YES_NO_OPTION) == 1)
+ {
+ ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
+ _chatWindow.printText("Downloaded file from chat partner");
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 14:00:32
|
Revision: 65
http://zerofile.svn.sourceforge.net/zerofile/?rev=65&view=rev
Author: karl-bengtsson
Date: 2007-12-04 06:00:29 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
further refinement of download methods
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFile.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 13:49:00 UTC (rev 64)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:00:29 UTC (rev 65)
@@ -120,9 +120,16 @@
if (stanza.contains("<x xmlns=\"jabber:x:oob\">"))
{
System.out.println(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
- ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
- // This is a file
-
+ if (ZeroFileSettings.getCheckBox().equals("true"))
+ {
+ ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
+ _chatWindow.printText("Downloading file from chat partner");
+ }
+ else
+ {
+ ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
+ _chatWindow.printText("Downloading file from chat partner");
+ }
}
}
else
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-12-04 13:49:00 UTC (rev 64)
+++ trunk/src/ZeroFile.java 2007-12-04 14:00:29 UTC (rev 65)
@@ -62,9 +62,9 @@
{
String localFileName;
if (!ZeroFileSettings.getDownloadFolder().equals(""))
- localFileName = ZeroFileSettings.getDownloadFolder() + address.substring(lastSlashIndex + 1);
+ localFileName = ZeroFileSettings.getDownloadFolder() +"/"+ address.substring(lastSlashIndex + 1);
else
- localFileName = System.getProperty("user.home") + address.substring(lastSlashIndex + 1);
+ localFileName = System.getProperty("user.home") +"/"+ address.substring(lastSlashIndex + 1);
URL url = new URL(address);
out = new BufferedOutputStream(
new FileOutputStream(localFileName));
@@ -73,11 +73,11 @@
byte[] buffer = new byte[1024];
int numRead;
long numWritten = 0;
- /*while ((numRead = in.read(buffer)) != -1)
+ while ((numRead = in.read(buffer)) != -1)
{
out.write(buffer, 0, numRead);
numWritten += numRead;
- }*/
+ }
System.out.println(localFileName + "\t" + numWritten);
}
catch (Exception exception)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 13:49:01
|
Revision: 64
http://zerofile.svn.sourceforge.net/zerofile/?rev=64&view=rev
Author: karl-bengtsson
Date: 2007-12-04 05:49:00 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 13:47:54 UTC (rev 63)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 13:49:00 UTC (rev 64)
@@ -120,6 +120,7 @@
if (stanza.contains("<x xmlns=\"jabber:x:oob\">"))
{
System.out.println(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
+ ZeroFile.downloadFileFromHTTP(XMPPDOMParser.getUrlFromFileTransferStanza(stanza));
// This is a file
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 13:47:51
|
Revision: 63
http://zerofile.svn.sourceforge.net/zerofile/?rev=63&view=rev
Author: karl-bengtsson
Date: 2007-12-04 05:47:54 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
test of initial download method
Modified Paths:
--------------
trunk/src/ZeroFile.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-12-04 13:35:23 UTC (rev 62)
+++ trunk/src/ZeroFile.java 2007-12-04 13:47:54 UTC (rev 63)
@@ -1,5 +1,5 @@
-import java.io.IOException;
-import java.net.InetAddress;
+import java.io.*;
+import java.net.*;
public class ZeroFile {
/**
@@ -45,4 +45,63 @@
return null;
}
}
+
+ public static void downloadFileFromHTTP(String address)
+ {
+ OutputStream out = null;
+ URLConnection conn = null;
+ InputStream in = null;
+ int lastSlashIndex = address.lastIndexOf('/');
+ if (!(lastSlashIndex >= 0 && lastSlashIndex < address.length() - 1))
+ {
+ System.err.println("Could not figure out local file name for " + address);
+ }
+ else
+ {
+ try
+ {
+ String localFileName;
+ if (!ZeroFileSettings.getDownloadFolder().equals(""))
+ localFileName = ZeroFileSettings.getDownloadFolder() + address.substring(lastSlashIndex + 1);
+ else
+ localFileName = System.getProperty("user.home") + address.substring(lastSlashIndex + 1);
+ URL url = new URL(address);
+ out = new BufferedOutputStream(
+ new FileOutputStream(localFileName));
+ conn = url.openConnection();
+ in = conn.getInputStream();
+ byte[] buffer = new byte[1024];
+ int numRead;
+ long numWritten = 0;
+ /*while ((numRead = in.read(buffer)) != -1)
+ {
+ out.write(buffer, 0, numRead);
+ numWritten += numRead;
+ }*/
+ System.out.println(localFileName + "\t" + numWritten);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace();
+ }
+ finally
+ {
+ try
+ {
+ if (in != null)
+ {
+ in.close();
+ }
+ if (out != null)
+ {
+ out.close();
+ }
+ }
+ catch (IOException ioe)
+ {
+ System.out.println(ioe);
+ }
+ }
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-12-04 13:35:18
|
Revision: 62
http://zerofile.svn.sourceforge.net/zerofile/?rev=62&view=rev
Author: karl-bengtsson
Date: 2007-12-04 05:35:23 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
slight update to url-finding method
Modified Paths:
--------------
trunk/src/XMPPDOMParser.java
Modified: trunk/src/XMPPDOMParser.java
===================================================================
--- trunk/src/XMPPDOMParser.java 2007-12-04 13:08:49 UTC (rev 61)
+++ trunk/src/XMPPDOMParser.java 2007-12-04 13:35:23 UTC (rev 62)
@@ -68,7 +68,7 @@
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document d = factory.newDocumentBuilder().parse(new InputSource(new StringReader(stanza)));
- return d.getElementsByTagName("url").toString();
+ return d.getElementsByTagName("url").item(0).getTextContent();
//return d.getAttributes().getNamedItem("from").toString();
}
catch (Exception e)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|