[Zerofile-svn] SF.net SVN: zerofile: [82] trunk/src
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
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.
|