Added first version of RPC system for external control of retroshare-nogui.

The protocol message format is as follows: 
	[HEADER: 16 bytes: 4 x Network Order uint32_t][ VARIABLE LENGTH BODY ] 

	[ MAGIC_CODE ] [ MSG_ID ] [ REQ_ID ] [ BODY_SIZE ] [ ........ BODY ......... ]
	MagicCode = 0x137f0001 ... this will be incremented for new versions of the protocol.
 	MsgID = Corresponds to the format of the Body.
	ReqID = Generated by Requester, Returned in Response, make sure its unique. (undefined behaviour for duplicates)
        BodySize = Byte Length of Body.

	The Body will consist of a protobuf encoded message.

For the moment, the RPC server just ECHOs the request back to the sender - for testing purposes.

Usage:
 * Create SSH connection to retroshare-nogui.
 * Create Request Message(s), and send over SSH channel - You can send as meny requests as you want. 
 * They will processed, and responses sent back (potentially in an arbitary order).

Specific Changes here:
 * Modified rssshd to support arbitary recv/send applications. (interface is RpcComms).
 * Added rpc directory, with server, setup and echo service.
 * Modified Menu System to use the new interface to rssshd 
 * Wrote new matching interface for Terminal Usage.
	- NOTE: Strange BUG in Terminal version.... causes stderr to disappear. TODO.
 * Added -C commandline option to switch on RPC system.

This is the first version - so I expect there will be bugs. Please report for a prompt fix!



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5444 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-08-20 14:59:41 +00:00
parent c17460d1b1
commit bb10b6b400
20 changed files with 1612 additions and 72 deletions

View file

@ -1,3 +1,28 @@
/*
* RetroShare External Interface.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef RSNOGUI_MENU_H
#define RSNOGUI_MENU_H
@ -7,7 +32,7 @@
#include <map>
#include <list>
#include "rstermserver.h" // generic processing command.
#include "rpcsystem.h" // generic processing command.
#define MENU_PROCESS_MASK 0x0fff
@ -172,7 +197,7 @@ protected:
};
#if 0
class MenuInterface: public RsTermServer
{
public:
@ -193,5 +218,32 @@ private:
bool mInputRequired;
};
#endif
class MenuInterface: public RpcSystem
{
public:
MenuInterface(RpcComms *c, Menu *b, uint32_t drawFlags)
:mComms(c), mCurrentMenu(b), mBase(b), mDrawFlags(drawFlags), mInputRequired(false) { return; }
uint32_t process(char key, uint32_t drawFlags, std::string &buffer);
uint32_t drawHeader(uint32_t drawFlags, std::string &buffer);
// RsSystem Interface.
virtual void reset();
virtual int tick();
private:
RpcComms *mComms;
Menu *mCurrentMenu;
Menu *mBase;
uint32_t mDrawFlags;
bool mInputRequired;
time_t mUpdateTime;
};
#endif