Merge pull request #1296 from chelovechishko/namespaces

fix ODR violations caused by same names for different things
This commit is contained in:
G10h4ck 2018-07-09 10:55:07 +02:00 committed by GitHub
commit 4b6fd5d944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 133 additions and 118 deletions

View File

@ -89,11 +89,11 @@ static const std::string kConfigKeyProxyServerIpAddrTor = "PROXY_SERVER_IPADDR";
static const std::string kConfigKeyProxyServerPortTor = "PROXY_SERVER_PORT"; static const std::string kConfigKeyProxyServerPortTor = "PROXY_SERVER_PORT";
static const std::string kConfigKeyProxyServerIpAddrI2P = "PROXY_SERVER_IPADDR_I2P"; static const std::string kConfigKeyProxyServerIpAddrI2P = "PROXY_SERVER_IPADDR_I2P";
static const std::string kConfigKeyProxyServerPortI2P = "PROXY_SERVER_PORT_I2P"; static const std::string kConfigKeyProxyServerPortI2P = "PROXY_SERVER_PORT_I2P";
void printConnectState(std::ostream &out, peerState &peer); void printConnectState(std::ostream &out, peerState &peer);
peerState::peerState() peerState::peerState()
:netMode(RS_NET_MODE_UNKNOWN), vs_disc(RS_VS_DISC_FULL), vs_dht(RS_VS_DHT_FULL), lastcontact(0), :netMode(RS_NET_MODE_UNKNOWN), vs_disc(RS_VS_DISC_FULL), vs_dht(RS_VS_DHT_FULL), lastcontact(0),
hiddenNode(false), hiddenPort(0), hiddenType(RS_HIDDEN_TYPE_NONE) hiddenNode(false), hiddenPort(0), hiddenType(RS_HIDDEN_TYPE_NONE)
{ {
sockaddr_storage_clear(localaddr); sockaddr_storage_clear(localaddr);
@ -107,13 +107,13 @@ std::string textPeerConnectState(peerState &state)
std::string out = "Id: " + state.id.toStdString() + "\n"; std::string out = "Id: " + state.id.toStdString() + "\n";
rs_sprintf_append(out, "NetMode: %lu\n", state.netMode); rs_sprintf_append(out, "NetMode: %lu\n", state.netMode);
rs_sprintf_append(out, "VisState: Disc: %u Dht: %u\n", state.vs_disc, state.vs_dht); rs_sprintf_append(out, "VisState: Disc: %u Dht: %u\n", state.vs_disc, state.vs_dht);
out += "laddr: "; out += "laddr: ";
out += sockaddr_storage_tostring(state.localaddr); out += sockaddr_storage_tostring(state.localaddr);
out += "\neaddr: "; out += "\neaddr: ";
out += sockaddr_storage_tostring(state.serveraddr); out += sockaddr_storage_tostring(state.serveraddr);
out += "\n"; out += "\n";
return out; return out;
} }
@ -136,7 +136,7 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_
mOwnState.netMode = RS_NET_MODE_UPNP; // Default to UPNP. mOwnState.netMode = RS_NET_MODE_UPNP; // Default to UPNP.
mOwnState.vs_disc = RS_VS_DISC_FULL; mOwnState.vs_disc = RS_VS_DISC_FULL;
mOwnState.vs_dht = RS_VS_DHT_FULL; mOwnState.vs_dht = RS_VS_DHT_FULL;
// setup default ProxyServerAddress. // setup default ProxyServerAddress.
// Tor // Tor
sockaddr_storage_clear(mProxyServerAddressTor); sockaddr_storage_clear(mProxyServerAddressTor);
@ -154,7 +154,7 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_
mProxyServerStatusTor = RS_NET_PROXY_STATUS_UNKNOWN ; mProxyServerStatusTor = RS_NET_PROXY_STATUS_UNKNOWN ;
mProxyServerStatusI2P = RS_NET_PROXY_STATUS_UNKNOWN; mProxyServerStatusI2P = RS_NET_PROXY_STATUS_UNKNOWN;
} }
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgr() Startup" << std::endl; std::cerr << "p3PeerMgr() Startup" << std::endl;
#endif #endif
@ -222,8 +222,8 @@ bool p3PeerMgrIMPL::forceHiddenNode()
struct sockaddr_storage loopback; struct sockaddr_storage loopback;
sockaddr_storage_clear(loopback); sockaddr_storage_clear(loopback);
sockaddr_storage_ipv4_aton(loopback, "127.0.0.1"); sockaddr_storage_ipv4_aton(loopback, "127.0.0.1");
uint16_t port = sockaddr_storage_port(mOwnState.localaddr); uint16_t port = sockaddr_storage_port(mOwnState.localaddr);
sockaddr_storage_ipv4_setport(loopback, port); sockaddr_storage_ipv4_setport(loopback, port);
setLocalAddress(AuthSSL::getAuthSSL()->OwnId(), loopback); setLocalAddress(AuthSSL::getAuthSSL()->OwnId(), loopback);
@ -254,7 +254,7 @@ bool p3PeerMgrIMPL::setOwnNetworkMode(uint32_t netMode)
changed = true; changed = true;
} }
} }
// Pass on Flags to NetMgr. // Pass on Flags to NetMgr.
mNetMgr->setNetworkMode((netMode & RS_NET_MODE_ACTUAL)); mNetMgr->setNetworkMode((netMode & RS_NET_MODE_ACTUAL));
return changed; return changed;
@ -267,7 +267,7 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht)
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::string out; std::string out;
rs_sprintf(out, "p3PeerMgr::setOwnVisState() Existing vis: %u/%u Input vis: %u/%u", rs_sprintf(out, "p3PeerMgr::setOwnVisState() Existing vis: %u/%u Input vis: %u/%u",
mOwnState.vs_disc, mOwnState.vs_dht, vs_disc, vs_dht); mOwnState.vs_disc, mOwnState.vs_dht, vs_disc, vs_dht);
rslog(RSL_WARNING, p3peermgrzone, out); rslog(RSL_WARNING, p3peermgrzone, out);
@ -275,7 +275,7 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht)
std::cerr << out.c_str() << std::endl; std::cerr << out.c_str() << std::endl;
#endif #endif
if (mOwnState.vs_disc != vs_disc || mOwnState.vs_dht != vs_dht) if (mOwnState.vs_disc != vs_disc || mOwnState.vs_dht != vs_dht)
{ {
mOwnState.vs_disc = vs_disc; mOwnState.vs_disc = vs_disc;
mOwnState.vs_dht = vs_dht; mOwnState.vs_dht = vs_dht;
@ -283,7 +283,7 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht)
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
} }
} }
// Pass on Flags to NetMgr. // Pass on Flags to NetMgr.
mNetMgr->setVisState(vs_disc, vs_dht); mNetMgr->setVisState(vs_disc, vs_dht);
@ -575,7 +575,7 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::strin
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
if (ssl_id == AuthSSL::getAuthSSL()->OwnId()) if (ssl_id == AuthSSL::getAuthSSL()->OwnId())
{ {
mOwnState.hiddenNode = true; mOwnState.hiddenNode = true;
mOwnState.hiddenDomain = domain; mOwnState.hiddenDomain = domain;
@ -917,7 +917,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
if (id == AuthSSL::getAuthSSL()->OwnId()) if (id == AuthSSL::getAuthSSL()->OwnId())
{ {
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::addFriend() cannot add own id as a friend." << std::endl; std::cerr << "p3PeerMgrIMPL::addFriend() cannot add own id as a friend." << std::endl;
@ -973,7 +973,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
/* setup connectivity parameters */ /* setup connectivity parameters */
it->second.vs_disc = vs_disc; it->second.vs_disc = vs_disc;
it->second.vs_dht = vs_dht; it->second.vs_dht = vs_dht;
it->second.netMode = netMode; it->second.netMode = netMode;
it->second.lastcontact = lastContact; it->second.lastcontact = lastContact;
@ -995,7 +995,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
pstate.id = id; pstate.id = id;
pstate.gpg_id = gpg_id; pstate.gpg_id = gpg_id;
pstate.name = AuthGPG::getAuthGPG()->getGPGName(gpg_id); pstate.name = AuthGPG::getAuthGPG()->getGPGName(gpg_id);
pstate.vs_disc = vs_disc; pstate.vs_disc = vs_disc;
pstate.vs_dht = vs_dht; pstate.vs_dht = vs_dht;
pstate.netMode = netMode; pstate.netMode = netMode;
@ -1018,7 +1018,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
mLinkMgr->addFriend(id, vs_dht != RS_VS_DHT_OFF); mLinkMgr->addFriend(id, vs_dht != RS_VS_DHT_OFF);
} }
service_flags &= servicePermissionFlags(gpg_id) ; // Always reduce the permissions. service_flags &= servicePermissionFlags(gpg_id) ; // Always reduce the permissions.
#ifdef RS_CHATSERVER //Defined by chatserver #ifdef RS_CHATSERVER //Defined by chatserver
setServicePermissionFlags(gpg_id,RS_NODE_PERM_NONE) ; setServicePermissionFlags(gpg_id,RS_NODE_PERM_NONE) ;
#else #else
@ -1029,7 +1029,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
printPeerLists(std::cerr); printPeerLists(std::cerr);
mLinkMgr->printPeerLists(std::cerr); mLinkMgr->printPeerLists(std::cerr);
#endif #endif
return true; return true;
} }
@ -1071,10 +1071,10 @@ bool p3PeerMgrIMPL::removeFriend(const RsPgpId &id)
} }
for(std::list<RsPeerId>::iterator rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); ++rit) for(std::list<RsPeerId>::iterator rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); ++rit)
if (mFriendList.end() != (it = mFriendList.find(*rit))) if (mFriendList.end() != (it = mFriendList.find(*rit)))
mFriendList.erase(it); mFriendList.erase(it);
std::map<RsPgpId,ServicePermissionFlags>::iterator it2 = mFriendsPermissionFlags.find(id) ; std::map<RsPgpId,ServicePermissionFlags>::iterator it2 = mFriendsPermissionFlags.find(id) ;
if(it2 != mFriendsPermissionFlags.end()) if(it2 != mFriendsPermissionFlags.end())
mFriendsPermissionFlags.erase(it2); mFriendsPermissionFlags.erase(it2);
@ -1146,13 +1146,13 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
} }
for(std::list<RsPeerId>::iterator rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); ++rit) for(std::list<RsPeerId>::iterator rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); ++rit)
if (mFriendList.end() != (it = mFriendList.find(*rit))) if (mFriendList.end() != (it = mFriendList.find(*rit)))
mFriendList.erase(it); mFriendList.erase(it);
std::map<RsPgpId,ServicePermissionFlags>::iterator it2 ; std::map<RsPgpId,ServicePermissionFlags>::iterator it2 ;
for(std::list<RsPgpId>::iterator rit = pgpid_toRemove.begin(); rit != pgpid_toRemove.end(); ++rit) for(std::list<RsPgpId>::iterator rit = pgpid_toRemove.begin(); rit != pgpid_toRemove.end(); ++rit)
if (mFriendsPermissionFlags.end() != (it2 = mFriendsPermissionFlags.find(*rit))) if (mFriendsPermissionFlags.end() != (it2 = mFriendsPermissionFlags.find(*rit)))
mFriendsPermissionFlags.erase(it2); mFriendsPermissionFlags.erase(it2);
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
@ -1432,7 +1432,7 @@ bool p3PeerMgrIMPL::setLocalAddress( const RsPeerId &id,
if (changed) if (changed)
{ {
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
mNetMgr->setLocalAddress(addr); mNetMgr->setLocalAddress(addr);
mLinkMgr->setLocalAddress(addr); mLinkMgr->setLocalAddress(addr);
} }
@ -1499,9 +1499,9 @@ bool p3PeerMgrIMPL::setExtAddress( const RsPeerId &id,
changed = true; changed = true;
} }
} }
mNetMgr->setExtAddress(addr); mNetMgr->setExtAddress(addr);
return changed; return changed;
} }
@ -1584,12 +1584,16 @@ bool p3PeerMgrIMPL::setDynDNS(const RsPeerId &id, const std::string &dyndns)
return changed; return changed;
} }
namespace pqi {
struct ZeroedInt struct ZeroedInt
{ {
ZeroedInt() { n=0 ;} ZeroedInt() { n=0 ;}
int n ; int n ;
}; };
}
bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, const sockaddr_storage &addr) bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, const sockaddr_storage &addr)
{ {
// The algorithm is the following: // The algorithm is the following:
@ -1617,10 +1621,10 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
// Update a list of own IPs: // Update a list of own IPs:
// - remove old values for that same peer // - remove old values for that same peer
// - remove values for non connected peers // - remove values for non connected peers
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
mReportedOwnAddresses[from] = addr_filtered ; mReportedOwnAddresses[from] = addr_filtered ;
for(std::map<RsPeerId,sockaddr_storage>::iterator it(mReportedOwnAddresses.begin());it!=mReportedOwnAddresses.end();) for(std::map<RsPeerId,sockaddr_storage>::iterator it(mReportedOwnAddresses.begin());it!=mReportedOwnAddresses.end();)
@ -1641,8 +1645,8 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
std::cerr << "p3PeerMgr:: Current external address is calculated to be: " << sockaddr_storage_iptostring(current_best_ext_address_guess) << " (simultaneously reported by " << count << " peers)." << std::endl; std::cerr << "p3PeerMgr:: Current external address is calculated to be: " << sockaddr_storage_iptostring(current_best_ext_address_guess) << " (simultaneously reported by " << count << " peers)." << std::endl;
} }
// now current // now current
sockaddr_storage own_addr ; sockaddr_storage own_addr ;
@ -1665,7 +1669,7 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, from.toStdString(), sockaddr_storage_iptostring(own_addr), sockaddr_storage_iptostring(addr)); RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, from.toStdString(), sockaddr_storage_iptostring(own_addr), sockaddr_storage_iptostring(addr));
} }
// we could also sweep over all connected friends and see if some report a different address. // we could also sweep over all connected friends and see if some report a different address.
return true ; return true ;
@ -1673,46 +1677,46 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
bool p3PeerMgrIMPL::locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage& addr, uint32_t& count) bool p3PeerMgrIMPL::locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage& addr, uint32_t& count)
{ {
std::map<sockaddr_storage,ZeroedInt> addr_counts ; std::map<sockaddr_storage, pqi::ZeroedInt> addr_counts ;
for(std::map<RsPeerId,sockaddr_storage>::iterator it(mReportedOwnAddresses.begin());it!=mReportedOwnAddresses.end();++it) for(std::map<RsPeerId,sockaddr_storage>::iterator it(mReportedOwnAddresses.begin());it!=mReportedOwnAddresses.end();++it)
++addr_counts[it->second].n ; ++addr_counts[it->second].n ;
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "Current ext addr statistics:" << std::endl; std::cerr << "Current ext addr statistics:" << std::endl;
#endif #endif
count = 0 ; count = 0 ;
for(std::map<sockaddr_storage,ZeroedInt>::const_iterator it(addr_counts.begin());it!=addr_counts.end();++it) for(std::map<sockaddr_storage, pqi::ZeroedInt>::const_iterator it(addr_counts.begin());it!=addr_counts.end();++it)
{ {
if(uint32_t(it->second.n) > count) if(uint32_t(it->second.n) > count)
{ {
addr = it->first ; addr = it->first ;
count = it->second.n ; count = it->second.n ;
} }
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << sockaddr_storage_iptostring(it->first) << " : " << it->second.n << std::endl; std::cerr << sockaddr_storage_iptostring(it->first) << " : " << it->second.n << std::endl;
#endif #endif
} }
return true ; return true ;
} }
bool p3PeerMgrIMPL::getExtAddressReportedByFriends(sockaddr_storage &addr, uint8_t& /*isstable*/) bool p3PeerMgrIMPL::getExtAddressReportedByFriends(sockaddr_storage &addr, uint8_t& /*isstable*/)
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
uint32_t count ; uint32_t count ;
locked_computeCurrentBestOwnExtAddressCandidate(addr,count) ; locked_computeCurrentBestOwnExtAddressCandidate(addr,count) ;
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "Estimation count = " << count << ". Trusted? = " << (count>=2) << std::endl; std::cerr << "Estimation count = " << count << ". Trusted? = " << (count>=2) << std::endl;
#endif #endif
return count >= 2 ;// 2 is not conservative enough. 3 should be probably better. return count >= 2 ;// 2 is not conservative enough. 3 should be probably better.
} }
static bool cleanIpList(std::list<pqiIpAddress>& lst,const RsPeerId& pid,p3LinkMgr *link_mgr) static bool cleanIpList(std::list<pqiIpAddress>& lst,const RsPeerId& pid,p3LinkMgr *link_mgr)
@ -1765,7 +1769,7 @@ bool p3PeerMgrIMPL::updateAddressList(const RsPeerId& id, const pqiIpAddrSet
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
/* check if it is our own ip */ /* check if it is our own ip */
if (id == getOwnId()) if (id == getOwnId())
{ {
mOwnState.ipAddrs.updateAddrs(clean_set); mOwnState.ipAddrs.updateAddrs(clean_set);
return true; return true;
@ -1811,11 +1815,11 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const RsPeerId& id, const pqiIpAddre
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::updateCurrentAddress() called for id : " << id << std::endl; std::cerr << "p3PeerMgrIMPL::updateCurrentAddress() called for id : " << id << std::endl;
#endif #endif
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
/* cannot be own id */ /* cannot be own id */
/* check if it is a friend */ /* check if it is a friend */
std::map<RsPeerId, peerState>::iterator it; std::map<RsPeerId, peerState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id))) if (mFriendList.end() == (it = mFriendList.find(id)))
@ -1846,23 +1850,23 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const RsPeerId& id, const pqiIpAddre
std::cerr << addrstr; std::cerr << addrstr;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
return true; return true;
} }
bool p3PeerMgrIMPL::updateLastContact(const RsPeerId& id) bool p3PeerMgrIMPL::updateLastContact(const RsPeerId& id)
{ {
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::updateLastContact() called for id : " << id << std::endl; std::cerr << "p3PeerMgrIMPL::updateLastContact() called for id : " << id << std::endl;
#endif #endif
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
/* cannot be own id */ /* cannot be own id */
/* check if it is a friend */ /* check if it is a friend */
std::map<RsPeerId, peerState>::iterator it; std::map<RsPeerId, peerState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id))) if (mFriendList.end() == (it = mFriendList.find(id)))
@ -1877,7 +1881,7 @@ bool p3PeerMgrIMPL::updateLastContact(const RsPeerId& id)
it->second.lastcontact = time(NULL); it->second.lastcontact = time(NULL);
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
return true; return true;
} }
@ -2061,7 +2065,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
getProxyServerAddress(RS_HIDDEN_TYPE_TOR, proxy_addr_tor); getProxyServerAddress(RS_HIDDEN_TYPE_TOR, proxy_addr_tor);
getProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr_i2p); getProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr_i2p);
mPeerMtx.lock(); /****** MUTEX LOCKED *******/ mPeerMtx.lock(); /****** MUTEX LOCKED *******/
RsPeerNetItem *item = new RsPeerNetItem(); RsPeerNetItem *item = new RsPeerNetItem();
item->clear(); item->clear();
@ -2088,14 +2092,14 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
item->vs_disc = mOwnState.vs_disc; item->vs_disc = mOwnState.vs_disc;
item->vs_dht = mOwnState.vs_dht; item->vs_dht = mOwnState.vs_dht;
item->lastContact = mOwnState.lastcontact; item->lastContact = mOwnState.lastcontact;
item->localAddrV4.addr = mOwnState.localaddr; item->localAddrV4.addr = mOwnState.localaddr;
item->extAddrV4.addr = mOwnState.serveraddr; item->extAddrV4.addr = mOwnState.serveraddr;
sockaddr_storage_clear(item->localAddrV6.addr); sockaddr_storage_clear(item->localAddrV6.addr);
sockaddr_storage_clear(item->extAddrV6.addr); sockaddr_storage_clear(item->extAddrV6.addr);
item->dyndns = mOwnState.dyndns; item->dyndns = mOwnState.dyndns;
mOwnState.ipAddrs.mLocal.loadTlv(item->localAddrList); mOwnState.ipAddrs.mLocal.loadTlv(item->localAddrList);
mOwnState.ipAddrs.mExt.loadTlv(item->extAddrList); mOwnState.ipAddrs.mExt.loadTlv(item->extAddrList);
@ -2125,20 +2129,20 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
item->vs_dht = (it->second).vs_dht; item->vs_dht = (it->second).vs_dht;
item->lastContact = (it->second).lastcontact; item->lastContact = (it->second).lastcontact;
item->localAddrV4.addr = (it->second).localaddr; item->localAddrV4.addr = (it->second).localaddr;
item->extAddrV4.addr = (it->second).serveraddr; item->extAddrV4.addr = (it->second).serveraddr;
sockaddr_storage_clear(item->localAddrV6.addr); sockaddr_storage_clear(item->localAddrV6.addr);
sockaddr_storage_clear(item->extAddrV6.addr); sockaddr_storage_clear(item->extAddrV6.addr);
item->dyndns = (it->second).dyndns; item->dyndns = (it->second).dyndns;
(it->second).ipAddrs.mLocal.loadTlv(item->localAddrList); (it->second).ipAddrs.mLocal.loadTlv(item->localAddrList);
(it->second).ipAddrs.mExt.loadTlv(item->extAddrList); (it->second).ipAddrs.mExt.loadTlv(item->extAddrList);
item->domain_addr = (it->second).hiddenDomain; item->domain_addr = (it->second).hiddenDomain;
item->domain_port = (it->second).hiddenPort; item->domain_port = (it->second).hiddenPort;
saveData.push_back(item); saveData.push_back(item);
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::saveList() Peer Config Item:" << std::endl; std::cerr << "p3PeerMgrIMPL::saveList() Peer Config Item:" << std::endl;
@ -2150,7 +2154,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
RsPeerBandwidthLimitsItem *pblitem = new RsPeerBandwidthLimitsItem ; RsPeerBandwidthLimitsItem *pblitem = new RsPeerBandwidthLimitsItem ;
pblitem->peers = mPeerBandwidthLimits ; pblitem->peers = mPeerBandwidthLimits ;
saveData.push_back(pblitem) ; saveData.push_back(pblitem) ;
RsPeerServicePermissionItem *sitem = new RsPeerServicePermissionItem ; RsPeerServicePermissionItem *sitem = new RsPeerServicePermissionItem ;
for(std::map<RsPgpId,ServicePermissionFlags>::const_iterator it(mFriendsPermissionFlags.begin());it!=mFriendsPermissionFlags.end();++it) for(std::map<RsPgpId,ServicePermissionFlags>::const_iterator it(mFriendsPermissionFlags.begin());it!=mFriendsPermissionFlags.end();++it)
@ -2158,11 +2162,11 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
sitem->pgp_ids.push_back(it->first) ; sitem->pgp_ids.push_back(it->first) ;
sitem->service_flags.push_back(it->second) ; sitem->service_flags.push_back(it->second) ;
} }
saveData.push_back(sitem) ; saveData.push_back(sitem) ;
// Now save config for network digging strategies // Now save config for network digging strategies
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ; RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
RsTlvKeyValue kv; RsTlvKeyValue kv;
@ -2199,7 +2203,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
kv.key = kConfigKeyProxyServerPortI2P; kv.key = kConfigKeyProxyServerPortI2P;
kv.value = sockaddr_storage_porttostring(proxy_addr_i2p); kv.value = sockaddr_storage_porttostring(proxy_addr_i2p);
vitem->tlvkvs.pairs.push_back(kv) ; vitem->tlvkvs.pairs.push_back(kv) ;
saveData.push_back(vitem); saveData.push_back(vitem);
/* save groups */ /* save groups */
@ -2213,7 +2217,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
return true; return true;
} }
bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn) bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn)
{ {
RsPgpId pgp_id ; RsPgpId pgp_id ;
@ -2235,7 +2239,7 @@ bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& ma
return getMaxRates(pgp_id,maxUp,maxDn) ; return getMaxRates(pgp_id,maxUp,maxDn) ;
} }
bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn) bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn)
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
@ -2254,25 +2258,25 @@ bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& max
return false ; return false ;
} }
} }
bool p3PeerMgrIMPL::setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn) bool p3PeerMgrIMPL::setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn)
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
PeerBandwidthLimits& p(mPeerBandwidthLimits[pid]) ; PeerBandwidthLimits& p(mPeerBandwidthLimits[pid]) ;
if(maxUp == p.max_up_rate_kbs && maxDn == p.max_dl_rate_kbs) if(maxUp == p.max_up_rate_kbs && maxDn == p.max_dl_rate_kbs)
return true ; return true ;
std::cerr << "Updating max rates for peer " << pid << " to " << maxUp << " kB/s (up), " << maxDn << " kB/s (dn)" << std::endl; std::cerr << "Updating max rates for peer " << pid << " to " << maxUp << " kB/s (up), " << maxDn << " kB/s (dn)" << std::endl;
p.max_up_rate_kbs = maxUp ; p.max_up_rate_kbs = maxUp ;
p.max_dl_rate_kbs = maxDn ; p.max_dl_rate_kbs = maxDn ;
IndicateConfigChanged(); IndicateConfigChanged();
return true ; return true ;
} }
void p3PeerMgrIMPL::saveDone() void p3PeerMgrIMPL::saveDone()
{ {
/* clean up the save List */ /* clean up the save List */
@ -2396,7 +2400,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "setting use_extr_addr_finder to " << useExtAddrFinder << std::endl ; std::cerr << "setting use_extr_addr_finder to " << useExtAddrFinder << std::endl ;
#endif #endif
} }
// Tor // Tor
else if (kit->key == kConfigKeyProxyServerIpAddrTor) else if (kit->key == kConfigKeyProxyServerIpAddrTor)
{ {
@ -2859,13 +2863,13 @@ bool p3PeerMgrIMPL::removeAllFriendLocations(const RsPgpId &gpgid)
{ {
return false; return false;
} }
std::list<RsPeerId>::iterator it; std::list<RsPeerId>::iterator it;
for(it = sslIds.begin(); it != sslIds.end(); ++it) for(it = sslIds.begin(); it != sslIds.end(); ++it)
{ {
removeFriend(*it, true); removeFriend(*it, true);
} }
return true; return true;
} }
@ -2877,7 +2881,7 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgr::getAssociatedPeers() for id : " << gpg_id << std::endl; std::cerr << "p3PeerMgr::getAssociatedPeers() for id : " << gpg_id << std::endl;
#endif #endif
int count = 0; int count = 0;
std::map<RsPeerId, peerState>::iterator it; std::map<RsPeerId, peerState>::iterator it;
for(it = mFriendList.begin(); it != mFriendList.end(); ++it) for(it = mFriendList.begin(); it != mFriendList.end(); ++it)
@ -2890,10 +2894,10 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgr::getAssociatedPeers() found ssl id : " << it->first << std::endl; std::cerr << "p3PeerMgr::getAssociatedPeers() found ssl id : " << it->first << std::endl;
#endif #endif
} }
} }
return (count > 0); return (count > 0);
} }
@ -2930,10 +2934,10 @@ bool p3PeerMgrIMPL::removeBannedIps()
return true ; return true ;
} }
// /* This only removes SSL certs, that are old... Can end up with no Certs per GPG Id // /* This only removes SSL certs, that are old... Can end up with no Certs per GPG Id
// * We are removing the concept of a "DummyId" - There is no need for it. // * We are removing the concept of a "DummyId" - There is no need for it.
// */ // */
// //
// bool isDummyFriend(RsPeerId id) // bool isDummyFriend(RsPeerId id)
// { // {
// bool ret = (id.substr(0,5) == "dummy"); // bool ret = (id.substr(0,5) == "dummy");
@ -2974,7 +2978,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
// First put a sensible number in all PGP ids // First put a sensible number in all PGP ids
for(std::list<RsPgpId>::const_iterator it = pgpList.begin(); it != pgpList.end(); ++it) for(std::list<RsPgpId>::const_iterator it = pgpList.begin(); it != pgpList.end(); ++it)
@ -2984,7 +2988,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
std::cerr << "p3PeerMgr::removeUnusedLocations()" << std::endl; std::cerr << "p3PeerMgr::removeUnusedLocations()" << std::endl;
#endif #endif
// Then compute the most recently used location for all PGP ids // Then compute the most recently used location for all PGP ids
for( std::map<RsPeerId, peerState>::iterator it = mFriendList.begin(); it != mFriendList.end(); ++it) for( std::map<RsPeerId, peerState>::iterator it = mFriendList.begin(); it != mFriendList.end(); ++it)
{ {
time_t& bst(mostRecentTime[it->second.gpg_id]) ; time_t& bst(mostRecentTime[it->second.gpg_id]) ;
@ -3010,4 +3014,4 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
return true; return true;
} }

View File

@ -55,7 +55,7 @@
#define RSBANLIST_DELAY_BETWEEN_TALK_TO_DHT 240 // every 4 mins. #define RSBANLIST_DELAY_BETWEEN_TALK_TO_DHT 240 // every 4 mins.
/************ IMPLEMENTATION NOTES ********************************* /************ IMPLEMENTATION NOTES *********************************
* *
* Get Bad Peers passed to us (from DHT mainly). * Get Bad Peers passed to us (from DHT mainly).
* we distribute and track the network list of bad peers. * we distribute and track the network list of bad peers.
* *
@ -113,6 +113,8 @@ void p3BanList::setAutoRangeLimit(int n)
IndicateConfigChanged(); IndicateConfigChanged();
} }
namespace services {
class ZeroedInt class ZeroedInt
{ {
public: public:
@ -120,6 +122,8 @@ class ZeroedInt
uint32_t n ; uint32_t n ;
}; };
}
BanListPeer::BanListPeer() BanListPeer::BanListPeer()
{ {
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
@ -220,14 +224,14 @@ void p3BanList::autoFigureOutBanRanges()
std::cerr << "Automatically figuring out IP ranges from banned IPs." << std::endl; std::cerr << "Automatically figuring out IP ranges from banned IPs." << std::endl;
#endif #endif
std::map<sockaddr_storage,ZeroedInt> range_map ; std::map<sockaddr_storage, services::ZeroedInt> range_map ;
for(std::map<sockaddr_storage,BanListPeer>::iterator it(mBanSet.begin());it!=mBanSet.end();++it) for(std::map<sockaddr_storage,BanListPeer>::iterator it(mBanSet.begin());it!=mBanSet.end();++it)
++range_map[makeBitsRange(it->first,1)].n ; ++range_map[makeBitsRange(it->first,1)].n ;
time_t now = time(NULL) ; time_t now = time(NULL) ;
for(std::map<sockaddr_storage,ZeroedInt>::const_iterator it=range_map.begin();it!=range_map.end();++it) for(std::map<sockaddr_storage, services::ZeroedInt>::const_iterator it=range_map.begin();it!=range_map.end();++it)
{ {
#ifdef DEBUG_BANLIST #ifdef DEBUG_BANLIST
std::cerr << "Ban range: " << sockaddr_storage_iptostring(it->first) << " : " << it->second.n << std::endl; std::cerr << "Ban range: " << sockaddr_storage_iptostring(it->first) << " : " << it->second.n << std::endl;
@ -646,7 +650,7 @@ bool p3BanList::processIncoming()
break; break;
case RS_PKT_SUBTYPE_BANLIST_ITEM: case RS_PKT_SUBTYPE_BANLIST_ITEM:
{ {
// Order is important!. // Order is important!.
updated = (recvBanItem((RsBanListItem *) item) || updated); updated = (recvBanItem((RsBanListItem *) item) || updated);
} }
break; break;
@ -669,8 +673,8 @@ bool p3BanList::processIncoming()
} }
return true ; return true ;
} }
bool p3BanList::recvBanItem(RsBanListItem *item) bool p3BanList::recvBanItem(RsBanListItem *item)
{ {
@ -681,7 +685,7 @@ bool p3BanList::recvBanItem(RsBanListItem *item)
for(it = item->peerList.mList.begin(); it != item->peerList.mList.end(); ++it) for(it = item->peerList.mList.begin(); it != item->peerList.mList.end(); ++it)
{ {
// Order is important!. // Order is important!.
updated = (addBanEntry(item->PeerId(), it->addr.addr, it->level, it->reason, now - it->age) || updated); updated = (addBanEntry(item->PeerId(), it->addr.addr, it->level, it->reason, now - it->age) || updated);
} }
return updated; return updated;
@ -961,7 +965,7 @@ bool p3BanList::addBanEntry( const RsPeerId &peerId,
it = mBanSources.find(peerId); it = mBanSources.find(peerId);
updated = true; updated = true;
} }
// index is FAMILY + IP - the rest should be Zeros.. // index is FAMILY + IP - the rest should be Zeros..
struct sockaddr_storage bannedaddr; struct sockaddr_storage bannedaddr;
sockaddr_storage_clear(bannedaddr); sockaddr_storage_clear(bannedaddr);
@ -980,7 +984,7 @@ bool p3BanList::addBanEntry( const RsPeerId &peerId,
blp.level = level; blp.level = level;
blp.mTs = time_stamp ; blp.mTs = time_stamp ;
blp.masked_bytes = 0 ; blp.masked_bytes = 0 ;
it->second.mBanPeers[bannedaddr] = blp; it->second.mBanPeers[bannedaddr] = blp;
it->second.mLastUpdate = now; it->second.mLastUpdate = now;
updated = true; updated = true;
@ -1036,7 +1040,7 @@ int p3BanList::condenseBanSources_locked()
time_t now = time(NULL); time_t now = time(NULL);
RsPeerId ownId = mServiceCtrl->getOwnId(); RsPeerId ownId = mServiceCtrl->getOwnId();
#ifdef DEBUG_BANLIST #ifdef DEBUG_BANLIST
std::cerr << "p3BanList::condenseBanSources_locked()"; std::cerr << "p3BanList::condenseBanSources_locked()";
std::cerr << std::endl; std::cerr << std::endl;
@ -1062,7 +1066,7 @@ int p3BanList::condenseBanSources_locked()
std::cerr << " Condensing Info from peer: " << it->first; std::cerr << " Condensing Info from peer: " << it->first;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
std::map<struct sockaddr_storage, BanListPeer>::const_iterator lit; std::map<struct sockaddr_storage, BanListPeer>::const_iterator lit;
for(lit = it->second.mBanPeers.begin(); lit != it->second.mBanPeers.end(); ++lit) for(lit = it->second.mBanPeers.begin(); lit != it->second.mBanPeers.end(); ++lit)
{ {
@ -1135,7 +1139,7 @@ int p3BanList::condenseBanSources_locked()
} }
} }
#ifdef DEBUG_BANLIST #ifdef DEBUG_BANLIST
std::cerr << "p3BanList::condenseBanSources_locked() Printing New Set:"; std::cerr << "p3BanList::condenseBanSources_locked() Printing New Set:";
std::cerr << std::endl; std::cerr << std::endl;
@ -1280,7 +1284,7 @@ int p3BanList::printBanSet_locked(std::ostream &out)
int p3BanList::printBanSources_locked(std::ostream &out) int p3BanList::printBanSources_locked(std::ostream &out)
{ {
time_t now = time(NULL); time_t now = time(NULL);
std::map<RsPeerId, BanList>::const_iterator it; std::map<RsPeerId, BanList>::const_iterator it;
for(it = mBanSources.begin(); it != mBanSources.end(); ++it) for(it = mBanSources.begin(); it != mBanSources.end(); ++it)
{ {

View File

@ -433,7 +433,7 @@ void MainWindow::initStackedPage()
#ifndef RS_RELEASE_VERSION #ifndef RS_RELEASE_VERSION
#ifdef PLUGINMGR #ifdef PLUGINMGR
addPage(pluginsPage = new PluginsPage(ui->stackPages), grp, NULL); addPage(pluginsPage = new gui::PluginsPage(ui->stackPages), grp, NULL);
#endif #endif
#endif #endif
@ -643,10 +643,10 @@ const QList<UserNotify*> &MainWindow::getUserNotifyList()
/*static*/ void MainWindow::displayLobbySystrayMsg(const QString& title,const QString& msg) /*static*/ void MainWindow::displayLobbySystrayMsg(const QString& title,const QString& msg)
{ {
if (_instance == NULL) if (_instance == NULL)
return; return;
if(Settings->getDisplayTrayChatLobby()) if(Settings->getDisplayTrayChatLobby())
_instance->displaySystrayMsg(title,msg) ; _instance->displaySystrayMsg(title,msg) ;
} }
@ -1011,7 +1011,7 @@ void SetForegroundWindowInternal(HWND hWnd)
return NULL; return NULL;
} }
switch (page) switch (page)
{ {
case Network: case Network:
return _instance->friendsDialog->networkDialog; return _instance->friendsDialog->networkDialog;
@ -1457,7 +1457,7 @@ void MainWindow::externalLinkActivated(const QUrl &url)
int res = mb.exec() ; int res = mb.exec() ;
if (res == QMessageBox::No) if (res == QMessageBox::No)
return ; return ;
if(dontAsk_CB->isChecked()) if(dontAsk_CB->isChecked())

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -39,6 +39,8 @@ class QScriptEngine;
class PluginManager; class PluginManager;
namespace gui {
//! A demo widget for showing plugin engine in action :) //! A demo widget for showing plugin engine in action :)
@ -46,7 +48,7 @@ class PluginManager;
//! loaded plugin widgets. All specific actions moved to //! loaded plugin widgets. All specific actions moved to
//! PluginManagerWidget class. It contains a PluginManager instance, but it's //! PluginManagerWidget class. It contains a PluginManager instance, but it's
//! supposed that in future a pluginManager will become a global variable //! supposed that in future a pluginManager will become a global variable
class PluginsPage : public MainPage class PluginsPage : public MainPage
{ {
Q_OBJECT Q_OBJECT
@ -70,10 +72,10 @@ protected:
QVBoxLayout* pluginPageLayout; QVBoxLayout* pluginPageLayout;
QGroupBox* pluginPanel; QGroupBox* pluginPanel;
QVBoxLayout* pluginPanelLayout; QVBoxLayout* pluginPanelLayout;
//! Plugin widgets will be loaded into this tabs //! Plugin widgets will be loaded into this tabs
QTabWidget* pluginTabs ; QTabWidget* pluginTabs ;
QVBoxLayout* pmLay; QVBoxLayout* pmLay;
QFrame* pmFrame; QFrame* pmFrame;
QSpacerItem* pmSpacer; QSpacerItem* pmSpacer;
@ -82,5 +84,7 @@ protected:
PluginManager* pluginManager; PluginManager* pluginManager;
}; };
} // namespace gui
#endif #endif

View File

@ -33,7 +33,7 @@
#include "../MainWindow.h" #include "../MainWindow.h"
PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags) settings::PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags) : ConfigPage(parent, flags)
{ {
ui.setupUi(this); ui.setupUi(this);
@ -123,7 +123,7 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags)
if(plugin == NULL || plugin->qt_config_panel() == NULL) if(plugin == NULL || plugin->qt_config_panel() == NULL)
item->_configure_PB->hide() ; item->_configure_PB->hide() ;
if(plugin != NULL){ if(plugin != NULL){
item->enableButton->hide(); item->enableButton->hide();
@ -159,7 +159,7 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags)
QObject::connect(ui.enableAll,SIGNAL(toggled(bool)),this,SLOT(toggleEnableAll(bool))) ; QObject::connect(ui.enableAll,SIGNAL(toggled(bool)),this,SLOT(toggleEnableAll(bool))) ;
} }
QString PluginsPage::helpText() const QString settings::PluginsPage::helpText() const
{ {
return tr("<h1><img width=\"24\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Plugins</h1> \ return tr("<h1><img width=\"24\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Plugins</h1> \
<p>Plugins are loaded from the directories listed in the bottom list.</p> \ <p>Plugins are loaded from the directories listed in the bottom list.</p> \
@ -171,11 +171,11 @@ QString PluginsPage::helpText() const
<p>If you want to develop your own plugins, contact the developpers team \ <p>If you want to develop your own plugins, contact the developpers team \
they will be happy to help you out!</p>") ; they will be happy to help you out!</p>") ;
} }
void PluginsPage::toggleEnableAll(bool b) void settings::PluginsPage::toggleEnableAll(bool b)
{ {
rsPlugins->allowAllPlugins(b) ; rsPlugins->allowAllPlugins(b) ;
} }
void PluginsPage::aboutPlugin(int i) void settings::PluginsPage::aboutPlugin(int i)
{ {
std::cerr << "Launching about window for plugin " << i << std::endl; std::cerr << "Launching about window for plugin " << i << std::endl;
@ -183,7 +183,7 @@ void PluginsPage::aboutPlugin(int i)
if(rsPlugins->plugin(i) != NULL && (dialog = rsPlugins->plugin(i)->qt_about_page()) != NULL) if(rsPlugins->plugin(i) != NULL && (dialog = rsPlugins->plugin(i)->qt_about_page()) != NULL)
dialog->exec() ; dialog->exec() ;
} }
void PluginsPage::configurePlugin(int i) void settings::PluginsPage::configurePlugin(int i)
{ {
std::cerr << "Launching configuration window for plugin " << i << std::endl; std::cerr << "Launching configuration window for plugin " << i << std::endl;
@ -191,14 +191,14 @@ void PluginsPage::configurePlugin(int i)
rsPlugins->plugin(i)->qt_config_panel()->show() ; rsPlugins->plugin(i)->qt_config_panel()->show() ;
} }
void PluginsPage::enablePlugin(const QString& hash) void settings::PluginsPage::enablePlugin(const QString& hash)
{ {
std::cerr << "Switching status of plugin " << hash.toStdString() << " to enable" << std::endl; std::cerr << "Switching status of plugin " << hash.toStdString() << " to enable" << std::endl;
rsPlugins->enablePlugin(RsFileHash(hash.toStdString()) ); rsPlugins->enablePlugin(RsFileHash(hash.toStdString()) );
} }
void PluginsPage::disablePlugin(const QString& hash) void settings::PluginsPage::disablePlugin(const QString& hash)
{ {
std::cerr << "Switching status of plugin " << hash.toStdString() << " to disable " << std::endl; std::cerr << "Switching status of plugin " << hash.toStdString() << " to disable " << std::endl;
@ -206,11 +206,11 @@ void PluginsPage::disablePlugin(const QString& hash)
} }
PluginsPage::~PluginsPage() settings::PluginsPage::~PluginsPage()
{ {
} }
/** Loads the settings for this page */ /** Loads the settings for this page */
void PluginsPage::load() void settings::PluginsPage::load()
{ {
} }

View File

@ -24,6 +24,8 @@
#include <retroshare-gui/configpage.h> #include <retroshare-gui/configpage.h>
#include "ui_PluginsPage.h" #include "ui_PluginsPage.h"
namespace settings {
class PluginsPage : public ConfigPage class PluginsPage : public ConfigPage
{ {
Q_OBJECT Q_OBJECT
@ -52,3 +54,4 @@ class PluginsPage : public ConfigPage
Ui::PluginsPage ui; Ui::PluginsPage ui;
}; };
} // namespace settings

View File

@ -158,7 +158,7 @@ SettingsPage::initStackedWidget()
addPage(new ForumPage()); // FORUMS addPage(new ForumPage()); // FORUMS
addPage(new PostedPage()); // POSTED RENAME TO LINKS addPage(new PostedPage()); // POSTED RENAME TO LINKS
addPage(new NotifyPage()); // NOTIFY addPage(new NotifyPage()); // NOTIFY
addPage(new PluginsPage() ); // PLUGINS addPage(new settings::PluginsPage() ); // PLUGINS
addPage(new AppearancePage()); // APPEARENCE addPage(new AppearancePage()); // APPEARENCE
addPage(new SoundPage() ); // SOUND addPage(new SoundPage() ); // SOUND
addPage(new ServicePermissionsPage() ); // PERMISSIONS addPage(new ServicePermissionsPage() ); // PERMISSIONS