diff options
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java | 17 | ||||
-rw-r--r-- | sd/source/ui/remotecontrol/DiscoveryService.cxx | 14 |
2 files changed, 20 insertions, 11 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java index b8ba315c4f76..5ce7897e2d0c 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java @@ -39,7 +39,7 @@ public class ServerFinder { try { String aCommand = null; - String aAddress = null; + String aName = null; System.out.println("SF:listening for packet\n"); mSocket.receive(aPacket); System.out.println("SF:received packet\n"); @@ -53,11 +53,24 @@ public class ServerFinder { if (i == aBuffer.length || !aCommand.equals("LOREMOTE_ADVERTISE")) { return; } + for (int j = i; j < aBuffer.length; j++) { + if (aPacket.getData()[i] == '\n') { + aName = new String(aPacket.getData(), i + 1, j, CHARSET); + break; + } + } + if (aName == null) { + return; + } Server aServer = new Server(CommunicationService.Protocol.NETWORK, - aPacket.getAddress().toString(), "NONAME", + aPacket.getAddress().toString(), aName, System.currentTimeMillis()); mServerList.add(aServer); + // System.out.println("SF FOUND: IP=" + // + aPacket.getAddress().toString() + " HOSTNAME=" + // + aName); + Intent aIntent = new Intent( CommunicationService.MSG_SERVERLIST_CHANGED); LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent); diff --git a/sd/source/ui/remotecontrol/DiscoveryService.cxx b/sd/source/ui/remotecontrol/DiscoveryService.cxx index bc514d7d3835..f482158a6633 100644 --- a/sd/source/ui/remotecontrol/DiscoveryService.cxx +++ b/sd/source/ui/remotecontrol/DiscoveryService.cxx @@ -60,15 +60,11 @@ DiscoveryService::~DiscoveryService() void DiscoveryService::replyTo( sockaddr_in& rAddr ) { -// SocketAddr aLocalAddr; -// mSocket.getLocalAddr( aLocalAddr ); -// OString aAddrString = OUStringToOString( aLocalAddr.getHostname(), -// RTL_TEXTENCODING_UTF8 ); -// OStringBuffer aBuffer( "LOREMOTE_ADVERTISE\n" ); -// aBuffer.append( aAddrString ).append( "\n" ); -// mSocket.sendTo( rAddr, aBuffer.getStr(), aBuffer.getLength() ); - OString aMessage("LOREMOTE_ADVERTISE\n"); - sendto( mSocket, aMessage.getStr(), aMessage.getLength(), 0, (sockaddr*) &rAddr, sizeof(rAddr) ); + OStringBuffer aBuffer("LOREMOTE_ADVERTISE\n"); + aBuffer.append( OUStringToOString( osl::SocketAddr::getLocalHostname(), + RTL_TEXTENCODING_UTF8 ) ).append( "\n\n" ); + sendto( mSocket, aBuffer.getStr(), aBuffer.getLength(), 0, + (sockaddr*) &rAddr, sizeof(rAddr) ); } void DiscoveryService::execute() |