merge of branch v0.6-idclean 7180

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7187 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2014-03-17 20:56:06 +00:00
parent 7815efb16f
commit 0f29d28b1b
397 changed files with 6503 additions and 5702 deletions

View file

@ -150,7 +150,7 @@ class RsServer: public RsControl, public RsThread
/****************************************/
public:
virtual bool getPeerCryptoDetails(const std::string& ssl_id,RsPeerCryptoParams& params) { return pqih->getCryptoParams(ssl_id,params); }
virtual bool getPeerCryptoDetails(const RsPeerId& ssl_id,RsPeerCryptoParams& params) { return pqih->getCryptoParams(ssl_id,params); }
private:

View file

@ -44,7 +44,7 @@ uint32_t p3History::getMaxStorageDuration()
{
return mHistoryMgr->getMaxStorageDuration() ;
}
bool p3History::getMessages(const std::string &chatPeerId, std::list<HistoryMsg> &msgs, const uint32_t loadCount)
bool p3History::getMessages(const RsPeerId &chatPeerId, std::list<HistoryMsg> &msgs, const uint32_t loadCount)
{
return mHistoryMgr->getMessages(chatPeerId, msgs, loadCount);
}
@ -59,7 +59,7 @@ void p3History::removeMessages(const std::list<uint32_t> &msgIds)
mHistoryMgr->removeMessages(msgIds);
}
void p3History::clear(const std::string &chatPeerId)
void p3History::clear(const RsPeerId &chatPeerId)
{
mHistoryMgr->clear(chatPeerId);
}

View file

@ -41,10 +41,10 @@ public:
p3History(p3HistoryMgr* historyMgr);
virtual ~p3History();
virtual bool getMessages(const std::string &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount);
virtual bool getMessages(const RsPeerId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount);
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg);
virtual void removeMessages(const std::list<uint32_t> &msgIds);
virtual void clear(const std::string &chatPeerId);
virtual void clear(const RsPeerId &chatPeerId);
virtual bool getEnable(uint32_t chat_type);
virtual void setEnable(uint32_t chat_type, bool enable);
virtual uint32_t getSaveCount(uint32_t chat_type);

View file

@ -100,7 +100,7 @@ bool p3Msgs::decryptMessage(const std::string& mId)
{
return mMsgSrv->decryptMessage(mId);
}
bool p3Msgs::createDistantOfflineMessengingInvite(time_t ts, std::string& hash)
bool p3Msgs::createDistantOfflineMessengingInvite(time_t ts, DistantMsgPeerId &hash)
{
return mMsgSrv->createDistantOfflineMessengingInvite(ts,hash) ;
}
@ -116,9 +116,9 @@ bool p3Msgs::distantMessagingEnabled()
{
return mMsgSrv->distantMessagingEnabled();
}
bool p3Msgs::getDistantMessageHash(const std::string& pgp_id,std::string& hash)
bool p3Msgs::getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId &pid)
{
return mMsgSrv->getDistantMessageHash(pgp_id,hash);
return mMsgSrv->getDistantMessagePeerId(pgp_id,pid);
}
bool p3Msgs::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)
@ -218,7 +218,7 @@ bool p3Msgs::sendPublicChat(const std::string& msg)
return mChatSrv -> sendPublicChat(msg);
}
bool p3Msgs::sendPrivateChat(const std::string& id, const std::string& msg)
bool p3Msgs::sendPrivateChat(const RsPeerId& id, const std::string& msg)
{
/* send a message to peer */
return mChatSrv -> sendPrivateChat(id, msg);
@ -229,7 +229,7 @@ void p3Msgs::sendGroupChatStatusString(const std::string& status_string)
mChatSrv->sendGroupChatStatusString(status_string);
}
void p3Msgs::sendStatusString(const std::string& peer_id, const std::string& status_string)
void p3Msgs::sendStatusString(const RsPeerId& peer_id, const std::string& status_string)
{
mChatSrv->sendStatusString(peer_id, status_string);
}
@ -249,17 +249,17 @@ int p3Msgs::getPrivateChatQueueCount(bool incoming)
return mChatSrv->getPrivateChatQueueCount(incoming);
}
bool p3Msgs::getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids)
bool p3Msgs::getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids)
{
return mChatSrv->getPrivateChatQueueIds(incoming, ids);
}
bool p3Msgs::getPrivateChatQueue(bool incoming, const std::string& id, std::list<ChatInfo> &chats)
bool p3Msgs::getPrivateChatQueue(bool incoming, const RsPeerId& id, std::list<ChatInfo> &chats)
{
return mChatSrv->getPrivateChatQueue(incoming, id, chats);
}
bool p3Msgs::clearPrivateChatQueue(bool incoming, const std::string& id)
bool p3Msgs::clearPrivateChatQueue(bool incoming, const RsPeerId& id)
{
return mChatSrv->clearPrivateChatQueue(incoming, id);
}
@ -274,12 +274,12 @@ void p3Msgs::setOwnAvatarData(const unsigned char *data,int size)
mChatSrv->setOwnAvatarJpegData(data,size) ;
}
void p3Msgs::getAvatarData(const std::string& pid,unsigned char *& data,int& size)
void p3Msgs::getAvatarData(const RsPeerId& pid,unsigned char *& data,int& size)
{
mChatSrv->getAvatarJpegData(pid,data,size) ;
}
std::string p3Msgs::getCustomStateString(const std::string& peer_id)
std::string p3Msgs::getCustomStateString(const RsPeerId& peer_id)
{
return mChatSrv->getCustomStateString(peer_id) ;
}
@ -294,11 +294,11 @@ void p3Msgs::setCustomStateString(const std::string& state_string)
mChatSrv->setOwnCustomStateString(state_string) ;
}
bool p3Msgs::getVirtualPeerId(const ChatLobbyId& id,std::string& peer_id)
bool p3Msgs::getVirtualPeerId(const ChatLobbyId& id,RsPeerId& peer_id)
{
return mChatSrv->getVirtualPeerId(id,peer_id) ;
}
bool p3Msgs::isLobbyId(const std::string& peer_id,ChatLobbyId& id)
bool p3Msgs::isLobbyId(const RsPeerId& peer_id,ChatLobbyId& id)
{
return mChatSrv->isLobbyId(peer_id,id) ;
}
@ -307,7 +307,7 @@ void p3Msgs::getChatLobbyList(std::list<ChatLobbyInfo>& linfos)
{
mChatSrv->getChatLobbyList(linfos) ;
}
void p3Msgs::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id)
void p3Msgs::invitePeerToLobby(const ChatLobbyId& lobby_id, const RsPeerId& peer_id)
{
mChatSrv->invitePeerToLobby(lobby_id,peer_id) ;
}
@ -343,7 +343,7 @@ void p3Msgs::getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& pub
mChatSrv->getListOfNearbyChatLobbies(public_lobbies) ;
}
ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<std::string>& invited_friends,uint32_t privacy_type)
ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,uint32_t privacy_type)
{
return mChatSrv->createChatLobby(lobby_name,lobby_topic,invited_friends,privacy_type) ;
}
@ -371,7 +371,7 @@ void p3Msgs::getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites)
{
mChatSrv->getPendingChatLobbyInvites(invites) ;
}
bool p3Msgs::createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string)
bool p3Msgs::createDistantChatInvite(const RsPgpId& pgp_id,time_t time_of_validity,std::string& encrypted_string)
{
return mChatSrv->createDistantChatInvite(pgp_id,time_of_validity,encrypted_string) ;
}
@ -379,24 +379,24 @@ bool p3Msgs::getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invite
{
return mChatSrv->getDistantChatInviteList(invites) ;
}
bool p3Msgs::initiateDistantChatConnexion(const std::string& encrypted_str,time_t validity_time,std::string& hash,uint32_t& error_code)
bool p3Msgs::initiateDistantChatConnexion(const std::string& encrypted_str,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code)
{
return mChatSrv->initiateDistantChatConnexion(encrypted_str,validity_time,hash,error_code) ;
return mChatSrv->initiateDistantChatConnexion(encrypted_str,validity_time,pid,error_code) ;
}
bool p3Msgs::initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code)
bool p3Msgs::initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code)
{
return mChatSrv->initiateDistantChatConnexion(hash,error_code) ;
return mChatSrv->initiateDistantChatConnexion(pid,error_code) ;
}
bool p3Msgs::getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id)
bool p3Msgs::getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,RsPgpId& pgp_id)
{
return mChatSrv->getDistantChatStatus(hash,status,pgp_id) ;
return mChatSrv->getDistantChatStatus(pid,status,pgp_id) ;
}
bool p3Msgs::closeDistantChatConnexion(const std::string& hash)
bool p3Msgs::closeDistantChatConnexion(const DistantChatPeerId& pid)
{
return mChatSrv->closeDistantChatConnexion(hash) ;
return mChatSrv->closeDistantChatConnexion(pid) ;
}
bool p3Msgs::removeDistantChatInvite(const std::string& hash)
bool p3Msgs::removeDistantChatInvite(const DistantChatPeerId& pid)
{
return mChatSrv->removeDistantChatInvite(hash) ;
return mChatSrv->removeDistantChatInvite(pid) ;
}

View file

@ -80,17 +80,17 @@ class p3Msgs: public RsMsgs
virtual bool resetMessageStandardTagTypes(MsgTagType& tags);
virtual bool createDistantOfflineMessengingInvite(time_t, std::string&) ;
virtual bool createDistantOfflineMessengingInvite(time_t, DistantMsgPeerId&) ;
virtual bool getDistantOfflineMessengingInvites(std::vector<DistantOfflineMessengingInvite>&);
virtual void enableDistantMessaging(bool b) ;
virtual bool distantMessagingEnabled() ;
virtual bool getDistantMessageHash(const std::string& pgp_id,std::string& hash) ;
virtual bool getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId& pid) ;
/*!
* gets avatar from peer, image data in jpeg format
*/
virtual void getAvatarData(const std::string& pid,unsigned char *& data,int& size);
virtual void getAvatarData(const RsPeerId& pid,unsigned char *& data,int& size);
/*!
* sets clients avatar, image data should be in jpeg format
@ -115,7 +115,7 @@ class p3Msgs: public RsMsgs
/*!
* retrieves peer's custom status
*/
virtual std::string getCustomStateString(const std::string& peer_id) ;
virtual std::string getCustomStateString(const RsPeerId& peer_id) ;
/*!
@ -127,7 +127,7 @@ class p3Msgs: public RsMsgs
* chat is sent to specifc peer
* @param id peer to send chat msg to
*/
virtual bool sendPrivateChat(const std::string& id, const std::string& msg);
virtual bool sendPrivateChat(const RsPeerId& id, const std::string& msg);
/*!
* returns the count of messages in public or private queue
@ -149,24 +149,24 @@ class p3Msgs: public RsMsgs
/*!
* @param id's of available private chat messages
*/
virtual bool getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids);
virtual bool getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids);
/*!
* @param chats ref to list of received private chats is stored here
*/
virtual bool getPrivateChatQueue(bool incoming, const std::string& id, std::list<ChatInfo> &chats);
virtual bool getPrivateChatQueue(bool incoming, const RsPeerId& id, std::list<ChatInfo> &chats);
/*!
* @param clear private chat queue
*/
virtual bool clearPrivateChatQueue(bool incoming, const std::string& id);
virtual bool clearPrivateChatQueue(bool incoming, const RsPeerId& id);
/*!
* sends immediate status string to a specific peer, e.g. in a private chat
* @param peer_id peer to send status string to
* @param status_string immediate status to send
*/
virtual void sendStatusString(const std::string& peer_id, const std::string& status_string) ;
virtual void sendStatusString(const RsPeerId& peer_id, const std::string& status_string) ;
/*!
* sends immediate status to all peers
@ -178,10 +178,10 @@ class p3Msgs: public RsMsgs
virtual bool joinVisibleChatLobby(const ChatLobbyId& id) ;
virtual void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) ;
virtual bool getVirtualPeerId(const ChatLobbyId& id,std::string& vpid) ;
virtual bool isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id) ;
virtual bool getVirtualPeerId(const ChatLobbyId& id,RsPeerId& vpid) ;
virtual bool isLobbyId(const RsPeerId& virtual_peer_id,ChatLobbyId& lobby_id) ;
virtual void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
virtual void invitePeerToLobby(const ChatLobbyId&, const std::string&) ;
virtual void invitePeerToLobby(const ChatLobbyId&, const RsPeerId&) ;
virtual bool acceptLobbyInvite(const ChatLobbyId& id) ;
virtual void denyLobbyInvite(const ChatLobbyId& id) ;
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
@ -192,15 +192,15 @@ class p3Msgs: public RsMsgs
virtual bool getDefaultNickNameForChatLobby(std::string& nick) ;
virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe);
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<std::string>& invited_friends,uint32_t privacy_type) ;
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,uint32_t privacy_type) ;
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
virtual bool createDistantChatInvite(const RsPgpId& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) ;
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) ;
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) ;
virtual bool closeDistantChatConnexion(const std::string& hash) ;
virtual bool removeDistantChatInvite(const std::string& hash) ;
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code) ;
virtual bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) ;
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,RsPgpId& pgp_id) ;
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid) ;
virtual bool removeDistantChatInvite(const DistantChatPeerId& pid) ;
private:

View file

@ -160,7 +160,7 @@ bool p3Peers::OthersChanged()
}
/* Peer Details (Net & Auth) */
std::string p3Peers::getOwnId()
const RsPeerId& p3Peers::getOwnId()
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getOwnId()" << std::endl;
@ -169,7 +169,7 @@ std::string p3Peers::getOwnId()
return AuthSSL::getAuthSSL()->OwnId();
}
bool p3Peers::getOnlineList(std::list<std::string> &ids)
bool p3Peers::getOnlineList(std::list<RsPeerId> &ids)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getOnlineList()" << std::endl;
@ -180,7 +180,7 @@ bool p3Peers::getOnlineList(std::list<std::string> &ids)
return true;
}
bool p3Peers::getFriendList(std::list<std::string> &ids)
bool p3Peers::getFriendList(std::list<RsPeerId> &ids)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getFriendList()" << std::endl;
@ -215,7 +215,7 @@ bool p3Peers::getPeerCount (unsigned int *friendCount, unsigned int *onlineCount
return true;
}
bool p3Peers::isOnline(const std::string &id)
bool p3Peers::isOnline(const RsPeerId &id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::isOnline() " << id << std::endl;
@ -231,7 +231,7 @@ bool p3Peers::isOnline(const std::string &id)
return false;
}
bool p3Peers::isFriend(const std::string &ssl_id)
bool p3Peers::isFriend(const RsPeerId &ssl_id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::isFriend() " << ssl_id << std::endl;
@ -241,7 +241,7 @@ bool p3Peers::isFriend(const std::string &ssl_id)
return mPeerMgr->isFriend(ssl_id);
}
bool p3Peers::haveSecretKey(const std::string& id)
bool p3Peers::haveSecretKey(const RsPgpId& id)
{
return AuthGPG::getAuthGPG()->haveSecretKey(id) ;
}
@ -250,7 +250,7 @@ bool p3Peers::haveSecretKey(const std::string& id)
* to shift it immeidately
*/
bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl;
@ -258,7 +258,7 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
// NOW Only for SSL Details.
std::string sOwnId = AuthSSL::getAuthSSL()->OwnId();
RsPeerId sOwnId = AuthSSL::getAuthSSL()->OwnId();
peerState ps;
if (id == sOwnId)
@ -266,31 +266,30 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
mPeerMgr->getOwnNetStatus(ps);
ps.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
}
else
else if (!mPeerMgr->getFriendNetStatus(id, ps))
{
if (!mPeerMgr->getFriendNetStatus(id, ps))
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerDetails() ERROR not an SSL Id: " << id << std::endl;
std::cerr << "p3Peers::getPeerDetails() ERROR not an SSL Id: " << id << std::endl;
#endif
bool res = getGPGDetails(id, d);
d.isOnlyGPGdetail = true;
if(id.length() == 16)
d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
else if(id.length() == 32)
d.service_perm_flags = mPeerMgr->servicePermissionFlags_sslid(id) ;
else
{
std::cerr << "p3Peers::getPeerDetails() ERROR not an correct Id: " << id << std::endl;
d.service_perm_flags = RS_SERVICE_PERM_NONE ;
}
return res ;
}
return false ;
}
// bool res = getGPGDetails(id, d);
//
// d.isOnlyGPGdetail = true;
//
// if(id.length() == 16)
// d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
// else if(id.length() == 32)
// d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
// else
// {
// std::cerr << "p3Peers::getPeerDetails() ERROR not an correct Id: " << id << std::endl;
// d.service_perm_flags = RS_SERVICE_PERM_NONE ;
// }
//
// return res ;
/* get from gpg (first), to fill in the sign and trust details */
/* don't retrun now, we've got fill in the ssl and connection info */
getGPGDetails(ps.gpg_id, d);
@ -454,47 +453,44 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
return true;
}
bool p3Peers::isKeySupported(const std::string& id)
bool p3Peers::isKeySupported(const RsPgpId& id)
{
return AuthGPG::getAuthGPG()->isKeySupported(id);
}
std::string p3Peers::getGPGName(const std::string &gpg_id)
std::string p3Peers::getGPGName(const RsPgpId &gpg_id)
{
/* get from mAuthMgr as it should have more peers? */
return AuthGPG::getAuthGPG()->getGPGName(gpg_id);
}
bool p3Peers::isGPGAccepted(const std::string &gpg_id_is_friend)
bool p3Peers::isGPGAccepted(const RsPgpId &gpg_id_is_friend)
{
/* get from mAuthMgr as it should have more peers? */
return AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id_is_friend);
}
std::string p3Peers::getPeerName(const std::string &ssl_or_gpg_id)
std::string p3Peers::getPeerName(const RsPeerId& ssl)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerName() " << ssl_or_gpg_id << std::endl;
#endif
std::string name;
if (ssl_or_gpg_id == AuthSSL::getAuthSSL()->OwnId())
{
if (ssl == AuthSSL::getAuthSSL()->OwnId())
return AuthGPG::getAuthGPG()->getGPGOwnName();
}
if (mPeerMgr->getPeerName(ssl_or_gpg_id, name))
if (mPeerMgr->getPeerName(ssl, name))
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerName() got a ssl id. Name is : " << name << std::endl;
#endif
return name;
}
return AuthGPG::getAuthGPG()->getGPGName(ssl_or_gpg_id);
return std::string() ;
}
bool p3Peers::getGPGAllList(std::list<std::string> &ids)
bool p3Peers::getGPGAllList(std::list<RsPgpId> &ids)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getGPGAllList()" << std::endl;
@ -505,7 +501,7 @@ bool p3Peers::getGPGAllList(std::list<std::string> &ids)
return true;
}
bool p3Peers::getGPGValidList(std::list<std::string> &ids)
bool p3Peers::getGPGValidList(std::list<RsPgpId> &ids)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPOthersList()" << std::endl;
@ -516,7 +512,7 @@ bool p3Peers::getGPGValidList(std::list<std::string> &ids)
return true;
}
bool p3Peers::getGPGSignedList(std::list<std::string> &ids)
bool p3Peers::getGPGSignedList(std::list<RsPgpId> &ids)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPOthersList()" << std::endl;
@ -527,7 +523,7 @@ bool p3Peers::getGPGSignedList(std::list<std::string> &ids)
return true;
}
bool p3Peers::getGPGAcceptedList(std::list<std::string> &ids)
bool p3Peers::getGPGAcceptedList(std::list<RsPgpId> &ids)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getGPGAcceptedList()" << std::endl;
@ -537,7 +533,7 @@ bool p3Peers::getGPGAcceptedList(std::list<std::string> &ids)
}
bool p3Peers::getAssociatedSSLIds(const std::string &gpg_id, std::list<std::string> &ids)
bool p3Peers::getAssociatedSSLIds(const RsPgpId &gpg_id, std::list<RsPeerId> &ids)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getAssociatedSSLIds() for id : " << gpg_id << std::endl;
@ -551,17 +547,22 @@ bool p3Peers::gpgSignData(const void *data, const uint32_t len, unsigned char
return AuthGPG::getAuthGPG()->SignDataBin(data,len,sign,signlen);
}
bool p3Peers::getGPGDetails(const std::string &id, RsPeerDetails &d)
bool p3Peers::getGPGDetails(const RsPgpId &pgp_id, RsPeerDetails &d)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPgpDetails() called for id : " << id << std::endl;
std::cerr << "p3Peers::getPgpDetails() called for id : " << pgp_id << std::endl;
#endif
/* get from mAuthMgr */
return AuthGPG::getAuthGPG()->getGPGDetails(id, d);
/* get from mAuthMgr */
bool res = AuthGPG::getAuthGPG()->getGPGDetails(pgp_id, d);
d.isOnlyGPGdetail = true ;
d.service_perm_flags = mPeerMgr->servicePermissionFlags(pgp_id) ;
return res ;
}
std::string p3Peers::getGPGOwnId()
const RsPgpId& p3Peers::getGPGOwnId()
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPOwnId()" << std::endl;
@ -571,28 +572,23 @@ std::string p3Peers::getGPGOwnId()
return AuthGPG::getAuthGPG()->getGPGOwnId();
}
std::string p3Peers::getGPGId(const std::string &sslid_or_gpgid)
RsPgpId p3Peers::getGPGId(const RsPeerId& sslid)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPId()" << std::endl;
std::cerr << "p3Peers::getPGPId()" << std::endl;
#endif
/* get from mAuthMgr */
if (sslid_or_gpgid == AuthSSL::getAuthSSL()->OwnId()) {
return AuthGPG::getAuthGPG()->getGPGOwnId();
}
peerState pcs;
if (mPeerMgr->getFriendNetStatus(sslid_or_gpgid, pcs) || mPeerMgr->getOthersNetStatus(sslid_or_gpgid, pcs)) {
return pcs.gpg_id;
} else {
if ( AuthGPG::getAuthGPG()->isGPGId(sslid_or_gpgid)) {
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPId() given id is already an gpg id : " << sslid_or_gpgid << std::endl;
#endif
return sslid_or_gpgid;
}
}
return "";
/* get from mAuthMgr */
if (sslid == AuthSSL::getAuthSSL()->OwnId())
{
return AuthGPG::getAuthGPG()->getGPGOwnId();
}
peerState pcs;
if (mPeerMgr->getFriendNetStatus(sslid, pcs) || mPeerMgr->getOthersNetStatus(sslid, pcs)) {
return pcs.gpg_id;
}
return RsPgpId();
}
@ -601,27 +597,27 @@ std::string p3Peers::getGPGId(const std::string &sslid_or_gpgid)
*/
/* Add/Remove Friends */
bool p3Peers::addFriend(const std::string &ssl_id, const std::string &gpg_id,ServicePermissionFlags perm_flags)
bool p3Peers::addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags perm_flags)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() with : id : " << id << "; gpg_id : " << gpg_id << std::endl;
std::cerr << "p3Peers::addFriend() with : id : " << id << "; gpg_id : " << gpg_id << std::endl;
#endif
if (AuthGPG::getAuthGPG()->isGPGId(gpg_id))
if(AuthGPG::getAuthGPG()->isGPGId(gpg_id))
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() Authorising GPG Id: " << gpg_id << std::endl;
std::cerr << "p3Peers::addFriend() Authorising GPG Id: " << gpg_id << std::endl;
#endif
if (AuthGPG::getAuthGPG()->AllowConnection(gpg_id, true))
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() Authorization OK." << std::endl;
std::cerr << "p3Peers::addFriend() Authorization OK." << std::endl;
#endif
}
else
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() Authorization FAILED." << std::endl;
std::cerr << "p3Peers::addFriend() Authorization FAILED." << std::endl;
#endif
return false;
}
@ -629,12 +625,12 @@ bool p3Peers::addFriend(const std::string &ssl_id, const std::string &gpg_id,Se
else
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() Bad gpg_id : " << gpg_id << std::endl;
std::cerr << "p3Peers::addFriend() Bad gpg_id : " << gpg_id << std::endl;
#endif
return false;
}
if (ssl_id == gpg_id || ssl_id == "")
if(ssl_id.isNull())
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() WARNING id is NULL or gpgId" << std::endl;
@ -650,12 +646,12 @@ bool p3Peers::addFriend(const std::string &ssl_id, const std::string &gpg_id,Se
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags);
}
bool p3Peers::removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code)
bool p3Peers::removeKeysFromPGPKeyring(const std::list<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code)
{
return AuthGPG::getAuthGPG()->removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ;
}
bool p3Peers::removeFriendLocation(const std::string &sslId)
bool p3Peers::removeFriendLocation(const RsPeerId &sslId)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriendLocation() " << sslId << std::endl;
@ -666,7 +662,7 @@ bool p3Peers::removeFriendLocation(const std::string &sslId)
}
bool p3Peers::removeFriend(const std::string &gpgId)
bool p3Peers::removeFriend(const RsPgpId& gpgId)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() " << gpgId << std::endl;
@ -676,43 +672,31 @@ bool p3Peers::removeFriend(const std::string &gpgId)
return false;
}
if (AuthGPG::getAuthGPG()->isGPGId(gpgId))
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() Removing GPG Id: " << gpgId << std::endl;
#endif
if (AuthGPG::getAuthGPG()->AllowConnection(gpgId, false))
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() Removing GPG Id: " << gpgId << std::endl;
std::cerr << "p3Peers::removeFriend() OK." << std::endl;
#endif
if (AuthGPG::getAuthGPG()->AllowConnection(gpgId, false))
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() OK." << std::endl;
#endif
mPeerMgr->removeAllFriendLocations(gpgId);
return true;
}
else
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() FAILED." << std::endl;
#endif
mPeerMgr->removeAllFriendLocations(gpgId);
return false;
}
mPeerMgr->removeAllFriendLocations(gpgId);
return true;
}
else
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() Not GPG Id: " << gpg_id << std::endl;
std::cerr << "p3Peers::removeFriend() FAILED." << std::endl;
#endif
return removeFriendLocation(gpgId);
mPeerMgr->removeAllFriendLocations(gpgId);
return false;
}
return false;
}
/* Network Stuff */
bool p3Peers::connectAttempt(const std::string &id)
bool p3Peers::connectAttempt(const RsPeerId &id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::connectAttempt() " << id << std::endl;
@ -735,7 +719,7 @@ bool p3Peers::getAllowServerIPDetermination()
return mNetMgr->getIPServersEnabled() ;
}
bool p3Peers::setLocation(const std::string &ssl_id, const std::string &location)
bool p3Peers::setLocation(const RsPeerId &ssl_id, const std::string &location)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setLocation() " << ssl_id << std::endl;
@ -745,7 +729,7 @@ bool p3Peers::setLocation(const std::string &ssl_id, const std::string &locatio
}
bool splitAddressString(const std::string &addr, std::string &domain, uint16_t &port)
bool splitAddressString(const std::string &addr, std::string &domain, uint16_t &port)
{
std::cerr << "splitAddressString() Input: " << addr << std::endl;
@ -783,7 +767,7 @@ bool splitAddressString(const std::string &addr, std::string &domain, uint16_t
}
bool p3Peers::setHiddenNode(const std::string &id, const std::string &hidden_node_address)
bool p3Peers::setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setHiddenNode() " << id << std::endl;
@ -801,7 +785,7 @@ bool p3Peers::setHiddenNode(const std::string &id, const std::string &hidden_no
}
bool p3Peers::setHiddenNode(const std::string &id, const std::string &address, uint16_t port)
bool p3Peers::setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setHiddenNode() " << id << std::endl;
@ -814,7 +798,7 @@ bool p3Peers::setHiddenNode(const std::string &id, const std::string &address,
return true;
}
bool p3Peers::setLocalAddress(const std::string &id, const std::string &addr_str, uint16_t port)
bool p3Peers::setLocalAddress(const RsPeerId &id, const std::string &addr_str, uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setLocalAddress() " << id << std::endl;
@ -840,7 +824,7 @@ bool p3Peers::setLocalAddress(const std::string &id, const std::string &addr_st
return false;
}
bool p3Peers::setExtAddress(const std::string &id, const std::string &addr_str, uint16_t port)
bool p3Peers::setExtAddress(const RsPeerId &id, const std::string &addr_str, uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setExtAddress() " << id << std::endl;
@ -867,7 +851,7 @@ bool p3Peers::setExtAddress(const std::string &id, const std::string &addr_str,
return false;
}
bool p3Peers::setDynDNS(const std::string &id, const std::string &dyndns)
bool p3Peers::setDynDNS(const RsPeerId &id, const std::string &dyndns)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setDynDNS() called with id: " << id << " dyndns: " << dyndns <<std::endl;
@ -875,7 +859,7 @@ bool p3Peers::setDynDNS(const std::string &id, const std::string &dyndns)
return mPeerMgr->setDynDNS(id, dyndns);
}
bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
bool p3Peers::setNetworkMode(const RsPeerId &id, uint32_t extNetMode)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setNetworkMode() " << id << std::endl;
@ -908,7 +892,7 @@ bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
}
bool p3Peers::setVisState(const std::string &id, uint16_t vs_disc, uint16_t vs_dht)
bool p3Peers::setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setVisState() " << id << std::endl;
@ -967,13 +951,33 @@ bool p3Peers::setProxyServer(const std::string &addr_str, const uint16_t port)
//===========================================================================
/* Auth Stuff */
std::string
p3Peers::GetRetroshareInvite(bool include_signatures)
std::string p3Peers::GetRetroshareInvite(bool include_signatures)
{
return GetRetroshareInvite(getOwnId(),include_signatures);
}
std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures)
{
unsigned char *mem_block = NULL;
size_t mem_block_size = 0;
bool p3Peers::GetPGPBase64StringAndCheckSum( const std::string& gpg_id,
if(!AuthGPG::getAuthGPG()->exportPublicKey(RsPgpId(pgp_id),mem_block,mem_block_size,false,include_signatures))
{
std::cerr << "Cannot output certificate for id \"" << pgp_id << "\". Sorry." << std::endl;
return "" ;
}
RsPeerDetails Detail ;
if(!getGPGDetails(pgp_id,Detail) )
return "" ;
RsCertificate cert( Detail,mem_block,mem_block_size ) ;
return cert.armouredPGPKey() ;
}
bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id,
std::string& gpg_base64_string,
std::string& gpg_base64_checksum)
{
@ -983,7 +987,7 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const std::string& gpg_id,
unsigned char *mem_block ;
size_t mem_block_size ;
if(!AuthGPG::getAuthGPG()->exportPublicKey(PGPIdType(gpg_id),mem_block,mem_block_size,false,false))
if(!AuthGPG::getAuthGPG()->exportPublicKey(gpg_id,mem_block,mem_block_size,false,false))
return false ;
Radix64::encode((const char *)mem_block,mem_block_size,gpg_base64_string) ;
@ -998,7 +1002,7 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const std::string& gpg_id,
return true ;
}
std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_signatures)
std::string p3Peers::GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl;
@ -1013,7 +1017,7 @@ std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_
unsigned char *mem_block = NULL;
size_t mem_block_size = 0;
if(!AuthGPG::getAuthGPG()->exportPublicKey(PGPIdType(Detail.gpg_id),mem_block,mem_block_size,false,include_signatures))
if(!AuthGPG::getAuthGPG()->exportPublicKey(RsPgpId(Detail.gpg_id),mem_block,mem_block_size,false,include_signatures))
{
std::cerr << "Cannot output certificate for id \"" << Detail.gpg_id << "\". Sorry." << std::endl;
return "" ;
@ -1033,15 +1037,15 @@ std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_
//===========================================================================
bool p3Peers::loadCertificateFromString(const std::string& cert, std::string& ssl_id, std::string& gpg_id, std::string& error_string)
bool p3Peers::loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id, RsPgpId& gpg_id, std::string& error_string)
{
RsCertificate crt(cert) ;
PGPIdType gpgid ;
RsPgpId gpgid ;
bool res = AuthGPG::getAuthGPG()->LoadCertificateFromString(crt.armouredPGPKey(),gpgid,error_string) ;
gpg_id = gpgid.toStdString() ;
ssl_id = crt.sslid_string() ;
gpg_id = gpgid;
ssl_id = crt.sslid() ;
return res ;
}
@ -1064,10 +1068,10 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
std::cerr << "Parsing cert for sslid, location, ext and local address details. : " << certstr << std::endl;
#endif
pd.id = cert.sslid_string() ;
pd.id = cert.sslid() ;
pd.location = cert.location_name_string();
pd.isOnlyGPGdetail = pd.id.empty();
pd.isOnlyGPGdetail = pd.id.isNull();
pd.service_perm_flags = RS_SERVICE_PERM_ALL ;
if (!cert.hidden_node_string().empty())
@ -1099,7 +1103,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
return false ;
}
if (pd.gpg_id == "")
if (pd.gpg_id.isNull())
return false;
else
return true;
@ -1112,7 +1116,7 @@ bool p3Peers::cleanCertificate(const std::string &certstr, std::string &cleanCer
return RsCertificate::cleanCertificate(certstr,cleanCert,format,error_code) ;
}
bool p3Peers::saveCertificateToFile(const std::string &id, const std::string &/*fname*/)
bool p3Peers::saveCertificateToFile(const RsPeerId &id, const std::string &/*fname*/)
{
/* remove unused parameter warnings */
(void) id;
@ -1128,7 +1132,7 @@ bool p3Peers::saveCertificateToFile(const std::string &id, const std::string &/
return false;
}
std::string p3Peers::saveCertificateToString(const std::string &id)
std::string p3Peers::saveCertificateToString(const RsPeerId &id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::SaveCertificateToString() " << id;
@ -1141,7 +1145,7 @@ std::string p3Peers::saveCertificateToString(const std::string &id)
}
}
bool p3Peers::signGPGCertificate(const std::string &id)
bool p3Peers::signGPGCertificate(const RsPgpId &id)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::SignCertificate() " << id;
@ -1154,54 +1158,15 @@ bool p3Peers::signGPGCertificate(const std::string &id)
}
bool p3Peers::trustGPGCertificate(const std::string &id, uint32_t trustlvl)
bool p3Peers::trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::TrustCertificate() " << id;
std::cerr << std::endl;
#endif
//check if we've got a ssl or gpg id
std::string gpgId = getGPGId(id);
if (gpgId.empty()) {
//if no result then it must be a gpg id
return AuthGPG::getAuthGPG()->TrustCertificate(id, trustlvl);
} else {
return AuthGPG::getAuthGPG()->TrustCertificate(gpgId, trustlvl);
}
return AuthGPG::getAuthGPG()->TrustCertificate(id, trustlvl);
}
//int ensureExtension(std::string &name, std::string def_ext)
//{
// /* if it has an extension, don't change */
// int len = name.length();
// int extpos = name.find_last_of('.');
// std::string out;
// rs_sprintf_append(out, "ensureExtension() name: %s\n\t\t extpos: %d len: \n", name.c_str(), extpos, len);
// /* check that the '.' has between 1 and 4 char after it (an extension) */
// if ((extpos > 0) && (extpos < len - 1) && (extpos + 6 > len))
// {
// /* extension there */
// std::string curext = name.substr(extpos, len);
// out += "ensureExtension() curext: " + curext;
// std::cerr << out << std::endl;
// return 0;
// }
// if (extpos != len - 1)
// {
// name += ".";
// }
// name += def_ext;
// out += "ensureExtension() added ext: " + name;
// std::cerr << out << std::endl;
// return 1;
//}
/* Group Stuff */
bool p3Peers::addGroup(RsGroupInfo &groupInfo)
{
@ -1255,15 +1220,15 @@ bool p3Peers::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
return mPeerMgr->getGroupInfoList(groupInfoList);
}
bool p3Peers::assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign)
bool p3Peers::assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign)
{
std::list<std::string> peerIds;
std::list<RsPgpId> peerIds;
peerIds.push_back(peerId);
return assignPeersToGroup(groupId, peerIds, assign);
}
bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign)
bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::assignPeersToGroup()" << std::endl;
@ -1275,7 +1240,7 @@ bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<std
return res ;
}
FileSearchFlags p3Peers::computePeerPermissionFlags(const std::string& peer_ssl_id,
FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id,
FileStorageFlags share_flags,
const std::list<std::string>& directory_parent_groups)
{
@ -1286,7 +1251,7 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const std::string& peer_ssl_
//
bool found = false ;
std::string pgp_id = getGPGId(peer_ssl_id) ;
RsPgpId pgp_id = getGPGId(peer_ssl_id) ;
for(std::list<std::string>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it)
{
@ -1297,7 +1262,7 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const std::string& peer_ssl_
continue ;
}
for(std::list<std::string>::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2)
for(std::list<RsPgpId>::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2)
if(*it2 == pgp_id)
found = true ;
}
@ -1315,9 +1280,8 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const std::string& peer_ssl_
RsPeerDetails::RsPeerDetails()
:isOnlyGPGdetail(false),
id(""),gpg_id(""),
name(""),email(""),location(""),
org(""),issuer(""),fpr(""),authcode(""),
org(""),authcode(""),
trustLvl(0), validLvl(0),ownsign(false),
hasSignedMe(false),accept_connection(false),
state(0),localAddr(""),localPort(0),extAddr(""),extPort(0),netMode(0),vs_disc(0), vs_dht(0),
@ -1343,7 +1307,7 @@ std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail)
out << " signers:";
out << std::endl;
std::list<std::string>::const_iterator it;
std::list<RsPgpId>::const_iterator it;
for(it = detail.gpgSigners.begin();
it != detail.gpgSigners.end(); it++)
{
@ -1380,15 +1344,15 @@ RsGroupInfo::RsGroupInfo()
flag = 0;
}
ServicePermissionFlags p3Peers::servicePermissionFlags_sslid(const std::string& ssl_id)
ServicePermissionFlags p3Peers::servicePermissionFlags(const RsPeerId& ssl_id)
{
return mPeerMgr->servicePermissionFlags_sslid(ssl_id) ;
return mPeerMgr->servicePermissionFlags(ssl_id) ;
}
ServicePermissionFlags p3Peers::servicePermissionFlags(const std::string& gpg_id)
ServicePermissionFlags p3Peers::servicePermissionFlags(const RsPgpId& gpg_id)
{
return mPeerMgr->servicePermissionFlags(gpg_id) ;
}
void p3Peers::setServicePermissionFlags(const std::string& gpg_id,const ServicePermissionFlags& flags)
void p3Peers::setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags)
{
mPeerMgr->setServicePermissionFlags(gpg_id,flags) ;
}

View file

@ -44,54 +44,54 @@ virtual bool FriendsChanged();
virtual bool OthersChanged();
/* Peer Details (Net & Auth) */
virtual std::string getOwnId();
virtual const RsPeerId& getOwnId();
virtual bool haveSecretKey(const std::string& gpg_id) ;
virtual bool haveSecretKey(const RsPgpId& gpg_id) ;
virtual bool getOnlineList(std::list<std::string> &ids);
virtual bool getFriendList(std::list<std::string> &ids);
virtual bool getOnlineList(std::list<RsPeerId> &ids);
virtual bool getFriendList(std::list<RsPeerId> &ids);
//virtual bool getOthersList(std::list<std::string> &ids);
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl);
virtual bool isOnline(const std::string &id);
virtual bool isFriend(const std::string &id);
virtual bool isGPGAccepted(const std::string &gpg_id_is_friend); //
virtual std::string getGPGName(const std::string &gpg_id);
virtual std::string getPeerName(const std::string &ssl_or_gpg_id);
virtual bool getPeerDetails(const std::string &ssl_or_gpg_id, RsPeerDetails &d);
virtual bool isOnline(const RsPeerId &id);
virtual bool isFriend(const RsPeerId &id);
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend); //
virtual std::string getGPGName(const RsPgpId &gpg_id);
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
/* Using PGP Ids */
virtual std::string getGPGOwnId();
virtual std::string getGPGId(const std::string &ssl_id);
virtual bool isKeySupported(const std::string& ids);
virtual bool getGPGAcceptedList(std::list<std::string> &ids);
virtual bool getGPGSignedList(std::list<std::string> &ids);
virtual bool getGPGValidList(std::list<std::string> &ids);
virtual bool getGPGAllList(std::list<std::string> &ids);
virtual bool getGPGDetails(const std::string &id, RsPeerDetails &d);
virtual bool getAssociatedSSLIds(const std::string &gpg_id, std::list<std::string> &ids);
virtual const RsPgpId& getGPGOwnId();
virtual RsPgpId getGPGId(const RsPeerId &ssl_id);
virtual bool isKeySupported(const RsPgpId& ids);
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
virtual bool getGPGDetails(const RsPgpId &id, RsPeerDetails &d);
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids);
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
/* Add/Remove Friends */
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL);
virtual bool removeFriend(const std::string &ssl_or_gpgid);
virtual bool removeFriendLocation(const std::string &sslId);
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL);
virtual bool removeFriend(const RsPgpId& gpgid);
virtual bool removeFriendLocation(const RsPeerId& sslId);
/* keyring management */
virtual bool removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code);
virtual bool removeKeysFromPGPKeyring(const std::list<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code);
/* Network Stuff */
virtual bool connectAttempt(const std::string &id);
virtual bool setLocation(const std::string &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs
virtual bool setHiddenNode(const std::string &id, const std::string &hidden_node_address);
virtual bool setHiddenNode(const std::string &id, const std::string &address, uint16_t port);
virtual bool connectAttempt(const RsPeerId &id);
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address);
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port);
virtual bool setLocalAddress(const std::string &id, const std::string &addr, uint16_t port);
virtual bool setExtAddress(const std::string &id, const std::string &addr, uint16_t port);
virtual bool setDynDNS(const std::string &id, const std::string &dyndns);
virtual bool setNetworkMode(const std::string &id, uint32_t netMode);
virtual bool setVisState(const std::string &id, uint16_t vs_disc, uint16_t vs_dht);
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
virtual bool getProxyServer(std::string &addr, uint16_t &port);
virtual bool setProxyServer(const std::string &addr, const uint16_t port);
@ -102,22 +102,24 @@ virtual bool getAllowServerIPDetermination() ;
/* Auth Stuff */
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures);
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures);
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
// same but for own id
virtual std::string GetRetroshareInvite(bool include_signatures);
virtual bool GetPGPBase64StringAndCheckSum(const std::string& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) ;
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) ;
virtual bool hasExportMinimal() ;
virtual bool loadCertificateFromString(const std::string& cert, std::string& ssl_id,std::string& pgp_id, std::string& error_string);
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string);
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code);
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code);
virtual bool saveCertificateToFile(const std::string &id, const std::string &fname);
virtual std::string saveCertificateToString(const std::string &id);
virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname);
virtual std::string saveCertificateToString(const RsPeerId &id);
virtual bool signGPGCertificate(const std::string &id);
virtual bool trustGPGCertificate(const std::string &id, uint32_t trustlvl);
virtual bool signGPGCertificate(const RsPgpId &id);
virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl);
/* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo);
@ -125,16 +127,16 @@ virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
virtual bool removeGroup(const std::string &groupId);
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign);
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign);
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId &peerId, bool assign);
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId>& peerIds, bool assign);
virtual FileSearchFlags computePeerPermissionFlags(const std::string& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
// service permission stuff
virtual ServicePermissionFlags servicePermissionFlags(const std::string& gpg_id) ;
virtual ServicePermissionFlags servicePermissionFlags_sslid(const std::string& ssl_id) ;
virtual void setServicePermissionFlags(const std::string& gpg_id,const ServicePermissionFlags& flags) ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id) ;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
private:

View file

@ -206,7 +206,7 @@ int p3ServerConfig::getTotalBandwidthRates(RsConfigDataRates &rates)
}
int p3ServerConfig::getAllBandwidthRates(std::map<std::string, RsConfigDataRates> &ratemap)
int p3ServerConfig::getAllBandwidthRates(std::map<RsPeerId, RsConfigDataRates> &ratemap)
{
if (rsBandwidthControl)
{

View file

@ -57,7 +57,7 @@ virtual int getConfigStartup(RsConfigStartup &params);
/***** for RsConfig -> p3BandwidthControl ****/
virtual int getTotalBandwidthRates(RsConfigDataRates &rates);
virtual int getAllBandwidthRates(std::map<std::string, RsConfigDataRates> &ratemap);
virtual int getAllBandwidthRates(std::map<RsPeerId, RsConfigDataRates> &ratemap);
/* From RsInit */

View file

@ -47,12 +47,12 @@ bool p3Status::getStatusList(std::list<StatusInfo>& statusInfo){
return mStatusSrv->getStatusList(statusInfo);
}
bool p3Status::getStatus(const std::string &id, StatusInfo &statusInfo)
bool p3Status::getStatus(const RsPeerId &id, StatusInfo &statusInfo)
{
return mStatusSrv->getStatus(id, statusInfo);
}
bool p3Status::sendStatus(const std::string &id, uint32_t status){
bool p3Status::sendStatus(const RsPeerId &id, uint32_t status){
return mStatusSrv->sendStatus(id, status);
}

View file

@ -45,8 +45,8 @@ public:
virtual bool getOwnStatus(StatusInfo& statusInfo);
virtual bool getStatusList(std::list<StatusInfo>& statusInfo);
virtual bool getStatus(const std::string &id, StatusInfo &statusInfo);
virtual bool sendStatus(const std::string &id, uint32_t status);
virtual bool getStatus(const RsPeerId &id, StatusInfo &statusInfo);
virtual bool sendStatus(const RsPeerId &id, uint32_t status);
private:

View file

@ -100,14 +100,6 @@ bool RsAccountsDetail::lockPreferredAccount()
bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString)
{
std::string lower_case_user_string;
stringToLowerCase(prefUserString, lower_case_user_string) ;
std::string upper_case_user_string;
stringToUpperCase(prefUserString, upper_case_user_string) ;
std::cerr << "RsAccountsDetail::selectAccountByString(" << prefUserString << ")";
std::cerr << std::endl;
if (mAccountsLocked)
{
std::cerr << "RsAccountsDetail::selectAccountByString() ERROR Accounts Locked";
@ -115,18 +107,22 @@ bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString)
return false;
}
// try both.
//
RsPeerId ssl_id(prefUserString) ;
RsPgpId pgp_id(prefUserString) ;
std::cerr << "RsAccountsDetail::selectAccountByString(" << prefUserString << ")" << std::endl;
bool pgpNameFound = false;
std::map<std::string, AccountDetails>::const_iterator it;
std::map<RsPeerId, AccountDetails>::const_iterator it;
for(it = mAccounts.begin() ; it!= mAccounts.end() ; it++)
{
std::cerr << "\tChecking account (pgpid = " << it->second.mPgpId;
std::cerr << ", name=" << it->second.mPgpName << ", sslId=";
std::cerr << it->second.mSslId << ")" << std::endl;
if(prefUserString == it->second.mPgpName ||
upper_case_user_string == it->second.mPgpId ||
lower_case_user_string == it->second.mSslId)
if(prefUserString == it->second.mPgpName || pgp_id == it->second.mPgpId || ssl_id == it->second.mSslId)
{
mPreferredId = it->second.mSslId;
pgpNameFound = true;
@ -136,7 +132,7 @@ bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString)
}
bool RsAccountsDetail::selectId(const std::string preferredId)
bool RsAccountsDetail::selectId(const RsPeerId& preferredId)
{
if (mAccountsLocked)
@ -146,7 +142,7 @@ bool RsAccountsDetail::selectId(const std::string preferredId)
return false;
}
std::map<std::string, AccountDetails>::const_iterator it;
std::map<RsPeerId, AccountDetails>::const_iterator it;
it = mAccounts.find(preferredId);
if (it != mAccounts.end())
@ -163,7 +159,7 @@ bool RsAccountsDetail::selectId(const std::string preferredId)
bool RsAccountsDetail::checkPreferredId()
{
std::map<std::string, AccountDetails>::const_iterator it;
std::map<RsPeerId, AccountDetails>::const_iterator it;
it = mAccounts.find(mPreferredId);
if (it != mAccounts.end())
@ -172,7 +168,7 @@ bool RsAccountsDetail::checkPreferredId()
}
else
{
mPreferredId = "";
mPreferredId.clear();
return false;
}
}
@ -208,7 +204,7 @@ std::string RsAccountsDetail::PathAccountDirectory()
{
std::string path;
std::map<std::string, AccountDetails>::const_iterator it;
std::map<RsPeerId, AccountDetails>::const_iterator it;
it = mAccounts.find(mPreferredId);
if (it == mAccounts.end())
{
@ -371,7 +367,10 @@ bool RsAccountsDetail::loadPreferredAccount()
path[i] = '\0';
// Store PreferredId.
mPreferredId = path;
mPreferredId = RsPeerId(std::string(path));
if(mPreferredId.isNull())
return false ;
}
fclose(ifd);
return true;
@ -390,7 +389,7 @@ bool RsAccountsDetail::storePreferredAccount()
if (ifd != NULL)
{
fprintf(ifd, "%s\n", mPreferredId.c_str());
fprintf(ifd, "%s\n", mPreferredId.toStdString().c_str());
fclose(ifd);
std::cerr << "Creating Init File: " << initfile << std::endl;
@ -408,15 +407,15 @@ bool RsAccountsDetail::storePreferredAccount()
*
*/
bool RsAccountsDetail::getPreferredAccountId(std::string &id)
bool RsAccountsDetail::getPreferredAccountId(RsPeerId &id)
{
id = mPreferredId;
return (mPreferredId != "");
return (!mPreferredId.isNull());
}
bool RsAccountsDetail::getAccountIds(std::list<std::string> &ids)
bool RsAccountsDetail::getAccountIds(std::list<RsPeerId> &ids)
{
std::map<std::string, AccountDetails>::iterator it;
std::map<RsPeerId, AccountDetails>::iterator it;
std::cerr << "getAccountIds:" << std::endl;
for(it = mAccounts.begin(); it != mAccounts.end(); it++)
@ -433,11 +432,11 @@ bool RsAccountsDetail::getAccountIds(std::list<std::string> &ids)
}
bool RsAccountsDetail::getAccountDetails(const std::string &id,
std::string &gpgId, std::string &gpgName,
bool RsAccountsDetail::getAccountDetails(const RsPeerId &id,
RsPgpId &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location)
{
std::map<std::string, AccountDetails>::iterator it;
std::map<RsPeerId, AccountDetails>::iterator it;
it = mAccounts.find(id);
if (it != mAccounts.end())
{
@ -452,7 +451,7 @@ bool RsAccountsDetail::getAccountDetails(const std::string &id,
bool RsAccountsDetail::getAccountOptions(bool &ishidden, bool isFirstTimeRun)
{
std::map<std::string, AccountDetails>::iterator it;
std::map<RsPeerId, AccountDetails>::iterator it;
it = mAccounts.find(mPreferredId);
if (it != mAccounts.end())
{
@ -465,7 +464,7 @@ bool RsAccountsDetail::getAccountOptions(bool &ishidden, bool isFirstTimeRun)
/* directories with valid certificates in the expected location */
bool RsAccountsDetail::getAvailableAccounts(std::map<std::string, AccountDetails> &accounts,int& failing_accounts,std::map<std::string,std::vector<std::string> >& unsupported_keys)
bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &accounts,int& failing_accounts,std::map<std::string,std::vector<std::string> >& unsupported_keys)
{
failing_accounts = 0 ;
/* get the directories */
@ -584,7 +583,7 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<std::string, AccountDetails
std::cerr << "getAvailableAccounts() Accepted: " << *it << std::endl;
#endif
std::map<std::string, AccountDetails>::iterator ait;
std::map<RsPeerId, AccountDetails>::iterator ait;
ait = accounts.find(tmpId.mSslId);
if (ait != accounts.end())
{
@ -623,7 +622,7 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
basename += "user";
std::string cert_name = basename + "_cert.pem";
std::string userName, userId;
std::string userName;
#ifdef AUTHSSL_DEBUG
std::cerr << "checkAccount() dir: " << accountdir << std::endl;
@ -646,8 +645,8 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
if(!AuthGPG::getAuthGPG()->isKeySupported(account.mPgpId))
{
std::string keystring = account.mPgpId + " " + account.mPgpName + "&#60;" + account.mPgpEmail ;
unsupported_keys[keystring].push_back("Location: " + account.mLocation + "&nbsp;&nbsp;(" + account.mSslId + ")") ;
std::string keystring = account.mPgpId.toStdString() + " " + account.mPgpName + "&#60;" + account.mPgpEmail ;
unsupported_keys[keystring].push_back("Location: " + account.mLocation + "&nbsp;&nbsp;(" + account.mSslId.toStdString() + ")") ;
return false ;
}
@ -788,12 +787,12 @@ std::string RsAccountsDetail::PathDataDirectory()
/* Generating GPGme Account */
int RsAccountsDetail::GetPGPLogins(std::list<std::string> &pgpIds) {
int RsAccountsDetail::GetPGPLogins(std::list<RsPgpId> &pgpIds) {
AuthGPG::getAuthGPG()->availableGPGCertificatesWithPrivateKeys(pgpIds);
return 1;
}
int RsAccountsDetail::GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email)
int RsAccountsDetail::GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email)
{
#ifdef GPG_DEBUG
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"" << std::endl;
@ -819,7 +818,7 @@ int RsAccountsDetail::GetPGPLoginDetails(const std::string& id, std::string
/* Before any SSL stuff can be loaded, the correct PGP must be selected / generated:
**/
bool RsAccountsDetail::SelectPGPAccount(const std::string& pgpId)
bool RsAccountsDetail::SelectPGPAccount(const RsPgpId& pgpId)
{
bool retVal = false;
@ -837,7 +836,7 @@ bool RsAccountsDetail::SelectPGPAccount(const std::string& pgpId)
}
bool RsAccountsDetail::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString)
bool RsAccountsDetail::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString)
{
return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, errString);
}
@ -849,12 +848,12 @@ void RsAccountsDetail::getUnsupportedKeys(std::map<std::string,std::vector<std::
return;
}
bool RsAccountsDetail::exportIdentity(const std::string& fname,const std::string& id)
bool RsAccountsDetail::exportIdentity(const std::string& fname,const RsPgpId& id)
{
return AuthGPG::getAuthGPG()->exportProfile(fname,id);
}
bool RsAccountsDetail::importIdentity(const std::string& fname,std::string& id,std::string& import_error)
bool RsAccountsDetail::importIdentity(const std::string& fname,RsPgpId& id,std::string& import_error)
{
return AuthGPG::getAuthGPG()->importProfile(fname,id,import_error);
}
@ -917,7 +916,7 @@ bool RsAccountsDetail::copyGnuPGKeyrings()
/* Create SSL Certificates */
bool RsAccountsDetail::GenerateSSLCertificate(const std::string& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, std::string &sslId, std::string &errString)
bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
{
/* select the PGP Identity first */
if (!SelectPGPAccount(pgp_id))
@ -1045,7 +1044,8 @@ bool RsAccountsDetail::GenerateSSLCertificate(const std::string& pgp_id, con
/* try to load it, and get Id */
std::string location;
std::string pgpid_retrieved;
RsPgpId pgpid_retrieved;
if (LoadCheckX509(cert_name.c_str(), pgpid_retrieved, location, sslId) == 0) {
std::cerr << "RsInit::GenerateSSLCertificate() Cannot check own signature, maybe the files are corrupted." << std::endl;
return false;
@ -1054,13 +1054,9 @@ bool RsAccountsDetail::GenerateSSLCertificate(const std::string& pgp_id, con
/* Move directory to correct id */
std::string accountdir;
if (ishiddenloc)
{
accountdir = "HID06_" + sslId;
}
accountdir = "HID06_" + sslId.toStdString();
else
{
accountdir = "LOC06_" + sslId;
}
accountdir = "LOC06_" + sslId.toStdString();
std::string fullAccountDir = mBaseDirectory + "/" + accountdir;
std::string finalbase = fullAccountDir + "/";
@ -1253,28 +1249,28 @@ std::string RsAccounts::PGPDirectory() { return rsAccounts.PathPGPDirectory(); }
std::string RsAccounts::AccountDirectory() { return rsAccounts.PathAccountDirectory(); }
// PGP Accounts.
int RsAccounts::GetPGPLogins(std::list<std::string> &pgpIds)
int RsAccounts::GetPGPLogins(std::list<RsPgpId> &pgpIds)
{
return rsAccounts.GetPGPLogins(pgpIds);
}
int RsAccounts::GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email)
int RsAccounts::GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email)
{
return rsAccounts.GetPGPLoginDetails(id, name, email);
}
bool RsAccounts::GeneratePGPCertificate(const std::string &name, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString)
bool RsAccounts::GeneratePGPCertificate(const std::string &name, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString)
{
return rsAccounts.GeneratePGPCertificate(name, email, passwd, pgpId, errString);
}
// PGP Support Functions.
bool RsAccounts::ExportIdentity(const std::string& fname,const std::string& pgp_id)
bool RsAccounts::ExportIdentity(const std::string& fname,const RsPgpId& pgp_id)
{
return rsAccounts.exportIdentity(fname,pgp_id);
}
bool RsAccounts::ImportIdentity(const std::string& fname,std::string& imported_pgp_id,std::string& import_error)
bool RsAccounts::ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error)
{
return rsAccounts.importIdentity(fname,imported_pgp_id,import_error);
}
@ -1290,29 +1286,29 @@ bool RsAccounts::CopyGnuPGKeyrings()
}
// Rs Accounts
bool RsAccounts::SelectAccount(const std::string &id)
bool RsAccounts::SelectAccount(const RsPeerId &id)
{
return rsAccounts.selectId(id);
}
bool RsAccounts::GetPreferredAccountId(std::string &id)
bool RsAccounts::GetPreferredAccountId(RsPeerId &id)
{
return rsAccounts.getPreferredAccountId(id);
}
bool RsAccounts::GetAccountIds(std::list<std::string> &ids)
bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids)
{
return rsAccounts.getAccountIds(ids);
}
bool RsAccounts::GetAccountDetails(const std::string &id,
std::string &pgpId, std::string &pgpName,
bool RsAccounts::GetAccountDetails(const RsPeerId &id,
RsPgpId &pgpId, std::string &pgpName,
std::string &pgpEmail, std::string &location)
{
return rsAccounts.getAccountDetails(id, pgpId, pgpName, pgpEmail, location);
}
bool RsAccounts::GenerateSSLCertificate(const std::string& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, std::string &sslId, std::string &errString)
bool RsAccounts::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
{
return rsAccounts.GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString);
}

View file

@ -36,20 +36,21 @@
#include <string>
#include <list>
#include <map>
#include "retroshare/rstypes.h"
class AccountDetails
{
public:
AccountDetails();
std::string mSslId;
RsPeerId mSslId;
std::string mAccountDir;
std::string mPgpId;
RsPgpId mPgpId;
std::string mPgpName;
std::string mPgpEmail;
std::string mLocation;
std::string mLocation;
bool mIsHiddenLoc;
bool mFirstRun;
@ -85,38 +86,36 @@ class RsAccountsDetail
// PGP Accounts.
int GetPGPLogins(std::list<std::string> &pgpIds);
int GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email);
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString);
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString);
bool SelectPGPAccount(const std::string& pgpId);
bool SelectPGPAccount(const RsPgpId& pgpId);
// PGP Support Functions.
bool exportIdentity(const std::string& fname,const std::string& pgp_id) ;
bool importIdentity(const std::string& fname,std::string& imported_pgp_id,std::string& import_error) ;
bool exportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
bool importIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
bool copyGnuPGKeyrings() ;
// Selecting Rs Account.
bool selectAccountByString(const std::string &prefUserString);
bool selectId(const std::string preferredId);
bool selectId(const RsPeerId& preferredId);
// Details of Rs Account.
bool getPreferredAccountId(std::string &id);
bool getAccountDetails(const std::string &id,
std::string &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location);
bool getPreferredAccountId(RsPeerId &id);
bool getAccountDetails(const RsPeerId &id, RsPgpId& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
bool getAccountOptions(bool &ishidden, bool isFirstTimeRun);
bool getAccountIds(std::list<std::string> &ids);
bool getAccountIds(std::list<RsPeerId> &ids);
bool GenerateSSLCertificate(const std::string& gpg_id,
bool GenerateSSLCertificate(const RsPgpId& gpg_id,
const std::string& org, const std::string& loc,
const std::string& country, const bool ishiddenloc,
const std::string& passwd, std::string &sslId,
const std::string& passwd, RsPeerId &sslId,
std::string &errString);
// From init file.
@ -130,7 +129,7 @@ class RsAccountsDetail
std::string getHomePath() ;
bool getAvailableAccounts(std::map<std::string, AccountDetails> &accounts,
bool getAvailableAccounts(std::map<RsPeerId, AccountDetails> &accounts,
int& failing_accounts,
std::map<std::string,std::vector<std::string> >& unsupported_keys);
@ -140,8 +139,8 @@ class RsAccountsDetail
bool mAccountsLocked;
std::map<std::string, AccountDetails> mAccounts;
std::string mPreferredId;
std::map<RsPeerId, AccountDetails> mAccounts;
RsPeerId mPreferredId;
std::string mBaseDirectory;
std::map<std::string,std::vector<std::string> > mUnsupportedKeys ;

View file

@ -86,7 +86,7 @@ class RsInitConfig
{
public:
static std::string main_executable_hash;
static RsFileHash main_executable_hash;
#ifdef WINDOWS_SYS
static bool portable;
@ -143,7 +143,7 @@ const int p3facestartupzone = 47238;
static const std::string configLogFileName = "retro.log";
static const int SSLPWD_LEN = 64;
std::string RsInitConfig::main_executable_hash;
RsFileHash RsInitConfig::main_executable_hash;
rs_lock_handle_t RsInitConfig::lockHandle;
@ -350,7 +350,6 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
#endif
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
int c;
std::string prefUserString = "";
std::string opt_base_dir;
@ -566,7 +565,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
}
/* check that we have selected someone */
std::string preferredId;
RsPeerId preferredId;
bool existingUser = rsAccounts.getPreferredAccountId(preferredId);
if (existingUser)
@ -652,22 +651,20 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
}
// Logic that used to be external to RsInit...
std::string accountId;
RsPeerId accountId;
if (!rsAccounts.getPreferredAccountId(accountId))
{
return 3; // invalid PreferredAccount;
}
std::string pgpId, pgpName, pgpEmail, location;
RsPgpId pgpId;
std::string pgpName, pgpEmail, location;
if (!rsAccounts.getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
{
return 3; // invalid PreferredAccount;
}
if (!rsAccounts.SelectPGPAccount(pgpId))
{
return 3; // PGP Error.
}
int retVal = LockConfigDirectory(rsAccounts.PathAccountDirectory(), lockFilePath);
if(retVal != 0)
@ -694,7 +691,7 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
*/
int RsInit::LoadCertificates(bool autoLoginNT)
{
std::string preferredId;
RsPeerId preferredId;
if (!rsAccounts.getPreferredAccountId(preferredId))
{
std::cerr << "No Account Selected" << std::endl;
@ -758,7 +755,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
bool RsInit::RsClearAutoLogin()
{
std::string preferredId;
RsPeerId preferredId;
if (!rsAccounts.getPreferredAccountId(preferredId))
{
std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl;
@ -982,7 +979,7 @@ int RsServer::StartupRetroShare()
return false ;
}
std::string ownId = AuthSSL::getAuthSSL()->OwnId();
RsPeerId ownId = AuthSSL::getAuthSSL()->OwnId();
/**************************************************************************/
/* Any Initial Configuration (Commandline Options) */
@ -1360,17 +1357,15 @@ int RsServer::StartupRetroShare()
// empty and matches an exist directory location
// the given ssl user id then this directory is cleaned
// and deleted
std::string priorGxsDir = "./" + mLinkMgr->getOwnId() + "/";
std::string priorGxsDir = "./" + mLinkMgr->getOwnId().toStdString() + "/";
std::string currGxsDir = rsAccounts.PathAccountDirectory() + "/GXS_phase2";
#ifdef GXS_DEV_TESTNET // Different Directory for testing.
currGxsDir += "_TESTNET9";
#endif
bool cleanUpGxsDir = false;
if(!priorGxsDir.empty())
cleanUpGxsDir = RsDirUtil::checkDirectory(priorGxsDir);
RsDirUtil::checkDirectory(priorGxsDir);
std::set<std::string> filesToKeep;
bool cleanUpSuccess = RsDirUtil::cleanupDirectory(priorGxsDir, filesToKeep);
@ -1406,7 +1401,7 @@ int RsServer::StartupRetroShare()
RsGxsNetService* gxsid_ns = new RsGxsNetService(
RS_SERVICE_GXSV2_TYPE_GXSID, gxsid_ds, nxsMgr,
mGxsIdService, mGxsIdService, mGxsCircles,
false); // don't synchronise group automatic (need explicit group request)
true); // don't synchronise group automatic (need explicit group request)
mGxsIdService->setNes(gxsid_ns);
/**** GxsCircle service ****/
@ -1820,3 +1815,10 @@ int RsServer::StartupRetroShare()
return 1;
}
void chris_test()
{
std::cout << "tested\n";
}

View file

@ -97,7 +97,7 @@ extern BOOL WINAPI CryptUnprotectData(
#endif
bool RsLoginHandler::getSSLPassword(const std::string& ssl_id,bool enable_gpg_ask_passwd,std::string& ssl_passwd)
bool RsLoginHandler::getSSLPassword(const RsPeerId& ssl_id,bool enable_gpg_ask_passwd,std::string& ssl_passwd)
{
// First, see if autologin is available
//
@ -113,7 +113,7 @@ bool RsLoginHandler::getSSLPassword(const std::string& ssl_id,bool enable_gpg_as
return getSSLPasswdFromGPGFile(ssl_id,ssl_passwd) ;
}
bool RsLoginHandler::tryAutoLogin(const std::string& ssl_id,std::string& ssl_passwd)
bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd)
{
std::cerr << "RsTryAutoLogin()" << std::endl;
@ -124,7 +124,7 @@ bool RsLoginHandler::tryAutoLogin(const std::string& ssl_id,std::string& ssl_pas
gchar *passwd = NULL;
std::cerr << "Using attribute: " << ssl_id << std::endl;
if( gnome_keyring_find_password_sync(&my_schema, &passwd,"RetroShare SSL Id",ssl_id.c_str(),NULL) == GNOME_KEYRING_RESULT_OK )
if( gnome_keyring_find_password_sync(&my_schema, &passwd,"RetroShare SSL Id",ssl_id.toStdString().c_str(),NULL) == GNOME_KEYRING_RESULT_OK )
{
std::cerr << "Got SSL passwd ********************" /*<< passwd*/ << " from gnome keyring" << std::endl;
ssl_passwd = std::string(passwd);
@ -355,14 +355,14 @@ bool RsLoginHandler::tryAutoLogin(const std::string& ssl_id,std::string& ssl_pas
}
bool RsLoginHandler::enableAutoLogin(const std::string& ssl_id,const std::string& ssl_passwd)
bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& ssl_passwd)
{
std::cerr << "RsStoreAutoLogin()" << std::endl;
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS /* UNIX */
#if defined(UBUNTU) || defined(__FreeBSD__) || defined(__OpenBSD__)
if(GNOME_KEYRING_RESULT_OK == gnome_keyring_store_password_sync(&my_schema, NULL, (gchar*)("RetroShare password for SSL Id "+ssl_id).c_str(),(gchar*)ssl_passwd.c_str(),"RetroShare SSL Id",ssl_id.c_str(),NULL))
if(GNOME_KEYRING_RESULT_OK == gnome_keyring_store_password_sync(&my_schema, NULL, (gchar*)("RetroShare password for SSL Id "+ssl_id.toStdString()).c_str(),(gchar*)ssl_passwd.c_str(),"RetroShare SSL Id",ssl_id.toStdString().c_str(),NULL))
{
std::cerr << "Stored passwd " << "************************" << " into gnome keyring" << std::endl;
return true ;
@ -519,10 +519,10 @@ bool RsLoginHandler::enableAutoLogin(const std::string& ssl_id,const std::string
return false;
}
bool RsLoginHandler::clearAutoLogin(const std::string& ssl_id)
bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id)
{
#ifdef UBUNTU
if(GNOME_KEYRING_RESULT_OK == gnome_keyring_delete_password_sync(&my_schema,"RetroShare SSL Id", ssl_id.c_str(),NULL))
if(GNOME_KEYRING_RESULT_OK == gnome_keyring_delete_password_sync(&my_schema,"RetroShare SSL Id", ssl_id.toStdString().c_str(),NULL))
{
std::cerr << "Successfully Cleared gnome keyring passwd for SSLID " << ssl_id << std::endl;
return true ;
@ -621,7 +621,7 @@ bool RsLoginHandler::clearAutoLogin(const std::string& ssl_id)
#endif
}
bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(const std::string& ssl_id,const std::string& ssl_passwd)
bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(const RsPeerId& ssl_id,const std::string& ssl_passwd)
{
// We want to pursue login with gpg passwd. Let's do it:
//
@ -652,7 +652,7 @@ bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(const std::string& ssl_id
return ok ;
}
bool RsLoginHandler::getSSLPasswdFromGPGFile(const std::string& ssl_id,std::string& sslPassword)
bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string& sslPassword)
{
// Let's read the password from an encrypted file
// Let's check if there's a ssl_passpharese_file that we can decrypt with PGP
@ -687,12 +687,12 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const std::string& ssl_id,std::stri
}
std::string RsLoginHandler::getSSLPasswdFileName(const std::string& /*ssl_id*/)
std::string RsLoginHandler::getSSLPasswdFileName(const RsPeerId& /*ssl_id*/)
{
return rsAccounts.PathAccountKeysDirectory() + "/" + "ssl_passphrase.pgp";
}
std::string RsLoginHandler::getAutologinFileName(const std::string& /*ssl_id*/)
std::string RsLoginHandler::getAutologinFileName(const RsPeerId& /*ssl_id*/)
{
return rsAccounts.PathAccountKeysDirectory() + "/" + "help.dta" ;
}

View file

@ -22,26 +22,26 @@ class RsLoginHandler
public:
// Gets the SSL passwd by any means: try autologin, and look into gpg file if enable_gpg_key_callback==true
//
static bool getSSLPassword(const std::string& ssl_id,bool enable_gpg_key_callback,std::string& ssl_password) ;
static bool getSSLPassword(const RsPeerId& ssl_id,bool enable_gpg_key_callback,std::string& ssl_password) ;
// Checks whether the ssl passwd is already in the gpg file. If the file's not here, the passwd is stored there,
// encrypted with the current GPG key.
//
static bool checkAndStoreSSLPasswdIntoGPGFile(const std::string& ssl_id,const std::string& ssl_passwd) ;
static bool checkAndStoreSSLPasswdIntoGPGFile(const RsPeerId& ssl_id,const std::string& ssl_passwd) ;
// Stores the given ssl_id/passwd pair into the keyring, or by default into a file in /[ssl_id]/keys/help.dta
//
static bool enableAutoLogin(const std::string& ssl_id,const std::string& passwd) ;
static bool enableAutoLogin(const RsPeerId& ssl_id,const std::string& passwd) ;
// Clears autologin entry.
//
static bool clearAutoLogin(const std::string& ssl_id) ;
static bool clearAutoLogin(const RsPeerId& ssl_id) ;
private:
static bool tryAutoLogin(const std::string& ssl_id,std::string& ssl_passwd) ;
static bool getSSLPasswdFromGPGFile(const std::string& ssl_id,std::string& sslPassword) ;
static bool tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd) ;
static bool getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string& sslPassword) ;
static std::string getSSLPasswdFileName(const std::string& ssl_id) ;
static std::string getAutologinFileName(const std::string& ssl_id) ;
static std::string getSSLPasswdFileName(const RsPeerId& ssl_id) ;
static std::string getAutologinFileName(const RsPeerId& ssl_id) ;
};