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