Thread: [Zerofile-svn] SF.net SVN: zerofile: [11] trunk/src
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
From: <kar...@us...> - 2007-11-03 18:59:25
|
Revision: 11
http://zerofile.svn.sourceforge.net/zerofile/?rev=11&view=rev
Author: karl-bengtsson
Date: 2007-11-03 11:59:30 -0700 (Sat, 03 Nov 2007)
Log Message:
-----------
Moved test registration into the main ZeroFile.java file so that we only have one main() in all of our classes. The registration with Zeroconf should eventually be handled by some sort of special registration class.
Modified Paths:
--------------
trunk/src/ZeroConfRegistrationTest.java
trunk/src/ZeroFile.java
Modified: trunk/src/ZeroConfRegistrationTest.java
===================================================================
--- trunk/src/ZeroConfRegistrationTest.java 2007-11-03 13:21:05 UTC (rev 10)
+++ trunk/src/ZeroConfRegistrationTest.java 2007-11-03 18:59:30 UTC (rev 11)
@@ -1,5 +1,4 @@
import com.apple.dnssd.*;
-import java.net.*;
/*
* This class tests XMPP ZeroConf registration, by registering as
@@ -62,28 +61,4 @@
System.out.println("Registration Stopping");
r.stop( );
}
-
- public static void main(String[] args) {
- if (args.length > 1)
- {
- System.out.println("Usage: java TestRegister name");
- System.exit(-1);
- }
- else
- {
- try
- {
- //If name specified, use it, else use default name
- String name = (args.length > 0) ? args[0] : null;
- // Let system allocate us an available port to listen on
- ServerSocket s = new ServerSocket(0);
- new ZeroConfRegistrationTest(name, s.getLocalPort( ));
- }
- catch(Exception e)
- {
- e.printStackTrace( );
- System.exit(-1);
- }
- }
- }
}
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-03 13:21:05 UTC (rev 10)
+++ trunk/src/ZeroFile.java 2007-11-03 18:59:30 UTC (rev 11)
@@ -1,3 +1,5 @@
+import java.net.ServerSocket;
+
// Main loop of the program
public class ZeroFile {
@@ -8,5 +10,26 @@
public static void main(String[] args) {
ZeroFileMainWindow Huvudfonster = new ZeroFileMainWindow();
Huvudfonster.setVisible(true);
+ if (args.length > 1)
+ {
+ System.out.println("Usage: java TestRegister name");
+ System.exit(-1);
+ }
+ else
+ {
+ try
+ {
+ //If name specified, use it, else use default name
+ String name = (args.length > 0) ? args[0] : null;
+ // Let system allocate us an available port to listen on
+ ServerSocket s = new ServerSocket(0);
+ new ZeroConfRegistrationTest(name, s.getLocalPort( ));
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace( );
+ System.exit(-1);
+ }
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-03 20:03:06
|
Revision: 12
http://zerofile.svn.sourceforge.net/zerofile/?rev=12&view=rev
Author: karl-bengtsson
Date: 2007-11-03 13:03:06 -0700 (Sat, 03 Nov 2007)
Log Message:
-----------
A bunch of changes to structure up the classes and prepare for actual codng to begin. Added class definitions (but not much implementation) to handle zeroconf registration and browsing, and application settings.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalSession.java
trunk/src/ZeroFileMainWindow.java
Added Paths:
-----------
trunk/src/ZeroFileSettings.java
trunk/src/ZeroconfBrowsing.java
trunk/src/ZeroconfRegistration.java
Modified: trunk/src/XMPPLinkLocalSession.java
===================================================================
--- trunk/src/XMPPLinkLocalSession.java 2007-11-03 18:59:30 UTC (rev 11)
+++ trunk/src/XMPPLinkLocalSession.java 2007-11-03 20:03:06 UTC (rev 12)
@@ -1,4 +1,8 @@
-// Stub class, to be the base for our actual chat sessions
+/* Stub class, to be the base for our actual chat sessions
+* Should perhaps be renamed to indicate that this is actually a
+* chat session?
+*/
+
public class XMPPLinkLocalSession {
}
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-03 18:59:30 UTC (rev 11)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-03 20:03:06 UTC (rev 12)
@@ -1,4 +1,5 @@
// The class defining the main GUI window
+
import java.awt.*;
import javax.swing.*;
Added: trunk/src/ZeroFileSettings.java
===================================================================
--- trunk/src/ZeroFileSettings.java (rev 0)
+++ trunk/src/ZeroFileSettings.java 2007-11-03 20:03:06 UTC (rev 12)
@@ -0,0 +1,60 @@
+/* Settings for the program are stored in this class. Or something.
+ * At present, all it holds are a bunch of getters and setters.
+ */
+public class ZeroFileSettings {
+ private String _nickName;
+ private String _firstName;
+ private String _lastName;
+ private String _email;
+ private int _mainPort;
+
+ public String getNickName()
+ {
+ return _nickName;
+ }
+
+ public void setNickName(String n)
+ {
+ _nickName = n;
+ }
+
+ public String getFirstName()
+ {
+ return _firstName;
+ }
+
+ public void setFirstName(String f)
+ {
+ _firstName = f;
+ }
+
+ public String getLastName()
+ {
+ return _lastName;
+ }
+
+ public void setLastName(String l)
+ {
+ _nickName = l;
+ }
+
+ public String getEmail()
+ {
+ return _email;
+ }
+
+ public void setEmail(String e)
+ {
+ _email = e;
+ }
+
+ public int getMainPort()
+ {
+ return _mainPort;
+ }
+
+ public void setMainPort(int p)
+ {
+ _mainPort = p;
+ }
+}
Added: trunk/src/ZeroconfBrowsing.java
===================================================================
--- trunk/src/ZeroconfBrowsing.java (rev 0)
+++ trunk/src/ZeroconfBrowsing.java 2007-11-03 20:03:06 UTC (rev 12)
@@ -0,0 +1,4 @@
+// TODO
+public class ZeroconfBrowsing {
+
+}
Added: trunk/src/ZeroconfRegistration.java
===================================================================
--- trunk/src/ZeroconfRegistration.java (rev 0)
+++ trunk/src/ZeroconfRegistration.java 2007-11-03 20:03:06 UTC (rev 12)
@@ -0,0 +1,44 @@
+import com.apple.dnssd.DNSSDRegistration;
+import com.apple.dnssd.DNSSDService;
+import com.apple.dnssd.RegisterListener;
+import com.apple.dnssd.TXTRecord;
+
+public class ZeroconfRegistration implements RegisterListener{
+ private TXTRecord _TXTRecord = new TXTRecord();
+
+ public void serviceRegistered(DNSSDRegistration registration, int flags,
+ String serviceName, String regType, String domain)
+ {
+ // TODO
+ System.out.println("Registered Name : " + serviceName);
+ System.out.println(" Type : " + regType);
+ System.out.println(" Domain: " + domain);
+ }
+
+ public void operationFailed(DNSSDService service, int errorCode)
+ {
+ // TODO
+ System.out.println("Registration failed: " + errorCode);
+ }
+
+ public void registerService()
+ {
+ // TODO
+ }
+
+ public void unregisterService()
+ {
+ // TODO
+ }
+
+ public String getStatus()
+ {
+ return _TXTRecord.getValueAsString("status");
+
+ }
+
+ public void setStatus(String s)
+ {
+ _TXTRecord.set("status", s);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-05 15:25:41
|
Revision: 17
http://zerofile.svn.sourceforge.net/zerofile/?rev=17&view=rev
Author: karl-bengtsson
Date: 2007-11-05 07:25:41 -0800 (Mon, 05 Nov 2007)
Log Message:
-----------
*) Made all attributes and methods in ZeroFileSettings static, class attributes/methods (this class does not need to be instantiated)
*) Added chat window class stub
*) Removed inappropriate comments from the source code
Modified Paths:
--------------
trunk/src/ZeroFileSettings.java
trunk/src/ZeroFileSettingsWindow.java
Added Paths:
-----------
trunk/src/ZeroFileChatWindow.java
Added: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java (rev 0)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-05 15:25:41 UTC (rev 17)
@@ -0,0 +1,15 @@
+import java.io.Serializable;
+
+import javax.swing.JFrame;
+
+/**
+ *
+ */
+
+/**
+ * @author karl
+ *
+ */
+public class ZeroFileChatWindow extends JFrame implements Serializable {
+ static final long serialVersionUID = -5208364155946320552L;
+}
Modified: trunk/src/ZeroFileSettings.java
===================================================================
--- trunk/src/ZeroFileSettings.java 2007-11-05 15:16:26 UTC (rev 16)
+++ trunk/src/ZeroFileSettings.java 2007-11-05 15:25:41 UTC (rev 17)
@@ -2,58 +2,58 @@
* At present, all it holds are a bunch of getters and setters.
*/
public class ZeroFileSettings {
- private String _nickName;
- private String _firstName;
- private String _lastName;
- private String _email;
- private int _mainPort;
+ private static String _nickName;
+ private static String _firstName;
+ private static String _lastName;
+ private static String _email;
+ private static int _mainPort;
- public String getNickName()
+ public static String getNickName()
{
return _nickName;
}
- public void setNickName(String n)
+ public static void setNickName(String n)
{
_nickName = n;
}
- public String getFirstName()
+ public static String getFirstName()
{
return _firstName;
}
- public void setFirstName(String f)
+ public static void setFirstName(String f)
{
_firstName = f;
}
- public String getLastName()
+ public static String getLastName()
{
return _lastName;
}
- public void setLastName(String l)
+ public static void setLastName(String l)
{
_nickName = l;
}
- public String getEmail()
+ public static String getEmail()
{
return _email;
}
- public void setEmail(String e)
+ public static void setEmail(String e)
{
_email = e;
}
- public int getMainPort()
+ public static int getMainPort()
{
return _mainPort;
}
- public void setMainPort(int p)
+ public static void setMainPort(int p)
{
_mainPort = p;
}
Modified: trunk/src/ZeroFileSettingsWindow.java
===================================================================
--- trunk/src/ZeroFileSettingsWindow.java 2007-11-05 15:16:26 UTC (rev 16)
+++ trunk/src/ZeroFileSettingsWindow.java 2007-11-05 15:25:41 UTC (rev 17)
@@ -1,16 +1,7 @@
-
-/*
- * Din mamma!
- */
-
import java.io.Serializable;
import javax.swing.JFrame;
/**
- *
- */
-//hej
-/**
* @author Peter
*
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <el...@us...> - 2007-11-05 15:55:25
|
Revision: 18
http://zerofile.svn.sourceforge.net/zerofile/?rev=18&view=rev
Author: elpedr0
Date: 2007-11-05 07:55:17 -0800 (Mon, 05 Nov 2007)
Log Message:
-----------
Added a settingwindow with a button that popsup when you start the application.
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileSettingsWindow.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-05 15:25:41 UTC (rev 17)
+++ trunk/src/ZeroFile.java 2007-11-05 15:55:17 UTC (rev 18)
@@ -10,6 +10,7 @@
public static void main(String[] args) {
ZeroFileMainWindow Huvudfonster = new ZeroFileMainWindow();
Huvudfonster.setVisible(true);
+ ZeroFileSettingsWindow Settingsfonster = new ZeroFileSettingsWindow();
if (args.length > 1)
{
System.out.println("Usage: java TestRegister name");
Modified: trunk/src/ZeroFileSettingsWindow.java
===================================================================
--- trunk/src/ZeroFileSettingsWindow.java 2007-11-05 15:25:41 UTC (rev 17)
+++ trunk/src/ZeroFileSettingsWindow.java 2007-11-05 15:55:17 UTC (rev 18)
@@ -1,5 +1,6 @@
import java.io.Serializable;
-import javax.swing.JFrame;
+import javax.swing.*;
+import java.awt.*;
/**
* @author Peter
@@ -7,4 +8,11 @@
*/
public class ZeroFileSettingsWindow extends JFrame implements Serializable {
static final long serialVersionUID = -5208364155946320552L;
+
+ public ZeroFileSettingsWindow()
+ {
+ JButton Button1 = new JButton();
+ this.add(Button1);
+ this.setVisible(true);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-06 10:13:57
|
Revision: 19
http://zerofile.svn.sourceforge.net/zerofile/?rev=19&view=rev
Author: karl-bengtsson
Date: 2007-11-06 02:14:00 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
*) Changed the ZeroFileMainWindow class from inheriting from JFrame to being a static class with class methods instantiating all the required GUI components. This is cleaner.
*) Added some comments for Javadoc
*) Removed deprecated stuff from the main ZeroFile.java file
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileMainWindow.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-05 15:55:17 UTC (rev 18)
+++ trunk/src/ZeroFile.java 2007-11-06 10:14:00 UTC (rev 19)
@@ -5,11 +5,10 @@
public class ZeroFile {
/**
- * @param args
+ * @param name - The service name used by the registration class. Deprecated. Don't use.
*/
public static void main(String[] args) {
- ZeroFileMainWindow Huvudfonster = new ZeroFileMainWindow();
- Huvudfonster.setVisible(true);
+ ZeroFileMainWindow.startMainWindow();
ZeroFileSettingsWindow Settingsfonster = new ZeroFileSettingsWindow();
if (args.length > 1)
{
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-05 15:55:17 UTC (rev 18)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-06 10:14:00 UTC (rev 19)
@@ -1,13 +1,14 @@
-// The class defining the main GUI window
-
import java.awt.*;
import javax.swing.*;
-public class ZeroFileMainWindow extends JFrame implements java.io.Serializable
+public class ZeroFileMainWindow
{
- static final long serialVersionUID = -5208364155946320552L;
- public ZeroFileMainWindow ()
+ /**
+ * @author Karl Bengtsson
+ */
+ static void startMainWindow()
{
+ JFrame mainWindowFrame = new JFrame();
JMenuBar mainMenuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
mainMenuBar.add(fileMenu);
@@ -15,11 +16,12 @@
fileMenu.add(settingsMenuItem);
JMenuItem quitMenuItem = new JMenuItem("Quit");
fileMenu.add(quitMenuItem);
- this.setLayout(new GridLayout(0,1,1,1));
- this.setMinimumSize(new Dimension(120,300));
- this.setSize(new Dimension(150,400));
- this.setJMenuBar(mainMenuBar);
+ mainWindowFrame.setLayout(new GridLayout(0,1,1,1));
+ mainWindowFrame.setMinimumSize(new Dimension(120,300));
+ mainWindowFrame.setSize(new Dimension(150,400));
+ mainWindowFrame.setJMenuBar(mainMenuBar);
for (int i = 0; i<12; i++)
- this.add(new JButton("Button #"+i));
+ mainWindowFrame.add(new JButton("Button #"+i));
+ mainWindowFrame.setVisible(true);
}
}
\ 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-11-06 11:32:14
|
Revision: 23
http://zerofile.svn.sourceforge.net/zerofile/?rev=23&view=rev
Author: karl-bengtsson
Date: 2007-11-06 03:32:18 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
Cleaned up the settings window with labels and fields, and a better general design.
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileMainWindow.java
trunk/src/ZeroFileSettingsWindow.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-06 11:03:27 UTC (rev 22)
+++ trunk/src/ZeroFile.java 2007-11-06 11:32:18 UTC (rev 23)
@@ -9,7 +9,6 @@
*/
public static void main(String[] args) {
ZeroFileMainWindow.startMainWindow();
- ZeroFileSettingsWindow Settingsfonster = new ZeroFileSettingsWindow();
if (args.length > 1)
{
System.out.println("Usage: java TestRegister name");
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-06 11:03:27 UTC (rev 22)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-06 11:32:18 UTC (rev 23)
@@ -18,6 +18,11 @@
JMenu fileMenu = new JMenu("File");
mainMenuBar.add(fileMenu);
JMenuItem settingsMenuItem = new JMenuItem("Settings...");
+ settingsMenuItem.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ ZeroFileSettingsWindow.startSettingsWindow();
+ }
+ });
fileMenu.add(settingsMenuItem);
JMenuItem quitMenuItem = new JMenuItem("Quit");
quitMenuItem.addActionListener(new ActionListener(){
Modified: trunk/src/ZeroFileSettingsWindow.java
===================================================================
--- trunk/src/ZeroFileSettingsWindow.java 2007-11-06 11:03:27 UTC (rev 22)
+++ trunk/src/ZeroFileSettingsWindow.java 2007-11-06 11:32:18 UTC (rev 23)
@@ -1,23 +1,49 @@
-import java.io.Serializable;
import javax.swing.*;
import java.awt.*;
/**
* @author Peter
- *
*/
-public class ZeroFileSettingsWindow extends JFrame implements Serializable {
- static final long serialVersionUID = -5208364155946320552L;
-
- public ZeroFileSettingsWindow()
- {
- this.setSize(new Dimension(200,200));
- this.setLayout(new GridLayout(1,2));
- JButton Button1 = new JButton("OK");
- JButton Button2 = new JButton("Cancel");
- Button1.setSize(40, 20);
- this.add(Button1);
- this.add(Button2);
- this.setVisible(true);
+public class ZeroFileSettingsWindow
+{
+ static void startSettingsWindow()
+ {
+ JFrame settingsWindowFrame = new JFrame();
+ settingsWindowFrame.setSize(new Dimension(300,200));
+ settingsWindowFrame.setResizable(false);
+ settingsWindowFrame.setLayout(new GridLayout(0,2,1,1));
+
+ // Label + field for Nickname parameter
+ JLabel nickNameLabel = new JLabel("Nickname:");
+ JTextField nickNameField = new JTextField();
+ settingsWindowFrame.add(nickNameLabel);
+ settingsWindowFrame.add(nickNameField);
+
+ // Label + field for First Name parameter
+ JLabel firstNameLabel = new JLabel("First name:");
+ JTextField firstNameField = new JTextField();
+ settingsWindowFrame.add(firstNameLabel);
+ settingsWindowFrame.add(firstNameField);
+
+ // Label + field for Last Name parameter
+ JLabel lastNameLabel = new JLabel("Last name:");
+ JTextField lastNameField = new JTextField();
+ settingsWindowFrame.add(lastNameLabel);
+ settingsWindowFrame.add(lastNameField);
+
+ // Label + field for Last Name parameter
+ JLabel emailLabel = new JLabel("Email:");
+ JTextField emailField = new JTextField();
+ settingsWindowFrame.add(emailLabel);
+ settingsWindowFrame.add(emailField);
+
+ // OK and Cancel buttons
+ JButton okButton = new JButton("OK");
+ JButton cancelButton = new JButton("Cancel");
+ settingsWindowFrame.add(okButton);
+ settingsWindowFrame.add(cancelButton);
+
+ // Show the window
+ settingsWindowFrame.setVisible(true);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-06 12:01:57
|
Revision: 24
http://zerofile.svn.sourceforge.net/zerofile/?rev=24&view=rev
Author: karl-bengtsson
Date: 2007-11-06 04:02:00 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
Implemented basic GUI components on the chat window.
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileChatWindow.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-06 11:32:18 UTC (rev 23)
+++ trunk/src/ZeroFile.java 2007-11-06 12:02:00 UTC (rev 24)
@@ -9,6 +9,7 @@
*/
public static void main(String[] args) {
ZeroFileMainWindow.startMainWindow();
+ ZeroFileChatWindow.startChatWindow();
if (args.length > 1)
{
System.out.println("Usage: java TestRegister name");
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-11-06 11:32:18 UTC (rev 23)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-06 12:02:00 UTC (rev 24)
@@ -1,15 +1,23 @@
-import java.io.Serializable;
+import java.awt.*;
+import javax.swing.*;
-import javax.swing.JFrame;
-
/**
- *
+ * @author Karl Bengtsson
*/
-
-/**
- * @author karl
- *
- */
-public class ZeroFileChatWindow extends JFrame implements Serializable {
- static final long serialVersionUID = -5208364155946320552L;
+public class ZeroFileChatWindow {
+ static void startChatWindow()
+ {
+ JFrame chatWindowFrame = new JFrame();
+ chatWindowFrame.setLayout(new GridLayout(0,1,1,1));
+ JTextArea chatTextArea = new JTextArea();
+ chatWindowFrame.add(chatTextArea);
+ JPanel bottomPanel = new JPanel();
+ chatWindowFrame.add(bottomPanel);
+ bottomPanel.setLayout(new GridLayout(1,0,1,1));
+ JTextField entryTextField = new JTextField();
+ JButton sendButton = new JButton("Send");
+ bottomPanel.add(entryTextField);
+ bottomPanel.add(sendButton);
+ chatWindowFrame.setVisible(true);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-06 14:03:32
|
Revision: 25
http://zerofile.svn.sourceforge.net/zerofile/?rev=25&view=rev
Author: karl-bengtsson
Date: 2007-11-06 06:03:07 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
Started moving the registration logic into it's own class using static class methods.
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroconfRegistration.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-06 12:02:00 UTC (rev 24)
+++ trunk/src/ZeroFile.java 2007-11-06 14:03:07 UTC (rev 25)
@@ -20,10 +20,15 @@
try
{
//If name specified, use it, else use default name
- String name = (args.length > 0) ? args[0] : null;
+ //String name = (args.length > 0) ? args[0] : null;
// Let system allocate us an available port to listen on
ServerSocket s = new ServerSocket(0);
- new ZeroConfRegistrationTest(name, s.getLocalPort( ));
+ ZeroconfRegistration.registerService(s.getLocalPort());
+ Thread.sleep(5000);
+ ZeroconfRegistration.setStatus("dnd");
+ Thread.sleep(15000);
+ ZeroconfRegistration.unregisterService();
+ //new ZeroConfRegistrationTest(name, s.getLocalPort( ));
}
catch(Exception e)
{
Modified: trunk/src/ZeroconfRegistration.java
===================================================================
--- trunk/src/ZeroconfRegistration.java 2007-11-06 12:02:00 UTC (rev 24)
+++ trunk/src/ZeroconfRegistration.java 2007-11-06 14:03:07 UTC (rev 25)
@@ -1,3 +1,5 @@
+import com.apple.dnssd.DNSSD;
+import com.apple.dnssd.DNSSDException;
import com.apple.dnssd.DNSSDRegistration;
import com.apple.dnssd.DNSSDService;
import com.apple.dnssd.RegisterListener;
@@ -3,41 +5,57 @@
import com.apple.dnssd.TXTRecord;
-public class ZeroconfRegistration implements RegisterListener{
- private TXTRecord _TXTRecord = new TXTRecord();
-
- public void serviceRegistered(DNSSDRegistration registration, int flags,
- String serviceName, String regType, String domain)
+public class ZeroconfRegistration
+{
+ private static TXTRecord _txtRecord = new TXTRecord();
+ private static DNSSDRegistration _r;
+
+ static void registerService(int port)
+ throws DNSSDException, InterruptedException
{
- // TODO
- System.out.println("Registered Name : " + serviceName);
- System.out.println(" Type : " + regType);
- System.out.println(" Domain: " + domain);
+ _r = DNSSD.register("servicename", "_presence._tcp", port, new RegisterListener()
+ {
+ public void serviceRegistered(DNSSDRegistration registration, int flags,
+ String serviceName, String regType, String domain)
+ {
+ // TODO
+ System.out.println("Registered Name : " + serviceName);
+ System.out.println(" Type : " + regType);
+ System.out.println(" Domain: " + domain);
+ }
+ public void operationFailed(DNSSDService service, int errorCode)
+ {
+ // TODO
+ System.out.println("Registration failed: " + errorCode);
+ }
+ });
+ _txtRecord.set("txtvers", "1");
+ _txtRecord.set("status","avail");
+ _txtRecord.set("email","tes...@te...");
+ _txtRecord.set("jid","te...@te...");
+ _txtRecord.set("vc","SDUR!XN");
+ _txtRecord.set("port.p2pj",""+port);
+ _txtRecord.set("1st","Nisse");
+ _txtRecord.set("last","Nilsson");
+ _r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
}
- public void operationFailed(DNSSDService service, int errorCode)
+ static void unregisterService()
{
- // TODO
- System.out.println("Registration failed: " + errorCode);
+ _r.stop();
}
- public void registerService()
+ static String getStatus()
{
- // TODO
+ return _txtRecord.getValueAsString("status");
}
- public void unregisterService()
+ static void setStatus(String s)
+ throws DNSSDException, InterruptedException
{
- // TODO
+ if (_r != null)
+ {
+ _txtRecord.set("status", s);
+ _r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
+ }
}
-
- public String getStatus()
- {
- return _TXTRecord.getValueAsString("status");
-
- }
-
- public void setStatus(String s)
- {
- _TXTRecord.set("status", s);
- }
-}
+}
\ 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-11-06 14:28:28
|
Revision: 27
http://zerofile.svn.sourceforge.net/zerofile/?rev=27&view=rev
Author: karl-bengtsson
Date: 2007-11-06 06:28:26 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
*) Removed old ZeroConfRegistrationTest
*) Added overloading of serviceRegistered()-method, to make it possible to start registration with fewer arguments.
*) Cleaned up ZeroFile.java
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroconfRegistration.java
Removed Paths:
-------------
trunk/src/ZeroConfRegistrationTest.java
Deleted: trunk/src/ZeroConfRegistrationTest.java
===================================================================
--- trunk/src/ZeroConfRegistrationTest.java 2007-11-06 14:12:44 UTC (rev 26)
+++ trunk/src/ZeroConfRegistrationTest.java 2007-11-06 14:28:26 UTC (rev 27)
@@ -1,64 +0,0 @@
-import com.apple.dnssd.*;
-
-/*
- * This class tests XMPP ZeroConf registration, by registering as
- * providing a _presence._tcp service for about 30 seconds with
- * matching TXT records corresponding with the specification
- * at http://www.xmpp.org/registrar/linklocal.html
- *
- * The main method tests for parameters and handles exceptions.
- * It instantiates a ZeroConfRegistrationTest object, in which
- * the actual code for registering our presence is located.
- *
- * We implement the RegisterListener interface by implementing the
- * operationFailed() and serviceRegistered() methods, which are
- * called when a registration fails or succeeds. This makes it
- * possible to use a this-reference when declaring the listener in
- * the DNSSD.register() operation in the ZeroConfRegistrationTest.
- */
-public class ZeroConfRegistrationTest implements RegisterListener {
- public void serviceRegistered(DNSSDRegistration registration, int flags,
- String serviceName, String regType, String domain)
- {
- System.out.println("Registered Name : " + serviceName);
- System.out.println(" Type : " + regType);
- System.out.println(" Domain: " + domain);
- }
-
- public void operationFailed(DNSSDService service, int errorCode)
- {
- System.out.println("Registration failed: " + errorCode);
- }
-
- public ZeroConfRegistrationTest(String name, int port)
- throws DNSSDException, InterruptedException
- {
- System.out.println("Registration Starting");
- System.out.println("Requested Name: " + name);
- System.out.println(" Port: " + port);
-
- //Create and start a registration for the XMPP service
- DNSSDRegistration r = DNSSD.register(name, "_presence._tcp", port, this);
-
- // Create a TXT record to hold the flags
- TXTRecord txtRecord = new TXTRecord();
-
- // Set all the required TXT flags
- txtRecord.set("txtvers", "1");
- txtRecord.set("status","avail");
- txtRecord.set("email","tes...@te...");
- txtRecord.set("jid","te...@te...");
- txtRecord.set("vc","SDUR!XN");
- txtRecord.set("port.p2pj",""+port);
- txtRecord.set("1st","Nisse");
- txtRecord.set("last","Nilsson");
-
- // Attach the flags to the registration
- r.getTXTRecord().update(0, txtRecord.getRawBytes(), 0);
-
- // Wait thirty seconds, then exit
- Thread.sleep(30000);
- System.out.println("Registration Stopping");
- r.stop( );
- }
-}
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-06 14:12:44 UTC (rev 26)
+++ trunk/src/ZeroFile.java 2007-11-06 14:28:26 UTC (rev 27)
@@ -1,7 +1,5 @@
import java.net.ServerSocket;
-// Main loop of the program
-
public class ZeroFile {
/**
@@ -19,7 +17,6 @@
ZeroconfRegistration.setStatus("dnd");
Thread.sleep(15000);
ZeroconfRegistration.unregisterService();
- //new ZeroConfRegistrationTest(name, s.getLocalPort( ));
}
catch(Exception e)
{
Modified: trunk/src/ZeroconfRegistration.java
===================================================================
--- trunk/src/ZeroconfRegistration.java 2007-11-06 14:12:44 UTC (rev 26)
+++ trunk/src/ZeroconfRegistration.java 2007-11-06 14:28:26 UTC (rev 27)
@@ -10,7 +10,7 @@
private static TXTRecord _txtRecord = new TXTRecord();
private static DNSSDRegistration _r;
- static void registerService(int port)
+ static void registerService(String status,int port)
throws DNSSDException, InterruptedException
{
_r = DNSSD.register("servicename", "_presence._tcp", port, new RegisterListener()
@@ -30,16 +30,22 @@
}
});
_txtRecord.set("txtvers", "1");
- _txtRecord.set("status","avail");
- _txtRecord.set("email","tes...@te...");
- _txtRecord.set("jid","te...@te...");
+ _txtRecord.set("status",status);
+ //_txtRecord.set("email","tes...@te...");
+ //_txtRecord.set("jid","te...@te...");
_txtRecord.set("vc","SDUR!XN");
- _txtRecord.set("port.p2pj",""+port);
- _txtRecord.set("1st","Nisse");
- _txtRecord.set("last","Nilsson");
+ _txtRecord.set("port.p2pj",Integer.toString(port));
+ //_txtRecord.set("1st","Nisse");
+ //_txtRecord.set("last","Nilsson");
_r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
}
+ static void registerService(int port)
+ throws DNSSDException, InterruptedException
+ {
+ ZeroconfRegistration.registerService("avail",port);
+ }
+
static void unregisterService()
{
_r.stop();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-06 16:47:38
|
Revision: 29
http://zerofile.svn.sourceforge.net/zerofile/?rev=29&view=rev
Author: karl-bengtsson
Date: 2007-11-06 08:17:15 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
Further expanded methods in ZeroconfRegistration class
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroconfRegistration.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-06 15:49:52 UTC (rev 28)
+++ trunk/src/ZeroFile.java 2007-11-06 16:17:15 UTC (rev 29)
@@ -1,4 +1,4 @@
-import java.net.ServerSocket;
+//import java.net.ServerSocket;
public class ZeroFile {
/**
@@ -10,8 +10,11 @@
try
{
// Let system allocate us an available port to listen on
- ServerSocket s = new ServerSocket(0);
- ZeroconfRegistration.registerService(s.getLocalPort());
+ //ServerSocket s = new ServerSocket(0);
+ //ZeroconfRegistration.registerService(s.getLocalPort());
+ ZeroconfRegistration.registerService();
+ ZeroconfRegistration.set1st("Testar");
+ ZeroconfRegistration.setLast("Nisse");
Thread.sleep(5000);
ZeroconfRegistration.setStatus("dnd");
Thread.sleep(15000);
Modified: trunk/src/ZeroconfRegistration.java
===================================================================
--- trunk/src/ZeroconfRegistration.java 2007-11-06 15:49:52 UTC (rev 28)
+++ trunk/src/ZeroconfRegistration.java 2007-11-06 16:17:15 UTC (rev 29)
@@ -31,24 +31,27 @@
});
_txtRecord.set("txtvers", "1");
_txtRecord.set("status",status);
- //_txtRecord.set("email","tes...@te...");
- //_txtRecord.set("jid","te...@te...");
_txtRecord.set("vc","SDUR!XN");
_txtRecord.set("port.p2pj",Integer.toString(port));
- //_txtRecord.set("1st","Nisse");
- //_txtRecord.set("last","Nilsson");
_r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
}
static void registerService(int port)
- throws DNSSDException, InterruptedException
+ throws DNSSDException, InterruptedException
{
ZeroconfRegistration.registerService("avail",port);
}
+ static void registerService()
+ throws DNSSDException, InterruptedException
+ {
+ ZeroconfRegistration.registerService(5222);
+ }
+
static void unregisterService()
{
_r.stop();
+ System.out.println("Deregistered service");
}
static String getStatus()
@@ -57,7 +60,7 @@
}
static void setStatus(String s)
- throws DNSSDException, InterruptedException
+ throws DNSSDException, InterruptedException
{
if (_r != null)
{
@@ -65,4 +68,63 @@
_r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
}
}
+
+ static String getEmail()
+ {
+ return _txtRecord.getValueAsString("email");
+ }
+
+ static void setEmail(String e)
+ throws DNSSDException, InterruptedException
+ {
+ if (_r != null)
+ {
+ _txtRecord.set("email",e);
+ _r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
+ }
+ }
+
+ static String getJID()
+ {
+ return _txtRecord.getValueAsString("jid");
+ }
+
+ static void setJID(String jid)
+ throws DNSSDException, InterruptedException
+ {
+ if (_r != null)
+ {
+ _txtRecord.set("jid",jid);
+ _r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
+ }
+ }
+
+ static String get1st()
+ {
+ return _txtRecord.getValueAsString("1st");
+ }
+
+ static void set1st(String First)
+ throws DNSSDException, InterruptedException
+ {
+ if (_r!=null)
+ {
+ _txtRecord.set("1st",First);
+ _r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
+ }
+ }
+ static String getLast()
+ {
+ return _txtRecord.getValueAsString("Last");
+ }
+
+ static void setLast(String Last)
+ throws DNSSDException, InterruptedException
+ {
+ if (_r!=null)
+ {
+ _txtRecord.set("Last",Last);
+ _r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
+ }
+ }
}
\ 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-11-06 18:22:20
|
Revision: 31
http://zerofile.svn.sourceforge.net/zerofile/?rev=31&view=rev
Author: karl-bengtsson
Date: 2007-11-06 10:22:06 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
*) Made all GUI components in ZeroFileMainWindow private static attributes of that class, rather than local attributes in the startMainWindow()-method. This makes it possible to access and change them with public static methods of that class, which is useful when for instance updating the contact list.
*) Built methods for adding and removing contacts to said contact list. Also added a DefaultListModel tied to the list, through which changes are done (in accordance with the MVC pattern)
*) Added some (very ugly) stub code for testing to the XMPPLinkLocalHost and ZeroconfBrowsing classes, which will be replaced ASAP.
*) Bugfix in ZeroconfRegistration: the "last" TXT property was capitalized, and is now lowercase as it should be.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalHost.java
trunk/src/ZeroFile.java
trunk/src/ZeroFileMainWindow.java
trunk/src/ZeroconfBrowsing.java
trunk/src/ZeroconfRegistration.java
Modified: trunk/src/XMPPLinkLocalHost.java
===================================================================
--- trunk/src/XMPPLinkLocalHost.java 2007-11-06 17:07:38 UTC (rev 30)
+++ trunk/src/XMPPLinkLocalHost.java 2007-11-06 18:22:06 UTC (rev 31)
@@ -1,4 +1,12 @@
// Stub class, to represent a compatible XMPP-capable host on the ZeroConf network
public class XMPPLinkLocalHost {
-
+ private String _ipAddress;
+ public XMPPLinkLocalHost(String ipAddress)
+ {
+ _ipAddress = ipAddress;
+ }
+ public String getIPAddress()
+ {
+ return _ipAddress;
+ }
}
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-06 17:07:38 UTC (rev 30)
+++ trunk/src/ZeroFile.java 2007-11-06 18:22:06 UTC (rev 31)
@@ -15,8 +15,13 @@
ZeroconfRegistration.registerService();
ZeroconfRegistration.set1st("Testar");
ZeroconfRegistration.setLast("Nisse");
+ ZeroFileMainWindow.addContact("Test 1");
+ ZeroFileMainWindow.addContact("Test 2");
+ ZeroFileMainWindow.addContact("Test 3");
+ ZeroFileMainWindow.addContact("Test 4");
+ ZeroFileMainWindow.removeContact("Test 3");
Thread.sleep(5000);
- ZeroconfRegistration.setStatus("dnd");
+ ZeroconfRegistration.setStatus("away");
Thread.sleep(15000);
ZeroconfRegistration.unregisterService();
}
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-06 17:07:38 UTC (rev 30)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-06 18:22:06 UTC (rev 31)
@@ -7,58 +7,76 @@
/**
* @author Karl Bengtsson
*/
+ private static JFrame _mainWindowFrame;
+ private static JMenuBar _mainMenuBar;
+ private static JMenu _fileMenu;
+ private static JMenuItem _settingsMenuItem;
+ private static JMenuItem _quitMenuItem;
+ private static JMenu _helpMenu;
+ private static JMenuItem _aboutMenuItem;
+ private static JComboBox _statusLista;
+ private static DefaultListModel _contactListModel;
+ private static JList _contactList;
+ static void addContact(String c)
+ {
+ _contactListModel.addElement(c);
+ }
+ static void removeContact(String c)
+ {
+ _contactListModel.removeElement(c);
+ }
static void startMainWindow()
{
// Grundkittet, JFrame + JMenuBar
- JFrame mainWindowFrame = new JFrame();
- mainWindowFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JMenuBar mainMenuBar = new JMenuBar();
+ _mainWindowFrame = new JFrame();
+ _mainWindowFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ _mainMenuBar = new JMenuBar();
// File menu
- JMenu fileMenu = new JMenu("File");
- mainMenuBar.add(fileMenu);
- JMenuItem settingsMenuItem = new JMenuItem("Settings...");
- settingsMenuItem.addActionListener(new ActionListener(){
+ _fileMenu = new JMenu("File");
+ _mainMenuBar.add(_fileMenu);
+ _settingsMenuItem = new JMenuItem("Settings...");
+ _settingsMenuItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
ZeroFileSettingsWindow.startSettingsWindow();
}
});
- fileMenu.add(settingsMenuItem);
- JMenuItem quitMenuItem = new JMenuItem("Quit");
- quitMenuItem.addActionListener(new ActionListener(){
+ _fileMenu.add(_settingsMenuItem);
+ _quitMenuItem = new JMenuItem("Quit");
+ _quitMenuItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
System.exit(1);
}
});
- fileMenu.add(quitMenuItem);
+ _fileMenu.add(_quitMenuItem);
// Help menu
- JMenu helpMenu = new JMenu("Help");
- mainMenuBar.add(helpMenu);
- JMenuItem aboutMenuItem = new JMenuItem("About..");
- helpMenu.add(aboutMenuItem);
+ _helpMenu = new JMenu("Help");
+ _mainMenuBar.add(_helpMenu);
+ _aboutMenuItem = new JMenuItem("About..");
+ _helpMenu.add(_aboutMenuItem);
// Layout, storlekar, samt koppling av JMenuBar
- mainWindowFrame.setLayout(new GridLayout(0,1,1,1));
- mainWindowFrame.setMinimumSize(new Dimension(120,300));
- mainWindowFrame.setSize(new Dimension(150,400));
- mainWindowFrame.setJMenuBar(mainMenuBar);
+ _mainWindowFrame.setLayout(new GridLayout(0,1,1,1));
+ _mainWindowFrame.setMinimumSize(new Dimension(120,300));
+ _mainWindowFrame.setSize(new Dimension(150,400));
+ _mainWindowFrame.setJMenuBar(_mainMenuBar);
// Statuslista
String[] statusModes = {"Available","Away","Do not disturb"};
- JComboBox statusLista = new JComboBox(statusModes);
- statusLista.setMaximumSize(new Dimension(20,100));
- mainWindowFrame.add(statusLista);
+ _statusLista = new JComboBox(statusModes);
+ _statusLista.setMaximumSize(new Dimension(20,100));
+ _mainWindowFrame.add(_statusLista);
// Kontaktlista
- String[] TestKontakter = {"Din mamma","Din pappa","Din syster","Din broder","Din chef"};
- JList contactList = new JList(TestKontakter);
- contactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- contactList.setLayoutOrientation(JList.VERTICAL);
- contactList.setSize(500,700);
- mainWindowFrame.add(contactList);
+ _contactListModel = new DefaultListModel();
+ _contactList = new JList(_contactListModel);
+ _contactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ _contactList.setLayoutOrientation(JList.VERTICAL);
+ _contactList.setSize(500,700);
+ _mainWindowFrame.add(_contactList);
// Sm\x8All upp f\x9Anstret
- mainWindowFrame.setVisible(true);
+ _mainWindowFrame.setVisible(true);
}
}
\ No newline at end of file
Modified: trunk/src/ZeroconfBrowsing.java
===================================================================
--- trunk/src/ZeroconfBrowsing.java 2007-11-06 17:07:38 UTC (rev 30)
+++ trunk/src/ZeroconfBrowsing.java 2007-11-06 18:22:06 UTC (rev 31)
@@ -1,4 +1,8 @@
// TODO
public class ZeroconfBrowsing {
-
+ static XMPPLinkLocalHost[] findXMPPHosts()
+ {
+ XMPPLinkLocalHost[] testArr = {new XMPPLinkLocalHost("192.168.0.1"),new XMPPLinkLocalHost("192.168.0.2")};
+ return testArr;
+ }
}
Modified: trunk/src/ZeroconfRegistration.java
===================================================================
--- trunk/src/ZeroconfRegistration.java 2007-11-06 17:07:38 UTC (rev 30)
+++ trunk/src/ZeroconfRegistration.java 2007-11-06 18:22:06 UTC (rev 31)
@@ -115,7 +115,7 @@
}
static String getLast()
{
- return _txtRecord.getValueAsString("Last");
+ return _txtRecord.getValueAsString("last");
}
static void setLast(String Last)
@@ -123,7 +123,7 @@
{
if (_r!=null)
{
- _txtRecord.set("Last",Last);
+ _txtRecord.set("last",Last);
_r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-06 19:36:05
|
Revision: 32
http://zerofile.svn.sourceforge.net/zerofile/?rev=32&view=rev
Author: karl-bengtsson
Date: 2007-11-06 11:35:39 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
*) Added a static resolver class with a single method used to find out information about a given XMPP service on the network.
*) Further refined the ZeroconfBrowsing class
*) Modified the attributes of the XMPPLinkLocalHost class - this class should only hold information that is readily available when browsing for services, not detailed information for which a resolving operation is required. Such detailed information (IP address, port number, nick name, etc) should be fetched only when needed, to minimize network traffic.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalHost.java
trunk/src/ZeroFile.java
trunk/src/ZeroFileMainWindow.java
trunk/src/ZeroconfBrowsing.java
Added Paths:
-----------
trunk/src/ZeroconfResolving.java
Modified: trunk/src/XMPPLinkLocalHost.java
===================================================================
--- trunk/src/XMPPLinkLocalHost.java 2007-11-06 18:22:06 UTC (rev 31)
+++ trunk/src/XMPPLinkLocalHost.java 2007-11-06 19:35:39 UTC (rev 32)
@@ -1,12 +1,43 @@
// Stub class, to represent a compatible XMPP-capable host on the ZeroConf network
public class XMPPLinkLocalHost {
- private String _ipAddress;
- public XMPPLinkLocalHost(String ipAddress)
+ private String _serviceName;
+ private String _nickName;
+ private String _firstName;
+ private String _lastName;
+
+ public XMPPLinkLocalHost(String serviceName)
{
- _ipAddress = ipAddress;
+ _serviceName = serviceName;
}
- public String getIPAddress()
+
+ /*public String getIPAddress()
{
return _ipAddress;
+ }*/
+
+ public String getServiceName()
+ {
+ return _serviceName;
}
+
+ public String getFirstName()
+ {
+ return _firstName;
+ }
+
+ public String getLastName()
+ {
+ return _lastName;
+ }
+
+ public String toString()
+ {
+ if (_nickName != null)
+ return _nickName;
+ else
+ if (_firstName != null && _lastName != null)
+ return _firstName + " " + _lastName;
+ else
+ return _serviceName;
+ }
}
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-06 18:22:06 UTC (rev 31)
+++ trunk/src/ZeroFile.java 2007-11-06 19:35:39 UTC (rev 32)
@@ -15,14 +15,18 @@
ZeroconfRegistration.registerService();
ZeroconfRegistration.set1st("Testar");
ZeroconfRegistration.setLast("Nisse");
+ ZeroconfBrowsing.startBrowsing();
+ /*
ZeroFileMainWindow.addContact("Test 1");
ZeroFileMainWindow.addContact("Test 2");
ZeroFileMainWindow.addContact("Test 3");
ZeroFileMainWindow.addContact("Test 4");
ZeroFileMainWindow.removeContact("Test 3");
+ */
Thread.sleep(5000);
ZeroconfRegistration.setStatus("away");
Thread.sleep(15000);
+ ZeroconfBrowsing.stopBrowsing();
ZeroconfRegistration.unregisterService();
}
catch(Exception e)
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-06 18:22:06 UTC (rev 31)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-06 19:35:39 UTC (rev 32)
@@ -17,11 +17,11 @@
private static JComboBox _statusLista;
private static DefaultListModel _contactListModel;
private static JList _contactList;
- static void addContact(String c)
+ static void addContact(Object c)
{
_contactListModel.addElement(c);
}
- static void removeContact(String c)
+ static void removeContact(Object c)
{
_contactListModel.removeElement(c);
}
Modified: trunk/src/ZeroconfBrowsing.java
===================================================================
--- trunk/src/ZeroconfBrowsing.java 2007-11-06 18:22:06 UTC (rev 31)
+++ trunk/src/ZeroconfBrowsing.java 2007-11-06 19:35:39 UTC (rev 32)
@@ -1,8 +1,39 @@
-// TODO
+import com.apple.dnssd.*;
+
public class ZeroconfBrowsing {
- static XMPPLinkLocalHost[] findXMPPHosts()
+ private static DNSSDService _s;
+ static void startBrowsing()
+ throws DNSSDException, InterruptedException
{
- XMPPLinkLocalHost[] testArr = {new XMPPLinkLocalHost("192.168.0.1"),new XMPPLinkLocalHost("192.168.0.2")};
- return testArr;
+ _s = DNSSD.browse("_presence._tcp",new BrowseListener() {
+ public void operationFailed(DNSSDService service, int errorCode)
+ {
+ System.out.println("Browse failed: " + errorCode);
+ System.exit(-1);
+ }
+ public void serviceFound(DNSSDService browser, int flags, int ifIndex,
+ String name, String regType, String domain)
+ {
+ System.out.println("Yay, found: " + name + " at interface: " + ifIndex);
+ try
+ {
+ ZeroconfResolving.getHost(name);
+ }
+ catch (Exception e)
+ {
+ System.out.println("Error: " + e.getStackTrace());
+ }
+ }
+ public void serviceLost(DNSSDService browser, int flags, int ifIndex,
+ String name, String regType, String domain)
+ {
+ System.out.println("Lost: " + name);
+ }
+ });
+ System.out.println("Starting browsing...");
}
+ static void stopBrowsing(){
+ _s.stop();
+ System.out.println("Stopped browsing");
+ }
}
Added: trunk/src/ZeroconfResolving.java
===================================================================
--- trunk/src/ZeroconfResolving.java (rev 0)
+++ trunk/src/ZeroconfResolving.java 2007-11-06 19:35:39 UTC (rev 32)
@@ -0,0 +1,35 @@
+import com.apple.dnssd.*;
+
+/*
+ * A static class with methods for resolving hosts once we've found them
+ */
+
+public class ZeroconfResolving {
+ private static DNSSDService _r;
+ static void getHost(String serviceName)
+ throws DNSSDException, InterruptedException
+ {
+ _r = DNSSD.resolve(0, DNSSD.ALL_INTERFACES, serviceName, "_presence._tcp", "local", new ResolveListener()
+ {
+ public void operationFailed(DNSSDService service,int errorCode)
+ {
+ System.out.println("Resolved failed " + errorCode);
+ System.exit(-1);
+ }
+ public void serviceResolved(DNSSDService resolver, int flags, int ifIndex,
+ String fullName, String hostName, int port, TXTRecord txtRecord)
+ {
+ System.out.println("Host resolved: " + hostName + ":" + port);
+ System.out.println("Flags: " + flags + ", ifIndex: " + ifIndex + ", FQDN: " + fullName);
+ for (int i = 0; i < txtRecord.size(); i++)
+ {
+ String key = txtRecord.getKey(i);
+ String value = txtRecord.getValueAsString(i);
+ if (key.length() > 0)
+ System.out.println("\t" + key + "=" + value);
+ }
+ _r.stop();
+ }
+ });
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zo...@us...> - 2007-11-07 10:45:21
|
Revision: 33
http://zerofile.svn.sourceforge.net/zerofile/?rev=33&view=rev
Author: zondar
Date: 2007-11-07 02:45:23 -0800 (Wed, 07 Nov 2007)
Log Message:
-----------
Addad names to windows etc
Modified Paths:
--------------
trunk/src/ZeroFileChatWindow.java
trunk/src/ZeroFileMainWindow.java
trunk/src/ZeroFileSettingsWindow.java
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-11-06 19:35:39 UTC (rev 32)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-07 10:45:23 UTC (rev 33)
@@ -1,4 +1,5 @@
import java.awt.*;
+
import javax.swing.*;
/**
@@ -9,6 +10,9 @@
{
JFrame chatWindowFrame = new JFrame();
chatWindowFrame.setLayout(new GridLayout(0,1,1,1));
+ chatWindowFrame.setLocation(0,400);
+ chatWindowFrame.setSize(new Dimension(300,200));
+ chatWindowFrame.setTitle("chatwindow");
JTextArea chatTextArea = new JTextArea();
chatWindowFrame.add(chatTextArea);
JPanel bottomPanel = new JPanel();
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-06 19:35:39 UTC (rev 32)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-07 10:45:23 UTC (rev 33)
@@ -31,6 +31,7 @@
_mainWindowFrame = new JFrame();
_mainWindowFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
_mainMenuBar = new JMenuBar();
+ _mainWindowFrame.setTitle("ZeroFile");
// File menu
_fileMenu = new JMenu("File");
Modified: trunk/src/ZeroFileSettingsWindow.java
===================================================================
--- trunk/src/ZeroFileSettingsWindow.java 2007-11-06 19:35:39 UTC (rev 32)
+++ trunk/src/ZeroFileSettingsWindow.java 2007-11-07 10:45:23 UTC (rev 33)
@@ -12,6 +12,8 @@
settingsWindowFrame.setSize(new Dimension(300,200));
settingsWindowFrame.setResizable(false);
settingsWindowFrame.setLayout(new GridLayout(0,2,1,1));
+ settingsWindowFrame.setLocation(200, 200);
+ settingsWindowFrame.setTitle("Settings");
// Label + field for Nickname parameter
JLabel nickNameLabel = new JLabel("Nickname:", JLabel.CENTER);
@@ -43,6 +45,7 @@
settingsWindowFrame.add(checkBoxLabel);
settingsWindowFrame.add(checkBoxTransfer);
+
// OK and Cancel buttons
JButton okButton = new JButton("OK");
JButton cancelButton = new JButton("Cancel");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <el...@us...> - 2007-11-07 13:52:04
|
Revision: 34
http://zerofile.svn.sourceforge.net/zerofile/?rev=34&view=rev
Author: elpedr0
Date: 2007-11-07 05:51:57 -0800 (Wed, 07 Nov 2007)
Log Message:
-----------
Added at test save/load.
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileSettings.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-07 10:45:23 UTC (rev 33)
+++ trunk/src/ZeroFile.java 2007-11-07 13:51:57 UTC (rev 34)
@@ -1,3 +1,5 @@
+import java.io.IOException;
+
//import java.net.ServerSocket;
public class ZeroFile {
@@ -3,8 +5,11 @@
/**
* @param name - The service name used by the registration class. Deprecated. Don't use.
+ * @throws IOException
*/
- public static void main(String[] args) {
+ public static void main(String[] args) throws IOException {
ZeroFileMainWindow.startMainWindow();
ZeroFileChatWindow.startChatWindow();
+ ZeroFileSettings.saveSettings();
+ ZeroFileSettings.loadSettings();
try
{
Modified: trunk/src/ZeroFileSettings.java
===================================================================
--- trunk/src/ZeroFileSettings.java 2007-11-07 10:45:23 UTC (rev 33)
+++ trunk/src/ZeroFileSettings.java 2007-11-07 13:51:57 UTC (rev 34)
@@ -1,6 +1,9 @@
/* Settings for the program are stored in this class. Or something.
* At present, all it holds are a bunch of getters and setters.
*/
+import java.util.*;
+import java.io.*;
+
public class ZeroFileSettings {
private static String _nickName;
private static String _firstName;
@@ -8,6 +11,26 @@
private static String _email;
private static int _mainPort;
+ /*public static void saveSettings() throws IOException
+ {
+ // set up default properties
+ Properties defaultProps = new Properties();
+ FileInputStream defaultStream = new FileInputStream("defaultProperties");
+ defaultProps.load(defaultStream);
+ defaultStream.close();
+
+ // set up real properties
+ Properties applicationProps = new Properties(defaultProps);
+ FileOutputStream appStream = new FileOutputStream("appProperties");
+
+
+ applicationProps.put ( "HEIGHT","300" ) ;
+ applicationProps.put ( "WIDTH","300" ) ;
+
+
+ }*/
+
+
public static String getNickName()
{
return _nickName;
@@ -57,4 +80,27 @@
{
_mainPort = p;
}
+
+ public static void saveSettings() throws IOException {
+
+ Properties applicationProps = new Properties();
+ FileOutputStream appStream = new FileOutputStream("appProperties");
+ applicationProps.put("first", "balle");
+ applicationProps.put("last", "ballesson");
+ applicationProps.save(appStream, "settings");
+ appStream.close();
+ }
+
+ public static void loadSettings() throws IOException {
+ Properties applicationProps = new Properties();
+ FileInputStream appStream = new FileInputStream("appProperties");
+ applicationProps.load(appStream);
+ String key = "last";
+ String val = applicationProps.getProperty ( key ) ;
+ System.out.println ( val ) ;
+ appStream.close();
+
+ }
+
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-07 14:31:58
|
Revision: 37
http://zerofile.svn.sourceforge.net/zerofile/?rev=37&view=rev
Author: karl-bengtsson
Date: 2007-11-07 06:32:01 -0800 (Wed, 07 Nov 2007)
Log Message:
-----------
*) Moved the resolving code into the XMPPLinkLocalHost class - this makes sense if we consider that we will only resolve for one named instance of a presence service at a time, and that this service will be represented by an XMPPLinkLocalHost object.
*) Fixed a small null reference bug in ZeroFileSettings
*) Modified the ZeroconfBrowsing.startBrowse() method to actually post newly discovered hosts to the main contact list of the program.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalHost.java
trunk/src/ZeroFileSettings.java
trunk/src/ZeroconfBrowsing.java
Modified: trunk/src/XMPPLinkLocalHost.java
===================================================================
--- trunk/src/XMPPLinkLocalHost.java 2007-11-07 14:04:37 UTC (rev 36)
+++ trunk/src/XMPPLinkLocalHost.java 2007-11-07 14:32:01 UTC (rev 37)
@@ -1,3 +1,9 @@
+import com.apple.dnssd.DNSSD;
+import com.apple.dnssd.DNSSDException;
+import com.apple.dnssd.DNSSDService;
+import com.apple.dnssd.ResolveListener;
+import com.apple.dnssd.TXTRecord;
+
// Stub class, to represent a compatible XMPP-capable host on the ZeroConf network
public class XMPPLinkLocalHost {
private String _serviceName;
@@ -4,17 +10,25 @@
private String _nickName;
private String _firstName;
private String _lastName;
+ private String _host;
+ private int _port;
+ private static DNSSDService _r;
public XMPPLinkLocalHost(String serviceName)
{
_serviceName = serviceName;
}
- /*public String getIPAddress()
+ public int getPort()
{
- return _ipAddress;
- }*/
+ return _port;
+ }
+ public String getHost()
+ {
+ return _host;
+ }
+
public String getServiceName()
{
return _serviceName;
@@ -40,4 +54,34 @@
else
return _serviceName;
}
+
+ public void updateData()
+ throws DNSSDException, InterruptedException
+ {
+ _r = DNSSD.resolve(0, DNSSD.UNIQUE, _serviceName, "_presence._tcp", "local", new ResolveListener()
+ {
+ public void operationFailed(DNSSDService service,int errorCode)
+ {
+ System.out.println("Resolved failed " + errorCode);
+ System.exit(-1);
+ }
+ public void serviceResolved(DNSSDService resolver, int flags, int ifIndex,
+ String fullName, String hostName, int port, TXTRecord txtRecord)
+ {
+ _host = hostName;
+ _port = port;
+ System.out.println("Host resolved: " + hostName + ":" + port);
+ System.out.println("Flags: " + flags + ", ifIndex: " + ifIndex + ", FQDN: " + fullName);
+ for (int i = 0; i < txtRecord.size(); i++)
+ {
+ String key = txtRecord.getKey(i);
+ String value = txtRecord.getValueAsString(i);
+ if (key.length() > 0)
+ System.out.println("\t" + key + "=" + value);
+ }
+ _r.stop();
+ }
+ });
+ }
+
}
Modified: trunk/src/ZeroFileSettings.java
===================================================================
--- trunk/src/ZeroFileSettings.java 2007-11-07 14:04:37 UTC (rev 36)
+++ trunk/src/ZeroFileSettings.java 2007-11-07 14:32:01 UTC (rev 37)
@@ -5,12 +5,12 @@
import java.io.*;
public class ZeroFileSettings {
- private static String _nickName;
+ //private static String _nickName;
private static String _firstName;
private static String _lastName;
private static String _email;
private static int _mainPort;
- private static Properties _zeroFileProperties;
+ private static Properties _zeroFileProperties = new Properties();
/*public static void saveSettings() throws IOException
{
@@ -62,7 +62,7 @@
public static void setLastName(String l)
{
- _nickName = l;
+ _lastName = l;
}
public static String getEmail()
Modified: trunk/src/ZeroconfBrowsing.java
===================================================================
--- trunk/src/ZeroconfBrowsing.java 2007-11-07 14:04:37 UTC (rev 36)
+++ trunk/src/ZeroconfBrowsing.java 2007-11-07 14:32:01 UTC (rev 37)
@@ -14,7 +14,9 @@
public void serviceFound(DNSSDService browser, int flags, int ifIndex,
String name, String regType, String domain)
{
- System.out.println("Yay, found: " + name + " at interface: " + ifIndex);
+ XMPPLinkLocalHost newHost = new XMPPLinkLocalHost(name);
+ ZeroFileMainWindow.addContact(newHost);
+ /*System.out.println("Yay, found: " + name + " at interface: " + ifIndex);
try
{
ZeroconfResolving.getHost(name);
@@ -22,12 +24,13 @@
catch (Exception e)
{
System.out.println("Error: " + e.getStackTrace());
- }
+ }*/
}
public void serviceLost(DNSSDService browser, int flags, int ifIndex,
String name, String regType, String domain)
{
- System.out.println("Lost: " + name);
+ ZeroFileMainWindow.removeContact("name");
+ //System.out.println("Lost: " + name);
}
});
System.out.println("Starting browsing...");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-07 15:57:11
|
Revision: 39
http://zerofile.svn.sourceforge.net/zerofile/?rev=39&view=rev
Author: karl-bengtsson
Date: 2007-11-07 07:57:15 -0800 (Wed, 07 Nov 2007)
Log Message:
-----------
Various changes in this commit. The contact list should now be almost fully operational. Yay!
*) In ZeroFileMainWindow: Completed the methods for adding and removing from the contact list, as well as checking if a certain host is already listed.
*) In ZeroconfBrowsing: Rewrote the browsing code to account for the above. Also added handling of unregistering of services.
*) In XMPPLinkLocalHost: Modified the class to include some more attributes.
*) In ZeroFile: removed the 20 second deregistration. Now the program stays registered until it exits.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalHost.java
trunk/src/ZeroFile.java
trunk/src/ZeroFileMainWindow.java
trunk/src/ZeroconfBrowsing.java
Modified: trunk/src/XMPPLinkLocalHost.java
===================================================================
--- trunk/src/XMPPLinkLocalHost.java 2007-11-07 15:20:24 UTC (rev 38)
+++ trunk/src/XMPPLinkLocalHost.java 2007-11-07 15:57:15 UTC (rev 39)
@@ -1,5 +1,4 @@
import com.apple.dnssd.DNSSD;
-import com.apple.dnssd.DNSSDException;
import com.apple.dnssd.DNSSDService;
import com.apple.dnssd.ResolveListener;
import com.apple.dnssd.TXTRecord;
@@ -56,32 +55,38 @@
}
public void updateData()
- throws DNSSDException, InterruptedException
{
- _r = DNSSD.resolve(0, DNSSD.UNIQUE, _serviceName, "_presence._tcp", "local", new ResolveListener()
+ try
{
- public void operationFailed(DNSSDService service,int errorCode)
+ _r = DNSSD.resolve(0, DNSSD.ALL_INTERFACES, _serviceName, "_presence._tcp", "local", new ResolveListener()
{
- System.out.println("Resolved failed " + errorCode);
- System.exit(-1);
- }
- public void serviceResolved(DNSSDService resolver, int flags, int ifIndex,
- String fullName, String hostName, int port, TXTRecord txtRecord)
- {
- _host = hostName;
- _port = port;
- System.out.println("Host resolved: " + hostName + ":" + port);
- System.out.println("Flags: " + flags + ", ifIndex: " + ifIndex + ", FQDN: " + fullName);
- for (int i = 0; i < txtRecord.size(); i++)
+ public void operationFailed(DNSSDService service,int errorCode)
{
- String key = txtRecord.getKey(i);
- String value = txtRecord.getValueAsString(i);
- if (key.length() > 0)
- System.out.println("\t" + key + "=" + value);
+ System.out.println("Resolved failed " + errorCode);
+ System.exit(-1);
}
- _r.stop();
- }
- });
+ public void serviceResolved(DNSSDService resolver, int flags, int ifIndex,
+ String fullName, String hostName, int port, TXTRecord txtRecord)
+ {
+ _host = hostName;
+ _port = port;
+ if (txtRecord != null)
+ {
+ if (txtRecord.contains("1st"))
+ _firstName = txtRecord.getValueAsString("1st").toString();
+ if (txtRecord.contains("last"))
+ _lastName = txtRecord.getValueAsString("last").toString();
+ if (txtRecord.contains("nick"))
+ _nickName = txtRecord.getValueAsString("nick").toString();
+ }
+ _r.stop();
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ System.out.println("Error: " + e.getStackTrace().toString());
+ }
}
}
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-07 15:20:24 UTC (rev 38)
+++ trunk/src/ZeroFile.java 2007-11-07 15:57:15 UTC (rev 39)
@@ -1,10 +1,8 @@
import java.io.IOException;
-//import java.net.ServerSocket;
-
public class ZeroFile {
/**
- * @param name - The service name used by the registration class. Deprecated. Don't use.
+ * Main class of the program.
* @throws IOException
*/
public static void main(String[] args) throws IOException {
@@ -14,25 +12,10 @@
ZeroFileSettings.loadSettings();
try
{
- // Let system allocate us an available port to listen on
- //ServerSocket s = new ServerSocket(0);
- //ZeroconfRegistration.registerService(s.getLocalPort());
ZeroconfRegistration.registerService();
ZeroconfRegistration.set1st("Testar");
ZeroconfRegistration.setLast("Nisse");
ZeroconfBrowsing.startBrowsing();
- /*
- ZeroFileMainWindow.addContact("Test 1");
- ZeroFileMainWindow.addContact("Test 2");
- ZeroFileMainWindow.addContact("Test 3");
- ZeroFileMainWindow.addContact("Test 4");
- ZeroFileMainWindow.removeContact("Test 3");
- */
- Thread.sleep(5000);
- ZeroconfRegistration.setStatus("away");
- Thread.sleep(15000);
- ZeroconfBrowsing.stopBrowsing();
- ZeroconfRegistration.unregisterService();
}
catch(Exception e)
{
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-07 15:20:24 UTC (rev 38)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-07 15:57:15 UTC (rev 39)
@@ -1,5 +1,6 @@
import java.awt.*;
import java.awt.event.*;
+
import javax.swing.*;
public class ZeroFileMainWindow
@@ -17,17 +18,30 @@
private static JComboBox _statusLista;
private static DefaultListModel _contactListModel;
private static JList _contactList;
- static void addContact(Object c)
+
+ static boolean containsHost(XMPPLinkLocalHost h)
{
- _contactListModel.addElement(c);
+ for (int i = 0; i<_contactListModel.size(); i++)
+ if (((XMPPLinkLocalHost)_contactListModel.getElementAt(i)).getServiceName().equals(h.getServiceName()))
+ return true;
+ return false;
}
- static void removeContact(Object c)
+
+ static void addHost(XMPPLinkLocalHost h)
{
- _contactListModel.removeElement(c);
+ _contactListModel.addElement(h);
}
+
+ static void removeHost(XMPPLinkLocalHost h)
+ {
+ for (int i = 0; i<_contactListModel.size(); i++)
+ if (((XMPPLinkLocalHost)_contactListModel.getElementAt(i)).getServiceName().equals(h.getServiceName()))
+ _contactListModel.remove(i);
+ }
+
static void startMainWindow()
{
- // Grundkittet, JFrame + JMenuBar
+ // Basics, JFrame + JMenuBar
_mainWindowFrame = new JFrame();
_mainWindowFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
_mainMenuBar = new JMenuBar();
@@ -57,19 +71,19 @@
_aboutMenuItem = new JMenuItem("About..");
_helpMenu.add(_aboutMenuItem);
- // Layout, storlekar, samt koppling av JMenuBar
+ // Layout, sizes, and the connection of the JMenuBar
_mainWindowFrame.setLayout(new GridLayout(0,1,1,1));
_mainWindowFrame.setMinimumSize(new Dimension(120,300));
_mainWindowFrame.setSize(new Dimension(150,400));
_mainWindowFrame.setJMenuBar(_mainMenuBar);
- // Statuslista
+ // Status list
String[] statusModes = {"Available","Away","Do not disturb"};
_statusLista = new JComboBox(statusModes);
_statusLista.setMaximumSize(new Dimension(20,100));
_mainWindowFrame.add(_statusLista);
- // Kontaktlista
+ // Contact list
_contactListModel = new DefaultListModel();
_contactList = new JList(_contactListModel);
_contactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
@@ -77,7 +91,7 @@
_contactList.setSize(500,700);
_mainWindowFrame.add(_contactList);
- // Sm\x8All upp f\x9Anstret
+ // Show the window
_mainWindowFrame.setVisible(true);
}
}
\ No newline at end of file
Modified: trunk/src/ZeroconfBrowsing.java
===================================================================
--- trunk/src/ZeroconfBrowsing.java 2007-11-07 15:20:24 UTC (rev 38)
+++ trunk/src/ZeroconfBrowsing.java 2007-11-07 15:57:15 UTC (rev 39)
@@ -15,22 +15,16 @@
String name, String regType, String domain)
{
XMPPLinkLocalHost newHost = new XMPPLinkLocalHost(name);
- ZeroFileMainWindow.addContact(newHost);
- /*System.out.println("Yay, found: " + name + " at interface: " + ifIndex);
- try
+ if (!ZeroFileMainWindow.containsHost(newHost))
{
- ZeroconfResolving.getHost(name);
+ newHost.updateData();
+ ZeroFileMainWindow.addHost(newHost);
}
- catch (Exception e)
- {
- System.out.println("Error: " + e.getStackTrace());
- }*/
}
public void serviceLost(DNSSDService browser, int flags, int ifIndex,
String name, String regType, String domain)
{
- ZeroFileMainWindow.removeContact("name");
- //System.out.println("Lost: " + name);
+ ZeroFileMainWindow.removeHost(new XMPPLinkLocalHost(name));
}
});
System.out.println("Starting browsing...");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <el...@us...> - 2007-11-09 12:18:32
|
Revision: 44
http://zerofile.svn.sourceforge.net/zerofile/?rev=44&view=rev
Author: elpedr0
Date: 2007-11-09 04:18:29 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
Working Save/load except for downloadpath and checkbox
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileSettings.java
trunk/src/ZeroFileSettingsWindow.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-09 10:30:52 UTC (rev 43)
+++ trunk/src/ZeroFile.java 2007-11-09 12:18:29 UTC (rev 44)
@@ -8,7 +8,6 @@
public static void main(String[] args) throws IOException {
ZeroFileMainWindow.startMainWindow();
ZeroFileChatWindow.startChatWindow();
- ZeroFileSettings.saveSettings();
ZeroFileSettings.loadSettings();
try
{
Modified: trunk/src/ZeroFileSettings.java
===================================================================
--- trunk/src/ZeroFileSettings.java 2007-11-09 10:30:52 UTC (rev 43)
+++ trunk/src/ZeroFileSettings.java 2007-11-09 12:18:29 UTC (rev 44)
@@ -5,33 +5,9 @@
import java.io.*;
public class ZeroFileSettings {
- //private static String _nickName;
- private static String _firstName;
- private static String _lastName;
- private static String _email;
- private static int _mainPort;
+
private static Properties _zeroFileProperties = new Properties();
- /*public static void saveSettings() throws IOException
- {
- // set up default properties
- Properties defaultProps = new Properties();
- FileInputStream defaultStream = new FileInputStream("defaultProperties");
- defaultProps.load(defaultStream);
- defaultStream.close();
-
- // set up real properties
- Properties applicationProps = new Properties(defaultProps);
- FileOutputStream appStream = new FileOutputStream("appProperties");
-
-
- applicationProps.put ( "HEIGHT","300" ) ;
- applicationProps.put ( "WIDTH","300" ) ;
-
-
- }*/
-
-
public static String getNickName()
{
if (_zeroFileProperties.containsKey("NickName"))
@@ -47,66 +23,66 @@
public static String getFirstName()
{
- return _firstName;
+ if (_zeroFileProperties.containsKey("FirstName"))
+ return _zeroFileProperties.getProperty("FirstName");
+ else
+ return "Anonymous";
}
public static void setFirstName(String f)
{
- _firstName = f;
+ _zeroFileProperties.put("FirstName", f);
}
public static String getLastName()
{
- return _lastName;
+ if (_zeroFileProperties.containsKey("LastName"))
+ return _zeroFileProperties.getProperty("LastName");
+ else
+ return "Anonymous";
}
public static void setLastName(String l)
{
- _lastName = l;
+ _zeroFileProperties.put("LastName", l);
}
public static String getEmail()
{
- return _email;
+ if (_zeroFileProperties.containsKey("Email"))
+ return _zeroFileProperties.getProperty("Email");
+ else
+ return "Ano...@an...";
}
public static void setEmail(String e)
{
- _email = e;
+ _zeroFileProperties.put("Email", e);
}
- public static int getMainPort()
- {
- return _mainPort;
+ public static String getMainPort() {
+ if (_zeroFileProperties.containsKey("Port"))
+ return _zeroFileProperties.getProperty("Port");
+ else
+ return "1337";
}
- public static void setMainPort(int p)
+ public static void setMainPort(String p)
{
- _mainPort = p;
+ _zeroFileProperties.put("Port", p);
}
public static void saveSettings() throws IOException {
-
- //Properties applicationProps = new Properties();
FileOutputStream appStream = new FileOutputStream("appProperties");
- _zeroFileProperties.put("first", "balle");
- //applicationProps.put("first", "balle");
- //applicationProps.put("last", "ballesson");
- _zeroFileProperties.store(appStream, "sttings");
- //applicationProps.store(appStream, "settings");
+ _zeroFileProperties.store(appStream, "settings");;
appStream.close();
}
public static void loadSettings() throws IOException {
- Properties applicationProps = new Properties();
FileInputStream appStream = new FileInputStream("appProperties");
- applicationProps.load(appStream);
- String key = "last";
- String val = applicationProps.getProperty ( key ) ;
- System.out.println ( val ) ;
- appStream.close();
+ _zeroFileProperties.load(appStream);
+ appStream.close();
}
-
}
Modified: trunk/src/ZeroFileSettingsWindow.java
===================================================================
--- trunk/src/ZeroFileSettingsWindow.java 2007-11-09 10:30:52 UTC (rev 43)
+++ trunk/src/ZeroFileSettingsWindow.java 2007-11-09 12:18:29 UTC (rev 44)
@@ -49,7 +49,7 @@
//Label + field for port parameter
JLabel portLabel = new JLabel("Port", JLabel.CENTER);
final JTextField portField = new JTextField();
- portField.setText(String.valueOf(ZeroFileSettings.getMainPort()));
+ portField.setText(ZeroFileSettings.getMainPort());
settingsWindowFrame.add(portLabel);
settingsWindowFrame.add(portField);
@@ -103,7 +103,7 @@
if(!emailField.getText().equals(""))
ZeroFileSettings.setEmail(emailField.getText());
if(!portField.getText().equals(""))
- ZeroFileSettings.setMainPort(Integer.valueOf(portField.getText()));
+ ZeroFileSettings.setMainPort(portField.getText());
try {
ZeroFileSettings.saveSettings();
} catch (IOException e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zo...@us...> - 2007-11-09 12:43:04
|
Revision: 45
http://zerofile.svn.sourceforge.net/zerofile/?rev=45&view=rev
Author: zondar
Date: 2007-11-09 04:43:02 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
added functionality to settings and settingswindow
Modified Paths:
--------------
trunk/src/ZeroFileSettings.java
trunk/src/ZeroFileSettingsWindow.java
Modified: trunk/src/ZeroFileSettings.java
===================================================================
--- trunk/src/ZeroFileSettings.java 2007-11-09 12:18:29 UTC (rev 44)
+++ trunk/src/ZeroFileSettings.java 2007-11-09 12:43:02 UTC (rev 45)
@@ -66,12 +66,39 @@
else
return "1337";
}
-
public static void setMainPort(String p)
{
_zeroFileProperties.put("Port", p);
}
+
+ public static void setCheckBox(String p)
+ {
+ _zeroFileProperties.put("CheckBox", p);
+ }
+
+ public static String getCheckBox() {
+ if (_zeroFileProperties.containsKey("CheckBox"))
+ return _zeroFileProperties.getProperty("CheckBox");
+ else
+ return "false";
+ }
+
+ public static void setDownloadFolder(String p)
+ {
+ _zeroFileProperties.put("DownloadFolder", p);
+ }
+
+ public static String getDownloadFolder() {
+ if (_zeroFileProperties.containsKey("DownloadFolder"))
+ return _zeroFileProperties.getProperty("DownloadFolder");
+ else
+ return "";
+ }
+
+
+
+
public static void saveSettings() throws IOException {
FileOutputStream appStream = new FileOutputStream("appProperties");
_zeroFileProperties.store(appStream, "settings");;
Modified: trunk/src/ZeroFileSettingsWindow.java
===================================================================
--- trunk/src/ZeroFileSettingsWindow.java 2007-11-09 12:18:29 UTC (rev 44)
+++ trunk/src/ZeroFileSettingsWindow.java 2007-11-09 12:43:02 UTC (rev 45)
@@ -56,6 +56,7 @@
//Label + browsing for chosing download folder
JLabel downloadLabel = new JLabel("Download Folder:", JLabel.CENTER);
final JLabel pathNowLabel = new JLabel("", JLabel.CENTER);
+ pathNowLabel.setText(ZeroFileSettings.getDownloadFolder());
JLabel pathLabel = new JLabel("Desired catalog:", JLabel.CENTER);
JButton browseButton = new JButton("Browse");
settingsWindowFrame.add(downloadLabel);
@@ -66,6 +67,7 @@
//Checkbox for auto accept file transfers
JLabel checkBoxLabel = new JLabel("Auto accept file transfers", JLabel.CENTER);
final JCheckBox checkBoxTransfer = new JCheckBox();
+ checkBoxTransfer.setSelected(Boolean.valueOf(ZeroFileSettings.getCheckBox()));
settingsWindowFrame.add(checkBoxLabel);
settingsWindowFrame.add(checkBoxTransfer);
@@ -93,7 +95,6 @@
okButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent okb){
- //checkBoxTransfer.isSelected();
if(!nickNameField.getText().equals(""))
ZeroFileSettings.setNickName(nickNameField.getText());
if(!firstNameField.getText().equals(""))
@@ -104,6 +105,9 @@
ZeroFileSettings.setEmail(emailField.getText());
if(!portField.getText().equals(""))
ZeroFileSettings.setMainPort(portField.getText());
+ if(!pathNowLabel.getText().equals(""))
+ ZeroFileSettings.setDownloadFolder(pathNowLabel.getText());
+ ZeroFileSettings.setCheckBox(String.valueOf(checkBoxTransfer.isSelected()));
try {
ZeroFileSettings.saveSettings();
} catch (IOException e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-13 13:55:21
|
Revision: 48
http://zerofile.svn.sourceforge.net/zerofile/?rev=48&view=rev
Author: karl-bengtsson
Date: 2007-11-13 05:55:03 -0800 (Tue, 13 Nov 2007)
Log Message:
-----------
We can now send messages, and read them out to the console. Parsing is required, as is fault tolerance, etc etc. Yay!
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFileChatWindow.java
trunk/src/ZeroFileMainWindow.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-11-10 12:51:28 UTC (rev 47)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-11-13 13:55:03 UTC (rev 48)
@@ -1,3 +1,6 @@
+import java.io.*;
+import java.net.*;
+
/*
* Class for handling chat sessions.
*/
@@ -4,22 +7,64 @@
public class XMPPLinkLocalChatSession {
private XMPPLinkLocalHost _remoteHost;
+ private Socket _s;
+ private Reader _fromRemoteHost;
+ private PrintWriter _toRemoteHost;
+ private PrintWriter _toUser = new PrintWriter(System.out,true);
+ private ZeroFileChatWindow _chatWindow;
+ private Thread _remoteHostReadingThread = new Thread() {
+ public void run() {
+ char[] buffer = new char[1024];
+ int chars_read;
+ try {
+ while ((chars_read = _fromRemoteHost.read(buffer)) != -1)
+ {
+ _toUser.write(buffer,0,chars_read);
+ _toUser.flush();
+ }
+ }
+ catch (IOException e) {System.out.println(e);}
+ System.out.println("Connection closed!");
+ }
+ };
public XMPPLinkLocalChatSession(XMPPLinkLocalHost hostToChatWith)
{
_remoteHost = hostToChatWith;
connect();
+ _chatWindow = new ZeroFileChatWindow(this);
}
public void sendMessage(String m)
{
- int port = _remoteHost.getPort();
+ _toRemoteHost.print("<message><body>"+m+"</body></message>");
+ _toRemoteHost.flush();
+ //System.out.println(m);
+ /*int port = _remoteHost.getPort();
String hostName = _remoteHost.getHost();
System.out.println("The text \"" + m + "\" should now be sent to:");
- System.out.println(hostName + ":" + port);
+ System.out.println(hostName + ":" + port);*/
}
public void connect()
{
- // TODO - establish connection to host
+ try
+ {
+ _s = new Socket(_remoteHost.getHost(),_remoteHost.getPort());
+ _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();
+ //_toRemoteHost.print(s);
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
}
+ public XMPPLinkLocalHost getRemoteHost()
+ {
+ return _remoteHost;
+ }
public void disconnect()
{
// TODO - disconnect from host
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-11-10 12:51:28 UTC (rev 47)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-13 13:55:03 UTC (rev 48)
@@ -14,12 +14,12 @@
private JTextField _entryTextField;
private JButton _sendButton;
private XMPPLinkLocalChatSession _session;
- public ZeroFileChatWindow(XMPPLinkLocalHost chatPartner)
+ public ZeroFileChatWindow(XMPPLinkLocalChatSession chatSession)
{
- chatPartner.updateData();
- _session = new XMPPLinkLocalChatSession(chatPartner);
+ _session = chatSession;
+ _session.getRemoteHost().updateData();
_chatWindowFrame = new JFrame();
- _chatWindowFrame.setTitle(chatPartner.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/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-10 12:51:28 UTC (rev 47)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-13 13:55:03 UTC (rev 48)
@@ -109,7 +109,7 @@
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2)
- new ZeroFileChatWindow((XMPPLinkLocalHost)_contactList.getSelectedValue());
+ new XMPPLinkLocalChatSession((XMPPLinkLocalHost)_contactList.getSelectedValue());
}
});
_mainWindowFrame.add(_contactList);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-13 14:20:26
|
Revision: 50
http://zerofile.svn.sourceforge.net/zerofile/?rev=50&view=rev
Author: karl-bengtsson
Date: 2007-11-13 06:20:20 -0800 (Tue, 13 Nov 2007)
Log Message:
-----------
Closing the chat window now properly ends the chat session and closes the socket.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFileChatWindow.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-11-13 13:58:06 UTC (rev 49)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-11-13 14:20:20 UTC (rev 50)
@@ -67,6 +67,15 @@
}
public void disconnect()
{
- // TODO - disconnect from host
+ try
+ {
+ _toRemoteHost.print("</stream:stream>");
+ _toRemoteHost.flush();
+ _s.close();
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
}
}
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-11-13 13:58:06 UTC (rev 49)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-13 14:20:20 UTC (rev 50)
@@ -1,6 +1,5 @@
import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.awt.event.*;
import javax.swing.*;
@@ -37,8 +36,40 @@
new ActionListener(){
public void actionPerformed(ActionEvent sendButtonPress){
_session.sendMessage(_entryTextField.getText());
+ _entryTextField.setText("");
}
}
);
+ _chatWindowFrame.addWindowListener(new WindowListener(){
+ public void windowClosing(WindowEvent e)
+ {
+
+ }
+ public void windowDeiconified(WindowEvent e)
+ {
+
+ }
+ public void windowActivated(WindowEvent e)
+ {
+
+ }
+ public void windowDeactivated(WindowEvent e)
+ {
+
+ }
+ public void windowClosed(WindowEvent e)
+ {
+ _session.disconnect();
+ }
+ public void windowIconified(WindowEvent e)
+ {
+
+ }
+ public void windowOpened(WindowEvent e)
+ {
+
+ }
+ });
+ _entryTextField.requestFocusInWindow();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-13 14:49:25
|
Revision: 51
http://zerofile.svn.sourceforge.net/zerofile/?rev=51&view=rev
Author: karl-bengtsson
Date: 2007-11-13 06:49:17 -0800 (Tue, 13 Nov 2007)
Log Message:
-----------
We now have a more descriptive service name, based on the host name of our system. This is gotten through a static method in the main ZeroFile class.
We also now don't list ourselves in the contact list.
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileMainWindow.java
trunk/src/ZeroconfBrowsing.java
trunk/src/ZeroconfRegistration.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-13 14:20:20 UTC (rev 50)
+++ trunk/src/ZeroFile.java 2007-11-13 14:49:17 UTC (rev 51)
@@ -1,4 +1,5 @@
import java.io.IOException;
+import java.net.InetAddress;
public class ZeroFile {
/**
@@ -23,4 +24,19 @@
System.exit(-1);
}
}
+
+ public static String getServiceName()
+ {
+ String serviceName = "serviceName";
+ try
+ {
+ InetAddress localMachine = InetAddress.getLocalHost();
+ serviceName = localMachine.getHostName();
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
+ return serviceName;
+ }
}
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-13 14:20:20 UTC (rev 50)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-13 14:49:17 UTC (rev 51)
@@ -82,6 +82,17 @@
_statusLista = new JComboBox(statusModes);
_statusLista.setMaximumSize(new Dimension(20,100));
_mainWindowFrame.add(_statusLista);
+ _statusLista.addItemListener(new ItemListener(){
+ public void itemStateChanged(ItemEvent e)
+ {
+ if (_statusLista.getSelectedItem().equals("Available"))
+ ZeroconfRegistration.setStatus("avail");
+ else if (_statusLista.getSelectedItem().equals("Away"))
+ ZeroconfRegistration.setStatus("away");
+ else
+ ZeroconfRegistration.setStatus("dnd");
+ }
+ });
// Contact list
_contactListModel = new DefaultListModel();
Modified: trunk/src/ZeroconfBrowsing.java
===================================================================
--- trunk/src/ZeroconfBrowsing.java 2007-11-13 14:20:20 UTC (rev 50)
+++ trunk/src/ZeroconfBrowsing.java 2007-11-13 14:49:17 UTC (rev 51)
@@ -15,7 +15,7 @@
String name, String regType, String domain)
{
XMPPLinkLocalHost newHost = new XMPPLinkLocalHost(name);
- if (!ZeroFileMainWindow.containsHost(newHost))
+ if (!ZeroFileMainWindow.containsHost(newHost) && !ZeroFile.getServiceName().equals(name))
{
newHost.updateData();
ZeroFileMainWindow.addHost(newHost);
Modified: trunk/src/ZeroconfRegistration.java
===================================================================
--- trunk/src/ZeroconfRegistration.java 2007-11-13 14:20:20 UTC (rev 50)
+++ trunk/src/ZeroconfRegistration.java 2007-11-13 14:49:17 UTC (rev 51)
@@ -13,7 +13,7 @@
static void registerService(String status,int port)
throws DNSSDException, InterruptedException
{
- _r = DNSSD.register("servicename", "_presence._tcp", port, new RegisterListener()
+ _r = DNSSD.register(ZeroFile.getServiceName(), "_presence._tcp", port, new RegisterListener()
{
public void serviceRegistered(DNSSDRegistration registration, int flags,
String serviceName, String regType, String domain)
@@ -60,13 +60,19 @@
}
static void setStatus(String s)
- throws DNSSDException, InterruptedException
{
- if (_r != null)
+ try
{
- _txtRecord.set("status", s);
- _r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
+ if (_r != null)
+ {
+ _txtRecord.set("status", s);
+ _r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
+ }
}
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
}
static String getEmail()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <kar...@us...> - 2007-11-21 11:53:10
|
Revision: 54
http://zerofile.svn.sourceforge.net/zerofile/?rev=54&view=rev
Author: karl-bengtsson
Date: 2007-11-21 03:53:15 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
Ugly as fuck patch to solve the problem of our registered service name not being set until after browsing begins - getMyServiceName now sleeps until service name is set. DO NOT CALL GETMYSERVICENAME() WITHOUT HAVING STARTED REGISTRATION OR YOU WILL DIE
Modified Paths:
--------------
trunk/src/ZeroconfBrowsing.java
trunk/src/ZeroconfRegistration.java
Modified: trunk/src/ZeroconfBrowsing.java
===================================================================
--- trunk/src/ZeroconfBrowsing.java 2007-11-21 11:01:21 UTC (rev 53)
+++ trunk/src/ZeroconfBrowsing.java 2007-11-21 11:53:15 UTC (rev 54)
@@ -15,7 +15,7 @@
String name, String regType, String domain)
{
XMPPLinkLocalHost newHost = new XMPPLinkLocalHost(name);
- if (!ZeroFileMainWindow.containsHost(newHost) && !ZeroFile.getServiceName().equals(name))
+ if (!ZeroFileMainWindow.containsHost(newHost) && !ZeroconfRegistration.getMyServiceName().equals(name))
{
newHost.updateData();
ZeroFileMainWindow.addHost(newHost);
Modified: trunk/src/ZeroconfRegistration.java
===================================================================
--- trunk/src/ZeroconfRegistration.java 2007-11-21 11:01:21 UTC (rev 53)
+++ trunk/src/ZeroconfRegistration.java 2007-11-21 11:53:15 UTC (rev 54)
@@ -9,23 +9,20 @@
{
private static TXTRecord _txtRecord = new TXTRecord();
private static DNSSDRegistration _r;
+ private static String _myServiceName;
static void registerService(String status,int port)
throws DNSSDException, InterruptedException
{
- _r = DNSSD.register(ZeroFile.getServiceName(), "_presence._tcp", port, new RegisterListener()
+ _r = DNSSD.register(null, "_presence._tcp", port, new RegisterListener()
{
public void serviceRegistered(DNSSDRegistration registration, int flags,
String serviceName, String regType, String domain)
{
- // TODO
- System.out.println("Registered Name : " + serviceName);
- System.out.println(" Type : " + regType);
- System.out.println(" Domain: " + domain);
+ _myServiceName = serviceName;
}
public void operationFailed(DNSSDService service, int errorCode)
{
- // TODO
System.out.println("Registration failed: " + errorCode);
}
});
@@ -36,6 +33,17 @@
_r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
}
+ public static String getMyServiceName()
+ {
+ while (_myServiceName == null)
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return _myServiceName;
+ }
+
static void registerService(int port)
throws DNSSDException, InterruptedException
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-21 16:39:53
|
Revision: 55
http://zerofile.svn.sourceforge.net/zerofile/?rev=55&view=rev
Author: karl-bengtsson
Date: 2007-11-21 08:39:56 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
Bugfixes, simplifications, and refactoring of code (we're now back to the old model of the chat window owning the chat session, rather than the other way around).
Now recieved and sent messages are output to the chat window, rather than just the console. They are however still not parsed as proper XML, just dumped raw.
Needs to be done: XMPPLinkLocalChatSession class needs a thorough review and refactoring, our chat window needs to be prettified, and we need to start parsing xml.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/XMPPSessionListener.java
trunk/src/ZeroFile.java
trunk/src/ZeroFileChatWindow.java
trunk/src/ZeroFileMainWindow.java
trunk/src/ZeroconfBrowsing.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-11-21 11:53:15 UTC (rev 54)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-11-21 16:39:56 UTC (rev 55)
@@ -6,12 +6,12 @@
*/
public class XMPPLinkLocalChatSession {
- //private XMPPLinkLocalHost _remoteHost;
private Socket _s;
private Reader _fromRemoteHost;
private PrintWriter _toRemoteHost;
private PrintWriter _toUser = new PrintWriter(System.out,true);
private ZeroFileChatWindow _chatWindow;
+
private Thread _remoteHostReadingThread = new Thread() {
public void run() {
char[] buffer = new char[1024];
@@ -21,23 +21,25 @@
{
_toUser.write(buffer,0,chars_read);
_toUser.flush();
+ _chatWindow.printText(String.valueOf(buffer));
}
}
catch (IOException e) {System.out.println(e);}
System.out.println("Connection closed!");
}
};
- public XMPPLinkLocalChatSession(XMPPLinkLocalHost hostToChatWith)
+
+ public XMPPLinkLocalChatSession(ZeroFileChatWindow cW,XMPPLinkLocalHost hostToChatWith)
{
- //_remoteHost = hostToChatWith;
+ _chatWindow = cW;
connect(hostToChatWith.getHost(),hostToChatWith.getPort());
- _chatWindow = new ZeroFileChatWindow(this);
}
- public XMPPLinkLocalChatSession(Socket s)
+
+ public XMPPLinkLocalChatSession(ZeroFileChatWindow cW,Socket s)
{
+ _chatWindow = cW;
try
{
- //_remoteHost = XMPPLinkLocalHost();
_s = s;
_fromRemoteHost = new InputStreamReader(_s.getInputStream());
_toRemoteHost = new PrintWriter(_s.getOutputStream());
@@ -45,28 +47,23 @@
_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>");
_toRemoteHost.flush();
- //System.out.println(m);
- /*int port = _remoteHost.getPort();
- String hostName = _remoteHost.getHost();
- System.out.println("The text \"" + m + "\" should now be sent to:");
- System.out.println(hostName + ":" + port);*/
}
+
public void connect(String host,int port)
{
try
{
- //_s = new Socket(_remoteHost.getHost(),_remoteHost.getPort());
_s = new Socket(host,port);
_fromRemoteHost = new InputStreamReader(_s.getInputStream());
_toRemoteHost = new PrintWriter(_s.getOutputStream());
@@ -74,17 +71,13 @@
_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();
- //_toRemoteHost.print(s);
}
catch (Exception e)
{
System.out.println(e);
}
}
- /*public XMPPLinkLocalHost getRemoteHost()
- {
- return _remoteHost;
- }*/
+
public void disconnect()
{
try
Modified: trunk/src/XMPPSessionListener.java
===================================================================
--- trunk/src/XMPPSessionListener.java 2007-11-21 11:53:15 UTC (rev 54)
+++ trunk/src/XMPPSessionListener.java 2007-11-21 16:39:56 UTC (rev 55)
@@ -1,4 +1,3 @@
-import java.io.*;
import java.net.*;
public class XMPPSessionListener {
@@ -13,7 +12,8 @@
while(true)
{
Socket connection = _listeningSock.accept();
- new XMPPLinkLocalChatSession(connection);
+ new ZeroFileChatWindow(connection);
+ //new XMPPLinkLocalChatSession(connection);
}
}
catch (Exception e)
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-21 11:53:15 UTC (rev 54)
+++ trunk/src/ZeroFile.java 2007-11-21 16:39:56 UTC (rev 55)
@@ -11,7 +11,6 @@
ZeroFileSettings.loadSettings();
try
{
- ZeroFileSettings.loadSettings();
ZeroconfRegistration.registerService();
XMPPSessionListener.startListening(ZeroFileSettings.getMainPort());
ZeroconfRegistration.set1st(ZeroFileSettings.getFirstName());
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-11-21 11:53:15 UTC (rev 54)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-21 16:39:56 UTC (rev 55)
@@ -1,5 +1,6 @@
import java.awt.*;
import java.awt.event.*;
+import java.net.*;
import javax.swing.*;
@@ -13,12 +14,32 @@
private JTextField _entryTextField;
private JButton _sendButton;
private XMPPLinkLocalChatSession _session;
- public ZeroFileChatWindow(XMPPLinkLocalChatSession chatSession)
+ public ZeroFileChatWindow(Socket sock)
{
- _session = chatSession;
- //_session.getRemoteHost().updateData();
+ this.ZeroFileChatWindowInit();
+ _session = new XMPPLinkLocalChatSession(this,sock);
+ }
+ public ZeroFileChatWindow(XMPPLinkLocalHost hostToChatWith)
+ {
+ this.ZeroFileChatWindowInit();
+ hostToChatWith.updateData();
+ this.setWindowTitle(hostToChatWith.toString());
+ _session = new XMPPLinkLocalChatSession(this,hostToChatWith);
+ }
+
+ public void setWindowTitle(String t)
+ {
+ _chatWindowFrame.setTitle(t);
+ }
+
+ public void printText(String s)
+ {
+ _chatTextArea.append("\n"+s);
+ }
+
+ private void ZeroFileChatWindowInit()
+ {
_chatWindowFrame = new JFrame();
- //_chatWindowFrame.setTitle(_session.getRemoteHost().toString());
_chatWindowFrame.setLayout(new GridLayout(0,1,1,1));
_chatWindowFrame.setLocation(0,400);
_chatWindowFrame.setSize(new Dimension(300,200));
@@ -35,7 +56,9 @@
_sendButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent sendButtonPress){
- _session.sendMessage(_entryTextField.getText());
+ String message = _entryTextField.getText();
+ printText(message);
+ _session.sendMessage(message);
_entryTextField.setText("");
}
}
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-21 11:53:15 UTC (rev 54)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-21 16:39:56 UTC (rev 55)
@@ -16,8 +16,8 @@
private static JMenu _helpMenu;
private static JMenuItem _aboutMenuItem;
private static JComboBox _statusLista;
- private static DefaultListModel _contactListModel;
- private static JList _contactList;
+ private static DefaultListModel _contactListModel = new DefaultListModel();;
+ private static JList _contactList = new JList(_contactListModel);;
static boolean containsHost(XMPPLinkLocalHost h)
{
@@ -29,6 +29,8 @@
static void addHost(XMPPLinkLocalHost h)
{
+ System.out.println("forsoker adda: " + h.toString());
+ //h.updateData();
_contactListModel.addElement(h);
}
@@ -95,8 +97,8 @@
});
// Contact list
- _contactListModel = new DefaultListModel();
- _contactList = new JList(_contactListModel);
+ //_contactListModel = new DefaultListModel();
+ //_contactList = new JList(_contactListModel);
_contactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
_contactList.setLayoutOrientation(JList.VERTICAL);
_contactList.setSize(500,700);
@@ -120,7 +122,8 @@
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2)
- new XMPPLinkLocalChatSession((XMPPLinkLocalHost)_contactList.getSelectedValue());
+ new ZeroFileChatWindow((XMPPLinkLocalHost)_contactList.getSelectedValue());
+ //new XMPPLinkLocalChatSession((XMPPLinkLocalHost)_contactList.getSelectedValue());
}
});
_mainWindowFrame.add(_contactList);
Modified: trunk/src/ZeroconfBrowsing.java
===================================================================
--- trunk/src/ZeroconfBrowsing.java 2007-11-21 11:53:15 UTC (rev 54)
+++ trunk/src/ZeroconfBrowsing.java 2007-11-21 16:39:56 UTC (rev 55)
@@ -15,10 +15,11 @@
String name, String regType, String domain)
{
XMPPLinkLocalHost newHost = new XMPPLinkLocalHost(name);
+ newHost.updateData();
if (!ZeroFileMainWindow.containsHost(newHost) && !ZeroconfRegistration.getMyServiceName().equals(name))
{
- newHost.updateData();
ZeroFileMainWindow.addHost(newHost);
+ System.out.println("hittat servicename: " + name);
}
}
public void serviceLost(DNSSDService browser, int flags, int ifIndex,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kar...@us...> - 2007-11-27 13:04:42
|
Revision: 56
http://zerofile.svn.sourceforge.net/zerofile/?rev=56&view=rev
Author: karl-bengtsson
Date: 2007-11-27 05:04:34 -0800 (Tue, 27 Nov 2007)
Log Message:
-----------
Changed back to the old inheritance structure for chats/chat windows and simplified the chat session class greatly.
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/XMPPSessionListener.java
trunk/src/ZeroFileChatWindow.java
trunk/src/ZeroFileMainWindow.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-11-21 16:39:56 UTC (rev 55)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-11-27 13:04:34 UTC (rev 56)
@@ -6,10 +6,12 @@
*/
public class XMPPLinkLocalChatSession {
+ private boolean _sentHandshake = false;
+ private boolean _recievedHandshake =false;
private Socket _s;
private Reader _fromRemoteHost;
private PrintWriter _toRemoteHost;
- private PrintWriter _toUser = new PrintWriter(System.out,true);
+ //private PrintWriter _toUser = new PrintWriter(System.out,true);
private ZeroFileChatWindow _chatWindow;
private Thread _remoteHostReadingThread = new Thread() {
@@ -19,9 +21,10 @@
try {
while ((chars_read = _fromRemoteHost.read(buffer)) != -1)
{
- _toUser.write(buffer,0,chars_read);
- _toUser.flush();
- _chatWindow.printText(String.valueOf(buffer));
+ RecievedStanza(String.valueOf(buffer).substring(0,chars_read));
+ //_toUser.write(buffer,0,chars_read);
+ //_toUser.flush();
+ //_chatWindow.printText(String.valueOf(buffer));
}
}
catch (IOException e) {System.out.println(e);}
@@ -29,24 +32,31 @@
}
};
- public XMPPLinkLocalChatSession(ZeroFileChatWindow cW,XMPPLinkLocalHost hostToChatWith)
+ public void sendHandshake()
{
- _chatWindow = cW;
- connect(hostToChatWith.getHost(),hostToChatWith.getPort());
+ try
+ {
+ _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();
+ _sentHandshake = true;
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
}
- public XMPPLinkLocalChatSession(ZeroFileChatWindow cW,Socket s)
+ public XMPPLinkLocalChatSession(XMPPLinkLocalHost hostToChatWith)
{
- _chatWindow = cW;
+ _chatWindow = new ZeroFileChatWindow(this);
try
{
- _s = s;
+ _s = new Socket(hostToChatWith.getHost(),hostToChatWith.getPort());
+ _toRemoteHost = new PrintWriter(_s.getOutputStream());
_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();
+ sendHandshake();
}
catch (Exception e)
{
@@ -54,29 +64,39 @@
}
}
- public void sendMessage(String m)
+ private void RecievedStanza(String stanza)
{
- _toRemoteHost.print("<message><body>"+m+"</body></message>");
- _toRemoteHost.flush();
+ RecievedMessage(stanza);
}
- public void connect(String host,int port)
+ private void RecievedMessage(String mess)
{
+ if (_chatWindow == null)
+ _chatWindow = new ZeroFileChatWindow(this);
+ _chatWindow.printText(mess);
+ }
+
+ public XMPPLinkLocalChatSession(Socket s)
+ {
+ _s = s;
try
{
- _s = new Socket(host,port);
_fromRemoteHost = new InputStreamReader(_s.getInputStream());
+ _remoteHostReadingThread.start();
_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();
+ sendHandshake();
}
catch (Exception e)
{
System.out.println(e);
}
}
+
+ public void sendMessage(String m)
+ {
+ _toRemoteHost.print("<message><body>"+m+"</body></message>");
+ _toRemoteHost.flush();
+ }
public void disconnect()
{
Modified: trunk/src/XMPPSessionListener.java
===================================================================
--- trunk/src/XMPPSessionListener.java 2007-11-21 16:39:56 UTC (rev 55)
+++ trunk/src/XMPPSessionListener.java 2007-11-27 13:04:34 UTC (rev 56)
@@ -12,8 +12,8 @@
while(true)
{
Socket connection = _listeningSock.accept();
- new ZeroFileChatWindow(connection);
- //new XMPPLinkLocalChatSession(connection);
+ //new ZeroFileChatWindow(connection);
+ new XMPPLinkLocalChatSession(connection);
}
}
catch (Exception e)
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-11-21 16:39:56 UTC (rev 55)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-27 13:04:34 UTC (rev 56)
@@ -1,6 +1,5 @@
import java.awt.*;
import java.awt.event.*;
-import java.net.*;
import javax.swing.*;
@@ -14,7 +13,7 @@
private JTextField _entryTextField;
private JButton _sendButton;
private XMPPLinkLocalChatSession _session;
- public ZeroFileChatWindow(Socket sock)
+ /*public ZeroFileChatWindow(Socket sock)
{
this.ZeroFileChatWindowInit();
_session = new XMPPLinkLocalChatSession(this,sock);
@@ -25,6 +24,12 @@
hostToChatWith.updateData();
this.setWindowTitle(hostToChatWith.toString());
_session = new XMPPLinkLocalChatSession(this,hostToChatWith);
+ }*/
+
+ public ZeroFileChatWindow(XMPPLinkLocalChatSession sess)
+ {
+ this.ZeroFileChatWindowInit();
+ _session = sess;
}
public void setWindowTitle(String t)
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-21 16:39:56 UTC (rev 55)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-27 13:04:34 UTC (rev 56)
@@ -29,8 +29,8 @@
static void addHost(XMPPLinkLocalHost h)
{
- System.out.println("forsoker adda: " + h.toString());
- //h.updateData();
+ //System.out.println("forsoker adda: " + h.toString());
+ h.updateData();
_contactListModel.addElement(h);
}
@@ -122,8 +122,8 @@
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2)
- new ZeroFileChatWindow((XMPPLinkLocalHost)_contactList.getSelectedValue());
- //new XMPPLinkLocalChatSession((XMPPLinkLocalHost)_contactList.getSelectedValue());
+ //new ZeroFileChatWindow((XMPPLinkLocalHost)_contactList.getSelectedValue());
+ new XMPPLinkLocalChatSession((XMPPLinkLocalHost)_contactList.getSelectedValue());
}
});
_mainWindowFrame.add(_contactList);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|