mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 00:19:30 -05:00
added new directory and .pro file for retrpshare-nogui
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@989 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
10ce95c0a2
commit
b9c9a71666
165
retroshare-nogui/src/notifytxt.cc
Normal file
165
retroshare-nogui/src/notifytxt.cc
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
/*
|
||||||
|
* "$Id: notifytxt.cc,v 1.1 2007-02-19 20:08:30 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 "notifytxt.h"
|
||||||
|
#include "rsiface/rspeers.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
void NotifyTxt::notifyErrorMsg(int list, int type, std::string msg)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyTxt::notifyChat()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyTxt::notifyListChange(int list, int type)
|
||||||
|
{
|
||||||
|
std::cerr << "NotifyTxt::notifyListChange()" << std::endl;
|
||||||
|
switch(list)
|
||||||
|
{
|
||||||
|
case NOTIFY_LIST_NEIGHBOURS:
|
||||||
|
displayNeighbours();
|
||||||
|
break;
|
||||||
|
case NOTIFY_LIST_FRIENDS:
|
||||||
|
displayFriends();
|
||||||
|
break;
|
||||||
|
case NOTIFY_LIST_DIRLIST:
|
||||||
|
displayDirectories();
|
||||||
|
break;
|
||||||
|
case NOTIFY_LIST_SEARCHLIST:
|
||||||
|
displaySearch();
|
||||||
|
break;
|
||||||
|
case NOTIFY_LIST_MESSAGELIST:
|
||||||
|
displayMessages();
|
||||||
|
break;
|
||||||
|
case NOTIFY_LIST_CHANNELLIST:
|
||||||
|
displayChannels();
|
||||||
|
break;
|
||||||
|
case NOTIFY_LIST_TRANSFERLIST:
|
||||||
|
displayTransfers();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void NotifyTxt::displayNeighbours()
|
||||||
|
{
|
||||||
|
std::list<std::string> ids;
|
||||||
|
std::list<std::string>::iterator it;
|
||||||
|
|
||||||
|
rsPeers->getOthersList(ids);
|
||||||
|
|
||||||
|
std::ostringstream out;
|
||||||
|
for(it = ids.begin(); it != ids.end(); it++)
|
||||||
|
{
|
||||||
|
RsPeerDetails detail;
|
||||||
|
rsPeers->getPeerDetails(*it, detail);
|
||||||
|
|
||||||
|
out << "Neighbour: ";
|
||||||
|
out << detail;
|
||||||
|
out << std::endl;
|
||||||
|
}
|
||||||
|
std::cerr << out.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyTxt::displayFriends()
|
||||||
|
{
|
||||||
|
std::list<std::string> ids;
|
||||||
|
std::list<std::string>::iterator it;
|
||||||
|
|
||||||
|
rsPeers->getFriendList(ids);
|
||||||
|
|
||||||
|
std::ostringstream out;
|
||||||
|
for(it = ids.begin(); it != ids.end(); it++)
|
||||||
|
{
|
||||||
|
RsPeerDetails detail;
|
||||||
|
rsPeers->getPeerDetails(*it, detail);
|
||||||
|
|
||||||
|
out << "Neighbour: ";
|
||||||
|
out << detail;
|
||||||
|
out << std::endl;
|
||||||
|
}
|
||||||
|
std::cerr << out.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyTxt::displayDirectories()
|
||||||
|
{
|
||||||
|
iface->lockData(); /* Lock Interface */
|
||||||
|
|
||||||
|
std::ostringstream out;
|
||||||
|
std::cerr << out.str();
|
||||||
|
|
||||||
|
iface->unlockData(); /* UnLock Interface */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NotifyTxt::displaySearch()
|
||||||
|
{
|
||||||
|
iface->lockData(); /* Lock Interface */
|
||||||
|
|
||||||
|
std::ostringstream out;
|
||||||
|
std::cerr << out.str();
|
||||||
|
|
||||||
|
iface->unlockData(); /* UnLock Interface */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NotifyTxt::displayMessages()
|
||||||
|
{
|
||||||
|
iface->lockData(); /* Lock Interface */
|
||||||
|
iface->unlockData(); /* UnLock Interface */
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyTxt::displayChannels()
|
||||||
|
{
|
||||||
|
iface->lockData(); /* Lock Interface */
|
||||||
|
|
||||||
|
std::ostringstream out;
|
||||||
|
std::cerr << out.str();
|
||||||
|
|
||||||
|
iface->unlockData(); /* UnLock Interface */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NotifyTxt::displayTransfers()
|
||||||
|
{
|
||||||
|
iface->lockData(); /* Lock Interface */
|
||||||
|
|
||||||
|
std::ostringstream out;
|
||||||
|
std::cerr << out.str();
|
||||||
|
|
||||||
|
iface->unlockData(); /* UnLock Interface */
|
||||||
|
}
|
||||||
|
|
57
retroshare-nogui/src/notifytxt.h
Normal file
57
retroshare-nogui/src/notifytxt.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#ifndef RSIFACE_NOTIFY_TXT_H
|
||||||
|
#define RSIFACE_NOTIFY_TXT_H
|
||||||
|
/*
|
||||||
|
* "$Id: notifytxt.h,v 1.1 2007-02-19 20:08:30 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 "rsiface/rsiface.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class NotifyTxt: public NotifyBase
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void displayNeighbours();
|
||||||
|
void displayFriends();
|
||||||
|
void displayDirectories();
|
||||||
|
void displaySearch();
|
||||||
|
void displayMessages();
|
||||||
|
void displayChannels();
|
||||||
|
void displayTransfers();
|
||||||
|
|
||||||
|
RsIface *iface; /* so we can get the data */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
78
retroshare-nogui/src/retroshare-nogui.pro
Normal file
78
retroshare-nogui/src/retroshare-nogui.pro
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
TEMPLATE = app
|
||||||
|
TARGET = retroshare-nogui
|
||||||
|
|
||||||
|
################################# Linux ##########################################
|
||||||
|
|
||||||
|
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 ###################
|
||||||
|
|
||||||
|
win32-x-g++ {
|
||||||
|
OBJECTS_DIR = temp/win32-x-g++/obj
|
||||||
|
|
||||||
|
LIBS += ../../../../lib/win32-x-g++/libretroshare.a
|
||||||
|
LIBS += ../../../../lib/win32-x-g++/libssl.a
|
||||||
|
LIBS += ../../../../lib/win32-x-g++/libcrypto.a
|
||||||
|
LIBS += ../../../../lib/win32-x-g++/libminiupnpc.a
|
||||||
|
LIBS += ../../../../lib/win32-x-g++/libz.a
|
||||||
|
LIBS += -L${HOME}/.wine/drive_c/pthreads/lib -lpthreadGCE2
|
||||||
|
LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32 -gdi32
|
||||||
|
LIBS += -lole32 -lwinmm
|
||||||
|
RC_FILE = gui/images/retroshare_win.rc
|
||||||
|
}
|
||||||
|
|
||||||
|
#################################### Windows #####################################
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
OBJECTS_DIR = temp/obj
|
||||||
|
RCC_DIR = temp/qrc
|
||||||
|
UI_DIR = temp/ui
|
||||||
|
MOC_DIR = temp/moc
|
||||||
|
|
||||||
|
LIBS += -L"../../../../lib" -lretroshare -lssl -lcrypto -lpthreadGC2d -lminiupnpc -lz
|
||||||
|
LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32-cygwin -gdi32
|
||||||
|
LIBS += -lole32 -lwinmm
|
||||||
|
}
|
||||||
|
|
||||||
|
##################################### MacOS ######################################
|
||||||
|
|
||||||
|
macx {
|
||||||
|
# ENABLE THIS OPTION FOR Univeral Binary BUILD.
|
||||||
|
# CONFIG += ppc x86
|
||||||
|
|
||||||
|
LIBS += -Wl,-search_paths_first
|
||||||
|
}
|
||||||
|
|
||||||
|
############################## Common stuff ######################################
|
||||||
|
|
||||||
|
DEPENDPATH += ../../libretroshare/src
|
||||||
|
|
||||||
|
INCLUDEPATH += . ../../libretroshare/src
|
||||||
|
|
||||||
|
# Input
|
||||||
|
HEADERS += notifytxt.h
|
||||||
|
SOURCES += notifytxt.cc \
|
||||||
|
retroshare.cc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
112
retroshare-nogui/src/retroshare.cc
Normal file
112
retroshare-nogui/src/retroshare.cc
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* "$Id: retroshare.cc,v 1.4 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 "rsiface/rsiface.h" /* definition of iface */
|
||||||
|
|
||||||
|
#include "notifytxt.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#ifdef WINDOWS_SYS
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Basic instructions for running libretroshare as background thread.
|
||||||
|
* ******************************************************************* *
|
||||||
|
* This allows your program to communicate with authenticated peers.
|
||||||
|
*
|
||||||
|
* libretroshare's interfaces are defined in libretroshare/src/rsiface.
|
||||||
|
* This should be the only headers that you need to include.
|
||||||
|
*
|
||||||
|
* The startup routine's are defined in rsiface.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
/* Retroshare startup is configured using an RsInit object.
|
||||||
|
* This is an opaque class, which the user cannot directly tweak
|
||||||
|
* If you want to peek at whats happening underneath look in
|
||||||
|
* libretroshare/src/rsserver/p3face-startup.cc
|
||||||
|
*
|
||||||
|
* You create it with InitRsConfig(), and delete with CleanupRsConfig()
|
||||||
|
* InitRetroshare(argv, argc, config) parses the command line options,
|
||||||
|
* and initialises the config paths.
|
||||||
|
*
|
||||||
|
* *** There are several functions that I should add to modify
|
||||||
|
* **** the config the moment these can only be set via the commandline
|
||||||
|
* - RsConfigDirectory(...) is probably the most useful.
|
||||||
|
* - RsConfigNetAddr(...) for setting port, etc.
|
||||||
|
* - RsConfigOutput(...) for logging and debugging.
|
||||||
|
*
|
||||||
|
* Next you need to worry about loading your certificate, or making
|
||||||
|
* a new one:
|
||||||
|
*
|
||||||
|
* RsGenerateCertificate(...) To create a new key, certificate
|
||||||
|
* LoadPassword(...) set password for existing certificate.
|
||||||
|
**/
|
||||||
|
|
||||||
|
RsInit *config = InitRsConfig();
|
||||||
|
InitRetroShare(argc, argv, config);
|
||||||
|
|
||||||
|
/* load password should be called at this point: LoadPassword()
|
||||||
|
* otherwise loaded from commandline.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Key + Certificate are loaded into libretroshare */
|
||||||
|
LoadCertificates(config, false);
|
||||||
|
|
||||||
|
/* Now setup the libretroshare interface objs
|
||||||
|
* You will need to create you own NotifyXXX class
|
||||||
|
* if you want to receive notifications of events */
|
||||||
|
|
||||||
|
NotifyTxt *notify = new NotifyTxt();
|
||||||
|
RsIface *iface = createRsIface(*notify);
|
||||||
|
RsControl *rsServer = createRsControl(*iface, *notify);
|
||||||
|
|
||||||
|
notify->setRsIface(iface);
|
||||||
|
|
||||||
|
/* Start-up libretroshare server threads */
|
||||||
|
|
||||||
|
rsServer -> StartupRetroShare(config);
|
||||||
|
CleanupRsConfig(config);
|
||||||
|
|
||||||
|
/* pass control to the GUI */
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
std::cerr << "GUI Tick()" << std::endl;
|
||||||
|
#ifndef WINDOWS_SYS
|
||||||
|
sleep(1);
|
||||||
|
#else
|
||||||
|
Sleep(1000);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user