summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java280
-rwxr-xr-xdesktop/source/app/sofficemain.cxx1
-rw-r--r--sd/Library_sd.mk6
-rw-r--r--sd/source/ui/remotecontrol/Server.cxx5
4 files changed, 150 insertions, 142 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java
index 5b1b33462925..29ae7de98286 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java
@@ -16,141 +16,147 @@ import android.support.v4.content.LocalBroadcastManager;
public class ServerFinder {
- private Context mContext;
-
- private static final int PORT = 1598;
- private static final String CHARSET = "UTF-8";
-
- private static final long SEARCH_INTERVAL = 1000 * 20;
-
- private DatagramSocket mSocket = null;
-
- private Thread mListenerThread = null;
-
- private boolean mFinishRequested = false;
-
- private HashMap<String, Server> mServerList = new HashMap<String, Server>();
-
- public ServerFinder(Context aContext) {
- mContext = aContext;
- }
-
- private void listenForServer() {
- byte[] aBuffer = new byte[500];
- DatagramPacket aPacket = new DatagramPacket(aBuffer, aBuffer.length);
-
- try {
- String aCommand = null;
- String aName = null;
- mSocket.receive(aPacket);
- 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; 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(), aName,
- System.currentTimeMillis());
- mServerList.put(aServer.getAddress(), 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);
-
- } catch (java.net.SocketTimeoutException e) {
- // Ignore -- we want to timeout to enable checking whether we
- // should stop listening periodically
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- public void startFinding() {
- if (mSocket != null)
- return;
-
- mFinishRequested = false;
-
- if (mListenerThread == null) {
- mListenerThread = new Thread() {
- @Override
- public void run() {
- long aTime = 0;
- try {
- mSocket = new DatagramSocket();
- mSocket.setSoTimeout(1000 * 10);
- while (!mFinishRequested) {
- if (System.currentTimeMillis() - aTime > SEARCH_INTERVAL) {
- String aString = "LOREMOTE_SEARCH\n";
- DatagramPacket aPacket = new DatagramPacket(
- aString.getBytes(CHARSET),
- aString.length(),
- InetAddress.getByName("239.0.0.1"),
- PORT);
- mSocket.send(aPacket);
- aTime = System.currentTimeMillis();
- for (Server aServer : mServerList.values()) {
- if (System.currentTimeMillis()
- - aServer.getTimeDiscovered() > 60 * 1000) {
- mServerList.remove(aServer.getAddress());
- Intent aIntent = new Intent(
- CommunicationService.MSG_SERVERLIST_CHANGED);
- LocalBroadcastManager.getInstance(
- mContext)
- .sendBroadcast(aIntent);
-
- }
- }
- }
-
- 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) {
- mFinishRequested = true;
- mListenerThread = null;
- }
- }
-
- public Server[] getServerList() {
- return mServerList.values().toArray(new Server[mServerList.size()]);
- }
+ private Context mContext;
+
+ private static final int PORT = 1598;
+ private static final String GROUPADDRESS = "239.0.0.1";
+
+ private static final String CHARSET = "UTF-8";
+
+ private static final long SEARCH_INTERVAL = 1000 * 20;
+
+ private DatagramSocket mSocket = null;
+
+ private Thread mListenerThread = null;
+
+ private boolean mFinishRequested = false;
+
+ private HashMap<String, Server> mServerList = new HashMap<String, Server>();
+
+ public ServerFinder(Context aContext) {
+ mContext = aContext;
+ }
+
+ private void listenForServer() {
+ byte[] aBuffer = new byte[500];
+ DatagramPacket aPacket = new DatagramPacket(aBuffer, aBuffer.length);
+
+ try {
+ String aCommand = null;
+ String aName = null;
+ System.out.println("SF:Reading");
+ mSocket.receive(aPacket);
+ System.out.println("SF:Received");
+ 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; 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(), aName,
+ System.currentTimeMillis());
+ mServerList.put(aServer.getAddress(), 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);
+
+ } catch (java.net.SocketTimeoutException e) {
+ // Ignore -- we want to timeout to enable checking whether we
+ // should stop listening periodically
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ public void startFinding() {
+ if (mSocket != null)
+ return;
+
+ mFinishRequested = false;
+
+ if (mListenerThread == null) {
+ mListenerThread = new Thread() {
+ @Override
+ public void run() {
+ long aTime = 0;
+ try {
+ mSocket = new DatagramSocket();
+ mSocket.setSoTimeout(1000 * 10);
+ while (!mFinishRequested) {
+ System.out.println("SF:Looping");
+ if (System.currentTimeMillis() - aTime > SEARCH_INTERVAL) {
+ System.out.println("SF:Sending");
+ String aString = "LOREMOTE_SEARCH\n";
+ DatagramPacket aPacket = new DatagramPacket(
+ aString.getBytes(CHARSET),
+ aString.length(),
+ InetAddress.getByName(GROUPADDRESS),
+ PORT);
+ mSocket.send(aPacket);
+ aTime = System.currentTimeMillis();
+ for (Server aServer : mServerList.values()) {
+ if (System.currentTimeMillis()
+ - aServer.getTimeDiscovered() > 60 * 1000) {
+ mServerList.remove(aServer.getAddress());
+ Intent aIntent = new Intent(
+ CommunicationService.MSG_SERVERLIST_CHANGED);
+ LocalBroadcastManager.getInstance(
+ mContext)
+ .sendBroadcast(aIntent);
+
+ }
+ }
+ }
+
+ 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) {
+ mFinishRequested = true;
+ mListenerThread = null;
+ }
+ }
+
+ public Server[] getServerList() {
+ return mServerList.values().toArray(new Server[mServerList.size()]);
+ }
}
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index 20059396f442..a0fba044922e 100755
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -99,6 +99,7 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main()
#endif
throw; // to get exception type printed
}
+#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
index 8737ba0273e1..ca00b1987963 100644
--- a/sd/Library_sd.mk
+++ b/sd/Library_sd.mk
@@ -35,7 +35,6 @@ $(eval $(call gb_SdiTarget_set_include,sd/sdi/sdslots,\
$$(INCLUDE) \
))
-
$(eval $(call gb_SdiTarget_SdiTarget,sd/sdi/sdgslots,sd/sdi/sdgslots))
$(eval $(call gb_SdiTarget_set_include,sd/sdi/sdgslots,\
@@ -61,6 +60,10 @@ $(eval $(call gb_Library_set_include,sd,\
-I$(WORKDIR)/SdiTarget/sd/sdi \
))
+$(eval $(call gb_Library_use_externals,sd,\
+ libxml2 \
+))
+
$(eval $(call gb_Library_add_defs,sd,\
-DSD_DLLIMPLEMENTATION \
))
@@ -102,6 +105,7 @@ $(eval $(call gb_Library_use_libraries,sd,\
ucbhelper \
utl \
vcl \
+ xmlsecurity \
$(gb_STDLIBS) \
))
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index 372103e16328..8371728a1323 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -58,9 +58,6 @@ void RemoteServer::listenThread()
{
}
-
- // TODO: decryption
-
sal_uInt64 aRet, aRead;
vector<char> aBuffer;
vector<OString> aCommand;
@@ -86,7 +83,7 @@ void RemoteServer::listenThread()
aReceiver.parseCommand( aCommand );
aCommand.clear();
}
- aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the newline
+ aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the empty line
aRead -= (aLocation + 1);
}
}