You can subscribe to this list here.
2007 |
Jan
|
Feb
(4) |
Mar
(59) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: <ba...@us...> - 2007-03-04 15:01:50
|
Revision: 73 http://trivial.svn.sourceforge.net/trivial/?rev=73&view=rev Author: baepel Date: 2007-03-04 07:01:40 -0800 (Sun, 04 Mar 2007) Log Message: ----------- Modified Paths: -------------- trunk/eclipse/easypaste/.classpath trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java Removed Paths: ------------- trunk/eclipse/easypaste/launch/EasyController_Mac.launch Modified: trunk/eclipse/easypaste/.classpath =================================================================== --- trunk/eclipse/easypaste/.classpath 2007-03-04 15:01:20 UTC (rev 72) +++ trunk/eclipse/easypaste/.classpath 2007-03-04 15:01:40 UTC (rev 73) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src"/> + <classpathentry excluding="net/sf/trivial/easypaste/internal/mac/**/*" kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/bonjour"/> <classpathentry combineaccessrules="false" kind="src" path="/utils"/> Deleted: trunk/eclipse/easypaste/launch/EasyController_Mac.launch =================================================================== --- trunk/eclipse/easypaste/launch/EasyController_Mac.launch 2007-03-04 15:01:20 UTC (rev 72) +++ trunk/eclipse/easypaste/launch/EasyController_Mac.launch 2007-03-04 15:01:40 UTC (rev 73) @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="UTF-8"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.sf.trivial.easypaste.launcher.EasyController"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-ea"/> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="4"/> -</listAttribute> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="easypaste"/> -<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> -<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/easypaste"/> -</listAttribute> -<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -</launchConfiguration> Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 15:01:20 UTC (rev 72) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 15:01:40 UTC (rev 73) @@ -2,7 +2,6 @@ import java.io.IOException; -import net.sf.trivial.easypaste.internal.pi.presence.ServiceRegistrerImpl; import net.sf.trivial.easypaste.internal.presence.AbstractPresenceService; import net.sf.trivial.easypaste.internal.presence.ServiceBrowser; Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java 2007-03-04 15:01:20 UTC (rev 72) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java 2007-03-04 15:01:40 UTC (rev 73) @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.Iterator; -import net.sf.trivial.easypaste.internal.mac.presence.ServiceRegistrerImpl; import net.sf.trivial.easypaste.presence.Peer; import net.sf.trivial.easypaste.presence.PresenceService; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 15:01:31
|
Revision: 72 http://trivial.svn.sourceforge.net/trivial/?rev=72&view=rev Author: fterrier Date: 2007-03-04 07:01:20 -0800 (Sun, 04 Mar 2007) Log Message: ----------- added presence service for platform independent Modified Paths: -------------- trunk/eclipse/bonjour/.classpath trunk/eclipse/bonjour/jmdns/src/samples/DiscoverServices.java trunk/eclipse/bonjour/jmdns/src/samples/ListServices.java Removed Paths: ------------- trunk/eclipse/bonjour/jmdns/src/com/ trunk/eclipse/bonjour/jmdns/src/javax/ Modified: trunk/eclipse/bonjour/.classpath =================================================================== --- trunk/eclipse/bonjour/.classpath 2007-03-04 14:58:41 UTC (rev 71) +++ trunk/eclipse/bonjour/.classpath 2007-03-04 15:01:20 UTC (rev 72) @@ -3,7 +3,7 @@ <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="jmdns/src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="lib" path="jmdns/lib/jmdns.jar"/> - <classpathentry kind="lib" path="apple/dns_sd.jar"/> + <classpathentry exported="true" kind="lib" path="jmdns/lib/jmdns.jar"/> + <classpathentry exported="true" kind="lib" path="apple/dns_sd.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: trunk/eclipse/bonjour/jmdns/src/samples/DiscoverServices.java =================================================================== --- trunk/eclipse/bonjour/jmdns/src/samples/DiscoverServices.java 2007-03-04 14:58:41 UTC (rev 71) +++ trunk/eclipse/bonjour/jmdns/src/samples/DiscoverServices.java 2007-03-04 15:01:20 UTC (rev 72) @@ -55,7 +55,7 @@ handler.setLevel(Level.FINER); */ JmDNS jmdns = new JmDNS(); - jmdns.addServiceListener("_http._tcp.local.", new SampleListener()); + jmdns.addServiceListener("_daap._tcp.local.", new SampleListener()); System.out.println("Press q and Enter, to quit"); int b; Modified: trunk/eclipse/bonjour/jmdns/src/samples/ListServices.java =================================================================== --- trunk/eclipse/bonjour/jmdns/src/samples/ListServices.java 2007-03-04 14:58:41 UTC (rev 71) +++ trunk/eclipse/bonjour/jmdns/src/samples/ListServices.java 2007-03-04 15:01:20 UTC (rev 72) @@ -46,7 +46,7 @@ try { JmDNS jmdns = new JmDNS(); while (true) { - ServiceInfo[] infos = jmdns.list("_http._tcp.local."); + ServiceInfo[] infos = jmdns.list("_workstation._tcp.local."); for (int i=0; i < infos.length; i++) { System.out.println(infos[i]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 14:58:40
|
Revision: 71 http://trivial.svn.sourceforge.net/trivial/?rev=71&view=rev Author: jlgeering Date: 2007-03-04 06:58:41 -0800 (Sun, 04 Mar 2007) Log Message: ----------- EasyStart Added Paths: ----------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyStart.java Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyStart.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyStart.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyStart.java 2007-03-04 14:58:41 UTC (rev 71) @@ -0,0 +1,17 @@ +package net.sf.trivial.easypaste.launcher; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class EasyStart { + + private static Log log = LogFactory.getLog(EasyStart.class); + + public static void main(String[] args) { + String os = System.getProperty("os.name"); + log.debug("os.name=" + os); + if ("Mac OS X".equals(os)) { + log.info("Detected Mac OS X"); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-03-04 14:57:13
|
Revision: 70 http://trivial.svn.sourceforge.net/trivial/?rev=70&view=rev Author: baepel Date: 2007-03-04 06:56:51 -0800 (Sun, 04 Mar 2007) Log Message: ----------- fixed mac dependency Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 14:52:27 UTC (rev 69) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 14:56:51 UTC (rev 70) @@ -2,7 +2,7 @@ import java.io.IOException; -import net.sf.trivial.easypaste.internal.mac.presence.ServiceRegistrerImpl; +import net.sf.trivial.easypaste.internal.pi.presence.ServiceRegistrerImpl; import net.sf.trivial.easypaste.internal.presence.AbstractPresenceService; import net.sf.trivial.easypaste.internal.presence.ServiceBrowser; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 14:52:27
|
Revision: 69 http://trivial.svn.sourceforge.net/trivial/?rev=69&view=rev Author: fterrier Date: 2007-03-04 06:52:27 -0800 (Sun, 04 Mar 2007) Log Message: ----------- added presence service for platform independent Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowserImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowserImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowserImpl.java 2007-03-04 14:34:14 UTC (rev 68) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowserImpl.java 2007-03-04 14:52:27 UTC (rev 69) @@ -56,7 +56,7 @@ try { // call browse - service = DNSSD.browse(0, 0, proto+"._tcp", "", this); + service = DNSSD.browse(0, 0, proto, "", this); } catch (Exception e) { // TODO Auto-generated catch block Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrerImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrerImpl.java 2007-03-04 14:34:14 UTC (rev 68) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrerImpl.java 2007-03-04 14:52:27 UTC (rev 69) @@ -42,7 +42,7 @@ try { - registration = DNSSD.register(name, proto+"._tcp", port, this); + registration = DNSSD.register(name, proto, port, this); } catch (Exception e) { e.printStackTrace(); Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 14:34:14 UTC (rev 68) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 14:52:27 UTC (rev 69) @@ -11,8 +11,10 @@ public PresenceServiceImpl(int port, String serviceName) throws IOException { super(port, serviceName); this.serviceBrowser = new ServiceBrowserImpl(this); + this.serviceRegistrer = new ServiceRegistrerImpl(); } + private final ServiceRegistrerImpl serviceRegistrer; private final ServiceBrowserImpl serviceBrowser; @Override @@ -22,8 +24,7 @@ @Override public ServiceRegistrerImpl getServiceRegistrer() { - // TODO Auto-generated method stub - return null; + return serviceRegistrer; } } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java 2007-03-04 14:34:14 UTC (rev 68) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java 2007-03-04 14:52:27 UTC (rev 69) @@ -6,22 +6,27 @@ import javax.jmdns.ServiceEvent; import javax.jmdns.ServiceListener; +import net.sf.trivial.easypaste.internal.presence.PeerImpl; + public class ServiceBrowserImpl implements net.sf.trivial.easypaste.internal.presence.ServiceBrowser, ServiceListener { public void serviceAdded(ServiceEvent event) { - + System.out.println("Requesting service for: "+event.getName()); + + jmdns.requestServiceInfo(event.getType(), event.getName()); } public void serviceRemoved(ServiceEvent event) { - // TODO Auto-generated method stub - + presenceService.unregister(event.getName()); } public void serviceResolved(ServiceEvent event) { - // TODO Auto-generated method stub + System.out.println("Service browser gets info: "+event.getInfo()); + presenceService.register(new PeerImpl(event.getName(),event.getType(), + null,event.getInfo().getInetAddress(),event.getInfo().getPort())); } public ServiceBrowserImpl(PresenceServiceImpl presenceService) throws IOException { @@ -31,12 +36,11 @@ private final PresenceServiceImpl presenceService; private final JmDNS jmdns; - private final String protoSuffix = "._tmp.local."; public void browse(String proto) { try { JmDNS jmdns = new JmDNS(); - jmdns.addServiceListener(proto+protoSuffix, this); + jmdns.addServiceListener(proto, this); } catch (IOException e) { // TODO Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java 2007-03-04 14:34:14 UTC (rev 68) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java 2007-03-04 14:52:27 UTC (rev 69) @@ -1,16 +1,31 @@ package net.sf.trivial.easypaste.internal.pi.presence; +import java.io.IOException; +import javax.jmdns.JmDNS; +import javax.jmdns.ServiceInfo; + + public class ServiceRegistrerImpl implements net.sf.trivial.easypaste.internal.presence.ServiceRegistrer { + public ServiceRegistrerImpl() throws IOException { + this.jmdns = new JmDNS(); + } + + private final JmDNS jmdns; + public void register(String name, String proto, int port) { - // TODO Auto-generated method stub - + try { + JmDNS jmdns = new JmDNS(); + ServiceInfo info = new ServiceInfo(proto, name, 1268, 0, 0, ""); + jmdns.registerService(info); + } catch (IOException e) { + e.printStackTrace(); + } } public void stop() { - // TODO Auto-generated method stub - + jmdns.close(); } } \ No newline at end of file Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java 2007-03-04 14:34:14 UTC (rev 68) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java 2007-03-04 14:52:27 UTC (rev 69) @@ -63,7 +63,7 @@ private final String serviceName; static final int WAIT = 15000; - static final String PROTO = "_flebeleb"; + static final String PROTO = "_easypaste._tcp"; public AbstractPresenceService(int port, String serviceName) { this.port = port; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 14:34:16
|
Revision: 68 http://trivial.svn.sourceforge.net/trivial/?rev=68&view=rev Author: jlgeering Date: 2007-03-04 06:34:14 -0800 (Sun, 04 Mar 2007) Log Message: ----------- Logging for CBReaderImpl Modified Paths: -------------- trunk/eclipse/easypaste/src/log4j.properties trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java Modified: trunk/eclipse/easypaste/src/log4j.properties =================================================================== --- trunk/eclipse/easypaste/src/log4j.properties 2007-03-04 14:29:21 UTC (rev 67) +++ trunk/eclipse/easypaste/src/log4j.properties 2007-03-04 14:34:14 UTC (rev 68) @@ -2,4 +2,4 @@ log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=- %m%n +log4j.appender.console.layout.ConversionPattern=%m%n Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java 2007-03-04 14:29:21 UTC (rev 67) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java 2007-03-04 14:34:14 UTC (rev 68) @@ -3,12 +3,16 @@ import net.sf.trivial.easypaste.ClipboardReader; import net.sf.trivial.easypaste.DistributedClipboard; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.apple.cocoa.application.NSPasteboard; public class ClipboardReaderImpl implements ClipboardReader, Runnable { + private Log log = LogFactory.getLog(ClipboardReaderImpl.class); + private boolean running; - private Object stopped = new Object(); private DistributedClipboard distributedClipboard; @@ -42,18 +46,19 @@ } public synchronized void start() throws InterruptedException { - System.out.println("Clipboard reader starting"); - if (!running) { + log.info("Starting ClipboardReader ..."); running = true; new Thread(this, "ClipboardReader").start(); } + else { + System.out.println("Not starting Clipboard Reader (already started)"); + } } public synchronized void stop() throws InterruptedException { - System.out.println("Clipboard reader stopping"); - if (running) { + log.info("Stopping ClipboardReader ..."); running = false; stopped.wait(); } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java 2007-03-04 14:29:21 UTC (rev 67) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java 2007-03-04 14:34:14 UTC (rev 68) @@ -1,15 +1,20 @@ package net.sf.trivial.easypaste.internal.pi; +import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; -import java.awt.Toolkit; +import java.awt.datatransfer.Transferable; + import net.sf.trivial.easypaste.ClipboardReader; import net.sf.trivial.easypaste.DistributedClipboard; -import java.awt.datatransfer.Transferable; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + public class ClipboardReaderImpl implements ClipboardReader, Runnable { + private Log log = LogFactory.getLog(ClipboardReaderImpl.class); + private boolean running; - private Object stopped = new Object(); private DistributedClipboard distributedClipboard; @@ -53,18 +58,16 @@ } public synchronized void start() throws InterruptedException { - System.out.println("Clipboard reader starting"); - if (!running) { + log.info("Starting ClipboardReader ..."); running = true; new Thread(this, "ClipboardReader").start(); } } public synchronized void stop() throws InterruptedException { - System.out.println("Clipboard reader stopping"); - if (running) { + log.info("Stopping ClipboardReader ..."); running = false; stopped.wait(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 14:29:21
|
Revision: 67 http://trivial.svn.sourceforge.net/trivial/?rev=67&view=rev Author: jlgeering Date: 2007-03-04 06:29:21 -0800 (Sun, 04 Mar 2007) Log Message: ----------- logging libraries Modified Paths: -------------- trunk/eclipse/utils/.classpath Added Paths: ----------- trunk/eclipse/utils/lib/ trunk/eclipse/utils/lib/commons-logging-1.1.jar trunk/eclipse/utils/lib/log4j-1.2.14.jar trunk/eclipse/utils/lic/ trunk/eclipse/utils/lic/commons-logging.txt trunk/eclipse/utils/lic/log4j.txt Modified: trunk/eclipse/utils/.classpath =================================================================== --- trunk/eclipse/utils/.classpath 2007-03-04 14:19:25 UTC (rev 66) +++ trunk/eclipse/utils/.classpath 2007-03-04 14:29:21 UTC (rev 67) @@ -4,5 +4,7 @@ <classpathentry kind="src" path="growl/src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="lib" path="System_Library_Java"/> + <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.14.jar"/> + <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Added: trunk/eclipse/utils/lib/commons-logging-1.1.jar =================================================================== (Binary files differ) Property changes on: trunk/eclipse/utils/lib/commons-logging-1.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/eclipse/utils/lib/log4j-1.2.14.jar =================================================================== (Binary files differ) Property changes on: trunk/eclipse/utils/lib/log4j-1.2.14.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/eclipse/utils/lic/commons-logging.txt =================================================================== --- trunk/eclipse/utils/lic/commons-logging.txt (rev 0) +++ trunk/eclipse/utils/lic/commons-logging.txt 2007-03-04 14:29:21 UTC (rev 67) @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. Added: trunk/eclipse/utils/lic/log4j.txt =================================================================== --- trunk/eclipse/utils/lic/log4j.txt (rev 0) +++ trunk/eclipse/utils/lic/log4j.txt 2007-03-04 14:29:21 UTC (rev 67) @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 14:19:26
|
Revision: 66 http://trivial.svn.sourceforge.net/trivial/?rev=66&view=rev Author: fterrier Date: 2007-03-04 06:19:25 -0800 (Sun, 04 Mar 2007) Log Message: ----------- readded distributedcli?\195?\168borad Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/EasyController.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/pi/EasyController.java Added Paths: ----------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties Removed Paths: ------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/Messages.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/messages.properties Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 14:14:33 UTC (rev 65) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 14:19:25 UTC (rev 66) @@ -1,19 +1,23 @@ package net.sf.trivial.easypaste.internal.pi.presence; +import java.io.IOException; + import net.sf.trivial.easypaste.internal.mac.presence.ServiceRegistrerImpl; import net.sf.trivial.easypaste.internal.presence.AbstractPresenceService; import net.sf.trivial.easypaste.internal.presence.ServiceBrowser; public class PresenceServiceImpl extends AbstractPresenceService { - public PresenceServiceImpl(int port, String serviceName) { + public PresenceServiceImpl(int port, String serviceName) throws IOException { super(port, serviceName); + this.serviceBrowser = new ServiceBrowserImpl(this); } + private final ServiceBrowserImpl serviceBrowser; + @Override public ServiceBrowser getServiceBrowser() { - // TODO Auto-generated method stub - return null; + return serviceBrowser; } @Override Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java 2007-03-04 14:14:33 UTC (rev 65) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java 2007-03-04 14:19:25 UTC (rev 66) @@ -1,16 +1,17 @@ package net.sf.trivial.easypaste.internal.pi.presence; +import java.io.IOException; + +import javax.jmdns.JmDNS; import javax.jmdns.ServiceEvent; import javax.jmdns.ServiceListener; - public class ServiceBrowserImpl implements net.sf.trivial.easypaste.internal.presence.ServiceBrowser, ServiceListener { public void serviceAdded(ServiceEvent event) { - // TODO Auto-generated method stub - + } public void serviceRemoved(ServiceEvent event) { @@ -22,15 +23,28 @@ // TODO Auto-generated method stub } + + public ServiceBrowserImpl(PresenceServiceImpl presenceService) throws IOException { + this.jmdns = new JmDNS(); + this.presenceService = presenceService; + } + private final PresenceServiceImpl presenceService; + private final JmDNS jmdns; + private final String protoSuffix = "._tmp.local."; + public void browse(String proto) { - // TODO Auto-generated method stub - + try { + JmDNS jmdns = new JmDNS(); + jmdns.addServiceListener(proto+protoSuffix, this); + } + catch (IOException e) { + // TODO + } } public void stop() { - // TODO Auto-generated method stub - + jmdns.close(); } Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java (from rev 65, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/Messages.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java 2007-03-04 14:19:25 UTC (rev 66) @@ -0,0 +1,22 @@ +package net.sf.trivial.easypaste.launcher; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "net.sf.trivial.easypaste.launcher.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/EasyController.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/EasyController.java 2007-03-04 14:14:33 UTC (rev 65) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/EasyController.java 2007-03-04 14:19:25 UTC (rev 66) @@ -11,6 +11,7 @@ import net.sf.trivial.easypaste.internal.mac.ClipboardReaderImpl; import net.sf.trivial.easypaste.internal.mac.ClipboardWriterImpl; import net.sf.trivial.easypaste.internal.mac.GrowlNotification; +import net.sf.trivial.easypaste.launcher.Messages; import net.sf.trivial.easypaste.presence.PresenceService; public class EasyController { Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/Messages.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/Messages.java 2007-03-04 14:14:33 UTC (rev 65) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/Messages.java 2007-03-04 14:19:25 UTC (rev 66) @@ -1,22 +0,0 @@ -package net.sf.trivial.easypaste.launcher.mac; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "net.sf.trivial.easypaste.launcher.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/messages.properties =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/messages.properties 2007-03-04 14:14:33 UTC (rev 65) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/messages.properties 2007-03-04 14:19:25 UTC (rev 66) @@ -1 +0,0 @@ -EasyController.ServiceName=Franz's easypaste Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties (from rev 65, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/messages.properties) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties 2007-03-04 14:19:25 UTC (rev 66) @@ -0,0 +1 @@ +EasyController.ServiceName=Franz's easypaste Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/pi/EasyController.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/pi/EasyController.java 2007-03-04 14:14:33 UTC (rev 65) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/pi/EasyController.java 2007-03-04 14:19:25 UTC (rev 66) @@ -10,6 +10,8 @@ import net.sf.trivial.easypaste.internal.DistributedClipboardImpl; import net.sf.trivial.easypaste.internal.pi.ClipboardReaderImpl; import net.sf.trivial.easypaste.internal.pi.ClipboardWriterImpl; +import net.sf.trivial.easypaste.internal.pi.presence.PresenceServiceImpl; +import net.sf.trivial.easypaste.launcher.Messages; import net.sf.trivial.easypaste.presence.PresenceService; public class EasyController { @@ -27,16 +29,17 @@ DistributedClipboard dclip = new DistributedClipboardImpl(PORT); ClipboardReader creader = new ClipboardReaderImpl(); ClipboardWriter cwriter = new ClipboardWriterImpl(); - PresenceService presenceService = new net.sf.trivial.easypaste.internal.pi.presence.PresenceServiceImpl(PORT, name); + try { + PresenceService presenceService = new PresenceServiceImpl(PORT, name); - dclip.setClipboardWriter(cwriter); - dclip.setNotificationService(not); - dclip.setPresenceService(presenceService); - creader.setDistributedClipboard(dclip); - try { + dclip.setClipboardWriter(cwriter); + // dclip.setNotificationService(not); + dclip.setPresenceService(presenceService); + creader.setDistributedClipboard(dclip); + presenceService.start(); creader.start(); - } catch (InterruptedException e) { + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-03-04 14:14:40
|
Revision: 65 http://trivial.svn.sourceforge.net/trivial/?rev=65&view=rev Author: baepel Date: 2007-03-04 06:14:33 -0800 (Sun, 04 Mar 2007) Log Message: ----------- en voila de commit message SALOPE ! Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java Added Paths: ----------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardWriterImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/pi/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/pi/EasyController.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java 2007-03-04 14:10:46 UTC (rev 64) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java 2007-03-04 14:14:33 UTC (rev 65) @@ -1,126 +1,72 @@ -//Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. -//Jad home page: http://www.kpdus.com/jad.html -//Decompiler options: packimports(3) -//Source File Name: ClipPaste.java - package net.sf.trivial.easypaste.internal.pi; -import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.ClipboardOwner; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.StringSelection; +import java.awt.Toolkit; +import net.sf.trivial.easypaste.ClipboardReader; +import net.sf.trivial.easypaste.DistributedClipboard; import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.io.IOException; +public class ClipboardReaderImpl implements ClipboardReader, Runnable { -import com.apple.cocoa.foundation.NSMutableArray; -import com.growl.Growl; + private boolean running; -import easypaste.EasyListener; + private Object stopped = new Object(); -public class ClipboardReaderImpl implements ClipboardOwner { + private DistributedClipboard distributedClipboard; - private boolean running; private Clipboard clipboard; - private Growl growl; - private EasyListener el; - - private final static String GROWL_NOTIFICATION = "clipboard update"; + String curString; + String lastString; + public ClipboardReaderImpl() { clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - growl = new Growl("Easypast", "logo.png"); - NSMutableArray nsa = new NSMutableArray(); - nsa.addObject(GROWL_NOTIFICATION); - growl.setAllowedNotifications(nsa); - try { - growl.setDefaultNotifications(nsa); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - growl.register(); - el = new EasyListener(); running = false; } - - public void readOnce() { - if (running) { - System.out.println(0); - return; - } - System.out.println(1); - running = true; - new Thread(new Runnable() { - public void run() { - Transferable transferable; - System.out.println(clipboard.getName()); - - Transferable t = new StringSelection("d"); - ClipboardOwner co = new ClipboardOwner() { - public void lostOwnership(Clipboard clipboard, Transferable contents) { - System.out.println(6); - - } - - }; - System.out.println(t); -// clipboard.setContents(t, co); - clipboard.setContents(new StringSelection("e"), co); - String s = ""; -// System.out.println(clipboard.getName()); - boolean loop = true; - while (loop) { -// System.out.println(3); -// System.out.println(Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null)); - transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(new Object()); - System.out.println(transferable); - try { - if (transferable != null - && transferable.isDataFlavorSupported(DataFlavor.stringFlavor) - && !s.equals((String) transferable.getTransferData(DataFlavor.stringFlavor))) { -//// loop = false; -// System.out.println(4); -// - s = (String) transferable.getTransferData(DataFlavor.stringFlavor); - System.out.println(s); -// growl.notifyGrowlOf(GROWL_NOTIFICATION, "Clipboard Update", s); -// el.sendString(s); -//// break; - } -// } catch (UnsupportedFlavorException e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } catch (IOException e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } -// System.out.println(5); - try { - Thread.sleep(2000); - } catch (InterruptedException e) {} + public void run() { + while (running) { + // get current string from clipboard + Transferable trans = clipboard.getContents(null); + try { + curString = (String) trans.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor); + // check if it has changed + if (!curString.equals(lastString)) { + lastString = curString; + distributedClipboard.setLocalContent(curString); } - running = false; + } catch (Exception e) { + e.printStackTrace(); } - - }, "Clipboard Reader").start(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + stopped.notify(); + } + public void setDistributedClipboard(DistributedClipboard distributedClipboard) { + this.distributedClipboard = distributedClipboard; } - public static void main(String args[]) { - ClipboardReaderImpl cbr = new ClipboardReaderImpl(); - cbr.readOnce(); - cbr.readOnce(); + public synchronized void start() throws InterruptedException { + System.out.println("Clipboard reader starting"); + + if (!running) { + running = true; + new Thread(this, "ClipboardReader").start(); + } } - public void lostOwnership(Clipboard clipboard, Transferable contents) { - // TODO Auto-generated method stub - System.out.println(6); + public synchronized void stop() throws InterruptedException { + System.out.println("Clipboard reader stopping"); + + if (running) { + running = false; + stopped.wait(); + } } -} \ No newline at end of file +} Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardWriterImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardWriterImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardWriterImpl.java 2007-03-04 14:14:33 UTC (rev 65) @@ -0,0 +1,20 @@ +package net.sf.trivial.easypaste.internal.pi; + +import java.awt.datatransfer.Clipboard; +import java.awt.Toolkit; + +import net.sf.trivial.easypaste.ClipboardWriter; + +public class ClipboardWriterImpl implements ClipboardWriter { + + private Clipboard clipboard; + + public ClipboardWriterImpl() { + clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + } + + public void writeToClipboard(String content) { + // clipboard.add ... + } + +} Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/pi/EasyController.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/pi/EasyController.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/pi/EasyController.java 2007-03-04 14:14:33 UTC (rev 65) @@ -0,0 +1,45 @@ +package net.sf.trivial.easypaste.launcher.pi; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import net.sf.trivial.easypaste.ClipboardReader; +import net.sf.trivial.easypaste.ClipboardWriter; +import net.sf.trivial.easypaste.DistributedClipboard; +import net.sf.trivial.easypaste.NotificationService; +import net.sf.trivial.easypaste.internal.DistributedClipboardImpl; +import net.sf.trivial.easypaste.internal.pi.ClipboardReaderImpl; +import net.sf.trivial.easypaste.internal.pi.ClipboardWriterImpl; +import net.sf.trivial.easypaste.presence.PresenceService; + +public class EasyController { + + private static final int PORT = 5555; + private static String name; + + public static void main(String[] args) { + try { + name = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException e1) { + name = Messages.getString("EasyController.ServiceName"); //$NON-NLS-1$ + } + + DistributedClipboard dclip = new DistributedClipboardImpl(PORT); + ClipboardReader creader = new ClipboardReaderImpl(); + ClipboardWriter cwriter = new ClipboardWriterImpl(); + PresenceService presenceService = new net.sf.trivial.easypaste.internal.pi.presence.PresenceServiceImpl(PORT, name); + + dclip.setClipboardWriter(cwriter); + dclip.setNotificationService(not); + dclip.setPresenceService(presenceService); + creader.setDistributedClipboard(dclip); + try { + presenceService.start(); + creader.start(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 14:10:45
|
Revision: 64 http://trivial.svn.sourceforge.net/trivial/?rev=64&view=rev Author: jlgeering Date: 2007-03-04 06:10:46 -0800 (Sun, 04 Mar 2007) Log Message: ----------- log4j.properties: log to console Added Paths: ----------- trunk/eclipse/easypaste/src/log4j.properties Added: trunk/eclipse/easypaste/src/log4j.properties =================================================================== --- trunk/eclipse/easypaste/src/log4j.properties (rev 0) +++ trunk/eclipse/easypaste/src/log4j.properties 2007-03-04 14:10:46 UTC (rev 64) @@ -0,0 +1,5 @@ +log4j.rootCategory=DEBUG, console + +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=- %m%n This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 14:00:31
|
Revision: 63 http://trivial.svn.sourceforge.net/trivial/?rev=63&view=rev Author: fterrier Date: 2007-03-04 06:00:30 -0800 (Sun, 04 Mar 2007) Log Message: ----------- launcher Modified Paths: -------------- trunk/eclipse/easypaste/.classpath trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java Added Paths: ----------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowserImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/EasyController.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/Messages.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/messages.properties Removed Paths: ------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties Modified: trunk/eclipse/easypaste/.classpath =================================================================== --- trunk/eclipse/easypaste/.classpath 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/.classpath 2007-03-04 14:00:30 UTC (rev 63) @@ -2,6 +2,7 @@ <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry combineaccessrules="false" kind="src" path="/bonjour"/> <classpathentry combineaccessrules="false" kind="src" path="/utils"/> <classpathentry kind="output" path="bin"/> </classpath> Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PresenceServiceImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PresenceServiceImpl.java 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1,26 @@ +package net.sf.trivial.easypaste.internal.mac.presence; + +import net.sf.trivial.easypaste.internal.presence.AbstractPresenceService; + +public class PresenceServiceImpl extends AbstractPresenceService { + + private final ServiceBrowserImpl serviceBrowser; + private final ServiceRegistrerImpl serviceRegistrer; + + public PresenceServiceImpl(int port, String serviceName) { + super(port, serviceName); + serviceBrowser = new ServiceBrowserImpl(this); + serviceRegistrer = new ServiceRegistrerImpl(); + } + + @Override + public ServiceBrowserImpl getServiceBrowser() { + return serviceBrowser; + } + + @Override + public ServiceRegistrerImpl getServiceRegistrer() { + return serviceRegistrer; + } + +} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java 2007-03-04 14:00:30 UTC (rev 63) @@ -1,74 +0,0 @@ -package net.sf.trivial.easypaste.internal.mac.presence; - - -import net.sf.trivial.easypaste.internal.presence.PresenceServicePIImpl; - -import com.apple.dnssd.BrowseListener; -import com.apple.dnssd.DNSSD; -import com.apple.dnssd.DNSSDService; - - -/** - * Discovering existing bonjour services - * - * @author pajai - */ -public class ServiceBrowser implements BrowseListener, net.sf.trivial.easypaste.internal.presence.ServiceBrowser { - - private DNSSDService service; - private PresenceServicePIImpl presenceService; - - ServiceBrowser(PresenceServicePIImpl presenceService) { - this.presenceService = presenceService; - } - - /** method from BrowseListener */ - public void serviceFound (DNSSDService browser, int flag, int ifIndex, - String serviceName, String regType, String domain) { -// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " found"); - - // resolve service if not already registered - if (!presenceService.isRegistered(serviceName)) { - ServiceResolver resolver = new ServiceResolver (serviceName, regType, domain, presenceService); - resolver.resolve(); - } - } - - /** method from BrowseListener */ - public void serviceLost (DNSSDService browser, int flags, int ifIndex, - String serviceName, String regType, String domain) { -// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " lost"); - - // unregister service, if was registered - if (presenceService.isRegistered(serviceName)) { - presenceService.unregister(serviceName); - } - } - - /** method from BrowseListener */ - public void operationFailed (DNSSDService service, int errorCode) { -// System.out.println ("Browsing failed."); - } - - /** launch a browse of services of the given protocol */ - public void browse (String proto) { - - try { - - // call browse - service = DNSSD.browse(0, 0, proto+"._tcp", "", this); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - /** stop the browse operation, this is important, otherwise bandwidth is wasted */ - public void stop () { - service.stop(); -// System.out.println ("Browser stopped."); - } - -} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowserImpl.java (from rev 62, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowserImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowserImpl.java 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1,74 @@ +package net.sf.trivial.easypaste.internal.mac.presence; + + +import net.sf.trivial.easypaste.internal.presence.AbstractPresenceService; + +import com.apple.dnssd.BrowseListener; +import com.apple.dnssd.DNSSD; +import com.apple.dnssd.DNSSDService; + + +/** + * Discovering existing bonjour services + * + * @author pajai + */ +public class ServiceBrowserImpl implements BrowseListener, net.sf.trivial.easypaste.internal.presence.ServiceBrowser { + + private DNSSDService service; + private AbstractPresenceService presenceService; + + ServiceBrowserImpl(AbstractPresenceService presenceService) { + this.presenceService = presenceService; + } + + /** method from BrowseListener */ + public void serviceFound (DNSSDService browser, int flag, int ifIndex, + String serviceName, String regType, String domain) { +// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " found"); + + // resolve service if not already registered + if (!presenceService.isRegistered(serviceName)) { + ServiceResolver resolver = new ServiceResolver (serviceName, regType, domain, presenceService); + resolver.resolve(); + } + } + + /** method from BrowseListener */ + public void serviceLost (DNSSDService browser, int flags, int ifIndex, + String serviceName, String regType, String domain) { +// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " lost"); + + // unregister service, if was registered + if (presenceService.isRegistered(serviceName)) { + presenceService.unregister(serviceName); + } + } + + /** method from BrowseListener */ + public void operationFailed (DNSSDService service, int errorCode) { +// System.out.println ("Browsing failed."); + } + + /** launch a browse of services of the given protocol */ + public void browse (String proto) { + + try { + + // call browse + service = DNSSD.browse(0, 0, proto+"._tcp", "", this); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** stop the browse operation, this is important, otherwise bandwidth is wasted */ + public void stop () { + service.stop(); +// System.out.println ("Browser stopped."); + } + +} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java 2007-03-04 14:00:30 UTC (rev 63) @@ -1,52 +0,0 @@ -package net.sf.trivial.easypaste.internal.mac.presence; - -import com.apple.dnssd.DNSSD; -import com.apple.dnssd.DNSSDRegistration; -import com.apple.dnssd.DNSSDService; -import com.apple.dnssd.RegisterListener; - -/** - * Register a service - * - * @author pajai - * - */ -public class ServiceRegistrer implements RegisterListener,net.sf.trivial.easypaste.internal.presence.ServiceRegistrer { - - private DNSSDRegistration registration; - - /** method from RegisterListener */ - public void serviceRegistered ( - DNSSDRegistration regitration, - int flags, - String serviceName, - String regType, - String domain) { - -// System.out.println("Service " + serviceName + " " + regType + " " + domain + " registered"); - } - - /** method from RegisterListener */ - public void operationFailed (DNSSDService service, int errorCode) { -// System.out.println("Operation failed"); - } - - public void stop () { - - registration.stop(); -// System.out.println ("Stop registration."); - - } - - public void register (String name, String proto, int port) { - - try { - - registration = DNSSD.register(name, proto+"._tcp", port, this); - - } catch (Exception e) { - e.printStackTrace(); - } - - } -} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrerImpl.java (from rev 62, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrerImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrerImpl.java 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1,52 @@ +package net.sf.trivial.easypaste.internal.mac.presence; + +import com.apple.dnssd.DNSSD; +import com.apple.dnssd.DNSSDRegistration; +import com.apple.dnssd.DNSSDService; +import com.apple.dnssd.RegisterListener; + +/** + * Register a service + * + * @author pajai + * + */ +public class ServiceRegistrerImpl implements RegisterListener,net.sf.trivial.easypaste.internal.presence.ServiceRegistrer { + + private DNSSDRegistration registration; + + /** method from RegisterListener */ + public void serviceRegistered ( + DNSSDRegistration regitration, + int flags, + String serviceName, + String regType, + String domain) { + +// System.out.println("Service " + serviceName + " " + regType + " " + domain + " registered"); + } + + /** method from RegisterListener */ + public void operationFailed (DNSSDService service, int errorCode) { +// System.out.println("Operation failed"); + } + + public void stop () { + + registration.stop(); +// System.out.println ("Stop registration."); + + } + + public void register (String name, String proto, int port) { + + try { + + registration = DNSSD.register(name, proto+"._tcp", port, this); + + } catch (Exception e) { + e.printStackTrace(); + } + + } +} Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java 2007-03-04 14:00:30 UTC (rev 63) @@ -4,7 +4,7 @@ import java.net.UnknownHostException; import net.sf.trivial.easypaste.internal.presence.PeerImpl; -import net.sf.trivial.easypaste.internal.presence.PresenceServicePIImpl; +import net.sf.trivial.easypaste.internal.presence.AbstractPresenceService; import com.apple.dnssd.DNSSD; @@ -30,11 +30,11 @@ private String regType; private String domain; - private final PresenceServicePIImpl presenceService; + private final AbstractPresenceService presenceService; /** a new resolver is created for each discovered service */ public ServiceResolver (String serviceName, String regType, String domain, - PresenceServicePIImpl presenceService) { + AbstractPresenceService presenceService) { this.serviceName = serviceName; this.regType = regType; this.domain = domain; Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1,25 @@ +package net.sf.trivial.easypaste.internal.pi.presence; + +import net.sf.trivial.easypaste.internal.mac.presence.ServiceRegistrerImpl; +import net.sf.trivial.easypaste.internal.presence.AbstractPresenceService; +import net.sf.trivial.easypaste.internal.presence.ServiceBrowser; + +public class PresenceServiceImpl extends AbstractPresenceService { + + public PresenceServiceImpl(int port, String serviceName) { + super(port, serviceName); + } + + @Override + public ServiceBrowser getServiceBrowser() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ServiceRegistrerImpl getServiceRegistrer() { + // TODO Auto-generated method stub + return null; + } + +} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 14:00:30 UTC (rev 63) @@ -1,16 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - - -public class ServiceBrowser implements net.sf.trivial.easypaste.internal.presence.ServiceBrowser { - - public void browse(String proto) { - // TODO Auto-generated method stub - - } - - public void stop() { - // TODO Auto-generated method stub - - } - -} \ No newline at end of file Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java (from rev 62, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1,37 @@ +package net.sf.trivial.easypaste.internal.pi.presence; + +import javax.jmdns.ServiceEvent; +import javax.jmdns.ServiceListener; + + +public class ServiceBrowserImpl implements net.sf.trivial.easypaste.internal.presence.ServiceBrowser, + ServiceListener { + + + public void serviceAdded(ServiceEvent event) { + // TODO Auto-generated method stub + + } + + public void serviceRemoved(ServiceEvent event) { + // TODO Auto-generated method stub + + } + + public void serviceResolved(ServiceEvent event) { + // TODO Auto-generated method stub + + } + + public void browse(String proto) { + // TODO Auto-generated method stub + + } + + public void stop() { + // TODO Auto-generated method stub + + } + + +} \ No newline at end of file Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java 2007-03-04 14:00:30 UTC (rev 63) @@ -1,16 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - - -public class ServiceRegistrer implements net.sf.trivial.easypaste.internal.presence.ServiceRegistrer { - - public void register(String name, String proto, int port) { - // TODO Auto-generated method stub - - } - - public void stop() { - // TODO Auto-generated method stub - - } - -} \ No newline at end of file Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java (from rev 62, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1,16 @@ +package net.sf.trivial.easypaste.internal.pi.presence; + + +public class ServiceRegistrerImpl implements net.sf.trivial.easypaste.internal.presence.ServiceRegistrer { + + public void register(String name, String proto, int port) { + // TODO Auto-generated method stub + + } + + public void stop() { + // TODO Auto-generated method stub + + } + +} \ No newline at end of file Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java (from rev 62, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1,90 @@ +package net.sf.trivial.easypaste.internal.presence; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; + +import net.sf.trivial.easypaste.internal.mac.presence.ServiceRegistrerImpl; +import net.sf.trivial.easypaste.presence.Peer; +import net.sf.trivial.easypaste.presence.PresenceService; + + +/** + * Registry for existing services + * + * @author pajai + */ +public abstract class AbstractPresenceService implements PresenceService { + + /** service map */ + private final HashMap<String,Peer> services = new HashMap<String,Peer>(); + + /** + * Register a service + */ + public synchronized void register (PeerImpl service) { + if (services.containsKey(service.getName()) + || service.getName().equals(serviceName)) return; + System.out.println("Presence service registered new peer : "+service); + + services.put(service.getName(), service); + } + + /** + * Test if a service is already registered + */ + public synchronized boolean isRegistered (String name) { + return services.containsKey(name); + } + + /** + * Unregister a service, using its service name + */ + public synchronized void unregister (String name) { + if (services.containsKey(name)) + services.remove(name); + } + + /** + * Print registered services + */ + public synchronized void printList () { + System.out.println ("Registered services:"); + for (Iterator it = services.values().iterator(); it.hasNext(); ) { + System.out.println ( ((PeerImpl)it.next()).toString() ); + } + } + + public Collection<Peer> getPeers() { + return services.values(); + } + + private final int port; + private final String serviceName; + + static final int WAIT = 15000; + static final String PROTO = "_flebeleb"; + + public AbstractPresenceService(int port, String serviceName) { + this.port = port; + this.serviceName = serviceName; + } + + public abstract ServiceBrowser getServiceBrowser(); + + public abstract ServiceRegistrerImpl getServiceRegistrer(); + + public void start() { + System.out.println("Presence service starting"); + + getServiceBrowser().browse(PROTO); + getServiceRegistrer().register(serviceName, PROTO, port); + } + + public void stop() { + System.out.println("Presence service stopping"); + + getServiceBrowser().stop(); + getServiceRegistrer().stop(); + } +} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java 2007-03-04 14:00:30 UTC (rev 63) @@ -1,90 +0,0 @@ -package net.sf.trivial.easypaste.internal.presence; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; - -import net.sf.trivial.easypaste.internal.mac.presence.ServiceRegistrer; -import net.sf.trivial.easypaste.presence.Peer; -import net.sf.trivial.easypaste.presence.PresenceService; - - -/** - * Registry for existing services - * - * @author pajai - */ -public abstract class PresenceServicePIImpl implements PresenceService { - - /** service map */ - private final HashMap<String,Peer> services = new HashMap<String,Peer>(); - - /** - * Register a service - */ - public synchronized void register (PeerImpl service) { - if (services.containsKey(service.getName()) - || service.getName().equals(serviceName)) return; - System.out.println("Presence service registered new peer : "+service); - - services.put(service.getName(), service); - } - - /** - * Test if a service is already registered - */ - public synchronized boolean isRegistered (String name) { - return services.containsKey(name); - } - - /** - * Unregister a service, using its service name - */ - public synchronized void unregister (String name) { - if (services.containsKey(name)) - services.remove(name); - } - - /** - * Print registered services - */ - public synchronized void printList () { - System.out.println ("Registered services:"); - for (Iterator it = services.values().iterator(); it.hasNext(); ) { - System.out.println ( ((PeerImpl)it.next()).toString() ); - } - } - - public Collection<Peer> getPeers() { - return services.values(); - } - - private final int port; - private final String serviceName; - - static final int WAIT = 15000; - static final String PROTO = "_flebeleb"; - - public PresenceServicePIImpl(int port, String serviceName) { - this.port = port; - this.serviceName = serviceName; - } - - public abstract ServiceBrowser getServiceBrowser(); - - public abstract ServiceRegistrer getServiceRegistrer(); - - public void start() { - System.out.println("Presence service starting"); - - getServiceBrowser().browse(PROTO); - getServiceRegistrer().register(serviceName, PROTO, port); - } - - public void stop() { - System.out.println("Presence service stopping"); - - getServiceBrowser().stop(); - getServiceRegistrer().stop(); - } -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java 2007-03-04 14:00:30 UTC (rev 63) @@ -1,47 +0,0 @@ -package net.sf.trivial.easypaste.launcher; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -import net.sf.trivial.easypaste.ClipboardReader; -import net.sf.trivial.easypaste.ClipboardWriter; -import net.sf.trivial.easypaste.DistributedClipboard; -import net.sf.trivial.easypaste.NotificationService; -import net.sf.trivial.easypaste.internal.DistributedClipboardImpl; -import net.sf.trivial.easypaste.internal.mac.ClipboardReaderImpl; -import net.sf.trivial.easypaste.internal.mac.ClipboardWriterImpl; -import net.sf.trivial.easypaste.internal.mac.GrowlNotification; -import net.sf.trivial.easypaste.presence.PresenceService; - -public class EasyController { - - private static final int PORT = 5555; - private static String name; - - public static void main(String[] args) { - try { - name = InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException e1) { - name = Messages.getString("EasyController.ServiceName"); //$NON-NLS-1$ - } - - DistributedClipboard dclip = new DistributedClipboardImpl(PORT); - ClipboardReader creader = new ClipboardReaderImpl(); - ClipboardWriter cwriter = new ClipboardWriterImpl(); - NotificationService not = new GrowlNotification(); - PresenceService presenceService = new net.sf.trivial.easypaste.internal.mac.presence.PresenceService(PORT, name); - - dclip.setClipboardWriter(cwriter); - dclip.setNotificationService(not); - dclip.setPresenceService(presenceService); - creader.setDistributedClipboard(dclip); - try { - presenceService.start(); - creader.start(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java 2007-03-04 14:00:30 UTC (rev 63) @@ -1,22 +0,0 @@ -package net.sf.trivial.easypaste.launcher; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "net.sf.trivial.easypaste.launcher.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/EasyController.java (from rev 62, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/EasyController.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/EasyController.java 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1,47 @@ +package net.sf.trivial.easypaste.launcher.mac; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import net.sf.trivial.easypaste.ClipboardReader; +import net.sf.trivial.easypaste.ClipboardWriter; +import net.sf.trivial.easypaste.DistributedClipboard; +import net.sf.trivial.easypaste.NotificationService; +import net.sf.trivial.easypaste.internal.DistributedClipboardImpl; +import net.sf.trivial.easypaste.internal.mac.ClipboardReaderImpl; +import net.sf.trivial.easypaste.internal.mac.ClipboardWriterImpl; +import net.sf.trivial.easypaste.internal.mac.GrowlNotification; +import net.sf.trivial.easypaste.presence.PresenceService; + +public class EasyController { + + private static final int PORT = 5555; + private static String name; + + public static void main(String[] args) { + try { + name = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException e1) { + name = Messages.getString("EasyController.ServiceName"); //$NON-NLS-1$ + } + + DistributedClipboard dclip = new DistributedClipboardImpl(PORT); + ClipboardReader creader = new ClipboardReaderImpl(); + ClipboardWriter cwriter = new ClipboardWriterImpl(); + NotificationService not = new GrowlNotification(); + PresenceService presenceService = new net.sf.trivial.easypaste.internal.mac.presence.PresenceServiceImpl(PORT, name); + + dclip.setClipboardWriter(cwriter); + dclip.setNotificationService(not); + dclip.setPresenceService(presenceService); + creader.setDistributedClipboard(dclip); + try { + presenceService.start(); + creader.start(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/Messages.java (from rev 61, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/Messages.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/Messages.java 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1,22 @@ +package net.sf.trivial.easypaste.launcher.mac; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "net.sf.trivial.easypaste.launcher.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/messages.properties (from rev 61, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/messages.properties (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/mac/messages.properties 2007-03-04 14:00:30 UTC (rev 63) @@ -0,0 +1 @@ +EasyController.ServiceName=Franz's easypaste Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties 2007-03-04 13:46:10 UTC (rev 62) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties 2007-03-04 14:00:30 UTC (rev 63) @@ -1 +0,0 @@ -EasyController.ServiceName=Franz's easypaste This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 13:46:10
|
Revision: 62 http://trivial.svn.sourceforge.net/trivial/?rev=62&view=rev Author: fterrier Date: 2007-03-04 05:46:10 -0800 (Sun, 04 Mar 2007) Log Message: ----------- reorganized packages - separated pi-mac-win ... started implementing jmdns presence service Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java Added Paths: ----------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/DistributedClipboardImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/NetworkClient.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/NetworkServer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PeerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/ServiceBrowser.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/ServiceRegistrer.java Removed Paths: ------------- trunk/eclipse/easypaste/src/easypaste/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PeerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/DistributedClipboardImpl.java (from rev 60, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/DistributedClipboardImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/DistributedClipboardImpl.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,72 @@ +package net.sf.trivial.easypaste.internal; + +import net.sf.trivial.easypaste.ClipboardWriter; +import net.sf.trivial.easypaste.DistributedClipboard; +import net.sf.trivial.easypaste.NotificationService; +import net.sf.trivial.easypaste.presence.PresenceService; + +public class DistributedClipboardImpl implements DistributedClipboard { + + private ClipboardWriter localWriter; + private PresenceService presenceService; + private NotificationService notificationService; + + private final NetworkClient client; + private final NetworkServer server; + private final int port; + + private String state; + + public DistributedClipboardImpl(int port) { + client = new NetworkClient(); + server = new NetworkServer(this); + this.port = port; + + state = ""; + + init(); + } + + private void init() { + server.listen(port); + } + + public void setClipboardWriter(ClipboardWriter writer) { + localWriter = writer; + } + public void setNotificationService(NotificationService ns) { + notificationService = ns; + } + + public void setLocalContent(String content) { + if (!state.equals(content)) { + state = content; + notify("Clipboard update (from local)", content); + // send to network using network client + client.sendToAllClients(presenceService.getPeers(), content); + } + } + + public void setPresenceService(PresenceService presenceService) { + this.presenceService = presenceService; + } + + protected void writeToClipboard(String content) { + if (!state.equals(content)) { + state = content; + notify("Clipboard update (from remote)", content); + localWriter.writeToClipboard(content); + } + } + + private void notify(String title, String message) { + if (notificationService != null) { + notificationService.notify(title, message); + } + else { + // TODO use logging. + System.out.println(title + ": " + message); + } + } + +} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/NetworkClient.java (from rev 60, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/NetworkClient.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/NetworkClient.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,65 @@ +package net.sf.trivial.easypaste.internal; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketAddress; +import java.util.Collection; + +import net.sf.trivial.easypaste.presence.Peer; + + +public class NetworkClient { + + public NetworkClient() { + } + + public void sendToClient(Peer service, String content) { + NetworkThread thread = new NetworkThread(service.getAddress(),service.getPort(),content); + // TODO do not run a new thread each time, instead use a thread pool + thread.start(); + } + + public void sendToAllClients(Collection<Peer> services, String content) { + for (Peer service : services) { + sendToClient(service, content); + } + } + + private static class NetworkThread extends Thread { + private int port; + private InetAddress address; + private String content; + + NetworkThread(InetAddress address, int port, String content) { + this.address = address; + this.port = port; + this.content = content; + } + + @Override + public void run() { + assert address != null && content != null; + + try { + Socket clientSocket = new Socket(); + + SocketAddress serverAddress = new InetSocketAddress(address,port); + clientSocket.connect(serverAddress); + + Writer writer = new OutputStreamWriter(clientSocket.getOutputStream()); + writer.write(content); + + writer.flush(); + clientSocket.close(); + } + catch (IOException e) { + e.printStackTrace(); + } + } + } + +} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/NetworkServer.java (from rev 60, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/NetworkServer.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/NetworkServer.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,77 @@ +package net.sf.trivial.easypaste.internal; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.ServerSocket; +import java.net.Socket; + +import net.sf.trivial.easypaste.DistributedClipboard; + +public class NetworkServer extends Thread { + + private DistributedClipboardImpl clipboard; + + public NetworkServer(DistributedClipboardImpl clipboard) { + this.clipboard = clipboard; + } + + private ServerSocket socket; + private boolean running; + + // TODO wrap around when MAX_LONG is reached + private long counter = 0; + private int port; + + public void listen(int port) { + this.port = port; + start(); + } + + public void stopListening() { + running = false; + } + + public void run() { + try { + running = true; + socket = new ServerSocket(port); + while (running) { + Socket clientSocket = socket.accept(); + if (!running) return; + counter++; + NetworkThread thread = new NetworkThread(clientSocket,counter); + thread.start(); + } + } + catch (IOException e) { + // TODO + } + } + + private class NetworkThread extends Thread { + private Socket clientSocket; + private long id; + + NetworkThread(Socket clientSocket, long id) { + this.clientSocket = clientSocket; + this.id = id; + } + + public void run() { + try { + InputStreamReader reader = new InputStreamReader(clientSocket.getInputStream()); + StringBuilder str = new StringBuilder(); + char[] tmp = new char[256]; + while (reader.read(tmp)!=-1) { + str.append(tmp); + } + if (counter == id) clipboard.writeToClipboard(str.toString()); + } + catch (IOException e) { + // TODO + } + } + + } + +} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence (from rev 60, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence) Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PeerImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java 2007-03-04 12:48:32 UTC (rev 60) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PeerImpl.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,47 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - -import java.net.InetAddress; - -import net.sf.trivial.easypaste.presence.Peer; - -/** - * Service, qualified by its name (e.g. Flebeleb), type (e.g. _flebeleb._tcp), - * domain (e.g. local.), hostName (e.g. xrb.local.) and port (e.g. 11111) - * - * @author pajai - */ -public class PeerImpl implements Peer { - - /* attributes got from the browse operation */ - private final String name; - private final String type; - private final String domain; - - /* attributes got from the resolve operation */ - private final InetAddress address; - private final int port; - - public PeerImpl (String name, String type, String domain, InetAddress address, int port) { - this.name = name; - this.type = type; - this.domain = domain; - this.address = address; - this.port = port; - } - - public InetAddress getAddress() { - return address; - } - - public int getPort() { - return port; - } - - public String getName() { - return name; - } - - public String toString () { - return name + " " + type + " " + domain + " " + address + ":" + String.valueOf(port); - } -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 12:48:32 UTC (rev 60) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/PresenceServiceImpl.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,89 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; - -import net.sf.trivial.easypaste.presence.Peer; -import net.sf.trivial.easypaste.presence.PresenceService; - - -/** - * Registry for existing services - * - * @author pajai - */ -public class PresenceServiceImpl implements PresenceService { - - /** service map */ - private final HashMap<String,Peer> services = new HashMap<String,Peer>(); - - /** - * Register a service - */ - synchronized void register (PeerImpl service) { - if (services.containsKey(service.getName()) - || service.getName().equals(serviceName)) return; - System.out.println("Presence service registered new peer : "+service); - - services.put(service.getName(), service); - } - - /** - * Test if a service is already registered - */ - synchronized boolean isRegistered (String name) { - return services.containsKey(name); - } - - /** - * Unregister a service, using its service name - */ - synchronized void unregister (String name) { - if (services.containsKey(name)) - services.remove(name); - } - - /** - * Print registered services - */ - public synchronized void printList () { - System.out.println ("Registered services:"); - for (Iterator it = services.values().iterator(); it.hasNext(); ) { - System.out.println ( ((PeerImpl)it.next()).toString() ); - } - } - - public Collection<Peer> getPeers() { - return services.values(); - } - - private final ServiceBrowser serviceBrowser; - private final ServiceRegistrer serviveRegistrer; - private final int port; - private final String serviceName; - - static final int WAIT = 15000; - static final String PROTO = "_flebeleb"; - - public PresenceServiceImpl(int port, String serviceName) { - this.serviceBrowser = new ServiceBrowser(this); - this.serviveRegistrer = new ServiceRegistrer(); - this.port = port; - this.serviceName = serviceName; - } - - public void start() { - System.out.println("Presence service starting"); - - serviceBrowser.browse(PROTO); - serviveRegistrer.register(serviceName, PROTO, port); - } - - public void stop() { - System.out.println("Presence service stopping"); - - serviceBrowser.stop(); - serviveRegistrer.stop(); - } -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 12:48:32 UTC (rev 60) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,72 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - - -import com.apple.dnssd.BrowseListener; -import com.apple.dnssd.DNSSD; -import com.apple.dnssd.DNSSDService; - - -/** - * Discovering existing bonjour services - * - * @author pajai - */ -public class ServiceBrowser implements BrowseListener { - - private DNSSDService service; - private PresenceServiceImpl presenceService; - - ServiceBrowser(PresenceServiceImpl presenceService) { - this.presenceService = presenceService; - } - - /** method from BrowseListener */ - public void serviceFound (DNSSDService browser, int flag, int ifIndex, - String serviceName, String regType, String domain) { -// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " found"); - - // resolve service if not already registered - if (!presenceService.isRegistered(serviceName)) { - ServiceResolver resolver = new ServiceResolver (serviceName, regType, domain, presenceService); - resolver.resolve(); - } - } - - /** method from BrowseListener */ - public void serviceLost (DNSSDService browser, int flags, int ifIndex, - String serviceName, String regType, String domain) { -// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " lost"); - - // unregister service, if was registered - if (presenceService.isRegistered(serviceName)) { - presenceService.unregister(serviceName); - } - } - - /** method from BrowseListener */ - public void operationFailed (DNSSDService service, int errorCode) { -// System.out.println ("Browsing failed."); - } - - /** launch a browse of services of the given protocol */ - public void browse (String proto) { - - try { - - // call browse - service = DNSSD.browse(0, 0, proto+"._tcp", "", this); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - /** stop the browse operation, this is important, otherwise bandwidth is wasted */ - public void stop () { - service.stop(); -// System.out.println ("Browser stopped."); - } - -} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java (from rev 61, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceBrowser.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,74 @@ +package net.sf.trivial.easypaste.internal.mac.presence; + + +import net.sf.trivial.easypaste.internal.presence.PresenceServicePIImpl; + +import com.apple.dnssd.BrowseListener; +import com.apple.dnssd.DNSSD; +import com.apple.dnssd.DNSSDService; + + +/** + * Discovering existing bonjour services + * + * @author pajai + */ +public class ServiceBrowser implements BrowseListener, net.sf.trivial.easypaste.internal.presence.ServiceBrowser { + + private DNSSDService service; + private PresenceServicePIImpl presenceService; + + ServiceBrowser(PresenceServicePIImpl presenceService) { + this.presenceService = presenceService; + } + + /** method from BrowseListener */ + public void serviceFound (DNSSDService browser, int flag, int ifIndex, + String serviceName, String regType, String domain) { +// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " found"); + + // resolve service if not already registered + if (!presenceService.isRegistered(serviceName)) { + ServiceResolver resolver = new ServiceResolver (serviceName, regType, domain, presenceService); + resolver.resolve(); + } + } + + /** method from BrowseListener */ + public void serviceLost (DNSSDService browser, int flags, int ifIndex, + String serviceName, String regType, String domain) { +// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " lost"); + + // unregister service, if was registered + if (presenceService.isRegistered(serviceName)) { + presenceService.unregister(serviceName); + } + } + + /** method from BrowseListener */ + public void operationFailed (DNSSDService service, int errorCode) { +// System.out.println ("Browsing failed."); + } + + /** launch a browse of services of the given protocol */ + public void browse (String proto) { + + try { + + // call browse + service = DNSSD.browse(0, 0, proto+"._tcp", "", this); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** stop the browse operation, this is important, otherwise bandwidth is wasted */ + public void stop () { + service.stop(); +// System.out.println ("Browser stopped."); + } + +} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java 2007-03-04 12:48:32 UTC (rev 60) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,52 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - -import com.apple.dnssd.DNSSD; -import com.apple.dnssd.DNSSDRegistration; -import com.apple.dnssd.DNSSDService; -import com.apple.dnssd.RegisterListener; - -/** - * Register a service - * - * @author pajai - * - */ -public class ServiceRegistrer implements RegisterListener { - - private DNSSDRegistration registration; - - /** method from RegisterListener */ - public void serviceRegistered ( - DNSSDRegistration regitration, - int flags, - String serviceName, - String regType, - String domain) { - -// System.out.println("Service " + serviceName + " " + regType + " " + domain + " registered"); - } - - /** method from RegisterListener */ - public void operationFailed (DNSSDService service, int errorCode) { -// System.out.println("Operation failed"); - } - - public void stop () { - - registration.stop(); -// System.out.println ("Stop registration."); - - } - - public void register (String name, String proto, int port) { - - try { - - registration = DNSSD.register(name, proto+"._tcp", port, this); - - } catch (Exception e) { - e.printStackTrace(); - } - - } -} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java (from rev 61, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceRegistrer.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,52 @@ +package net.sf.trivial.easypaste.internal.mac.presence; + +import com.apple.dnssd.DNSSD; +import com.apple.dnssd.DNSSDRegistration; +import com.apple.dnssd.DNSSDService; +import com.apple.dnssd.RegisterListener; + +/** + * Register a service + * + * @author pajai + * + */ +public class ServiceRegistrer implements RegisterListener,net.sf.trivial.easypaste.internal.presence.ServiceRegistrer { + + private DNSSDRegistration registration; + + /** method from RegisterListener */ + public void serviceRegistered ( + DNSSDRegistration regitration, + int flags, + String serviceName, + String regType, + String domain) { + +// System.out.println("Service " + serviceName + " " + regType + " " + domain + " registered"); + } + + /** method from RegisterListener */ + public void operationFailed (DNSSDService service, int errorCode) { +// System.out.println("Operation failed"); + } + + public void stop () { + + registration.stop(); +// System.out.println ("Stop registration."); + + } + + public void register (String name, String proto, int port) { + + try { + + registration = DNSSD.register(name, proto+"._tcp", port, this); + + } catch (Exception e) { + e.printStackTrace(); + } + + } +} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 12:48:32 UTC (rev 60) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,87 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - -import java.net.InetAddress; -import java.net.UnknownHostException; - - -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; - -/** - * Class to resolve a service, that is, to get its host name and port number - * - * @author pajai - */ -public class ServiceResolver implements ResolveListener { - - private DNSSDService resolve; - - /* - * store a few attributes of a discovered service, we need them later - * when the service has been resolved - */ - private String serviceName; - private String regType; - private String domain; - - private final PresenceServiceImpl presenceService; - - /** a new resolver is created for each discovered service */ - public ServiceResolver (String serviceName, String regType, String domain, - PresenceServiceImpl presenceService) { - this.serviceName = serviceName; - this.regType = regType; - this.domain = domain; - this.presenceService = presenceService; - - } - - /** method from ResolveListener */ - public void serviceResolved (DNSSDService resolver, int flags, int ifIndex, String fullName, - String hostName, int port, TXTRecord txtRecord) { - System.out.println ("Presence service resolved: " + fullName + " at " + hostName + ":" + port); - - try { - // create new Service object - PeerImpl service = new PeerImpl (serviceName, regType, domain, - InetAddress.getByName(hostName), port); - - // register service - presenceService.register(service); - -// // print the list of registered services -// presenceService.printList(); - - // stop this resolver - stop (); - } - catch (UnknownHostException e) { - // TODO - e.printStackTrace(); - } - } - - /** method from ResolveListener */ - public void operationFailed (DNSSDService service, int errorCode) { -// System.out.println ("Resolve failed."); - } - - /** start the resolution of a service */ - public void resolve () { - try { - resolve = DNSSD.resolve(0, 0, serviceName, regType, domain, this); - } catch (DNSSDException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** stop this resolver */ - public void stop () { - resolve.stop(); -// System.out.println ("Resolver stopped."); - } -} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java (from rev 61, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/presence/ServiceResolver.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,90 @@ +package net.sf.trivial.easypaste.internal.mac.presence; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import net.sf.trivial.easypaste.internal.presence.PeerImpl; +import net.sf.trivial.easypaste.internal.presence.PresenceServicePIImpl; + + +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; + +/** + * Class to resolve a service, that is, to get its host name and port number + * + * @author pajai + */ +public class ServiceResolver implements ResolveListener { + + private DNSSDService resolve; + + /* + * store a few attributes of a discovered service, we need them later + * when the service has been resolved + */ + private String serviceName; + private String regType; + private String domain; + + private final PresenceServicePIImpl presenceService; + + /** a new resolver is created for each discovered service */ + public ServiceResolver (String serviceName, String regType, String domain, + PresenceServicePIImpl presenceService) { + this.serviceName = serviceName; + this.regType = regType; + this.domain = domain; + this.presenceService = presenceService; + + } + + /** method from ResolveListener */ + public void serviceResolved (DNSSDService resolver, int flags, int ifIndex, String fullName, + String hostName, int port, TXTRecord txtRecord) { + System.out.println ("Presence service resolved: " + fullName + " at " + hostName + ":" + port); + + try { + // create new Service object + PeerImpl service = new PeerImpl (serviceName, regType, domain, + InetAddress.getByName(hostName), port); + + // register service + presenceService.register(service); + +// // print the list of registered services +// presenceService.printList(); + + // stop this resolver + stop (); + } + catch (UnknownHostException e) { + // TODO + e.printStackTrace(); + } + } + + /** method from ResolveListener */ + public void operationFailed (DNSSDService service, int errorCode) { +// System.out.println ("Resolve failed."); + } + + /** start the resolution of a service */ + public void resolve () { + try { + resolve = DNSSD.resolve(0, 0, serviceName, regType, domain, this); + } catch (DNSSDException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** stop this resolver */ + public void stop () { + resolve.stop(); +// System.out.println ("Resolver stopped."); + } +} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 13:17:14 UTC (rev 61) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,72 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi; - -import net.sf.trivial.easypaste.ClipboardWriter; -import net.sf.trivial.easypaste.DistributedClipboard; -import net.sf.trivial.easypaste.NotificationService; -import net.sf.trivial.easypaste.presence.PresenceService; - -public class DistributedClipboardImpl implements DistributedClipboard { - - private ClipboardWriter localWriter; - private PresenceService presenceService; - private NotificationService notificationService; - - private final NetworkClient client; - private final NetworkServer server; - private final int port; - - private String state; - - public DistributedClipboardImpl(int port) { - client = new NetworkClient(); - server = new NetworkServer(this); - this.port = port; - - state = ""; - - init(); - } - - private void init() { - server.listen(port); - } - - public void setClipboardWriter(ClipboardWriter writer) { - localWriter = writer; - } - public void setNotificationService(NotificationService ns) { - notificationService = ns; - } - - public void setLocalContent(String content) { - if (!state.equals(content)) { - state = content; - notify("Clipboard update (from local)", content); - // send to network using network client - client.sendToAllClients(presenceService.getPeers(), content); - } - } - - public void setPresenceService(PresenceService presenceService) { - this.presenceService = presenceService; - } - - protected void writeToClipboard(String content) { - if (!state.equals(content)) { - state = content; - notify("Clipboard update (from remote)", content); - localWriter.writeToClipboard(content); - } - } - - private void notify(String title, String message) { - if (notificationService != null) { - notificationService.notify(title, message); - } - else { - // TODO use logging. - System.out.println(title + ": " + message); - } - } - -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java 2007-03-04 13:17:14 UTC (rev 61) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,66 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.SocketAddress; -import java.util.Collection; - -import net.sf.trivial.easypaste.internal.pi.presence.PeerImpl; -import net.sf.trivial.easypaste.presence.Peer; - - -public class NetworkClient { - - public NetworkClient() { - } - - public void sendToClient(Peer service, String content) { - NetworkThread thread = new NetworkThread(service.getAddress(),service.getPort(),content); - // TODO do not run a new thread each time, instead use a thread pool - thread.start(); - } - - public void sendToAllClients(Collection<Peer> services, String content) { - for (Peer service : services) { - sendToClient(service, content); - } - } - - private static class NetworkThread extends Thread { - private int port; - private InetAddress address; - private String content; - - NetworkThread(InetAddress address, int port, String content) { - this.address = address; - this.port = port; - this.content = content; - } - - @Override - public void run() { - assert address != null && content != null; - - try { - Socket clientSocket = new Socket(); - - SocketAddress serverAddress = new InetSocketAddress(address,port); - clientSocket.connect(serverAddress); - - Writer writer = new OutputStreamWriter(clientSocket.getOutputStream()); - writer.write(content); - - writer.flush(); - clientSocket.close(); - } - catch (IOException e) { - e.printStackTrace(); - } - } - } - -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java 2007-03-04 13:17:14 UTC (rev 61) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,77 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.ServerSocket; -import java.net.Socket; - -import net.sf.trivial.easypaste.DistributedClipboard; - -public class NetworkServer extends Thread { - - private DistributedClipboardImpl clipboard; - - public NetworkServer(DistributedClipboardImpl clipboard) { - this.clipboard = clipboard; - } - - private ServerSocket socket; - private boolean running; - - // TODO wrap around when MAX_LONG is reached - private long counter = 0; - private int port; - - public void listen(int port) { - this.port = port; - start(); - } - - public void stopListening() { - running = false; - } - - public void run() { - try { - running = true; - socket = new ServerSocket(port); - while (running) { - Socket clientSocket = socket.accept(); - if (!running) return; - counter++; - NetworkThread thread = new NetworkThread(clientSocket,counter); - thread.start(); - } - } - catch (IOException e) { - // TODO - } - } - - private class NetworkThread extends Thread { - private Socket clientSocket; - private long id; - - NetworkThread(Socket clientSocket, long id) { - this.clientSocket = clientSocket; - this.id = id; - } - - public void run() { - try { - InputStreamReader reader = new InputStreamReader(clientSocket.getInputStream()); - StringBuilder str = new StringBuilder(); - char[] tmp = new char[256]; - while (reader.read(tmp)!=-1) { - str.append(tmp); - } - if (counter == id) clipboard.writeToClipboard(str.toString()); - } - catch (IOException e) { - // TODO - } - } - - } - -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java 2007-03-04 13:17:14 UTC (rev 61) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,47 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - -import java.net.InetAddress; - -import net.sf.trivial.easypaste.presence.Peer; - -/** - * Service, qualified by its name (e.g. Flebeleb), type (e.g. _flebeleb._tcp), - * domain (e.g. local.), hostName (e.g. xrb.local.) and port (e.g. 11111) - * - * @author pajai - */ -public class PeerImpl implements Peer { - - /* attributes got from the browse operation */ - private final String name; - private final String type; - private final String domain; - - /* attributes got from the resolve operation */ - private final InetAddress address; - private final int port; - - public PeerImpl (String name, String type, String domain, InetAddress address, int port) { - this.name = name; - this.type = type; - this.domain = domain; - this.address = address; - this.port = port; - } - - public InetAddress getAddress() { - return address; - } - - public int getPort() { - return port; - } - - public String getName() { - return name; - } - - public String toString () { - return name + " " + type + " " + domain + " " + address + ":" + String.valueOf(port); - } -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 13:17:14 UTC (rev 61) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,89 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; - -import net.sf.trivial.easypaste.presence.Peer; -import net.sf.trivial.easypaste.presence.PresenceService; - - -/** - * Registry for existing services - * - * @author pajai - */ -public class PresenceServiceImpl implements PresenceService { - - /** service map */ - private final HashMap<String,Peer> services = new HashMap<String,Peer>(); - - /** - * Register a service - */ - synchronized void register (PeerImpl service) { - if (services.containsKey(service.getName()) - || service.getName().equals(serviceName)) return; - System.out.println("Presence service registered new peer : "+service); - - services.put(service.getName(), service); - } - - /** - * Test if a service is already registered - */ - synchronized boolean isRegistered (String name) { - return services.containsKey(name); - } - - /** - * Unregister a service, using its service name - */ - synchronized void unregister (String name) { - if (services.containsKey(name)) - services.remove(name); - } - - /** - * Print registered services - */ - public synchronized void printList () { - System.out.println ("Registered services:"); - for (Iterator it = services.values().iterator(); it.hasNext(); ) { - System.out.println ( ((PeerImpl)it.next()).toString() ); - } - } - - public Collection<Peer> getPeers() { - return services.values(); - } - - private final ServiceBrowser serviceBrowser; - private final ServiceRegistrer serviveRegistrer; - private final int port; - private final String serviceName; - - static final int WAIT = 15000; - static final String PROTO = "_flebeleb"; - - public PresenceServiceImpl(int port, String serviceName) { - this.serviceBrowser = new ServiceBrowser(this); - this.serviveRegistrer = new ServiceRegistrer(); - this.port = port; - this.serviceName = serviceName; - } - - public void start() { - System.out.println("Presence service starting"); - - serviceBrowser.browse(PROTO); - serviveRegistrer.register(serviceName, PROTO, port); - } - - public void stop() { - System.out.println("Presence service stopping"); - - serviceBrowser.stop(); - serviveRegistrer.stop(); - } -} Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 13:17:14 UTC (rev 61) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,72 +1,16 @@ package net.sf.trivial.easypaste.internal.pi.presence; -import com.apple.dnssd.BrowseListener; -import com.apple.dnssd.DNSSD; -import com.apple.dnssd.DNSSDService; +public class ServiceBrowser implements net.sf.trivial.easypaste.internal.presence.ServiceBrowser { - -/** - * Discovering existing bonjour services - * - * @author pajai - */ -public class ServiceBrowser implements BrowseListener { - - private DNSSDService service; - private PresenceServiceImpl presenceService; - - ServiceBrowser(PresenceServiceImpl presenceService) { - this.presenceService = presenceService; + public void browse(String proto) { + // TODO Auto-generated method stub + } - - /** method from BrowseListener */ - public void serviceFound (DNSSDService browser, int flag, int ifIndex, - String serviceName, String regType, String domain) { -// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " found"); - // resolve service if not already registered - if (!presenceService.isRegistered(serviceName)) { - ServiceResolver resolver = new ServiceResolver (serviceName, regType, domain, presenceService); - resolver.resolve(); - } - } - - /** method from BrowseListener */ - public void serviceLost (DNSSDService browser, int flags, int ifIndex, - String serviceName, String regType, String domain) { -// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " lost"); + public void stop() { + // TODO Auto-generated method stub - // unregister service, if was registered - if (presenceService.isRegistered(serviceName)) { - presenceService.unregister(serviceName); - } } - /** method from BrowseListener */ - public void operationFailed (DNSSDService service, int errorCode) { -// System.out.println ("Browsing failed."); - } - - /** launch a browse of services of the given protocol */ - public void browse (String proto) { - - try { - - // call browse - service = DNSSD.browse(0, 0, proto+"._tcp", "", this); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - /** stop the browse operation, this is important, otherwise bandwidth is wasted */ - public void stop () { - service.stop(); -// System.out.println ("Browser stopped."); - } - -} +} \ No newline at end of file Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java 2007-03-04 13:17:14 UTC (rev 61) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,52 +1,16 @@ package net.sf.trivial.easypaste.internal.pi.presence; -import com.apple.dnssd.DNSSD; -import com.apple.dnssd.DNSSDRegistration; -import com.apple.dnssd.DNSSDService; -import com.apple.dnssd.RegisterListener; -/** - * Register a service - * - * @author pajai - * - */ -public class ServiceRegistrer implements RegisterListener { +public class ServiceRegistrer implements net.sf.trivial.easypaste.internal.presence.ServiceRegistrer { - private DNSSDRegistration registration; - - /** method from RegisterListener */ - public void serviceRegistered ( - DNSSDRegistration regitration, - int flags, - String serviceName, - String regType, - String domain) { - -// System.out.println("Service " + serviceName + " " + regType + " " + domain + " registered"); + public void register(String name, String proto, int port) { + // TODO Auto-generated method stub + } - /** method from RegisterListener */ - public void operationFailed (DNSSDService service, int errorCode) { -// System.out.println("Operation failed"); - } - - public void stop () { + public void stop() { + // TODO Auto-generated method stub - registration.stop(); -// System.out.println ("Stop registration."); - } - public void register (String name, String proto, int port) { - - try { - - registration = DNSSD.register(name, proto+"._tcp", port, this); - - } catch (Exception e) { - e.printStackTrace(); - } - - } -} +} \ No newline at end of file Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 13:17:14 UTC (rev 61) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,87 +0,0 @@ -package net.sf.trivial.easypaste.internal.pi.presence; - -import java.net.InetAddress; -import java.net.UnknownHostException; - - -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; - -/** - * Class to resolve a service, that is, to get its host name and port number - * - * @author pajai - */ -public class ServiceResolver implements ResolveListener { - - private DNSSDService resolve; - - /* - * store a few attributes of a discovered service, we need them later - * when the service has been resolved - */ - private String serviceName; - private String regType; - private String domain; - - private final PresenceServiceImpl presenceService; - - /** a new resolver is created for each discovered service */ - public ServiceResolver (String serviceName, String regType, String domain, - PresenceServiceImpl presenceService) { - this.serviceName = serviceName; - this.regType = regType; - this.domain = domain; - this.presenceService = presenceService; - - } - - /** method from ResolveListener */ - public void serviceResolved (DNSSDService resolver, int flags, int ifIndex, String fullName, - String hostName, int port, TXTRecord txtRecord) { - System.out.println ("Presence service resolved: " + fullName + " at " + hostName + ":" + port); - - try { - // create new Service object - PeerImpl service = new PeerImpl (serviceName, regType, domain, - InetAddress.getByName(hostName), port); - - // register service - presenceService.register(service); - -// // print the list of registered services -// presenceService.printList(); - - // stop this resolver - stop (); - } - catch (UnknownHostException e) { - // TODO - e.printStackTrace(); - } - } - - /** method from ResolveListener */ - public void operationFailed (DNSSDService service, int errorCode) { -// System.out.println ("Resolve failed."); - } - - /** start the resolution of a service */ - public void resolve () { - try { - resolve = DNSSD.resolve(0, 0, serviceName, regType, domain, this); - } catch (DNSSDException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** stop this resolver */ - public void stop () { - resolve.stop(); -// System.out.println ("Resolver stopped."); - } -} Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PeerImpl.java (from rev 60, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PeerImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PeerImpl.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,47 @@ +package net.sf.trivial.easypaste.internal.presence; + +import java.net.InetAddress; + +import net.sf.trivial.easypaste.presence.Peer; + +/** + * Service, qualified by its name (e.g. Flebeleb), type (e.g. _flebeleb._tcp), + * domain (e.g. local.), hostName (e.g. xrb.local.) and port (e.g. 11111) + * + * @author pajai + */ +public class PeerImpl implements Peer { + + /* attributes got from the browse operation */ + private final String name; + private final String type; + private final String domain; + + /* attributes got from the resolve operation */ + private final InetAddress address; + private final int port; + + public PeerImpl (String name, String type, String domain, InetAddress address, int port) { + this.name = name; + this.type = type; + this.domain = domain; + this.address = address; + this.port = port; + } + + public InetAddress getAddress() { + return address; + } + + public int getPort() { + return port; + } + + public String getName() { + return name; + } + + public String toString () { + return name + " " + type + " " + domain + " " + address + ":" + String.valueOf(port); + } +} Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,90 @@ +package net.sf.trivial.easypaste.internal.presence; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; + +import net.sf.trivial.easypaste.internal.mac.presence.ServiceRegistrer; +import net.sf.trivial.easypaste.presence.Peer; +import net.sf.trivial.easypaste.presence.PresenceService; + + +/** + * Registry for existing services + * + * @author pajai + */ +public abstract class PresenceServicePIImpl implements PresenceService { + + /** service map */ + private final HashMap<String,Peer> services = new HashMap<String,Peer>(); + + /** + * Register a service + */ + public synchronized void register (PeerImpl service) { + if (services.containsKey(service.getName()) + || service.getName().equals(serviceName)) return; + System.out.println("Presence service registered new peer : "+service); + + services.put(service.getName(), service); + } + + /** + * Test if a service is already registered + */ + public synchronized boolean isRegistered (String name) { + return services.containsKey(name); + } + + /** + * Unregister a service, using its service name + */ + public synchronized void unregister (String name) { + if (services.containsKey(name)) + services.remove(name); + } + + /** + * Print registered services + */ + public synchronized void printList () { + System.out.println ("Registered services:"); + for (Iterator it = services.values().iterator(); it.hasNext(); ) { + System.out.println ( ((PeerImpl)it.next()).toString() ); + } + } + + public Collection<Peer> getPeers() { + return services.values(); + } + + private final int port; + private final String serviceName; + + static final int WAIT = 15000; + static final String PROTO = "_flebeleb"; + + public PresenceServicePIImpl(int port, String serviceName) { + this.port = port; + this.serviceName = serviceName; + } + + public abstract ServiceBrowser getServiceBrowser(); + + public abstract ServiceRegistrer getServiceRegistrer(); + + public void start() { + System.out.println("Presence service starting"); + + getServiceBrowser().browse(PROTO); + getServiceRegistrer().register(serviceName, PROTO, port); + } + + public void stop() { + System.out.println("Presence service stopping"); + + getServiceBrowser().stop(); + getServiceRegistrer().stop(); + } +} Property changes on: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/PresenceServicePIImpl.java ___________________________________________________________________ Name: svn:executable + * Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/ServiceBrowser.java (from rev 60, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/ServiceBrowser.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/ServiceBrowser.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,9 @@ +package net.sf.trivial.easypaste.internal.presence; + +public interface ServiceBrowser { + + public void browse (String proto); + + public void stop (); + +} \ No newline at end of file Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/ServiceRegistrer.java (from rev 60, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/ServiceRegistrer.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/ServiceRegistrer.java 2007-03-04 13:46:10 UTC (rev 62) @@ -0,0 +1,9 @@ +package net.sf.trivial.easypaste.internal.presence; + +public interface ServiceRegistrer { + + public void register (String name, String proto, int port); + + public void stop (); + +} Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java 2007-03-04 13:17:14 UTC (rev 61) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java 2007-03-04 13:46:10 UTC (rev 62) @@ -1,27 +1,35 @@ package net.sf.trivial.easypaste.launcher; +import java.net.InetAddress; +import java.net.UnknownHostException; + import net.sf.trivial.easypaste.ClipboardReader; import net.sf.trivial.easypaste.ClipboardWriter; import net.sf.trivial.easypaste.DistributedClipboard; import net.sf.trivial.easypaste.NotificationService; +import net.sf.trivial.easypaste.internal.DistributedClipboardImpl; import net.sf.trivial.easypaste.internal.mac.ClipboardReaderImpl; import net.sf.trivial.easypaste.internal.mac.ClipboardWriterImpl; import net.sf.trivial.easypaste.internal.mac.GrowlNotification; -import net.sf.trivial.easypaste.internal.pi.DistributedClipboardImpl; -import net.sf.trivial.easypaste.internal.pi.presence.PresenceServiceImpl; import net.sf.trivial.easypaste.presence.PresenceService; public class EasyController { private static final int PORT = 5555; - private static final String name = Messages.getString("EasyController.ServiceName"); //$NON-NLS-1$ - + private static String name; + public static void main(String[] args) { + try { + name = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException e1) { + name = Messages.getString("EasyController.ServiceName"); //$NON-NLS-1$ + } + DistributedClipboard dclip = new DistributedClipboardImpl(PORT); ClipboardReader creader = new ClipboardReaderImpl(); ClipboardWriter cwriter = new ClipboardWriterImpl(); NotificationService not = new GrowlNotification(); - PresenceService presenceService = new PresenceServiceImpl(PORT, name); + PresenceService presenceService = new net.sf.trivial.easypaste.internal.mac.presence.PresenceService(PORT, name); dclip.setClipboardWriter(cwriter); dclip.setNotificationService(not); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 13:17:13
|
Revision: 61 http://trivial.svn.sourceforge.net/trivial/?rev=61&view=rev Author: jlgeering Date: 2007-03-04 05:17:14 -0800 (Sun, 04 Mar 2007) Log Message: ----------- Removed EasyListener Removed Paths: ------------- trunk/eclipse/easypaste/src/easypaste/EasyListener.java Deleted: trunk/eclipse/easypaste/src/easypaste/EasyListener.java =================================================================== --- trunk/eclipse/easypaste/src/easypaste/EasyListener.java 2007-03-04 12:48:32 UTC (rev 60) +++ trunk/eclipse/easypaste/src/easypaste/EasyListener.java 2007-03-04 13:17:14 UTC (rev 61) @@ -1,74 +0,0 @@ -package easypaste; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.Map; -import java.util.TreeMap; - -import com.apple.dnssd.BrowseListener; -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; - -public class EasyListener implements BrowseListener, ResolveListener { - - private Map<String, Integer> buddies; - - public EasyListener () { - buddies = new TreeMap<String, Integer>(); - try { - DNSSD.browse("_easypaste._tcp", this); - } catch (DNSSDException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public void serviceFound(DNSSDService browser, int flags, int ifIndex, java.lang.String serviceName, java.lang.String regType, java.lang.String domain) { - try { - DNSSD.resolve(flags, ifIndex, serviceName, regType, domain, this); - } catch (DNSSDException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public void serviceLost(DNSSDService browser, int flags, int ifIndex, java.lang.String serviceName, java.lang.String regType, java.lang.String domain) { - //buddies.remove(serviceName); - // TODO remove - //System.out.println(serviceName); - } - - public void operationFailed(DNSSDService arg0, int arg1) { - // TODO Auto-generated method stub - - } - - public void serviceResolved(DNSSDService resolver, int flags, int ifIndex, java.lang.String fullName, java.lang.String hostName, int port, TXTRecord txtRecord) { - buddies.put(hostName, port); - } - public void sendString(String s) { - Socket skt; - OutputStreamWriter osw; - for (String hostName : buddies.keySet()) { - try { - skt = new Socket(hostName, buddies.get(hostName)); - osw = new OutputStreamWriter(skt.getOutputStream()); - osw.write(s); - osw.flush(); - osw.close(); - skt.close(); - } catch (UnknownHostException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 12:48:31
|
Revision: 60 http://trivial.svn.sourceforge.net/trivial/?rev=60&view=rev Author: jlgeering Date: 2007-03-04 04:48:32 -0800 (Sun, 04 Mar 2007) Log Message: ----------- statefull DCB Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 12:43:56 UTC (rev 59) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 12:48:32 UTC (rev 60) @@ -40,6 +40,7 @@ public void setLocalContent(String content) { if (!state.equals(content)) { + state = content; notify("Clipboard update (from local)", content); // send to network using network client client.sendToAllClients(presenceService.getPeers(), content); @@ -51,7 +52,11 @@ } protected void writeToClipboard(String content) { - localWriter.writeToClipboard(content); + if (!state.equals(content)) { + state = content; + notify("Clipboard update (from remote)", content); + localWriter.writeToClipboard(content); + } } private void notify(String title, String message) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 12:43:56
|
Revision: 59 http://trivial.svn.sourceforge.net/trivial/?rev=59&view=rev Author: jlgeering Date: 2007-03-04 04:43:56 -0800 (Sun, 04 Mar 2007) Log Message: ----------- statefull DCB Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 12:34:16 UTC (rev 58) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 12:43:56 UTC (rev 59) @@ -6,27 +6,31 @@ import net.sf.trivial.easypaste.presence.PresenceService; public class DistributedClipboardImpl implements DistributedClipboard { - + private ClipboardWriter localWriter; private PresenceService presenceService; private NotificationService notificationService; - + private final NetworkClient client; private final NetworkServer server; private final int port; - + + private String state; + public DistributedClipboardImpl(int port) { client = new NetworkClient(); server = new NetworkServer(this); this.port = port; - + + state = ""; + init(); } - + private void init() { server.listen(port); } - + public void setClipboardWriter(ClipboardWriter writer) { localWriter = writer; } @@ -35,15 +39,17 @@ } public void setLocalContent(String content) { - notify("Clipboard update", content); - // send to network using network client - client.sendToAllClients(presenceService.getPeers(), content); + if (!state.equals(content)) { + notify("Clipboard update (from local)", content); + // send to network using network client + client.sendToAllClients(presenceService.getPeers(), content); + } } public void setPresenceService(PresenceService presenceService) { this.presenceService = presenceService; } - + protected void writeToClipboard(String content) { localWriter.writeToClipboard(content); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 12:34:16
|
Revision: 58 http://trivial.svn.sourceforge.net/trivial/?rev=58&view=rev Author: fterrier Date: 2007-03-04 04:34:16 -0800 (Sun, 04 Mar 2007) Log Message: ----------- corrected bug in network server where a new socket was created after each conection added service name in presence service Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java 2007-03-04 12:19:39 UTC (rev 57) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java 2007-03-04 12:34:16 UTC (rev 58) @@ -46,19 +46,19 @@ assert address != null && content != null; try { - Socket clientSocket = new Socket(); - - SocketAddress serverAddress = new InetSocketAddress(address,port); - clientSocket.connect(serverAddress); - - Writer writer = new OutputStreamWriter(clientSocket.getOutputStream()); - writer.write(content); - - writer.flush(); - clientSocket.close(); + Socket clientSocket = new Socket(); + + SocketAddress serverAddress = new InetSocketAddress(address,port); + clientSocket.connect(serverAddress); + + Writer writer = new OutputStreamWriter(clientSocket.getOutputStream()); + writer.write(content); + + writer.flush(); + clientSocket.close(); } catch (IOException e) { - + e.printStackTrace(); } } } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java 2007-03-04 12:19:39 UTC (rev 57) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java 2007-03-04 12:34:16 UTC (rev 58) @@ -34,8 +34,8 @@ public void run() { try { running = true; + socket = new ServerSocket(port); while (running) { - socket = new ServerSocket(port); Socket clientSocket = socket.accept(); if (!running) return; counter++; Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 12:19:39 UTC (rev 57) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 12:34:16 UTC (rev 58) @@ -22,6 +22,10 @@ * Register a service */ synchronized void register (PeerImpl service) { + if (services.containsKey(service.getName()) + || service.getName().equals(serviceName)) return; + System.out.println("Presence service registered new peer : "+service); + services.put(service.getName(), service); } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 12:19:39 UTC (rev 57) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 12:34:16 UTC (rev 58) @@ -42,7 +42,7 @@ /** method from ResolveListener */ public void serviceResolved (DNSSDService resolver, int flags, int ifIndex, String fullName, String hostName, int port, TXTRecord txtRecord) { -// System.out.println ("Service " + fullName + " is at " + hostName + ":" + port); + System.out.println ("Presence service resolved: " + fullName + " at " + hostName + ":" + port); try { // create new Service object @@ -60,6 +60,7 @@ } catch (UnknownHostException e) { // TODO + e.printStackTrace(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 12:19:43
|
Revision: 57 http://trivial.svn.sourceforge.net/trivial/?rev=57&view=rev Author: fterrier Date: 2007-03-04 04:19:39 -0800 (Sun, 04 Mar 2007) Log Message: ----------- added paremeter for service name in presence service Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java Added Paths: ----------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 12:15:11 UTC (rev 56) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 12:19:39 UTC (rev 57) @@ -57,22 +57,23 @@ private final ServiceBrowser serviceBrowser; private final ServiceRegistrer serviveRegistrer; private final int port; + private final String serviceName; static final int WAIT = 15000; static final String PROTO = "_flebeleb"; - static final String SERVICENAME = "Flebeleb"; - public PresenceServiceImpl(int port) { + public PresenceServiceImpl(int port, String serviceName) { this.serviceBrowser = new ServiceBrowser(this); this.serviveRegistrer = new ServiceRegistrer(); this.port = port; + this.serviceName = serviceName; } public void start() { System.out.println("Presence service starting"); serviceBrowser.browse(PROTO); - serviveRegistrer.register(SERVICENAME, PROTO, port); + serviveRegistrer.register(serviceName, PROTO, port); } public void stop() { Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java 2007-03-04 12:15:11 UTC (rev 56) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java 2007-03-04 12:19:39 UTC (rev 57) @@ -14,13 +14,14 @@ public class EasyController { private static final int PORT = 5555; + private static final String name = Messages.getString("EasyController.ServiceName"); //$NON-NLS-1$ public static void main(String[] args) { DistributedClipboard dclip = new DistributedClipboardImpl(PORT); ClipboardReader creader = new ClipboardReaderImpl(); ClipboardWriter cwriter = new ClipboardWriterImpl(); NotificationService not = new GrowlNotification(); - PresenceService presenceService = new PresenceServiceImpl(PORT); + PresenceService presenceService = new PresenceServiceImpl(PORT, name); dclip.setClipboardWriter(cwriter); dclip.setNotificationService(not); Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/Messages.java 2007-03-04 12:19:39 UTC (rev 57) @@ -0,0 +1,22 @@ +package net.sf.trivial.easypaste.launcher; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "net.sf.trivial.easypaste.launcher.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/messages.properties 2007-03-04 12:19:39 UTC (rev 57) @@ -0,0 +1 @@ +EasyController.ServiceName=Franz's easypaste This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 12:15:11
|
Revision: 56 http://trivial.svn.sourceforge.net/trivial/?rev=56&view=rev Author: fterrier Date: 2007-03-04 04:15:11 -0800 (Sun, 04 Mar 2007) Log Message: ----------- corrected lock in networkserver Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 12:10:57 UTC (rev 55) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 12:15:11 UTC (rev 56) @@ -28,6 +28,7 @@ // resolve service if not already registered if (!presenceService.isRegistered(serviceName)) { ServiceResolver resolver = new ServiceResolver (serviceName, regType, domain, presenceService); + resolver.resolve(); } } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 12:10:57 UTC (rev 55) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 12:15:11 UTC (rev 56) @@ -37,8 +37,6 @@ this.domain = domain; this.presenceService = presenceService; - // resolve service - resolve (serviceName, regType, domain); } /** method from ResolveListener */ @@ -71,7 +69,7 @@ } /** start the resolution of a service */ - public void resolve (String serviceName, String regType, String domain) { + public void resolve () { try { resolve = DNSSD.resolve(0, 0, serviceName, regType, domain, this); } catch (DNSSDException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 12:10:57
|
Revision: 55 http://trivial.svn.sourceforge.net/trivial/?rev=55&view=rev Author: fterrier Date: 2007-03-04 04:10:57 -0800 (Sun, 04 Mar 2007) Log Message: ----------- corrected lock in networkserver Modified Paths: -------------- trunk/eclipse/easypaste/launch/EasyController_Mac.launch trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/ClipboardReader.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/DistributedClipboard.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/Peer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceService.java Added Paths: ----------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java Removed Paths: ------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/EasyController.java Modified: trunk/eclipse/easypaste/launch/EasyController_Mac.launch =================================================================== --- trunk/eclipse/easypaste/launch/EasyController_Mac.launch 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/launch/EasyController_Mac.launch 2007-03-04 12:10:57 UTC (rev 55) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> <stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="UTF-8"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.sf.trivial.easypaste.internal.mac.EasyController"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.sf.trivial.easypaste.launcher.EasyController"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-ea"/> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listEntry value="4"/> Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/ClipboardReader.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/ClipboardReader.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/ClipboardReader.java 2007-03-04 12:10:57 UTC (rev 55) @@ -1,9 +1,34 @@ package net.sf.trivial.easypaste; +/** + * This interface defines the clipboard reader, whose role + * is to read the clipboard and notify changes. + * + * @author Jean-Luc Geering + * + */ public interface ClipboardReader { + /** + * Sets the distributed clipboard to which this reader + * reports clipboard changes. + * + * @param distributedClipboard + */ void setDistributedClipboard(DistributedClipboard distributedClipboard); + + /** + * Starts the clipboard reader. + * + * @throws InterruptedException + */ void start() throws InterruptedException; + + /** + * Stops the clipboard reader. + * + * @throws InterruptedException + */ void stop() throws InterruptedException; } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/DistributedClipboard.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/DistributedClipboard.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/DistributedClipboard.java 2007-03-04 12:10:57 UTC (rev 55) @@ -1,9 +1,16 @@ package net.sf.trivial.easypaste; +import net.sf.trivial.easypaste.presence.PresenceService; + +/** + * @author Jean-Luc Geering + * + */ public interface DistributedClipboard { void setLocalContent(String content); - void setClipboardWriter(ClipboardWriter cw); - void setNotificationService(NotificationService ns); + void setClipboardWriter(ClipboardWriter clipboardWriter); + void setNotificationService(NotificationService notificationService); + void setPresenceService(PresenceService presenceService); } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java 2007-03-04 12:10:57 UTC (rev 55) @@ -42,6 +42,8 @@ } public synchronized void start() throws InterruptedException { + System.out.println("Clipboard reader starting"); + if (!running) { running = true; new Thread(this, "ClipboardReader").start(); @@ -49,6 +51,8 @@ } public synchronized void stop() throws InterruptedException { + System.out.println("Clipboard reader stopping"); + if (running) { running = false; stopped.wait(); Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/EasyController.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/EasyController.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/EasyController.java 2007-03-04 12:10:57 UTC (rev 55) @@ -1,28 +0,0 @@ -package net.sf.trivial.easypaste.internal.mac; - -import net.sf.trivial.easypaste.ClipboardReader; -import net.sf.trivial.easypaste.ClipboardWriter; -import net.sf.trivial.easypaste.DistributedClipboard; -import net.sf.trivial.easypaste.NotificationService; -import net.sf.trivial.easypaste.internal.pi.DistributedClipboardImpl; - -public class EasyController { - - public static void main(String[] args) { - DistributedClipboard dclip = new DistributedClipboardImpl(); - ClipboardReader creader = new ClipboardReaderImpl(); - ClipboardWriter cwriter = new ClipboardWriterImpl(); - NotificationService not = new GrowlNotification(); - - dclip.setClipboardWriter(cwriter); - dclip.setNotificationService(not); - creader.setDistributedClipboard(dclip); - try { - creader.start(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -} Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 12:10:57 UTC (rev 55) @@ -7,24 +7,24 @@ public class DistributedClipboardImpl implements DistributedClipboard { - private static final int PORT = 5555; - private ClipboardWriter localWriter; private PresenceService presenceService; private NotificationService notificationService; - private NetworkClient client; - private NetworkServer server; + private final NetworkClient client; + private final NetworkServer server; + private final int port; - public DistributedClipboardImpl() { + public DistributedClipboardImpl(int port) { client = new NetworkClient(); server = new NetworkServer(this); + this.port = port; init(); } private void init() { - server.listen(PORT); + server.listen(port); } public void setClipboardWriter(ClipboardWriter writer) { Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java 2007-03-04 12:10:57 UTC (rev 55) @@ -7,7 +7,7 @@ import net.sf.trivial.easypaste.DistributedClipboard; -public class NetworkServer { +public class NetworkServer extends Thread { private DistributedClipboardImpl clipboard; @@ -20,8 +20,18 @@ // TODO wrap around when MAX_LONG is reached private long counter = 0; + private int port; public void listen(int port) { + this.port = port; + start(); + } + + public void stopListening() { + running = false; + } + + public void run() { try { running = true; while (running) { @@ -38,10 +48,6 @@ } } - public void stop() { - running = false; - } - private class NetworkThread extends Thread { private Socket clientSocket; private long id; Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 12:10:57 UTC (rev 55) @@ -21,21 +21,21 @@ /** * Register a service */ - public synchronized void register (PeerImpl service) { + synchronized void register (PeerImpl service) { services.put(service.getName(), service); } /** * Test if a service is already registered */ - public synchronized boolean isRegistered (String name) { + synchronized boolean isRegistered (String name) { return services.containsKey(name); } /** * Unregister a service, using its service name */ - public synchronized void unregister (String name) { + synchronized void unregister (String name) { if (services.containsKey(name)) services.remove(name); } @@ -56,23 +56,28 @@ private final ServiceBrowser serviceBrowser; private final ServiceRegistrer serviveRegistrer; - + private final int port; + static final int WAIT = 15000; static final String PROTO = "_flebeleb"; - static final int PORT = 11111; static final String SERVICENAME = "Flebeleb"; - public PresenceServiceImpl() { + public PresenceServiceImpl(int port) { this.serviceBrowser = new ServiceBrowser(this); this.serviveRegistrer = new ServiceRegistrer(); + this.port = port; } public void start() { + System.out.println("Presence service starting"); + serviceBrowser.browse(PROTO); - serviveRegistrer.register(SERVICENAME, PROTO, PORT); + serviveRegistrer.register(SERVICENAME, PROTO, port); } public void stop() { + System.out.println("Presence service stopping"); + serviceBrowser.stop(); serviveRegistrer.stop(); } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 12:10:57 UTC (rev 55) @@ -23,7 +23,7 @@ /** method from BrowseListener */ public void serviceFound (DNSSDService browser, int flag, int ifIndex, String serviceName, String regType, String domain) { - System.out.println ("Service " + serviceName + " " + regType + " " + domain + " found"); +// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " found"); // resolve service if not already registered if (!presenceService.isRegistered(serviceName)) { @@ -34,7 +34,7 @@ /** method from BrowseListener */ public void serviceLost (DNSSDService browser, int flags, int ifIndex, String serviceName, String regType, String domain) { - System.out.println ("Service " + serviceName + " " + regType + " " + domain + " lost"); +// System.out.println ("Service " + serviceName + " " + regType + " " + domain + " lost"); // unregister service, if was registered if (presenceService.isRegistered(serviceName)) { @@ -44,7 +44,7 @@ /** method from BrowseListener */ public void operationFailed (DNSSDService service, int errorCode) { - System.out.println ("Browsing failed."); +// System.out.println ("Browsing failed."); } /** launch a browse of services of the given protocol */ @@ -65,7 +65,7 @@ /** stop the browse operation, this is important, otherwise bandwidth is wasted */ public void stop () { service.stop(); - System.out.println ("Browser stopped."); +// System.out.println ("Browser stopped."); } } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java 2007-03-04 12:10:57 UTC (rev 55) @@ -23,18 +23,18 @@ String regType, String domain) { - System.out.println("Service " + serviceName + " " + regType + " " + domain + " registered"); +// System.out.println("Service " + serviceName + " " + regType + " " + domain + " registered"); } /** method from RegisterListener */ public void operationFailed (DNSSDService service, int errorCode) { - System.out.println("Operation failed"); +// System.out.println("Operation failed"); } public void stop () { registration.stop(); - System.out.println ("Stop registration."); +// System.out.println ("Stop registration."); } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 12:10:57 UTC (rev 55) @@ -44,7 +44,7 @@ /** method from ResolveListener */ public void serviceResolved (DNSSDService resolver, int flags, int ifIndex, String fullName, String hostName, int port, TXTRecord txtRecord) { - System.out.println ("Service " + fullName + " is at " + hostName + ":" + port); +// System.out.println ("Service " + fullName + " is at " + hostName + ":" + port); try { // create new Service object @@ -54,8 +54,8 @@ // register service presenceService.register(service); - // print the list of registered services - presenceService.printList(); +// // print the list of registered services +// presenceService.printList(); // stop this resolver stop (); @@ -67,7 +67,7 @@ /** method from ResolveListener */ public void operationFailed (DNSSDService service, int errorCode) { - System.out.println ("Resolve failed."); +// System.out.println ("Resolve failed."); } /** start the resolution of a service */ @@ -83,6 +83,6 @@ /** stop this resolver */ public void stop () { resolve.stop(); - System.out.println ("Resolver stopped."); +// System.out.println ("Resolver stopped."); } } Copied: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java (from rev 54, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/EasyController.java) =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyController.java 2007-03-04 12:10:57 UTC (rev 55) @@ -0,0 +1,38 @@ +package net.sf.trivial.easypaste.launcher; + +import net.sf.trivial.easypaste.ClipboardReader; +import net.sf.trivial.easypaste.ClipboardWriter; +import net.sf.trivial.easypaste.DistributedClipboard; +import net.sf.trivial.easypaste.NotificationService; +import net.sf.trivial.easypaste.internal.mac.ClipboardReaderImpl; +import net.sf.trivial.easypaste.internal.mac.ClipboardWriterImpl; +import net.sf.trivial.easypaste.internal.mac.GrowlNotification; +import net.sf.trivial.easypaste.internal.pi.DistributedClipboardImpl; +import net.sf.trivial.easypaste.internal.pi.presence.PresenceServiceImpl; +import net.sf.trivial.easypaste.presence.PresenceService; + +public class EasyController { + + private static final int PORT = 5555; + + public static void main(String[] args) { + DistributedClipboard dclip = new DistributedClipboardImpl(PORT); + ClipboardReader creader = new ClipboardReaderImpl(); + ClipboardWriter cwriter = new ClipboardWriterImpl(); + NotificationService not = new GrowlNotification(); + PresenceService presenceService = new PresenceServiceImpl(PORT); + + dclip.setClipboardWriter(cwriter); + dclip.setNotificationService(not); + dclip.setPresenceService(presenceService); + creader.setDistributedClipboard(dclip); + try { + presenceService.start(); + creader.start(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/Peer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/Peer.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/Peer.java 2007-03-04 12:10:57 UTC (rev 55) @@ -2,12 +2,34 @@ import java.net.InetAddress; +/** + * Interface for a peer. + * + * @author Fran\x8Dois Terrier + * + */ public interface Peer { + /** + * Returns the address of this peer. + * + * @return the address of this peer + */ public InetAddress getAddress(); + /** + * Returns the port under which this peer's service + * is reachable. + * + * @return the port of this peer + */ public int getPort(); + /** + * Returns the user defined name of this peer. + * + * @return the user defined name of this peer + */ public String getName(); } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceService.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceService.java 2007-03-04 10:42:24 UTC (rev 54) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceService.java 2007-03-04 12:10:57 UTC (rev 55) @@ -4,10 +4,22 @@ public interface PresenceService { + /** + * Returns the collection of present peers. + * + * @return the collection of present peers + */ public Collection<Peer> getPeers(); + /** + * Starts the presence service. Collects the peer + * present on the network. + */ public void start(); + /** + * Stops the presence service. + */ public void stop(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 10:42:25
|
Revision: 54 http://trivial.svn.sourceforge.net/trivial/?rev=54&view=rev Author: jlgeering Date: 2007-03-04 02:42:24 -0800 (Sun, 04 Mar 2007) Log Message: ----------- start - stop CBReader Notification in DCB Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java 2007-03-04 10:33:23 UTC (rev 53) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java 2007-03-04 10:42:24 UTC (rev 54) @@ -8,32 +8,19 @@ public class ClipboardReaderImpl implements ClipboardReader, Runnable { private boolean running; + + private Object stopped = new Object(); + private DistributedClipboard distributedClipboard; private NSPasteboard pasteboard; - -// private Growl growl; -// private final static String GROWL_NOTIFICATION = "clipboard update"; public ClipboardReaderImpl() { pasteboard = NSPasteboard.generalPasteboard(); -// growl = new Growl("Easypaste", "logo.png"); -// NSMutableArray nsa = new NSMutableArray(); -// nsa.addObject(GROWL_NOTIFICATION); -// growl.setAllowedNotifications(nsa); -// try { -// growl.setDefaultNotifications(nsa); -// } catch (Exception e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// growl.register(); running = false; } public void run() { - assert (!running): "ClipboardReader already running."; - running = true; while (running) { int count = pasteboard.changeCount(); while (count == pasteboard.changeCount()) { @@ -47,19 +34,24 @@ String content = pasteboard.stringForType("NSStringPboardType"); distributedClipboard.setLocalContent(content); } + stopped.notify(); } public void setDistributedClipboard(DistributedClipboard distributedClipboard) { this.distributedClipboard = distributedClipboard; } - public void start() { + public synchronized void start() throws InterruptedException { if (!running) { + running = true; new Thread(this, "ClipboardReader").start(); } } - public void stop() { - running = false; + public synchronized void stop() throws InterruptedException { + if (running) { + running = false; + stopped.wait(); + } } } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 10:33:23 UTC (rev 53) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 10:42:24 UTC (rev 54) @@ -1,11 +1,5 @@ package net.sf.trivial.easypaste.internal.pi; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.ServerSocket; -import java.net.Socket; - import net.sf.trivial.easypaste.ClipboardWriter; import net.sf.trivial.easypaste.DistributedClipboard; import net.sf.trivial.easypaste.NotificationService; @@ -17,6 +11,7 @@ private ClipboardWriter localWriter; private PresenceService presenceService; + private NotificationService notificationService; private NetworkClient client; private NetworkServer server; @@ -35,9 +30,12 @@ public void setClipboardWriter(ClipboardWriter writer) { localWriter = writer; } + public void setNotificationService(NotificationService ns) { + notificationService = ns; + } public void setLocalContent(String content) { - System.out.println(content); + notify("Clipboard update", content); // send to network using network client client.sendToAllClients(presenceService.getPeers(), content); } @@ -50,9 +48,14 @@ localWriter.writeToClipboard(content); } - public void setNotificationService(NotificationService ns) { - // TODO Auto-generated method stub - + private void notify(String title, String message) { + if (notificationService != null) { + notificationService.notify(title, message); + } + else { + // TODO use logging. + System.out.println(title + ": " + message); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 10:33:22
|
Revision: 53 http://trivial.svn.sourceforge.net/trivial/?rev=53&view=rev Author: fterrier Date: 2007-03-04 02:33:23 -0800 (Sun, 04 Mar 2007) Log Message: ----------- created packages - reorganized structure in internal and visiable packages refactored presence srvice - not yet done Added Paths: ----------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceService.java Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceService.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceService.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceService.java 2007-03-04 10:33:23 UTC (rev 53) @@ -0,0 +1,13 @@ +package net.sf.trivial.easypaste.presence; + +import java.util.Collection; + +public interface PresenceService { + + public Collection<Peer> getPeers(); + + public void start(); + + public void stop(); + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 10:32:55
|
Revision: 52 http://trivial.svn.sourceforge.net/trivial/?rev=52&view=rev Author: fterrier Date: 2007-03-04 02:32:50 -0800 (Sun, 04 Mar 2007) Log Message: ----------- created packages - reorganized structure in internal and visiable packages refactored presence srvice - not yet done Added Paths: ----------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java 2007-03-04 10:32:50 UTC (rev 52) @@ -0,0 +1,126 @@ +//Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. +//Jad home page: http://www.kpdus.com/jad.html +//Decompiler options: packimports(3) +//Source File Name: ClipPaste.java + +package net.sf.trivial.easypaste.internal.pi; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.IOException; + + +import com.apple.cocoa.foundation.NSMutableArray; +import com.growl.Growl; + +import easypaste.EasyListener; + +public class ClipboardReaderImpl implements ClipboardOwner { + + private boolean running; + private Clipboard clipboard; + private Growl growl; + private EasyListener el; + + private final static String GROWL_NOTIFICATION = "clipboard update"; + + public ClipboardReaderImpl() { + clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + growl = new Growl("Easypast", "logo.png"); + NSMutableArray nsa = new NSMutableArray(); + nsa.addObject(GROWL_NOTIFICATION); + growl.setAllowedNotifications(nsa); + try { + growl.setDefaultNotifications(nsa); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + growl.register(); + el = new EasyListener(); + running = false; + } + + public void readOnce() { + if (running) { + System.out.println(0); + return; + } + System.out.println(1); + running = true; + new Thread(new Runnable() { + public void run() { + Transferable transferable; + System.out.println(clipboard.getName()); + + Transferable t = new StringSelection("d"); + ClipboardOwner co = new ClipboardOwner() { + + public void lostOwnership(Clipboard clipboard, Transferable contents) { + System.out.println(6); + + } + + }; + System.out.println(t); +// clipboard.setContents(t, co); + clipboard.setContents(new StringSelection("e"), co); + String s = ""; +// System.out.println(clipboard.getName()); + boolean loop = true; + while (loop) { +// System.out.println(3); +// System.out.println(Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null)); + transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(new Object()); + System.out.println(transferable); + try { + if (transferable != null + && transferable.isDataFlavorSupported(DataFlavor.stringFlavor) + && !s.equals((String) transferable.getTransferData(DataFlavor.stringFlavor))) { +//// loop = false; +// System.out.println(4); +// + s = (String) transferable.getTransferData(DataFlavor.stringFlavor); + System.out.println(s); +// growl.notifyGrowlOf(GROWL_NOTIFICATION, "Clipboard Update", s); +// el.sendString(s); +//// break; + } +// } catch (UnsupportedFlavorException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } catch (IOException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// System.out.println(5); + try { + Thread.sleep(2000); + } catch (InterruptedException e) {} + } + running = false; + } + + }, "Clipboard Reader").start(); + + } + + public static void main(String args[]) { + ClipboardReaderImpl cbr = new ClipboardReaderImpl(); + cbr.readOnce(); + cbr.readOnce(); + } + + public void lostOwnership(Clipboard clipboard, Transferable contents) { + // TODO Auto-generated method stub + System.out.println(6); + } +} \ No newline at end of file Property changes on: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/ClipboardReaderImpl.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/DistributedClipboardImpl.java 2007-03-04 10:32:50 UTC (rev 52) @@ -0,0 +1,58 @@ +package net.sf.trivial.easypaste.internal.pi; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.ServerSocket; +import java.net.Socket; + +import net.sf.trivial.easypaste.ClipboardWriter; +import net.sf.trivial.easypaste.DistributedClipboard; +import net.sf.trivial.easypaste.NotificationService; +import net.sf.trivial.easypaste.presence.PresenceService; + +public class DistributedClipboardImpl implements DistributedClipboard { + + private static final int PORT = 5555; + + private ClipboardWriter localWriter; + private PresenceService presenceService; + + private NetworkClient client; + private NetworkServer server; + + public DistributedClipboardImpl() { + client = new NetworkClient(); + server = new NetworkServer(this); + + init(); + } + + private void init() { + server.listen(PORT); + } + + public void setClipboardWriter(ClipboardWriter writer) { + localWriter = writer; + } + + public void setLocalContent(String content) { + System.out.println(content); + // send to network using network client + client.sendToAllClients(presenceService.getPeers(), content); + } + + public void setPresenceService(PresenceService presenceService) { + this.presenceService = presenceService; + } + + protected void writeToClipboard(String content) { + localWriter.writeToClipboard(content); + } + + public void setNotificationService(NotificationService ns) { + // TODO Auto-generated method stub + + } + +} Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkClient.java 2007-03-04 10:32:50 UTC (rev 52) @@ -0,0 +1,66 @@ +package net.sf.trivial.easypaste.internal.pi; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketAddress; +import java.util.Collection; + +import net.sf.trivial.easypaste.internal.pi.presence.PeerImpl; +import net.sf.trivial.easypaste.presence.Peer; + + +public class NetworkClient { + + public NetworkClient() { + } + + public void sendToClient(Peer service, String content) { + NetworkThread thread = new NetworkThread(service.getAddress(),service.getPort(),content); + // TODO do not run a new thread each time, instead use a thread pool + thread.start(); + } + + public void sendToAllClients(Collection<Peer> services, String content) { + for (Peer service : services) { + sendToClient(service, content); + } + } + + private static class NetworkThread extends Thread { + private int port; + private InetAddress address; + private String content; + + NetworkThread(InetAddress address, int port, String content) { + this.address = address; + this.port = port; + this.content = content; + } + + @Override + public void run() { + assert address != null && content != null; + + try { + Socket clientSocket = new Socket(); + + SocketAddress serverAddress = new InetSocketAddress(address,port); + clientSocket.connect(serverAddress); + + Writer writer = new OutputStreamWriter(clientSocket.getOutputStream()); + writer.write(content); + + writer.flush(); + clientSocket.close(); + } + catch (IOException e) { + + } + } + } + +} Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/NetworkServer.java 2007-03-04 10:32:50 UTC (rev 52) @@ -0,0 +1,71 @@ +package net.sf.trivial.easypaste.internal.pi; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.ServerSocket; +import java.net.Socket; + +import net.sf.trivial.easypaste.DistributedClipboard; + +public class NetworkServer { + + private DistributedClipboardImpl clipboard; + + public NetworkServer(DistributedClipboardImpl clipboard) { + this.clipboard = clipboard; + } + + private ServerSocket socket; + private boolean running; + + // TODO wrap around when MAX_LONG is reached + private long counter = 0; + + public void listen(int port) { + try { + running = true; + while (running) { + socket = new ServerSocket(port); + Socket clientSocket = socket.accept(); + if (!running) return; + counter++; + NetworkThread thread = new NetworkThread(clientSocket,counter); + thread.start(); + } + } + catch (IOException e) { + // TODO + } + } + + public void stop() { + running = false; + } + + private class NetworkThread extends Thread { + private Socket clientSocket; + private long id; + + NetworkThread(Socket clientSocket, long id) { + this.clientSocket = clientSocket; + this.id = id; + } + + public void run() { + try { + InputStreamReader reader = new InputStreamReader(clientSocket.getInputStream()); + StringBuilder str = new StringBuilder(); + char[] tmp = new char[256]; + while (reader.read(tmp)!=-1) { + str.append(tmp); + } + if (counter == id) clipboard.writeToClipboard(str.toString()); + } + catch (IOException e) { + // TODO + } + } + + } + +} Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java 2007-03-04 10:32:50 UTC (rev 52) @@ -0,0 +1,47 @@ +package net.sf.trivial.easypaste.internal.pi.presence; + +import java.net.InetAddress; + +import net.sf.trivial.easypaste.presence.Peer; + +/** + * Service, qualified by its name (e.g. Flebeleb), type (e.g. _flebeleb._tcp), + * domain (e.g. local.), hostName (e.g. xrb.local.) and port (e.g. 11111) + * + * @author pajai + */ +public class PeerImpl implements Peer { + + /* attributes got from the browse operation */ + private final String name; + private final String type; + private final String domain; + + /* attributes got from the resolve operation */ + private final InetAddress address; + private final int port; + + public PeerImpl (String name, String type, String domain, InetAddress address, int port) { + this.name = name; + this.type = type; + this.domain = domain; + this.address = address; + this.port = port; + } + + public InetAddress getAddress() { + return address; + } + + public int getPort() { + return port; + } + + public String getName() { + return name; + } + + public String toString () { + return name + " " + type + " " + domain + " " + address + ":" + String.valueOf(port); + } +} Property changes on: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PeerImpl.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 10:32:50 UTC (rev 52) @@ -0,0 +1,79 @@ +package net.sf.trivial.easypaste.internal.pi.presence; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; + +import net.sf.trivial.easypaste.presence.Peer; +import net.sf.trivial.easypaste.presence.PresenceService; + + +/** + * Registry for existing services + * + * @author pajai + */ +public class PresenceServiceImpl implements PresenceService { + + /** service map */ + private final HashMap<String,Peer> services = new HashMap<String,Peer>(); + + /** + * Register a service + */ + public synchronized void register (PeerImpl service) { + services.put(service.getName(), service); + } + + /** + * Test if a service is already registered + */ + public synchronized boolean isRegistered (String name) { + return services.containsKey(name); + } + + /** + * Unregister a service, using its service name + */ + public synchronized void unregister (String name) { + if (services.containsKey(name)) + services.remove(name); + } + + /** + * Print registered services + */ + public synchronized void printList () { + System.out.println ("Registered services:"); + for (Iterator it = services.values().iterator(); it.hasNext(); ) { + System.out.println ( ((PeerImpl)it.next()).toString() ); + } + } + + public Collection<Peer> getPeers() { + return services.values(); + } + + private final ServiceBrowser serviceBrowser; + private final ServiceRegistrer serviveRegistrer; + + static final int WAIT = 15000; + static final String PROTO = "_flebeleb"; + static final int PORT = 11111; + static final String SERVICENAME = "Flebeleb"; + + public PresenceServiceImpl() { + this.serviceBrowser = new ServiceBrowser(this); + this.serviveRegistrer = new ServiceRegistrer(); + } + + public void start() { + serviceBrowser.browse(PROTO); + serviveRegistrer.register(SERVICENAME, PROTO, PORT); + } + + public void stop() { + serviceBrowser.stop(); + serviveRegistrer.stop(); + } +} Property changes on: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java 2007-03-04 10:32:50 UTC (rev 52) @@ -0,0 +1,71 @@ +package net.sf.trivial.easypaste.internal.pi.presence; + + +import com.apple.dnssd.BrowseListener; +import com.apple.dnssd.DNSSD; +import com.apple.dnssd.DNSSDService; + + +/** + * Discovering existing bonjour services + * + * @author pajai + */ +public class ServiceBrowser implements BrowseListener { + + private DNSSDService service; + private PresenceServiceImpl presenceService; + + ServiceBrowser(PresenceServiceImpl presenceService) { + this.presenceService = presenceService; + } + + /** method from BrowseListener */ + public void serviceFound (DNSSDService browser, int flag, int ifIndex, + String serviceName, String regType, String domain) { + System.out.println ("Service " + serviceName + " " + regType + " " + domain + " found"); + + // resolve service if not already registered + if (!presenceService.isRegistered(serviceName)) { + ServiceResolver resolver = new ServiceResolver (serviceName, regType, domain, presenceService); + } + } + + /** method from BrowseListener */ + public void serviceLost (DNSSDService browser, int flags, int ifIndex, + String serviceName, String regType, String domain) { + System.out.println ("Service " + serviceName + " " + regType + " " + domain + " lost"); + + // unregister service, if was registered + if (presenceService.isRegistered(serviceName)) { + presenceService.unregister(serviceName); + } + } + + /** method from BrowseListener */ + public void operationFailed (DNSSDService service, int errorCode) { + System.out.println ("Browsing failed."); + } + + /** launch a browse of services of the given protocol */ + public void browse (String proto) { + + try { + + // call browse + service = DNSSD.browse(0, 0, proto+"._tcp", "", this); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** stop the browse operation, this is important, otherwise bandwidth is wasted */ + public void stop () { + service.stop(); + System.out.println ("Browser stopped."); + } + +} Property changes on: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowser.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java 2007-03-04 10:32:50 UTC (rev 52) @@ -0,0 +1,52 @@ +package net.sf.trivial.easypaste.internal.pi.presence; + +import com.apple.dnssd.DNSSD; +import com.apple.dnssd.DNSSDRegistration; +import com.apple.dnssd.DNSSDService; +import com.apple.dnssd.RegisterListener; + +/** + * Register a service + * + * @author pajai + * + */ +public class ServiceRegistrer implements RegisterListener { + + private DNSSDRegistration registration; + + /** method from RegisterListener */ + public void serviceRegistered ( + DNSSDRegistration regitration, + int flags, + String serviceName, + String regType, + String domain) { + + System.out.println("Service " + serviceName + " " + regType + " " + domain + " registered"); + } + + /** method from RegisterListener */ + public void operationFailed (DNSSDService service, int errorCode) { + System.out.println("Operation failed"); + } + + public void stop () { + + registration.stop(); + System.out.println ("Stop registration."); + + } + + public void register (String name, String proto, int port) { + + try { + + registration = DNSSD.register(name, proto+"._tcp", port, this); + + } catch (Exception e) { + e.printStackTrace(); + } + + } +} Property changes on: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrer.java ___________________________________________________________________ Name: svn:executable + * Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java 2007-03-04 10:32:50 UTC (rev 52) @@ -0,0 +1,88 @@ +package net.sf.trivial.easypaste.internal.pi.presence; + +import java.net.InetAddress; +import java.net.UnknownHostException; + + +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; + +/** + * Class to resolve a service, that is, to get its host name and port number + * + * @author pajai + */ +public class ServiceResolver implements ResolveListener { + + private DNSSDService resolve; + + /* + * store a few attributes of a discovered service, we need them later + * when the service has been resolved + */ + private String serviceName; + private String regType; + private String domain; + + private final PresenceServiceImpl presenceService; + + /** a new resolver is created for each discovered service */ + public ServiceResolver (String serviceName, String regType, String domain, + PresenceServiceImpl presenceService) { + this.serviceName = serviceName; + this.regType = regType; + this.domain = domain; + this.presenceService = presenceService; + + // resolve service + resolve (serviceName, regType, domain); + } + + /** method from ResolveListener */ + public void serviceResolved (DNSSDService resolver, int flags, int ifIndex, String fullName, + String hostName, int port, TXTRecord txtRecord) { + System.out.println ("Service " + fullName + " is at " + hostName + ":" + port); + + try { + // create new Service object + PeerImpl service = new PeerImpl (serviceName, regType, domain, + InetAddress.getByName(hostName), port); + + // register service + presenceService.register(service); + + // print the list of registered services + presenceService.printList(); + + // stop this resolver + stop (); + } + catch (UnknownHostException e) { + // TODO + } + } + + /** method from ResolveListener */ + public void operationFailed (DNSSDService service, int errorCode) { + System.out.println ("Resolve failed."); + } + + /** start the resolution of a service */ + public void resolve (String serviceName, String regType, String domain) { + try { + resolve = DNSSD.resolve(0, 0, serviceName, regType, domain, this); + } catch (DNSSDException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** stop this resolver */ + public void stop () { + resolve.stop(); + System.out.println ("Resolver stopped."); + } +} Property changes on: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceResolver.java ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fte...@us...> - 2007-03-04 10:30:34
|
Revision: 51 http://trivial.svn.sourceforge.net/trivial/?rev=51&view=rev Author: fterrier Date: 2007-03-04 02:30:20 -0800 (Sun, 04 Mar 2007) Log Message: ----------- created packages - reorganized structure in internal and visiable packages refactored presence srvice - not yet done Modified Paths: -------------- trunk/eclipse/easypaste/src/easypaste/EasyPaste.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/EasyController.java Added Paths: ----------- trunk/eclipse/easypaste/src/easypaste/EasyListener.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java Removed Paths: ------------- trunk/eclipse/easypaste/src/easypaste/BrowserClass.java trunk/eclipse/easypaste/src/easypaste/RegisterClass.java trunk/eclipse/easypaste/src/easypaste/ResolverClass.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/EasyListener.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/java/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/mac/ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PeerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceProvider.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/ServiceRegistry.java Deleted: trunk/eclipse/easypaste/src/easypaste/BrowserClass.java =================================================================== --- trunk/eclipse/easypaste/src/easypaste/BrowserClass.java 2007-03-04 10:28:07 UTC (rev 50) +++ trunk/eclipse/easypaste/src/easypaste/BrowserClass.java 2007-03-04 10:30:20 UTC (rev 51) @@ -1,66 +0,0 @@ -package easypaste; - -import net.sf.trivial.easypaste.presence.ServiceRegistry; - -import com.apple.dnssd.BrowseListener; -import com.apple.dnssd.DNSSD; -import com.apple.dnssd.DNSSDService; - -/** - * Discovering existing bonjour services - * - * @author pajai - */ -public class BrowserClass implements BrowseListener { - - private DNSSDService service; - - /** method from BrowseListener */ - public void serviceFound (DNSSDService browser, int flag, int ifIndex, - String serviceName, String regType, String domain) { - System.out.println ("Service " + serviceName + " " + regType + " " + domain + " found"); - - // resolve service if not already registered - if (!ServiceRegistry.getInstance().isRegistered(serviceName)) { - ResolverClass resolver = new ResolverClass (serviceName, regType, domain); - } - } - - /** method from BrowseListener */ - public void serviceLost (DNSSDService browser, int flags, int ifIndex, - String serviceName, String regType, String domain) { - System.out.println ("Service " + serviceName + " " + regType + " " + domain + " lost"); - - // unregister service, if was registered - if (ServiceRegistry.getInstance().isRegistered(serviceName)) { - ServiceRegistry.getInstance().unregister(serviceName); - } - } - - /** method from BrowseListener */ - public void operationFailed (DNSSDService service, int errorCode) { - System.out.println ("Browsing failed."); - } - - /** launch a browse of services of the given protocol */ - public void browse (String proto) { - - try { - - // call browse - service = DNSSD.browse(0, 0, proto+"._tcp", "", this); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - /** stop the browse operation, this is important, otherwise bandwidth is wasted */ - public void stop () { - service.stop(); - System.out.println ("Browser stopped."); - } - -} Copied: trunk/eclipse/easypaste/src/easypaste/EasyListener.java (from rev 48, trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/EasyListener.java) =================================================================== --- trunk/eclipse/easypaste/src/easypaste/EasyListener.java (rev 0) +++ trunk/eclipse/easypaste/src/easypaste/EasyListener.java 2007-03-04 10:30:20 UTC (rev 51) @@ -0,0 +1,74 @@ +package easypaste; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.Map; +import java.util.TreeMap; + +import com.apple.dnssd.BrowseListener; +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; + +public class EasyListener implements BrowseListener, ResolveListener { + + private Map<String, Integer> buddies; + + public EasyListener () { + buddies = new TreeMap<String, Integer>(); + try { + DNSSD.browse("_easypaste._tcp", this); + } catch (DNSSDException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void serviceFound(DNSSDService browser, int flags, int ifIndex, java.lang.String serviceName, java.lang.String regType, java.lang.String domain) { + try { + DNSSD.resolve(flags, ifIndex, serviceName, regType, domain, this); + } catch (DNSSDException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void serviceLost(DNSSDService browser, int flags, int ifIndex, java.lang.String serviceName, java.lang.String regType, java.lang.String domain) { + //buddies.remove(serviceName); + // TODO remove + //System.out.println(serviceName); + } + + public void operationFailed(DNSSDService arg0, int arg1) { + // TODO Auto-generated method stub + + } + + public void serviceResolved(DNSSDService resolver, int flags, int ifIndex, java.lang.String fullName, java.lang.String hostName, int port, TXTRecord txtRecord) { + buddies.put(hostName, port); + } + public void sendString(String s) { + Socket skt; + OutputStreamWriter osw; + for (String hostName : buddies.keySet()) { + try { + skt = new Socket(hostName, buddies.get(hostName)); + osw = new OutputStreamWriter(skt.getOutputStream()); + osw.write(s); + osw.flush(); + osw.close(); + skt.close(); + } catch (UnknownHostException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } +} Modified: trunk/eclipse/easypaste/src/easypaste/EasyPaste.java =================================================================== --- trunk/eclipse/easypaste/src/easypaste/EasyPaste.java 2007-03-04 10:28:07 UTC (rev 50) +++ trunk/eclipse/easypaste/src/easypaste/EasyPaste.java 2007-03-04 10:30:20 UTC (rev 51) @@ -1,5 +1,8 @@ package easypaste; +import net.sf.trivial.easypaste.internal.pi.presence.ServiceBrowser; +import net.sf.trivial.easypaste.internal.pi.presence.ServiceRegistrer; + /** * Bonjour Main Test Class * @@ -12,16 +15,16 @@ static final int PORT = 11111; static final String SERVICENAME = "Flebeleb"; - RegisterClass register; - BrowserClass browser; + ServiceRegistrer register; + ServiceBrowser browser; public void start () { // registering service - register = new RegisterClass (); + register = new ServiceRegistrer (); register.register(SERVICENAME, PROTO, PORT); // browsing existing services - browser = new BrowserClass (); +// browser = new ServiceBrowser (); browser.browse(PROTO); } Deleted: trunk/eclipse/easypaste/src/easypaste/RegisterClass.java =================================================================== --- trunk/eclipse/easypaste/src/easypaste/RegisterClass.java 2007-03-04 10:28:07 UTC (rev 50) +++ trunk/eclipse/easypaste/src/easypaste/RegisterClass.java 2007-03-04 10:30:20 UTC (rev 51) @@ -1,52 +0,0 @@ -package easypaste; - -import com.apple.dnssd.DNSSD; -import com.apple.dnssd.DNSSDRegistration; -import com.apple.dnssd.DNSSDService; -import com.apple.dnssd.RegisterListener; - -/** - * Register a service - * - * @author pajai - * - */ -public class RegisterClass implements RegisterListener { - - private DNSSDRegistration registration; - - /** method from RegisterListener */ - public void serviceRegistered ( - DNSSDRegistration regitration, - int flags, - String serviceName, - String regType, - String domain) { - - System.out.println("Service " + serviceName + " " + regType + " " + domain + " registered"); - } - - /** method from RegisterListener */ - public void operationFailed (DNSSDService service, int errorCode) { - System.out.println("Operation failed"); - } - - public void stop () { - - registration.stop(); - System.out.println ("Stop registration."); - - } - - public void register (String name, String proto, int port) { - - try { - - registration = DNSSD.register(name, proto+"._tcp", port, this); - - } catch (Exception e) { - e.printStackTrace(); - } - - } -} Deleted: trunk/eclipse/easypaste/src/easypaste/ResolverClass.java =================================================================== --- trunk/eclipse/easypaste/src/easypaste/ResolverClass.java 2007-03-04 10:28:07 UTC (rev 50) +++ trunk/eclipse/easypaste/src/easypaste/ResolverClass.java 2007-03-04 10:30:20 UTC (rev 51) @@ -1,86 +0,0 @@ -package easypaste; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -import net.sf.trivial.easypaste.presence.PeerImpl; -import net.sf.trivial.easypaste.presence.ServiceRegistry; - -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; - -/** - * Class to resolve a service, that is, to get its host name and port number - * - * @author pajai - */ -public class ResolverClass implements ResolveListener { - - private DNSSDService resolve; - - /* - * store a few attributes of a discovered service, we need them later - * when the service has been resolved - */ - private String serviceName; - private String regType; - private String domain; - - /** a new resolver is created for each discovered service */ - public ResolverClass (String serviceName, String regType, String domain) { - this.serviceName = serviceName; - this.regType = regType; - this.domain = domain; - - // resolve service - resolve (serviceName, regType, domain); - } - - /** method from ResolveListener */ - public void serviceResolved (DNSSDService resolver, int flags, int ifIndex, String fullName, - String hostName, int port, TXTRecord txtRecord) { - System.out.println ("Service " + fullName + " is at " + hostName + ":" + port); - - try { - // create new Service object - PeerImpl service = new PeerImpl (serviceName, regType, domain, - InetAddress.getByName(hostName), port); - - // register service - ServiceRegistry.getInstance().register(service); - - // print the list of registered services - ServiceRegistry.getInstance().printList(); - - // stop this resolver - stop (); - } - catch (UnknownHostException e) { - // TODO - } - } - - /** method from ResolveListener */ - public void operationFailed (DNSSDService service, int errorCode) { - System.out.println ("Resolve failed."); - } - - /** start the resolution of a service */ - public void resolve (String serviceName, String regType, String domain) { - try { - resolve = DNSSD.resolve(0, 0, serviceName, regType, domain, this); - } catch (DNSSDException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** stop this resolver */ - public void stop () { - resolve.stop(); - System.out.println ("Resolver stopped."); - } -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/EasyListener.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/EasyListener.java 2007-03-04 10:28:07 UTC (rev 50) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/EasyListener.java 2007-03-04 10:30:20 UTC (rev 51) @@ -1,74 +0,0 @@ -package net.sf.trivial.easypaste; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.Map; -import java.util.TreeMap; - -import com.apple.dnssd.BrowseListener; -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; - -public class EasyListener implements BrowseListener, ResolveListener { - - private Map<String, Integer> buddies; - - public EasyListener () { - buddies = new TreeMap<String, Integer>(); - try { - DNSSD.browse("_easypaste._tcp", this); - } catch (DNSSDException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public void serviceFound(DNSSDService browser, int flags, int ifIndex, java.lang.String serviceName, java.lang.String regType, java.lang.String domain) { - try { - DNSSD.resolve(flags, ifIndex, serviceName, regType, domain, this); - } catch (DNSSDException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public void serviceLost(DNSSDService browser, int flags, int ifIndex, java.lang.String serviceName, java.lang.String regType, java.lang.String domain) { - //buddies.remove(serviceName); - // TODO remove - //System.out.println(serviceName); - } - - public void operationFailed(DNSSDService arg0, int arg1) { - // TODO Auto-generated method stub - - } - - public void serviceResolved(DNSSDService resolver, int flags, int ifIndex, java.lang.String fullName, java.lang.String hostName, int port, TXTRecord txtRecord) { - buddies.put(hostName, port); - } - public void sendString(String s) { - Socket skt; - OutputStreamWriter osw; - for (String hostName : buddies.keySet()) { - try { - skt = new Socket(hostName, buddies.get(hostName)); - osw = new OutputStreamWriter(skt.getOutputStream()); - osw.write(s); - osw.flush(); - osw.close(); - skt.close(); - } catch (UnknownHostException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } -} Added: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java (rev 0) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/ClipboardReaderImpl.java 2007-03-04 10:30:20 UTC (rev 51) @@ -0,0 +1,65 @@ +package net.sf.trivial.easypaste.internal.mac; + +import net.sf.trivial.easypaste.ClipboardReader; +import net.sf.trivial.easypaste.DistributedClipboard; + +import com.apple.cocoa.application.NSPasteboard; + +public class ClipboardReaderImpl implements ClipboardReader, Runnable { + + private boolean running; + private DistributedClipboard distributedClipboard; + + private NSPasteboard pasteboard; + +// private Growl growl; +// private final static String GROWL_NOTIFICATION = "clipboard update"; + + public ClipboardReaderImpl() { + pasteboard = NSPasteboard.generalPasteboard(); +// growl = new Growl("Easypaste", "logo.png"); +// NSMutableArray nsa = new NSMutableArray(); +// nsa.addObject(GROWL_NOTIFICATION); +// growl.setAllowedNotifications(nsa); +// try { +// growl.setDefaultNotifications(nsa); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// growl.register(); + running = false; + } + + public void run() { + assert (!running): "ClipboardReader already running."; + running = true; + while (running) { + int count = pasteboard.changeCount(); + while (count == pasteboard.changeCount()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + String content = pasteboard.stringForType("NSStringPboardType"); + distributedClipboard.setLocalContent(content); + } + } + + public void setDistributedClipboard(DistributedClipboard distributedClipboard) { + this.distributedClipboard = distributedClipboard; + } + + public void start() { + if (!running) { + new Thread(this, "ClipboardReader").start(); + } + } + + public void stop() { + running = false; + } +} Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/EasyController.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/EasyController.java 2007-03-04 10:28:07 UTC (rev 50) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/mac/EasyController.java 2007-03-04 10:30:20 UTC (rev 51) @@ -4,8 +4,7 @@ import net.sf.trivial.easypaste.ClipboardWriter; import net.sf.trivial.easypaste.DistributedClipboard; import net.sf.trivial.easypaste.NotificationService; -import net.sf.trivial.easypaste.java.DistributedClipboardImpl; -import net.sf.trivial.easypaste.mac.ClipboardReaderImpl; +import net.sf.trivial.easypaste.internal.pi.DistributedClipboardImpl; public class EasyController { Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PeerImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PeerImpl.java 2007-03-04 10:28:07 UTC (rev 50) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PeerImpl.java 2007-03-04 10:30:20 UTC (rev 51) @@ -1,45 +0,0 @@ -package net.sf.trivial.easypaste.presence; - -import java.net.InetAddress; - -/** - * Service, qualified by its name (e.g. Flebeleb), type (e.g. _flebeleb._tcp), - * domain (e.g. local.), hostName (e.g. xrb.local.) and port (e.g. 11111) - * - * @author pajai - */ -public class PeerImpl implements Peer { - - /* attributes got from the browse operation */ - private final String name; - private final String type; - private final String domain; - - /* attributes got from the resolve operation */ - private final InetAddress address; - private final int port; - - public PeerImpl (String name, String type, String domain, InetAddress address, int port) { - this.name = name; - this.type = type; - this.domain = domain; - this.address = address; - this.port = port; - } - - public InetAddress getAddress() { - return address; - } - - public int getPort() { - return port; - } - - public String getName() { - return name; - } - - public String toString () { - return name + " " + type + " " + domain + " " + address + ":" + String.valueOf(port); - } -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceProvider.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceProvider.java 2007-03-04 10:28:07 UTC (rev 50) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/PresenceProvider.java 2007-03-04 10:30:20 UTC (rev 51) @@ -1,9 +0,0 @@ -package net.sf.trivial.easypaste.presence; - -import java.util.Collection; - -public interface PresenceProvider { - - public Collection<Peer> getPeers(); - -} Deleted: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/ServiceRegistry.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/ServiceRegistry.java 2007-03-04 10:28:07 UTC (rev 50) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/presence/ServiceRegistry.java 2007-03-04 10:30:20 UTC (rev 51) @@ -1,66 +0,0 @@ -package net.sf.trivial.easypaste.presence; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; - - -/** - * Registry for existing services - * - * @author pajai - */ -public class ServiceRegistry implements PresenceProvider { - - /** service map */ - HashMap<String,Peer> services = new HashMap<String,Peer>(); - - /** store instance */ - static private ServiceRegistry instance; - - private ServiceRegistry () {} - - /** get instance of this singlet class */ - public static synchronized ServiceRegistry getInstance () { - if (instance == null) - instance = new ServiceRegistry (); - - return instance; - } - - /** - * Register a service - */ - public synchronized void register (PeerImpl service) { - services.put(service.getName(), service); - } - - /** - * Test if a service is already registered - */ - public synchronized boolean isRegistered (String name) { - return services.containsKey(name); - } - - /** - * Unregister a service, using its service name - */ - public synchronized void unregister (String name) { - if (services.containsKey(name)) - services.remove(name); - } - - /** - * Print registered services - */ - public synchronized void printList () { - System.out.println ("Registered services:"); - for (Iterator it = services.values().iterator(); it.hasNext(); ) { - System.out.println ( ((PeerImpl)it.next()).toString() ); - } - } - - public Collection<Peer> getPeers() { - return services.values(); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 10:28:07
|
Revision: 50 http://trivial.svn.sourceforge.net/trivial/?rev=50&view=rev Author: jlgeering Date: 2007-03-04 02:28:07 -0800 (Sun, 04 Mar 2007) Log Message: ----------- ClipboardReader throws Exceptions Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/ClipboardReader.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/ClipboardReader.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/ClipboardReader.java 2007-03-04 10:26:43 UTC (rev 49) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/ClipboardReader.java 2007-03-04 10:28:07 UTC (rev 50) @@ -3,7 +3,7 @@ public interface ClipboardReader { void setDistributedClipboard(DistributedClipboard distributedClipboard); - void start(); - void stop(); + void start() throws InterruptedException; + void stop() throws InterruptedException; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jlg...@us...> - 2007-03-04 10:26:42
|
Revision: 49 http://trivial.svn.sourceforge.net/trivial/?rev=49&view=rev Author: jlgeering Date: 2007-03-04 02:26:43 -0800 (Sun, 04 Mar 2007) Log Message: ----------- DistributedClipboard set notification Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/DistributedClipboard.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/DistributedClipboard.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/DistributedClipboard.java 2007-03-04 10:10:41 UTC (rev 48) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/DistributedClipboard.java 2007-03-04 10:26:43 UTC (rev 49) @@ -4,6 +4,6 @@ void setLocalContent(String content); - void setClipboardWriter(ClipboardWriter w); - + void setClipboardWriter(ClipboardWriter cw); + void setNotificationService(NotificationService ns); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |