summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2012-08-02 16:11:06 +0200
committerMichael Meeks <michael.meeks@suse.com>2012-08-06 10:23:08 +0100
commit341f89ec308bd5a66a36741d22f100721d8223de (patch)
tree1e0f279550384817a31df246b57a8524f11179d5
parente43e36facc93b9e27e4d8757124ca0e6fcd9396b (diff)
Early non-functional multicast code.
Change-Id: Id982b40e5e9df4dee037a2e54ed34206930123c9
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/TestClient.java3
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java2
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java104
-rw-r--r--sd/source/ui/remotecontrol/DiscoveryService.cxx9
-rw-r--r--sd/source/ui/remotecontrol/ImagePreparer.cxx2
5 files changed, 118 insertions, 2 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/TestClient.java b/android/sdremote/src/org/libreoffice/impressremote/TestClient.java
index ee8c57b68b96..dc74cd527f65 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/TestClient.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/TestClient.java
@@ -85,7 +85,8 @@ public class TestClient extends Activity {
mCommunicationService = ((CommunicationService.CBinder) aService)
.getService();
mCommunicationService.connectTo(
- CommunicationService.Protocol.NETWORK, "10.0.2.2");
+ CommunicationService.Protocol.NETWORK,
+ "192.168.0.18");
mCommunicationService.setActivityMessenger(mMessenger);
enableButtons(true);
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
index 258bff1b26be..e1669cc8497c 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
@@ -55,6 +55,8 @@ public class CommunicationService extends Service {
@Override
public void onCreate() {
// TODO Create a notification (if configured).
+ ServerFinder aFinder = new ServerFinder();
+ aFinder.startFinding();
}
@Override
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java
new file mode 100644
index 000000000000..d787e3478f1c
--- /dev/null
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java
@@ -0,0 +1,104 @@
+package org.libreoffice.impressremote.communication;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.SocketException;
+
+public class ServerFinder {
+
+ private static final int PORT = 1598;
+ private static final String CHARSET = "UTF-8";
+
+ private DatagramSocket mSocket = null;
+
+ private Thread mListenerThread = null;
+
+ public ServerFinder() {
+
+ }
+
+ private void listenForServer() {
+ byte[] aBuffer = new byte[500];
+ DatagramPacket aPacket = new DatagramPacket(aBuffer, aBuffer.length);
+
+ try {
+ String aCommand = null;
+ String aAddress = null;
+ System.out.println("SF:listening for packet\n");
+ mSocket.receive(aPacket);
+ System.out.println("SF:received packet\n");
+ int i;
+ for (i = 0; i < aBuffer.length; i++) {
+ if (aPacket.getData()[i] == '\n') {
+ aCommand = new String(aPacket.getData(), 0, i, CHARSET);
+ break;
+ }
+ }
+ if (i == aBuffer.length || !aCommand.equals("LOREMOTE_ADVERTISE")) {
+ return;
+ }
+
+ for (int j = i + 1; j < aBuffer.length; j++) {
+ if (aPacket.getData()[j] == '\n') {
+ aAddress = new String(aPacket.getData(), i + 1, j, CHARSET);
+ }
+ }
+
+ if (aAddress != null) {
+ System.out.println("Address is :" + aAddress + "\n");
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ public void startFinding() {
+ if (mSocket != null)
+ return;
+
+ if (mListenerThread == null) {
+ mListenerThread = new Thread() {
+ @Override
+ public void run() {
+ try {
+ mSocket = new DatagramSocket();
+ String aString = "LOREMOTE_SEARCH\n";
+ DatagramPacket aPacket = new DatagramPacket(
+ aString.getBytes(CHARSET),
+ aString.length(),
+ InetAddress.getByName("239.0.0.1"),
+ PORT);
+ mSocket.send(aPacket);
+ System.out.println("SF:sent packet\n");
+ while (true) {
+ listenForServer();
+ }
+ } catch (SocketException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ };
+ mListenerThread.start();
+ }
+
+ }
+
+ public void stopFinding() {
+ if (mListenerThread != null) {
+
+ }
+ }
+}
diff --git a/sd/source/ui/remotecontrol/DiscoveryService.cxx b/sd/source/ui/remotecontrol/DiscoveryService.cxx
index 1ded965bcdf2..2d2b3672079b 100644
--- a/sd/source/ui/remotecontrol/DiscoveryService.cxx
+++ b/sd/source/ui/remotecontrol/DiscoveryService.cxx
@@ -45,15 +45,24 @@ void DiscoveryService::replyTo( SocketAddr& rAddr )
void DiscoveryService::execute()
{
+ fprintf( stderr, "Discovery service is listening\n" );;
sal_uInt64 aRet, aRead;
vector<char> aBuffer;
aRead = 0;
+
+
+ SocketAddr aListenAddr( "239.0.0.1", PORT_DISCOVERY );
+ mSocket.bind( aListenAddr );
+
SocketAddr aAddr;
while ( true )
{
aBuffer.resize( aRead + 100 );
+
+ fprintf( stderr, "DiscoveryService waiting for packet\n" );
aRet = mSocket.recvFrom( &aBuffer[aRead], 100 );
+ fprintf( stderr, "DiscoveryService received a packet.\n" );
if ( aRet == 0 )
{
fprintf( stderr, "Socket returned 0\n" );
diff --git a/sd/source/ui/remotecontrol/ImagePreparer.cxx b/sd/source/ui/remotecontrol/ImagePreparer.cxx
index f948834fbb03..defc8637f52f 100644
--- a/sd/source/ui/remotecontrol/ImagePreparer.cxx
+++ b/sd/source/ui/remotecontrol/ImagePreparer.cxx
@@ -88,7 +88,7 @@ void ImagePreparer::execute()
}
sendNotes( i );
}
- notesToHtml( 0 );
+// notesToHtml( 0 );
mRef.clear();
}