Initial checkin of remote control.

Change-Id: I71ac6c302c963dd2f8cffdcdf80d58c2a1074695
This commit is contained in:
Andrzej J. R. Hunt
2012-08-06 10:21:48 +01:00
committed by Michael Meeks
parent 591395a832
commit e4239e0414
8 changed files with 310 additions and 0 deletions
+1
View File
@@ -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@
+7
View File
@@ -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 \
+75
View File
@@ -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;
};
}
+36
View File
@@ -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
@@ -0,0 +1,18 @@
#include "RemoteDialog.hxx"
RemoteDialog::RemoteDialog()
{
}
RemoteDialog::~RemoteDialog()
{
}
@@ -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;
};
}
}
+102
View File
@@ -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;
// }
// }
+49
View File
@@ -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