2007-11-14 22:18:48 -05:00
# ifndef RETROSHARE_GUI_INTERFACE_H
# define RETROSHARE_GUI_INTERFACE_H
/*
* " $Id: rsiface.h,v 1.9 2007-04-21 19:08:51 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 " .
*
*/
# include "rstypes.h"
# include <map>
class NotifyBase ;
class RsControl ;
class RsInit ;
2013-06-28 17:47:25 -04:00
class RsPeerCryptoParams ;
2009-03-15 18:45:40 -04:00
struct TurtleFileInfo ;
2007-11-14 22:18:48 -05:00
/* declare single RsIface for everyone to use! */
extern RsControl * rsicontrol ;
/* RsInit -> Configuration Parameters for RetroShare Startup
*/
RsInit * InitRsConfig ( ) ;
2008-06-14 09:22:39 -04:00
/* extract various options for GUI */
2007-11-14 22:18:48 -05:00
const char * RsConfigDirectory ( RsInit * config ) ;
2008-06-14 09:22:39 -04:00
bool RsConfigStartMinimised ( RsInit * config ) ;
2007-11-14 22:18:48 -05:00
void CleanupRsConfig ( RsInit * ) ;
// Called First... (handles comandline options)
int InitRetroShare ( int argc , char * * argv , RsInit * config ) ;
// This Functions are used for Login.
bool ValidateCertificate ( RsInit * config , std : : string & userName ) ;
bool ValidateTrustedUser ( RsInit * config , std : : string fname , std : : string & userName ) ;
bool LoadPassword ( RsInit * config , std : : string passwd ) ;
bool RsGenerateCertificate ( RsInit * config , std : : string name , std : : string org ,
std : : string loc , std : : string country , std : : string passwd , std : : string & errString ) ;
/* Auto Login Fns */
bool RsTryAutoLogin ( RsInit * config ) ;
bool RsStoreAutoLogin ( RsInit * config ) ;
bool RsClearAutoLogin ( std : : string basedir ) ;
// Handle actual Login.
int LoadCertificates ( RsInit * config , bool autoLoginNT ) ;
2013-08-21 17:36:33 -04:00
RsControl * createRsControl ( NotifyBase & notify ) ;
2007-11-14 22:18:48 -05:00
class RsControl /* The Main Interface Class - for controlling the server */
{
public :
2013-08-21 17:36:33 -04:00
RsControl ( NotifyBase & callback )
: cb ( callback ) { return ; }
2007-11-14 22:18:48 -05:00
2009-02-08 09:30:28 -05:00
virtual ~ RsControl ( ) { return ; }
2007-11-14 22:18:48 -05:00
2009-02-08 09:30:28 -05:00
/* Real Startup Fn */
virtual int StartupRetroShare ( ) = 0 ;
2007-11-14 22:18:48 -05:00
2009-02-08 09:30:28 -05:00
/****************************************/
2007-11-14 22:18:48 -05:00
2009-02-08 09:30:28 -05:00
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
virtual int SetInBroadcast ( std : : string id , bool in ) = 0 ; /* channel : channel broadcast */
virtual int SetInSubscribe ( std : : string id , bool in ) = 0 ; /* channel : subscribed channels */
virtual int ClearInBroadcast ( ) = 0 ;
virtual int ClearInSubscribe ( ) = 0 ;
2007-11-14 22:18:48 -05:00
2009-02-08 09:30:28 -05:00
/****************************************/
/* Config */
2007-11-14 22:18:48 -05:00
2009-02-08 09:30:28 -05:00
virtual int ConfigSetBootPrompt ( bool on ) = 0 ;
virtual void ConfigFinalSave ( ) = 0 ;
virtual void rsGlobalShutDown ( ) = 0 ;
2007-11-14 22:18:48 -05:00
2009-02-08 09:30:28 -05:00
/****************************************/
2013-06-28 17:47:25 -04:00
NotifyBase & getNotify ( ) { return cb ; }
virtual bool getPeerCryptoDetails ( const std : : string & ssl_id , RsPeerCryptoParams & params ) = 0 ;
2007-11-14 22:18:48 -05:00
private :
2009-02-08 09:30:28 -05:00
NotifyBase & cb ;
2007-11-14 22:18:48 -05:00
} ;
/********************** Overload this Class for callback *****************/
class NotifyBase
{
public :
NotifyBase ( ) { return ; }
virtual ~ NotifyBase ( ) { return ; }
virtual void notifyListPreChange ( int list , int type ) { ( void ) list ; ( void ) type ; return ; }
virtual void notifyListChange ( int list , int type ) { ( void ) list ; ( void ) type ; return ; }
virtual void notifyErrorMsg ( int list , int sev , std : : string msg ) { ( void ) list ; ( void ) sev ; ( void ) msg ; return ; }
2010-08-01 14:22:37 -04:00
virtual void notifyChatStatus ( const std : : string & /* peer_id */ , const std : : string & /* status_string */ , bool /* is_private */ ) { }
2012-01-06 17:17:08 -05:00
virtual void notifyChatLobbyEvent ( uint64_t /* lobby id */ , uint32_t /* event type */ , const std : : string & /* nickname */ , const std : : string & /* any string */ ) { }
2013-03-20 16:25:13 -04:00
virtual void notifyChatLobbyTimeShift ( int /* time_shift */ ) { }
2010-09-02 06:15:13 -04:00
virtual void notifyCustomState ( const std : : string & /* peer_id */ , const std : : string & /* status_string */ ) { }
2010-10-09 14:35:34 -04:00
virtual void notifyHashingInfo ( uint32_t type , const std : : string & fileinfo ) { ( void ) type ; ( void ) fileinfo ; }
2010-08-01 14:22:37 -04:00
virtual void notifyTurtleSearchResult ( uint32_t /* search_id */ , const std : : list < TurtleFileInfo > & files ) { ( void ) files ; }
2009-09-30 16:53:18 -04:00
virtual void notifyPeerHasNewAvatar ( std : : string peer_id ) { ( void ) peer_id ; }
2009-09-30 18:30:57 -04:00
virtual void notifyOwnAvatarChanged ( ) { }
2009-10-05 15:55:17 -04:00
virtual void notifyOwnStatusMessageChanged ( ) { }
2010-05-21 16:49:48 -04:00
virtual void notifyDiskFull ( uint32_t /* location */ , uint32_t /* size limit in MB */ ) { }
2010-08-20 14:45:44 -04:00
/* peer has changed the status */
virtual void notifyPeerStatusChanged ( const std : : string & /* peer_id */ , uint32_t /* status */ ) { }
/* one or more peers has changed the states */
virtual void notifyPeerStatusChangedSummary ( ) { }
2012-02-11 19:58:47 -05:00
virtual void notifyForumMsgReadSatusChanged ( const std : : string & /* channelId */ , const std : : string & /* msgId */ , uint32_t /* status */ ) { }
2010-10-06 20:17:42 -04:00
virtual void notifyChannelMsgReadSatusChanged ( const std : : string & /* channelId */ , const std : : string & /* msgId */ , uint32_t /* status */ ) { }
2010-11-05 18:46:40 -04:00
virtual void notifyDiscInfoChanged ( ) { }
2010-11-24 19:20:25 -05:00
virtual void notifyDownloadComplete ( const std : : string & /* fileHash */ ) { } ;
virtual void notifyDownloadCompleteCount ( uint32_t /* count */ ) { } ;
2011-09-29 05:20:09 -04:00
virtual void notifyHistoryChanged ( uint32_t /* msgId */ , int /* type */ ) { }
2009-11-05 14:38:10 -05:00
2011-08-05 16:45:09 -04:00
virtual bool askForPassword ( const std : : string & /* key_details */ , bool /* prev_is_bad */ , std : : string & /* password */ ) { return false ; }
2012-09-09 09:59:21 -04:00
virtual bool askForPluginConfirmation ( const std : : string & /* plugin_filename */ , const std : : string & /* plugin_file_hash */ ) { return false ; }
2013-03-20 16:25:13 -04:00
virtual bool askForDeferredSelfSignature ( const void * /* data */ , const uint32_t /* len */ , unsigned char * /* sign */ , unsigned int * /* signlen */ , int & signature_result ) { signature_result = false ; return true ; }
2013-03-01 18:00:43 -05:00
2007-11-14 22:18:48 -05:00
} ;
2012-01-07 08:33:30 -05:00
const int NOTIFY_LIST_NEIGHBOURS = 1 ;
const int NOTIFY_LIST_FRIENDS = 2 ;
const int NOTIFY_LIST_SEARCHLIST = 4 ;
const int NOTIFY_LIST_MESSAGELIST = 5 ;
const int NOTIFY_LIST_CHANNELLIST = 6 ;
const int NOTIFY_LIST_TRANSFERLIST = 7 ;
const int NOTIFY_LIST_CONFIG = 8 ;
const int NOTIFY_LIST_DIRLIST_LOCAL = 9 ;
const int NOTIFY_LIST_DIRLIST_FRIENDS = 10 ;
const int NOTIFY_LIST_FORUMLIST_LOCKED = 11 ; // use connect with Qt::QueuedConnection
const int NOTIFY_LIST_MESSAGE_TAGS = 12 ;
const int NOTIFY_LIST_PUBLIC_CHAT = 13 ;
const int NOTIFY_LIST_PRIVATE_INCOMING_CHAT = 14 ;
const int NOTIFY_LIST_PRIVATE_OUTGOING_CHAT = 15 ;
const int NOTIFY_LIST_GROUPLIST = 16 ;
const int NOTIFY_LIST_CHANNELLIST_LOCKED = 17 ; // use connect with Qt::QueuedConnection
const int NOTIFY_LIST_CHAT_LOBBY_INVITATION = 18 ;
2012-01-11 19:13:25 -05:00
const int NOTIFY_LIST_CHAT_LOBBY_LIST = 19 ;
2007-11-14 22:18:48 -05:00
const int NOTIFY_TYPE_SAME = 0x01 ;
const int NOTIFY_TYPE_MOD = 0x02 ; /* general purpose, check all */
const int NOTIFY_TYPE_ADD = 0x04 ; /* flagged additions */
const int NOTIFY_TYPE_DEL = 0x08 ; /* flagged deletions */
2010-10-09 14:35:34 -04:00
const uint32_t NOTIFY_HASHTYPE_EXAMINING_FILES = 1 ; /* Examining shared files */
const uint32_t NOTIFY_HASHTYPE_FINISH = 2 ; /* Finish */
const uint32_t NOTIFY_HASHTYPE_HASH_FILE = 3 ; /* Hashing file */
const uint32_t NOTIFY_HASHTYPE_SAVE_FILE_INDEX = 4 ; /* Hashing file */
2007-11-14 22:18:48 -05:00
# endif