From f7ff141a370cedd0a6b897be7264985a4ae2512d Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 27 Jun 2010 16:28:44 +0000 Subject: [PATCH] restored the retroshare-nogui executable git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3225 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/rsserver/rsinit.cc | 63 ++++++++++++++++------- retroshare-nogui/src/notifytxt.cc | 15 ++++-- retroshare-nogui/src/notifytxt.h | 31 +++++------ retroshare-nogui/src/retroshare-nogui.pro | 26 +++++----- retroshare-nogui/src/retroshare.cc | 16 +++--- 5 files changed, 91 insertions(+), 60 deletions(-) diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 7a6305403..5ca90fabb 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -177,6 +177,27 @@ bool RsInitConfig::udpListenerOnly; static bool getAvailableAccounts(std::list &ids); static bool checkAccount(std::string accountdir, accountId &id); +static std::string toUpperCase(const std::string& s) +{ + std::string res(s) ; + + for(uint32_t i=0;i 96 && res[i] < 123) + res[i] -= 97-65 ; + + return res ; +} + +static std::string toLowerCase(const std::string& s) +{ + std::string res(s) ; + + for(uint32_t i=0;i 64 && res[i] < 91) + res[i] += 97-65 ; + + return res ; +} void RsInit::InitRsConfig() { @@ -307,7 +328,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck /******************************** WINDOWS/UNIX SPECIFIC PART ******************/ int c; - std::string prefPgpName = ""; + std::string prefUserString = ""; /* getopt info: every availiable option is listed here. if it is followed by a ':' it needs an argument. If it is followed by a '::' the argument is optional. */ @@ -378,7 +399,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck std::cerr << std::endl; break; case 'U': - prefPgpName = optarg; + prefUserString = optarg; std::cerr << "Opt for User Id "; std::cerr << std::endl; break; @@ -395,10 +416,8 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck std::cerr << "-a AutoLogin (Windows Only) + StartMinimised" << std::endl; std::cerr << "-m StartMinimised" << std::endl; std::cerr << "-u Only listen to UDP" << std::endl; - std::cerr << "-e Use a forwarded external Port" << std::endl << std::endl; - std::cerr << "-U [User Name] Sets Account to Use, Useful when Autologin is enabled" << std::endl; - std::cerr << "Example" << std::endl; - std::cerr << "./retroshare-nogui -wmysecretpassword -e" << std::endl; + std::cerr << "-e Use a forwarded external Port" << std::endl ; + std::cerr << "-U [User Name/GPG id/SSL id] Sets Account to Use, Useful when Autologin is enabled." << std::endl; exit(1); break; default: @@ -504,22 +523,28 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck // if a different user id has been passed to cmd line check for that instead - bool pgpNameFound = false; - if(prefPgpName != ""){ + std::string lower_case_user_string = toLowerCase(prefUserString) ; + std::string upper_case_user_string = toUpperCase(prefUserString) ; - for(it = RsInitConfig::accountIds.begin() ; it!= RsInitConfig::accountIds.end() ; it++){ + bool pgpNameFound = false; + if(prefUserString != "") + { - if(prefPgpName == it->pgpName){ + for(it = RsInitConfig::accountIds.begin() ; it!= RsInitConfig::accountIds.end() ; it++) + { + std::cerr << "Checking account (gpgid = " << it->pgpId << ", name=" << it->pgpName << ", sslId=" << it->sslId << ")" << std::endl ; - RsInitConfig::preferedId = it->sslId; - pgpNameFound = true; - } - } - if(!pgpNameFound){ - std::cerr << "Invalid User name -U pgpName not Found" << std::endl; - exit(1); - } - } + if(prefUserString == it->pgpName || upper_case_user_string == it->pgpId || lower_case_user_string == it->sslId) + { + RsInitConfig::preferedId = it->sslId; + pgpNameFound = true; + } + } + if(!pgpNameFound){ + std::cerr << "Invalid User name/GPG id/SSL id: not found in list" << std::endl; + exit(1); + } + } diff --git a/retroshare-nogui/src/notifytxt.cc b/retroshare-nogui/src/notifytxt.cc index 0327b43e6..3d2c3983f 100644 --- a/retroshare-nogui/src/notifytxt.cc +++ b/retroshare-nogui/src/notifytxt.cc @@ -26,6 +26,7 @@ #include "notifytxt.h" #include "rsiface/rspeers.h" +#include #include #include @@ -40,14 +41,21 @@ void NotifyTxt::notifyChat() return; } +std::string NotifyTxt::askForPassword(const std::string& key_details,bool prev_is_bad) +{ + char *password = getpass(("Please enter GPG password for key "+key_details+": ").c_str()) ; + return std::string(password); +} + + void NotifyTxt::notifyListChange(int list, int type) { std::cerr << "NotifyTxt::notifyListChange()" << std::endl; switch(list) { - case NOTIFY_LIST_NEIGHBOURS: - displayNeighbours(); - break; +// case NOTIFY_LIST_NEIGHBOURS: +// displayNeighbours(); +// break; case NOTIFY_LIST_FRIENDS: displayFriends(); break; @@ -71,7 +79,6 @@ void NotifyTxt::notifyListChange(int list, int type) } return; } - void NotifyTxt::displayNeighbours() { diff --git a/retroshare-nogui/src/notifytxt.h b/retroshare-nogui/src/notifytxt.h index 13bd7f1b6..abb641592 100644 --- a/retroshare-nogui/src/notifytxt.h +++ b/retroshare-nogui/src/notifytxt.h @@ -32,26 +32,27 @@ class NotifyTxt: public NotifyBase { - public: - NotifyTxt() { return; } - virtual ~NotifyTxt() { return; } - void setRsIface(RsIface *i) { iface = i; } + public: + NotifyTxt() { return; } + virtual ~NotifyTxt() { return; } + void setRsIface(RsIface *i) { iface = i; } -virtual void notifyListChange(int list, int type); -virtual void notifyErrorMsg(int list, int sev, std::string msg); -virtual void notifyChat(); + virtual void notifyListChange(int list, int type); + virtual void notifyErrorMsg(int list, int sev, std::string msg); + virtual void notifyChat(); + virtual std::string askForPassword(const std::string& key_details,bool prev_is_bad) ; private: - void displayNeighbours(); - void displayFriends(); - void displayDirectories(); - void displaySearch(); - void displayMessages(); - void displayChannels(); - void displayTransfers(); + void displayNeighbours(); + void displayFriends(); + void displayDirectories(); + void displaySearch(); + void displayMessages(); + void displayChannels(); + void displayTransfers(); - RsIface *iface; /* so we can get the data */ + RsIface *iface; /* so we can get the data */ }; #endif diff --git a/retroshare-nogui/src/retroshare-nogui.pro b/retroshare-nogui/src/retroshare-nogui.pro index 16a9b8088..7be984ac1 100644 --- a/retroshare-nogui/src/retroshare-nogui.pro +++ b/retroshare-nogui/src/retroshare-nogui.pro @@ -2,24 +2,26 @@ TEMPLATE = app TARGET = retroshare-nogui ################################# Linux ########################################## +linux-* { + #CONFIG += version_detail_bash_script + QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64 + + system(which gpgme-config >/dev/null 2>&1) { + INCLUDEPATH += $$system(gpgme-config --cflags | sed -e "s/-I//g") + } else { + message(Could not find gpgme-config on your system, assuming gpgme.h is in /usr/include) + } + + LIBS += ../../libretroshare/src/lib/libretroshare.a + LIBS += -lssl -lgpgme -lupnp +} linux-g++ { OBJECTS_DIR = temp/linux-g++/obj - - LIBS += ../../../../lib/linux-g++/libretroshare.a - LIBS += ../../../../lib/linux-g++/libminiupnpc.a - LIBS += ../../../../lib/linux-g++/libssl.a - LIBS += ../../../../lib/linux-g++/libcrypto.a - LIBS += -lz } + linux-g++-64 { OBJECTS_DIR = temp/linux-g++-64/obj - - LIBS += ../../../../lib/linux-g++-64/libretroshare.a - LIBS += ../../../../lib/linux-g++-64/libminiupnpc.a - LIBS += ../../../../lib/linux-g++-64/libssl.a - LIBS += ../../../../lib/linux-g++-64/libcrypto.a - LIBS += -lz } #################### Cross compilation for windows under Linux ################### diff --git a/retroshare-nogui/src/retroshare.cc b/retroshare-nogui/src/retroshare.cc index 28c23028b..481b7a0a0 100644 --- a/retroshare-nogui/src/retroshare.cc +++ b/retroshare-nogui/src/retroshare.cc @@ -46,8 +46,6 @@ * The startup routine's are defined in rsiface.h */ -RsControl *rsicontrol ; - int main(int argc, char **argv) { /* Retroshare startup is configured using an RsInit object. @@ -79,8 +77,6 @@ int main(int argc, char **argv) * otherwise loaded from commandline. */ - /* Key + Certificate are loaded into libretroshare */ - RsInit::LoadCertificates(false); /* Now setup the libretroshare interface objs * You will need to create you own NotifyXXX class @@ -88,17 +84,17 @@ int main(int argc, char **argv) NotifyTxt *notify = new NotifyTxt(); RsIface *iface = createRsIface(*notify); - RsControl *rsServer = createRsControl(*iface, *notify); + RsControl *rsServer = createRsControl(*iface, *notify); + rsicontrol = rsServer ; notify->setRsIface(iface); + /* Key + Certificate are loaded into libretroshare */ + + RsInit::LoadCertificates(false); + /* Start-up libretroshare server threads */ - rsServer -> StartupRetroShare(); - - rsicontrol = rsServer ; - RsInit::passwd = "" ; - //CleanupRsConfig(config); /* pass control to the GUI */ while(1)