diff --git a/libretroshare/src/services/Makefile b/libretroshare/src/services/Makefile index 0abb4fcc3..e8bb7a8a0 100644 --- a/libretroshare/src/services/Makefile +++ b/libretroshare/src/services/Makefile @@ -7,7 +7,8 @@ RS_TOP_DIR = .. include $(RS_TOP_DIR)/scripts/config.mk ############################################################### -RSOBJ = p3service.o p3disc.o p3chatservice.o p3msgservice.o p3gamelauncher.o +RSOBJ = p3service.o p3chatservice.o p3msgservice.o p3gamelauncher.o +#p3disc.o #TESTOBJ = diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index 29b15ed95..88a3a9459 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -45,8 +45,8 @@ const int p3chatzone = 1745; -p3ChatService::p3ChatService() - :p3Service(RS_SERVICE_TYPE_CHAT) +p3ChatService::p3ChatService(p3ConnectMgr *cm) + :p3Service(RS_SERVICE_TYPE_CHAT), mConnMgr(cm) { addSerialType(new RsChatSerialiser()); } @@ -70,19 +70,22 @@ int p3ChatService::status() int p3ChatService::sendChat(std::string msg) { /* go through all the peers */ - sslroot *sslr = getSSLRoot(); - std::list::iterator it; - std::list &certs = sslr -> getCertList(); + std::list ids; + std::list::iterator it; + mConnMgr->getOnlineList(ids); - for(it = certs.begin(); it != certs.end(); it++) + /* add in own id -> so get reflection */ + ids.push_back(mConnMgr->getOwnId()); + + for(it = ids.begin(); it != ids.end(); it++) { pqioutput(PQL_DEBUG_BASIC, p3chatzone, "p3ChatService::sendChat()"); RsChatItem *ci = new RsChatItem(); - ci->PeerId((*it)->PeerId()); + ci->PeerId(*it); ci->chatFlags = 0; ci->sendTime = time(NULL); ci->message = msg; diff --git a/libretroshare/src/services/p3chatservice.h b/libretroshare/src/services/p3chatservice.h index 52d250493..a4a9f35a9 100644 --- a/libretroshare/src/services/p3chatservice.h +++ b/libretroshare/src/services/p3chatservice.h @@ -37,12 +37,13 @@ #include "serialiser/rsmsgitems.h" #include "services/p3service.h" +#include "pqi/p3connmgr.h" class p3ChatService: public p3Service { public: - p3ChatService(); + p3ChatService(p3ConnectMgr *cm); /* overloaded */ virtual int tick(); @@ -52,6 +53,9 @@ int sendChat(std::string msg); int sendPrivateChat(std::string msg, std::string id); std::list getChatQueue(); + + private: + p3ConnectMgr *mConnMgr; }; #endif // SERVICE_CHAT_HEADER diff --git a/libretroshare/src/services/p3disc.cc b/libretroshare/src/services/p3disc.cc index 70e41eaf0..a3e7ee753 100644 --- a/libretroshare/src/services/p3disc.cc +++ b/libretroshare/src/services/p3disc.cc @@ -26,8 +26,8 @@ #include "services/p3disc.h" -// for active local cert stuff. -#include "pqi/pqissl.h" +#include "pqi/p3authmgr.h" +#include "pqi/p3connmgr.h" #include #include @@ -51,8 +51,8 @@ static unsigned long determineCertAvailabilityFlags(cert *c); // Operating System specific includes. #include "pqi/pqinetwork.h" -p3disc::p3disc(sslroot *r) - :p3Service(RS_SERVICE_TYPE_DISC), sroot(r) +p3disc::p3disc(p3AuthMgr *am, p3ConnectMgr *cm) + :p3Service(RS_SERVICE_TYPE_DISC), mAuthMgr(am), mConnMgr(cm) { addSerialType(new RsDiscSerialiser()); diff --git a/libretroshare/src/services/p3disc.h b/libretroshare/src/services/p3disc.h index c0a212cff..cdcbc5671 100644 --- a/libretroshare/src/services/p3disc.h +++ b/libretroshare/src/services/p3disc.h @@ -36,19 +36,8 @@ #include "pqi/pqi.h" -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - -#include "pqi/xpgpcert.h" - -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - -#include "pqi/sslcert.h" - -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - +class p3ConnectMgr; +class p3AuthMgr; #include "serialiser/rsdiscitems.h" #include "services/p3service.h" @@ -60,8 +49,8 @@ class autoserver :id(NULL), ca(NULL), connect(false), c_ts(0), listen(false), l_ts(0), discFlags(0) { return;} - Person *id; - Person *ca; + std::string id; + std::string ca; bool connect; unsigned int c_ts; // this is connect_tf converted to timestamp, 0 invalid. @@ -94,7 +83,7 @@ class p3disc: public p3Service bool remote_disc; //sslroot *sslbase; - p3disc(sslroot *r); + p3disc(p3AuthMgr *am, p3ConnectMgr *cm); virtual ~p3disc(); // Overloaded from p3Service functions. @@ -155,15 +144,18 @@ std::list potentialproxy(cert *target); int collectCerts(); int distillData(); +#if 0 //cert *checkDuplicateX509(X509 *x509); std::list &getDiscovered(); // Main Storage - std::list neighbours; std::list ad_init; - std::list discovered; - sslroot *sroot; +#endif + std::list neighbours; + + p3AuthMgr *mAuthMgr; + p3ConnectMgr *mConnMgr; }; #endif // MRK_PQI_AUTODISC_H diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 2a6d06198..03f215c87 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -27,30 +27,15 @@ #include "pqi/pqibin.h" #include "pqi/pqiarchive.h" #include "pqi/pqidebug.h" +#include "pqi/p3connmgr.h" #include "services/p3msgservice.h" #include #include - -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - -#include "pqi/xpgpcert.h" - -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - -#include "pqi/sslcert.h" - -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - - const int msgservicezone = 54319; - /* Another little hack ..... unique message Ids * will be handled in this class..... * These are unique within this run of the server, @@ -68,11 +53,10 @@ unsigned int getNewUniqueMsgId() return msgUniqueId++; } -p3MsgService::p3MsgService() - :p3Service(RS_SERVICE_TYPE_MSG), +p3MsgService::p3MsgService(p3ConnectMgr *cm) + :p3Service(RS_SERVICE_TYPE_MSG), mConnMgr(cm), msgChanged(1), msgMajorChanged(1) { - sslr = getSSLRoot(); } @@ -110,7 +94,7 @@ int p3MsgService::incomingMsgs() mi -> recvTime = time(NULL); std::string mesg; - if (mi -> PeerId() == sslr->getOwnCert()->PeerId()) + if (mi -> PeerId() == mConnMgr->getOwnId()) { /* from the loopback device */ mi -> msgFlags = RS_MSG_FLAGS_OUTGOING; @@ -219,18 +203,23 @@ int p3MsgService::checkOutgoingMessages() * if online, send */ + const std::string ownId = mConnMgr->getOwnId(); + std::list::iterator it; for(it = msgOutgoing.begin(); it != msgOutgoing.end();) { /* find the certificate */ - certsign sign; - convert_to_certsign((*it)->PeerId(), sign); - cert *peer = sslr -> findcertsign(sign); - + std::string pid = (*it)->PeerId(); + peerConnectState pstate; + if (!mConnMgr->getFriendNetStatus(pid, pstate)) + { + delete(*it); + it = msgOutgoing.erase(it); + } /* if online, send it */ - if ((peer -> Status() & PERSON_STATUS_CONNECTED) - || (peer == sslr->getOwnCert())) + else if ((pstate.state & RS_PEER_S_ONLINE) + || (pid == ownId)) { /* send msg */ pqioutput(PQL_ALERT, msgservicezone, @@ -359,7 +348,7 @@ void p3MsgService::loadWelcomeMsg() /* Load Welcome Message */ RsMsgItem *msg = new RsMsgItem(); - msg -> PeerId(sslr->getOwnCert()->PeerId()); + msg -> PeerId(mConnMgr->getOwnId()); msg -> sendTime = 0; diff --git a/libretroshare/src/services/p3msgservice.h b/libretroshare/src/services/p3msgservice.h index eaca14d9b..722d7e362 100644 --- a/libretroshare/src/services/p3msgservice.h +++ b/libretroshare/src/services/p3msgservice.h @@ -37,13 +37,12 @@ #include "serialiser/rsmsgitems.h" #include "rsiface/rsiface.h" -class pqimonitor; -class sslroot; +class p3ConnectMgr; class p3MsgService: public p3Service { public: - p3MsgService(); + p3MsgService(p3ConnectMgr *cm); void loadWelcomeMsg(); /* startup message */ @@ -71,14 +70,14 @@ int incomingMsgs(); std::list imsg; std::list msgOutgoing; /* ones that haven't made it out yet! */ + p3ConnectMgr *mConnMgr; + // bool state flags. public: Indicator msgChanged; Indicator msgMajorChanged; -sslroot *sslr; std::string config_dir; - }; #endif // MESSAGE_SERVICE_HEADER