summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej J. R. Hunt <andrzej@ahunt.org>2012-07-09 10:57:32 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-08-06 10:21:48 +0100
commite4239e0414685f8d8dd2f34fcc970717c7bd6cb8 (patch)
treee5b6740484cd68eba1481b09551a0ad78ad3518d
parent591395a832aba635f9c8cf4e71a3558f14f41a37 (diff)
Initial checkin of remote control.
Change-Id: I71ac6c302c963dd2f8cffdcdf80d58c2a1074695
-rw-r--r--config_host.mk.in1
-rw-r--r--sd/Library_sd.mk7
-rw-r--r--sd/source/ui/remotecontrol/Receiver.cxx75
-rw-r--r--sd/source/ui/remotecontrol/Receiver.hxx36
-rw-r--r--sd/source/ui/remotecontrol/RemoteDialog.cxx18
-rw-r--r--sd/source/ui/remotecontrol/RemoteDialog.hxx22
-rw-r--r--sd/source/ui/remotecontrol/Server.cxx102
-rw-r--r--sd/source/ui/remotecontrol/Server.hxx49
8 files changed, 310 insertions, 0 deletions
diff --git a/config_host.mk.in b/config_host.mk.in
index 692601240268..86424ef87d46 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -276,6 +276,7 @@ export LIBEXTTEXTCAT_CFLAGS=@LIBEXTTEXTCAT_CFLAGS@
export LIBEXTTEXTCAT_LIBS=@LIBEXTTEXTCAT_LIBS@
export LIBFONTS_JAR=@LIBFONTS_JAR@
export LIBFORMULA_JAR=@LIBFORMULA_JAR@
+export LIBJSON=@LIBJSON@
export LIBLAYOUT_JAR=@LIBLAYOUT_JAR@
export LIBLOADER_JAR=@LIBLOADER_JAR@
export LIBMGR_X64_BINARY=@LIBMGR_X64_BINARY@
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
index 07b85ea726fd..a61de772776f 100644
--- a/sd/Library_sd.mk
+++ b/sd/Library_sd.mk
@@ -27,6 +27,10 @@
$(eval $(call gb_Library_Library,sd))
+$(eval $(call gb_Library_use_externals,sd,\
+ gtk \
+))
+
$(eval $(call gb_SdiTarget_SdiTarget,sd/sdi/sdslots,sd/sdi/sdslots))
$(eval $(call gb_SdiTarget_set_include,sd/sdi/sdslots,\
@@ -35,6 +39,7 @@ $(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,\
@@ -316,6 +321,8 @@ $(eval $(call gb_Library_add_exception_objects,sd,\
sd/source/ui/presenter/PresenterPreviewCache \
sd/source/ui/presenter/PresenterTextView \
sd/source/ui/presenter/SlideRenderer \
+ sd/source/ui/remotecontrol/Server \
+ sd/source/ui/remotecontrol/Receiver \
sd/source/ui/slideshow/PaneHider \
sd/source/ui/slideshow/SlideShowRestarter \
sd/source/ui/slideshow/showwin \
diff --git a/sd/source/ui/remotecontrol/Receiver.cxx b/sd/source/ui/remotecontrol/Receiver.cxx
new file mode 100644
index 000000000000..c77cc5479d35
--- /dev/null
+++ b/sd/source/ui/remotecontrol/Receiver.cxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2012 Andrzej J.R. Hunt
+ *
+ * LibreOffice - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * LibreOffice is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * Libreoffice is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with LibreOffice. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "Receiver.hxx"
+
+Receiver::Receiver()
+{
+ g_type_init ();
+}
+
+Receiver::~Receiver()
+{
+
+
+}
+
+void Receiver::parseCommand(char* aCommand, XSlideShowController *aController)
+{
+
+
+ JsonParser *parser;
+ JsonNode *root;
+ GError *error;
+
+ parser = json_parser_new ();
+ error = NULL;
+ json_parser_load_from_data( parser, aCommand, aCommand.size, error );
+
+ if (error) {
+
+ }
+
+ root = json_parser_get_root( parser );
+ JsonObject *aObject = json_node_get_object( root );
+ char* aInstruction = json_node_get_string( json_object_get_member( "command" ) );
+
+ switch ( aInstruction )
+ {
+ case "transition_next":
+ aController->gotoNextEffect();
+ // Next slide;
+ break;
+ case "transition_previous":
+ aController->gotoPreviousEffect();
+ break;
+ case "goto_slide":
+ //
+ break;
+ };
+
+
+} \ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/Receiver.hxx b/sd/source/ui/remotecontrol/Receiver.hxx
new file mode 100644
index 000000000000..78dbb0dd99f0
--- /dev/null
+++ b/sd/source/ui/remotecontrol/Receiver.hxx
@@ -0,0 +1,36 @@
+
+#ifndef _SD_IMPRESSREMOTE_RECEIVER_HXX
+#define _SD_IMPRESSREMOTE_RECEIVER_HXX
+
+#include <com/sun/star/presentation/XSlideShowController.hpp>
+
+
+
+#include <stdlib.h>
+#include <glib-object.h>
+#include <json-glib/json-glib.h>
+
+// Library_sd.mk:
+// $(eval $(call gb_Library_use_externals,sd,\
+// gobject \
+// ))
+
+
+namespace sd
+{
+
+class Receiver
+{
+public:
+ Receiver();
+ ~Receiver();
+ void parseCommand(char* aCommand, XSlideShowController *aController);
+
+private:
+
+
+}
+
+}
+
+#endif // _SD_IMPRESSREMOTE_RECEIVER_HXX \ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/RemoteDialog.cxx b/sd/source/ui/remotecontrol/RemoteDialog.cxx
new file mode 100644
index 000000000000..9c1deddcded6
--- /dev/null
+++ b/sd/source/ui/remotecontrol/RemoteDialog.cxx
@@ -0,0 +1,18 @@
+#include "RemoteDialog.hxx"
+
+
+RemoteDialog::RemoteDialog()
+{
+
+
+
+
+}
+
+RemoteDialog::~RemoteDialog()
+{
+
+
+
+}
+
diff --git a/sd/source/ui/remotecontrol/RemoteDialog.hxx b/sd/source/ui/remotecontrol/RemoteDialog.hxx
new file mode 100644
index 000000000000..80f5c34b352d
--- /dev/null
+++ b/sd/source/ui/remotecontrol/RemoteDialog.hxx
@@ -0,0 +1,22 @@
+// SERVER
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "Server.hxx"
+
+namespace sd
+{
+ namespace remotecontrol
+ {
+ class RemoteDialog
+ {
+ public:
+ RemoteDialog();
+ ~RemoteDialog();
+
+ private:
+
+ //int mSocket;
+ };
+ }
+} \ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
new file mode 100644
index 000000000000..345ea036208f
--- /dev/null
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -0,0 +1,102 @@
+
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <vector>
+
+#include "Server.hxx"
+#include "Receiver.hxx"
+
+
+
+
+#include <boost/thread.hpp>
+using namespace std;
+using namespace sd::remotecontrol;
+
+Server::Server(char* aEncryptionKey, XSlideShowController aController)
+: mReceiver()
+{
+ if ( (mSocket = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ {
+ // Error opening
+ }
+
+ sockaddr_in aAddress;
+ aAddress.sin_family = AF_INET;
+ aAddress.sin_port = htons(PORT);
+ aAddress.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ if ( bind( mSocket, (struct sockaddr*) &aAddress, sizeof(aAddress) ) == -1 )
+ {
+ // Error binding
+ }
+
+ if ( listen ( mSocket, 3 ) == -1 )
+ {
+ // Error listening
+ }
+ while (true)
+ {
+ mNewSocket = accept( mSocket, (struct sockaddr*) &aAddress, (socklen_t*) &aAddrLen );
+ boost::thread t( boost::bind(&Server::listenThread, this ))
+ }
+ // TODO: pass mNewSocket to the thread.
+}
+
+Server::~Server()
+{
+
+
+
+}
+
+// Run as a thread
+void Server::listenThread()
+{
+ char aTemp;
+ vector<char> aBuffer();
+ while (true)
+ {
+ int aLength;
+ while ( recv( mSocket, *aTemp, 1, 0) && aTemp != 0x0d ) // look for newline
+ {
+ aBuffer.push_back( aTemp );
+ // TODO: decryption
+ }
+ OUString aLengthString = OUString( aBuffer.front(), aBuffer.size(), RTL_TEXTENCODING_UNICODE );
+ const sal_Char* aLengthChar = aLengthString.convertToString( *aCLength, RTL_TEXTENCODING_ASCII_US, 0).getStr();
+
+ sal_uInt32 aLen = strtol( aLengthChar, NULL, 10);
+
+ char *aMessage = new char[aLen];
+ recv( mSocket, *aMessage, aLen, 0);
+ // Parse.
+ mReceiver.parseCommand( aCommand );
+
+ delete [] aMessage;
+ // TODO: deal with transmision errors gracefully.
+ }
+
+}
+
+
+// void Server::clientConnected()
+// {
+// our_mServerList.insert( our_mServerList.end, new Server() );
+// thread aThread = Boost::thread( listen );
+//
+// }
+//
+// void Server::clientDisconnected()
+// {
+// our_mServerList::iterator aBegin = our_mServerList.begin;
+// while ( *aBegin != this ) {
+// aBegin++;
+// }
+// if ( *aBegin == this )
+// {
+// our_mServerList.erase( this );
+// delete this;
+// }
+// } \ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/Server.hxx b/sd/source/ui/remotecontrol/Server.hxx
new file mode 100644
index 000000000000..6826e344bbb4
--- /dev/null
+++ b/sd/source/ui/remotecontrol/Server.hxx
@@ -0,0 +1,49 @@
+
+#ifndef _SD_IMPRESSREMOTE_SERVER_HXX
+#define _SD_IMPRESSREMOTE_SERVER_HXX
+
+// SERVER
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+//#include <com/sun/star/presentation/AnimationEffect.hpp>
+
+
+/**
+* The port for use for the main communication between LibO and remote control app.
+*/
+#define PORT 1599
+
+
+class XSlideShowController;
+
+class Receiver;
+
+namespace sd
+{
+
+ class Server
+ {
+ public:
+ Server();
+ ~Server();
+ void setPresentationController( XSlideShowController aController) { mController = aController; }
+
+ private:
+ int mSocket;
+// static vector<Server> our_mServerList;
+
+ void listen();
+
+ Receiver mReceiver;
+// Transmitter mTransmitter;
+ };
+ }
+}
+
+#endif // _SD_IMPRESSREMOTE_SERVER_HXX \ No newline at end of file