2007-11-14 22:18:48 -05:00
|
|
|
#ifndef MRK_P3RS_INTERFACE_H
|
|
|
|
#define MRK_P3RS_INTERFACE_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "$Id: p3face.h,v 1.9 2007-05-05 16:10:06 rmf24 Exp $"
|
|
|
|
*
|
|
|
|
* RetroShare C++ Interface.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2006 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 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".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-11-02 06:38:11 -05:00
|
|
|
//#include "server/filedexserver.h"
|
2008-11-09 17:17:20 -05:00
|
|
|
#include "ft/ftserver.h"
|
2008-01-25 02:58:29 -05:00
|
|
|
//#include "pqi/pqissl.h"
|
|
|
|
|
2008-02-07 11:18:34 -05:00
|
|
|
#include "pqi/p3cfgmgr.h"
|
2008-01-25 02:58:29 -05:00
|
|
|
#include "pqi/p3connmgr.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "pqi/pqipersongrp.h"
|
|
|
|
|
|
|
|
#include "rsiface/rsiface.h"
|
|
|
|
#include "rsiface/rstypes.h"
|
|
|
|
#include "util/rsthreads.h"
|
|
|
|
|
2008-02-04 12:55:13 -05:00
|
|
|
#include "services/p3disc.h"
|
2008-01-25 02:58:29 -05:00
|
|
|
#include "services/p3msgservice.h"
|
2008-02-04 12:55:13 -05:00
|
|
|
#include "services/p3chatservice.h"
|
2008-02-05 08:45:04 -05:00
|
|
|
#include "services/p3ranking.h"
|
2008-06-04 06:59:24 -04:00
|
|
|
#include "services/p3Qblog.h"
|
2010-02-03 17:53:35 -05:00
|
|
|
#include "services/p3blogs.h"
|
2010-04-15 06:47:48 -04:00
|
|
|
#include "services/p3statusservice.h"
|
2010-02-03 17:53:35 -05:00
|
|
|
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* The Main Interface Class - for controlling the server */
|
|
|
|
|
|
|
|
/* The init functions are actually Defined in p3face-startup.cc
|
|
|
|
*/
|
2009-02-08 09:30:28 -05:00
|
|
|
//RsInit *InitRsConfig();
|
|
|
|
//void CleanupRsConfig(RsInit *);
|
|
|
|
//int InitRetroShare(int argc, char **argv, RsInit *config);
|
|
|
|
//int LoadCertificates(RsInit *config);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
RsControl *createRsControl(RsIface &iface, NotifyBase ¬ify);
|
|
|
|
|
|
|
|
|
|
|
|
class RsServer: public RsControl, public RsThread
|
|
|
|
{
|
|
|
|
public:
|
2009-02-08 09:30:28 -05:00
|
|
|
/****************************************/
|
|
|
|
/* p3face-startup.cc: init... */
|
|
|
|
virtual int StartupRetroShare();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
public:
|
2009-02-08 09:30:28 -05:00
|
|
|
/****************************************/
|
|
|
|
/* p3face.cc: main loop / util fns / locking. */
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
RsServer(RsIface &i, NotifyBase &callback);
|
|
|
|
virtual ~RsServer();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/* Thread Fn: Run the Core */
|
|
|
|
virtual void run();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-07-02 12:58:13 -04:00
|
|
|
public: // no longer private:!!!
|
2009-02-08 09:30:28 -05:00
|
|
|
/* locking stuff */
|
|
|
|
void lockRsCore()
|
|
|
|
{
|
|
|
|
// std::cerr << "RsServer::lockRsCore()" << std::endl;
|
|
|
|
coreMutex.lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void unlockRsCore()
|
|
|
|
{
|
|
|
|
// std::cerr << "RsServer::unlockRsCore()" << std::endl;
|
|
|
|
coreMutex.unlock();
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-07-02 12:58:13 -04:00
|
|
|
private:
|
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/* mutex */
|
|
|
|
RsMutex coreMutex;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/* General Internal Helper Functions
|
|
|
|
(Must be Locked)
|
|
|
|
*/
|
2008-01-25 02:58:29 -05:00
|
|
|
#if 0
|
2009-02-08 09:30:28 -05:00
|
|
|
cert *intFindCert(RsCertId id);
|
|
|
|
RsCertId intGetCertId(cert *c);
|
2008-01-25 02:58:29 -05:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/****************************************/
|
|
|
|
/****************************************/
|
|
|
|
/* p3face-msg Operations */
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
public:
|
2009-02-08 09:30:28 -05:00
|
|
|
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
|
|
|
|
virtual int SetInChat(std::string id, bool in); /* friend : chat msgs */
|
|
|
|
virtual int SetInMsg(std::string id, bool in); /* friend : msg receipients */
|
|
|
|
virtual int SetInBroadcast(std::string id, bool in); /* channel : channel broadcast */
|
|
|
|
virtual int SetInSubscribe(std::string id, bool in); /* channel : subscribed channels */
|
|
|
|
virtual int SetInRecommend(std::string id, bool in); /* file : recommended file */
|
|
|
|
virtual int ClearInChat();
|
|
|
|
virtual int ClearInMsg();
|
|
|
|
virtual int ClearInBroadcast();
|
|
|
|
virtual int ClearInSubscribe();
|
|
|
|
virtual int ClearInRecommend();
|
|
|
|
|
|
|
|
virtual bool IsInChat(std::string id); /* friend : chat msgs */
|
|
|
|
virtual bool IsInMsg(std::string id); /* friend : msg recpts*/
|
2008-02-04 12:55:13 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
std::list<std::string> mInChatList, mInMsgList;
|
|
|
|
|
|
|
|
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/****************************************/
|
|
|
|
/****************************************/
|
|
|
|
/****************************************/
|
|
|
|
/****************************************/
|
2008-07-02 12:58:13 -04:00
|
|
|
public:
|
2009-02-08 09:30:28 -05:00
|
|
|
/* Config */
|
2008-06-09 20:47:24 -04:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
virtual int ConfigGetDataRates(float &inKb, float &outKb);
|
2009-06-08 13:09:00 -04:00
|
|
|
virtual int ConfigSetDataRates( int totalDownload, int totalUpload );
|
2009-02-08 09:30:28 -05:00
|
|
|
virtual int ConfigSetBootPrompt( bool on );
|
2008-02-07 11:18:34 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
virtual void ConfigFinalSave( );
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/************* Rs shut down function: in upnp 'port lease time' bug *****************/
|
2008-04-06 16:56:27 -04:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/**
|
|
|
|
* This function is responsible for ensuring Retroshare exits in a legal state:
|
|
|
|
* i.e. releases all held resources and saves current configuration
|
|
|
|
*/
|
|
|
|
virtual void rsGlobalShutDown( );
|
2007-11-14 22:18:48 -05:00
|
|
|
private:
|
2009-02-08 09:30:28 -05:00
|
|
|
int UpdateAllConfig();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/****************************************/
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
// The real Server Parts.
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
//filedexserver *server;
|
|
|
|
ftServer *ftserver;
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
p3ConnectMgr *mConnMgr;
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
pqipersongrp *pqih;
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
//sslroot *sslr;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/* services */
|
|
|
|
p3disc *ad;
|
|
|
|
p3MsgService *msgSrv;
|
|
|
|
p3ChatService *chatSrv;
|
2010-04-15 06:47:48 -04:00
|
|
|
p3StatusService *mStatusSrv;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/* caches (that need ticking) */
|
|
|
|
p3Ranking *mRanking;
|
|
|
|
p3Qblog *mQblog;
|
2008-02-05 08:45:04 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/* Config */
|
|
|
|
p3ConfigMgr *mConfigMgr;
|
|
|
|
p3GeneralConfig *mGeneralConfig;
|
2008-02-07 11:18:34 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
// Worker Data.....
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Helper function to convert windows paths
|
|
|
|
* into unix (ie switch \ to /) for FLTK's file chooser
|
|
|
|
*/
|
|
|
|
|
|
|
|
std::string make_path_unix(std::string winpath);
|
|
|
|
|
|
|
|
#endif
|