restored the retroshare-nogui executable

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3225 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-06-27 16:28:44 +00:00
parent 918decfd0d
commit f7ff141a37
5 changed files with 91 additions and 60 deletions

View File

@ -177,6 +177,27 @@ bool RsInitConfig::udpListenerOnly;
static bool getAvailableAccounts(std::list<accountId> &ids); static bool getAvailableAccounts(std::list<accountId> &ids);
static bool checkAccount(std::string accountdir, accountId &id); 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<res.size();++i)
if(res[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<res.size();++i)
if(res[i] > 64 && res[i] < 91)
res[i] += 97-65 ;
return res ;
}
void RsInit::InitRsConfig() void RsInit::InitRsConfig()
{ {
@ -307,7 +328,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ /******************************** WINDOWS/UNIX SPECIFIC PART ******************/
int c; int c;
std::string prefPgpName = ""; std::string prefUserString = "";
/* getopt info: every availiable option is listed here. if it is followed by a ':' it /* 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. 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; std::cerr << std::endl;
break; break;
case 'U': case 'U':
prefPgpName = optarg; prefUserString = optarg;
std::cerr << "Opt for User Id "; std::cerr << "Opt for User Id ";
std::cerr << std::endl; std::cerr << std::endl;
break; 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 << "-a AutoLogin (Windows Only) + StartMinimised" << std::endl;
std::cerr << "-m StartMinimised" << std::endl; std::cerr << "-m StartMinimised" << std::endl;
std::cerr << "-u Only listen to UDP" << 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 << "-e Use a forwarded external Port" << std::endl ;
std::cerr << "-U [User Name] Sets Account to Use, Useful when Autologin is enabled" << std::endl; std::cerr << "-U [User Name/GPG id/SSL id] Sets Account to Use, Useful when Autologin is enabled." << std::endl;
std::cerr << "Example" << std::endl;
std::cerr << "./retroshare-nogui -wmysecretpassword -e" << std::endl;
exit(1); exit(1);
break; break;
default: default:
@ -504,19 +523,25 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
// if a different user id has been passed to cmd line check for that instead // if a different user id has been passed to cmd line check for that instead
std::string lower_case_user_string = toLowerCase(prefUserString) ;
std::string upper_case_user_string = toUpperCase(prefUserString) ;
bool pgpNameFound = false; bool pgpNameFound = false;
if(prefPgpName != ""){ if(prefUserString != "")
{
for(it = RsInitConfig::accountIds.begin() ; it!= RsInitConfig::accountIds.end() ; it++){ for(it = RsInitConfig::accountIds.begin() ; it!= RsInitConfig::accountIds.end() ; it++)
{
if(prefPgpName == it->pgpName){ std::cerr << "Checking account (gpgid = " << it->pgpId << ", name=" << it->pgpName << ", sslId=" << it->sslId << ")" << std::endl ;
if(prefUserString == it->pgpName || upper_case_user_string == it->pgpId || lower_case_user_string == it->sslId)
{
RsInitConfig::preferedId = it->sslId; RsInitConfig::preferedId = it->sslId;
pgpNameFound = true; pgpNameFound = true;
} }
} }
if(!pgpNameFound){ if(!pgpNameFound){
std::cerr << "Invalid User name -U pgpName not Found" << std::endl; std::cerr << "Invalid User name/GPG id/SSL id: not found in list" << std::endl;
exit(1); exit(1);
} }
} }

View File

@ -26,6 +26,7 @@
#include "notifytxt.h" #include "notifytxt.h"
#include "rsiface/rspeers.h" #include "rsiface/rspeers.h"
#include <string.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@ -40,14 +41,21 @@ void NotifyTxt::notifyChat()
return; 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) void NotifyTxt::notifyListChange(int list, int type)
{ {
std::cerr << "NotifyTxt::notifyListChange()" << std::endl; std::cerr << "NotifyTxt::notifyListChange()" << std::endl;
switch(list) switch(list)
{ {
case NOTIFY_LIST_NEIGHBOURS: // case NOTIFY_LIST_NEIGHBOURS:
displayNeighbours(); // displayNeighbours();
break; // break;
case NOTIFY_LIST_FRIENDS: case NOTIFY_LIST_FRIENDS:
displayFriends(); displayFriends();
break; break;
@ -72,7 +80,6 @@ void NotifyTxt::notifyListChange(int list, int type)
return; return;
} }
void NotifyTxt::displayNeighbours() void NotifyTxt::displayNeighbours()
{ {
std::list<std::string> neighs; std::list<std::string> neighs;

View File

@ -37,9 +37,10 @@ class NotifyTxt: public NotifyBase
virtual ~NotifyTxt() { return; } virtual ~NotifyTxt() { return; }
void setRsIface(RsIface *i) { iface = i; } void setRsIface(RsIface *i) { iface = i; }
virtual void notifyListChange(int list, int type); virtual void notifyListChange(int list, int type);
virtual void notifyErrorMsg(int list, int sev, std::string msg); virtual void notifyErrorMsg(int list, int sev, std::string msg);
virtual void notifyChat(); virtual void notifyChat();
virtual std::string askForPassword(const std::string& key_details,bool prev_is_bad) ;
private: private:

View File

@ -2,24 +2,26 @@ TEMPLATE = app
TARGET = retroshare-nogui TARGET = retroshare-nogui
################################# Linux ########################################## ################################# 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++ { linux-g++ {
OBJECTS_DIR = temp/linux-g++/obj 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 { linux-g++-64 {
OBJECTS_DIR = temp/linux-g++-64/obj 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 ################### #################### Cross compilation for windows under Linux ###################

View File

@ -46,8 +46,6 @@
* The startup routine's are defined in rsiface.h * The startup routine's are defined in rsiface.h
*/ */
RsControl *rsicontrol ;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
/* Retroshare startup is configured using an RsInit object. /* Retroshare startup is configured using an RsInit object.
@ -79,8 +77,6 @@ int main(int argc, char **argv)
* otherwise loaded from commandline. * otherwise loaded from commandline.
*/ */
/* Key + Certificate are loaded into libretroshare */
RsInit::LoadCertificates(false);
/* Now setup the libretroshare interface objs /* Now setup the libretroshare interface objs
* You will need to create you own NotifyXXX class * You will need to create you own NotifyXXX class
@ -89,17 +85,17 @@ int main(int argc, char **argv)
NotifyTxt *notify = new NotifyTxt(); NotifyTxt *notify = new NotifyTxt();
RsIface *iface = createRsIface(*notify); RsIface *iface = createRsIface(*notify);
RsControl *rsServer = createRsControl(*iface, *notify); RsControl *rsServer = createRsControl(*iface, *notify);
rsicontrol = rsServer ;
notify->setRsIface(iface); notify->setRsIface(iface);
/* Key + Certificate are loaded into libretroshare */
RsInit::LoadCertificates(false);
/* Start-up libretroshare server threads */ /* Start-up libretroshare server threads */
rsServer -> StartupRetroShare(); rsServer -> StartupRetroShare();
rsicontrol = rsServer ;
RsInit::passwd = "" ;
//CleanupRsConfig(config);
/* pass control to the GUI */ /* pass control to the GUI */
while(1) while(1)
{ {