[Zerofile-svn] SF.net SVN: zerofile: [52] trunk/src
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
From: <kar...@us...> - 2007-11-21 11:00:01
|
Revision: 52
http://zerofile.svn.sourceforge.net/zerofile/?rev=52&view=rev
Author: karl-bengtsson
Date: 2007-11-21 03:00:01 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
We now listen for incoming connections, and when such connections are recieved, establish a socket and a chat window etc. All text is still output in raw format to the console.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFile.java
trunk/src/ZeroFileChatWindow.java
trunk/src/ZeroFileSettings.java
trunk/src/ZeroFileSettingsWindow.java
trunk/src/ZeroconfRegistration.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-11-13 14:49:17 UTC (rev 51)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-11-21 11:00:01 UTC (rev 52)
@@ -6,7 +6,7 @@
*/
public class XMPPLinkLocalChatSession {
- private XMPPLinkLocalHost _remoteHost;
+ //private XMPPLinkLocalHost _remoteHost;
private Socket _s;
private Reader _fromRemoteHost;
private PrintWriter _toRemoteHost;
@@ -29,10 +29,29 @@
};
public XMPPLinkLocalChatSession(XMPPLinkLocalHost hostToChatWith)
{
- _remoteHost = hostToChatWith;
- connect();
+ //_remoteHost = hostToChatWith;
+ connect(hostToChatWith.getHost(),hostToChatWith.getPort());
_chatWindow = new ZeroFileChatWindow(this);
}
+ public XMPPLinkLocalChatSession(Socket s)
+ {
+ try
+ {
+ //_remoteHost = XMPPLinkLocalHost();
+ _s = s;
+ _fromRemoteHost = new InputStreamReader(_s.getInputStream());
+ _toRemoteHost = new PrintWriter(_s.getOutputStream());
+ _remoteHostReadingThread.start();
+ _toRemoteHost.print("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
+ _toRemoteHost.print("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>");
+ _toRemoteHost.flush();
+ _chatWindow = new ZeroFileChatWindow(this);
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
+ }
public void sendMessage(String m)
{
_toRemoteHost.print("<message><body>"+m+"</body></message>");
@@ -43,11 +62,12 @@
System.out.println("The text \"" + m + "\" should now be sent to:");
System.out.println(hostName + ":" + port);*/
}
- public void connect()
+ public void connect(String host,int port)
{
try
{
- _s = new Socket(_remoteHost.getHost(),_remoteHost.getPort());
+ //_s = new Socket(_remoteHost.getHost(),_remoteHost.getPort());
+ _s = new Socket(host,port);
_fromRemoteHost = new InputStreamReader(_s.getInputStream());
_toRemoteHost = new PrintWriter(_s.getOutputStream());
_remoteHostReadingThread.start();
@@ -61,10 +81,10 @@
System.out.println(e);
}
}
- public XMPPLinkLocalHost getRemoteHost()
+ /*public XMPPLinkLocalHost getRemoteHost()
{
return _remoteHost;
- }
+ }*/
public void disconnect()
{
try
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-13 14:49:17 UTC (rev 51)
+++ trunk/src/ZeroFile.java 2007-11-21 11:00:01 UTC (rev 52)
@@ -11,8 +11,9 @@
ZeroFileSettings.loadSettings();
try
{
+ ZeroFileSettings.loadSettings();
ZeroconfRegistration.registerService();
- ZeroFileSettings.loadSettings();
+ XMPPSessionListener.startListening(ZeroFileSettings.getMainPort());
ZeroconfRegistration.set1st(ZeroFileSettings.getFirstName());
ZeroconfRegistration.setLast(ZeroFileSettings.getLastName());
ZeroconfRegistration.setEmail(ZeroFileSettings.getEmail());
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-11-13 14:49:17 UTC (rev 51)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-21 11:00:01 UTC (rev 52)
@@ -16,9 +16,9 @@
public ZeroFileChatWindow(XMPPLinkLocalChatSession chatSession)
{
_session = chatSession;
- _session.getRemoteHost().updateData();
+ //_session.getRemoteHost().updateData();
_chatWindowFrame = new JFrame();
- _chatWindowFrame.setTitle(_session.getRemoteHost().toString());
+ //_chatWindowFrame.setTitle(_session.getRemoteHost().toString());
_chatWindowFrame.setLayout(new GridLayout(0,1,1,1));
_chatWindowFrame.setLocation(0,400);
_chatWindowFrame.setSize(new Dimension(300,200));
Modified: trunk/src/ZeroFileSettings.java
===================================================================
--- trunk/src/ZeroFileSettings.java 2007-11-13 14:49:17 UTC (rev 51)
+++ trunk/src/ZeroFileSettings.java 2007-11-21 11:00:01 UTC (rev 52)
@@ -60,15 +60,15 @@
_zeroFileProperties.put("Email", e);
}
- public static String getMainPort() {
+ public static int getMainPort() {
if (_zeroFileProperties.containsKey("Port"))
- return _zeroFileProperties.getProperty("Port");
+ return Integer.valueOf(_zeroFileProperties.getProperty("Port"));
else
- return "1337";
+ return 5222;
}
- public static void setMainPort(String p)
+ public static void setMainPort(int p)
{
- _zeroFileProperties.put("Port", p);
+ _zeroFileProperties.put("Port", String.valueOf(p));
}
public static void setCheckBox(String p)
Modified: trunk/src/ZeroFileSettingsWindow.java
===================================================================
--- trunk/src/ZeroFileSettingsWindow.java 2007-11-13 14:49:17 UTC (rev 51)
+++ trunk/src/ZeroFileSettingsWindow.java 2007-11-21 11:00:01 UTC (rev 52)
@@ -49,7 +49,7 @@
//Label + field for port parameter
JLabel portLabel = new JLabel("Port", JLabel.CENTER);
final JTextField portField = new JTextField();
- portField.setText(ZeroFileSettings.getMainPort());
+ portField.setText(String.valueOf(ZeroFileSettings.getMainPort()));
settingsWindowFrame.add(portLabel);
settingsWindowFrame.add(portField);
@@ -104,7 +104,7 @@
if(!emailField.getText().equals(""))
ZeroFileSettings.setEmail(emailField.getText());
if(!portField.getText().equals(""))
- ZeroFileSettings.setMainPort(portField.getText());
+ ZeroFileSettings.setMainPort(Integer.valueOf(portField.getText()));
if(!pathNowLabel.getText().equals(""))
ZeroFileSettings.setDownloadFolder(pathNowLabel.getText());
ZeroFileSettings.setCheckBox(String.valueOf(checkBoxTransfer.isSelected()));
Modified: trunk/src/ZeroconfRegistration.java
===================================================================
--- trunk/src/ZeroconfRegistration.java 2007-11-13 14:49:17 UTC (rev 51)
+++ trunk/src/ZeroconfRegistration.java 2007-11-21 11:00:01 UTC (rev 52)
@@ -45,7 +45,7 @@
static void registerService()
throws DNSSDException, InterruptedException
{
- ZeroconfRegistration.registerService(5222);
+ ZeroconfRegistration.registerService(ZeroFileSettings.getMainPort());
}
static void unregisterService()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|