mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
Groups for friends in PeersDialog.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3523 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8b1ffdb5d9
commit
077b2871f1
23 changed files with 1784 additions and 544 deletions
|
@ -38,6 +38,7 @@ const int p3connectzone = 3431;
|
|||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
@ -196,6 +197,8 @@ p3ConnectMgr::p3ConnectMgr()
|
|||
|
||||
mNetFlags = pqiNetStatus();
|
||||
mOldNetFlags = pqiNetStatus();
|
||||
|
||||
lastGroupId = 1;
|
||||
}
|
||||
|
||||
#ifdef CONN_DEBUG
|
||||
|
@ -2200,11 +2203,13 @@ bool p3ConnectMgr::removeFriend(std::string id)
|
|||
|
||||
netAssistFriend(id, false);
|
||||
|
||||
std::list<std::string> toRemove;
|
||||
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* move to othersList */
|
||||
bool success = false;
|
||||
std::list<std::string> toRemove;
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
//remove ssl and gpg_ids
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
|
@ -2236,10 +2241,17 @@ bool p3ConnectMgr::removeFriend(std::string id)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::removeFriend() new mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* remove id from all groups */
|
||||
std::list<std::string> peerIds;
|
||||
peerIds.push_back(id);
|
||||
|
||||
assignPeersToGroup("", peerIds, false);
|
||||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
return !toRemove.empty();
|
||||
|
@ -2994,9 +3006,9 @@ std::list<RsItem *> p3ConnectMgr::saveList(bool &cleanup)
|
|||
{
|
||||
/* create a list of current peers */
|
||||
std::list<RsItem *> saveData;
|
||||
cleanup = true;
|
||||
cleanup = false;
|
||||
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
connMtx.lock(); /****** MUTEX LOCKED *******/
|
||||
|
||||
RsPeerNetItem *item = new RsPeerNetItem();
|
||||
item->clear();
|
||||
|
@ -3033,6 +3045,7 @@ std::list<RsItem *> p3ConnectMgr::saveList(bool &cleanup)
|
|||
#endif
|
||||
|
||||
saveData.push_back(item);
|
||||
saveCleanupList.push_back(item);
|
||||
|
||||
/* iterate through all friends and save */
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
|
@ -3054,6 +3067,7 @@ std::list<RsItem *> p3ConnectMgr::saveList(bool &cleanup)
|
|||
(it->second).ipAddrs.mExt.loadTlv(item->extAddrList);
|
||||
|
||||
saveData.push_back(item);
|
||||
saveCleanupList.push_back(item);
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::saveList() Peer Config Item:" << std::endl;
|
||||
item->print(std::cerr, 10);
|
||||
|
@ -3074,6 +3088,7 @@ std::list<RsItem *> p3ConnectMgr::saveList(bool &cleanup)
|
|||
std::cout << "Pushing item for use_extr_addr_finder = " << mUseExtAddrFinder << std::endl ;
|
||||
#endif
|
||||
saveData.push_back(vitem);
|
||||
saveCleanupList.push_back(vitem);
|
||||
|
||||
// Now save config for network digging strategies
|
||||
|
||||
|
@ -3088,10 +3103,33 @@ std::list<RsItem *> p3ConnectMgr::saveList(bool &cleanup)
|
|||
std::cout << "Pushing item for allow_tunnel_connection = " << mAllowTunnelConnection << std::endl ;
|
||||
#endif
|
||||
saveData.push_back(vitem2);
|
||||
saveCleanupList.push_back(vitem2);
|
||||
|
||||
/* save groups */
|
||||
|
||||
std::list<RsPeerGroupItem *>::iterator groupIt;
|
||||
for (groupIt = groupList.begin(); groupIt != groupList.end(); groupIt++) {
|
||||
saveData.push_back(*groupIt); // no delete
|
||||
}
|
||||
|
||||
return saveData;
|
||||
}
|
||||
|
||||
void p3ConnectMgr::saveDone()
|
||||
{
|
||||
/* clean up the save List */
|
||||
std::list<RsItem *>::iterator it;
|
||||
for(it = saveCleanupList.begin(); it != saveCleanupList.end(); it++)
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
|
||||
saveCleanupList.clear();
|
||||
|
||||
/* unlock mutex */
|
||||
connMtx.unlock(); /****** MUTEX UNLOCKED *******/
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::loadList(std::list<RsItem *> load)
|
||||
{
|
||||
|
||||
|
@ -3111,7 +3149,6 @@ bool p3ConnectMgr::loadList(std::list<RsItem *> load)
|
|||
for(it = load.begin(); it != load.end(); it++)
|
||||
{
|
||||
RsPeerNetItem *pitem = dynamic_cast<RsPeerNetItem *>(*it);
|
||||
RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet *>(*it) ;
|
||||
if (pitem)
|
||||
{
|
||||
if (pitem->pid == ownId)
|
||||
|
@ -3146,8 +3183,14 @@ bool p3ConnectMgr::loadList(std::list<RsItem *> load)
|
|||
addrs.mLocal.extractFromTlv(pitem->localAddrList);
|
||||
addrs.mExt.extractFromTlv(pitem->extAddrList);
|
||||
updateAddressList(pitem->pid, addrs);
|
||||
|
||||
delete(*it);
|
||||
|
||||
continue;
|
||||
}
|
||||
else if(vitem)
|
||||
|
||||
RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet *>(*it) ;
|
||||
if (vitem)
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
|
@ -3166,10 +3209,86 @@ bool p3ConnectMgr::loadList(std::list<RsItem *> load)
|
|||
std::cerr << "setting allow_tunnel_connection to " << mAllowTunnelConnection << std::endl ;
|
||||
}
|
||||
}
|
||||
|
||||
delete(*it);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
RsPeerGroupItem *gitem = dynamic_cast<RsPeerGroupItem *>(*it) ;
|
||||
if (gitem)
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::loadList() Peer group item:" << std::endl;
|
||||
gitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
groupList.push_back(gitem); // don't delete
|
||||
|
||||
if ((gitem->flag & RS_GROUP_FLAG_STANDARD) == 0) {
|
||||
/* calculate group id */
|
||||
uint32_t groupId = atoi(gitem->id.c_str());
|
||||
if (groupId > lastGroupId) {
|
||||
lastGroupId = groupId;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
delete (*it);
|
||||
}
|
||||
|
||||
{
|
||||
/* set missing groupIds */
|
||||
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* Standard groups */
|
||||
const int standardGroupCount = 5;
|
||||
const char *standardGroup[standardGroupCount] = { RS_GROUP_ID_FRIENDS, RS_GROUP_ID_FAMILY, RS_GROUP_ID_COWORKERS, RS_GROUP_ID_OTHERS, RS_GROUP_ID_FAVORITES };
|
||||
bool foundStandardGroup[standardGroupCount] = { false, false, false, false, false };
|
||||
|
||||
std::list<RsPeerGroupItem *>::iterator groupIt;
|
||||
for (groupIt = groupList.begin(); groupIt != groupList.end(); groupIt++) {
|
||||
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) {
|
||||
int i;
|
||||
for (i = 0; i < standardGroupCount; i++) {
|
||||
if ((*groupIt)->id == standardGroup[i]) {
|
||||
foundStandardGroup[i] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= standardGroupCount) {
|
||||
/* No more a standard group, remove the flag standard */
|
||||
(*groupIt)->flag &= ~RS_GROUP_FLAG_STANDARD;
|
||||
}
|
||||
} else {
|
||||
uint32_t groupId = atoi((*groupIt)->id.c_str());
|
||||
if (groupId == 0) {
|
||||
std::ostringstream out;
|
||||
out << (lastGroupId++);
|
||||
(*groupIt)->id = out.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize standard groups */
|
||||
for (int i = 0; i < standardGroupCount; i++) {
|
||||
if (foundStandardGroup[i] == false) {
|
||||
RsPeerGroupItem *gitem = new RsPeerGroupItem;
|
||||
gitem->id = standardGroup[i];
|
||||
gitem->name = standardGroup[i];
|
||||
gitem->flag |= RS_GROUP_FLAG_STANDARD;
|
||||
groupList.push_back(gitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3399,10 +3518,203 @@ bool p3ConnectMgr::getDHTEnabled()
|
|||
return netAssistConnectEnabled();
|
||||
}
|
||||
|
||||
|
||||
void p3ConnectMgr::getNetStatus(pqiNetStatus &status)
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
status = mNetFlags;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
************************** Groups ************************************
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
bool p3ConnectMgr::addGroup(RsGroupInfo &groupInfo)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
RsPeerGroupItem *groupItem = new RsPeerGroupItem;
|
||||
groupItem->set(groupInfo);
|
||||
|
||||
std::ostringstream out;
|
||||
out << (++lastGroupId);
|
||||
groupItem->id = out.str();
|
||||
|
||||
// remove standard flag
|
||||
groupItem->flag &= ~RS_GROUP_FLAG_STANDARD;
|
||||
|
||||
groupItem->PeerId(getOwnId());
|
||||
|
||||
groupList.push_back(groupItem);
|
||||
}
|
||||
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_ADD);
|
||||
|
||||
IndicateConfigChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
{
|
||||
if (groupId.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::list<RsPeerGroupItem*>::iterator groupIt;
|
||||
for (groupIt = groupList.begin(); groupIt != groupList.end(); groupIt++) {
|
||||
if ((*groupIt)->id == groupId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (groupIt != groupList.end()) {
|
||||
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) {
|
||||
// can't edit standard groups
|
||||
} else {
|
||||
changed = true;
|
||||
(*groupIt)->set(groupInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_MOD);
|
||||
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::removeGroup(const std::string &groupId)
|
||||
{
|
||||
if (groupId.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::list<RsPeerGroupItem*>::iterator groupIt;
|
||||
for (groupIt = groupList.begin(); groupIt != groupList.end(); groupIt++) {
|
||||
if ((*groupIt)->id == groupId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (groupIt != groupList.end()) {
|
||||
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) {
|
||||
// can't remove standard groups
|
||||
} else {
|
||||
changed = true;
|
||||
delete(*groupIt);
|
||||
groupList.erase(groupIt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_DEL);
|
||||
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
{
|
||||
if (groupId.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::list<RsPeerGroupItem*>::iterator groupIt;
|
||||
for (groupIt = groupList.begin(); groupIt != groupList.end(); groupIt++) {
|
||||
if ((*groupIt)->id == groupId) {
|
||||
(*groupIt)->get(groupInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::list<RsPeerGroupItem*>::iterator groupIt;
|
||||
for (groupIt = groupList.begin(); groupIt != groupList.end(); groupIt++) {
|
||||
RsGroupInfo groupInfo;
|
||||
(*groupIt)->get(groupInfo);
|
||||
groupInfoList.push_back(groupInfo);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// groupId == "" && assign == false -> remove from all groups
|
||||
bool p3ConnectMgr::assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign)
|
||||
{
|
||||
if (groupId.empty() && assign == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (peerIds.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::list<RsPeerGroupItem*>::iterator groupIt;
|
||||
for (groupIt = groupList.begin(); groupIt != groupList.end(); groupIt++) {
|
||||
if (groupId.empty() || (*groupIt)->id == groupId) {
|
||||
RsPeerGroupItem *groupItem = *groupIt;
|
||||
|
||||
std::list<std::string>::const_iterator peerIt;
|
||||
for (peerIt = peerIds.begin(); peerIt != peerIds.end(); peerIt++) {
|
||||
std::list<std::string>::iterator peerIt1 = std::find(groupItem->peerIds.begin(), groupItem->peerIds.end(), *peerIt);
|
||||
if (assign) {
|
||||
if (peerIt1 == groupItem->peerIds.end()) {
|
||||
groupItem->peerIds.push_back(*peerIt);
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
if (peerIt1 != groupItem->peerIds.end()) {
|
||||
groupItem->peerIds.erase(peerIt1);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (groupId.empty() == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_MOD);
|
||||
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
|
|
@ -201,7 +201,8 @@ class pqiNetStatus
|
|||
};
|
||||
|
||||
class p3tunnel;
|
||||
|
||||
class RsPeerGroupItem;
|
||||
class RsGroupInfo;
|
||||
|
||||
std::string textPeerConnectState(peerConnectState &state);
|
||||
|
||||
|
@ -299,6 +300,13 @@ bool connectAttempt(std::string id, struct sockaddr_in &addr,
|
|||
uint32_t &delay, uint32_t &period, uint32_t &type);
|
||||
bool connectResult(std::string id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address);
|
||||
|
||||
/******************** Groups **********************/
|
||||
bool addGroup(RsGroupInfo &groupInfo);
|
||||
bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||
bool removeGroup(const std::string &groupId);
|
||||
bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||
bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
||||
bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign);
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -362,6 +370,7 @@ bool retryConnectTCP(std::string id);
|
|||
/* Key Functions to be overloaded for Full Configuration */
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual std::list<RsItem *> saveList(bool &cleanup);
|
||||
virtual void saveDone();
|
||||
virtual bool loadList(std::list<RsItem *> load);
|
||||
/*****************************************************************/
|
||||
|
||||
|
@ -408,6 +417,11 @@ void netStatusReset_locked();
|
|||
|
||||
std::map<std::string, peerConnectState> mFriendList;
|
||||
std::map<std::string, peerConnectState> mOthersList;
|
||||
|
||||
std::list<RsPeerGroupItem *> groupList;
|
||||
uint32_t lastGroupId;
|
||||
|
||||
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
||||
};
|
||||
|
||||
#endif // MRK_PQI_CONNECTION_MANAGER_HEADER
|
||||
|
|
|
@ -230,6 +230,7 @@ const int NOTIFY_LIST_MESSAGE_TAGS = 12;
|
|||
const int NOTIFY_LIST_PUBLIC_CHAT = 13;
|
||||
const int NOTIFY_LIST_PRIVATE_INCOMING_CHAT = 14;
|
||||
const int NOTIFY_LIST_PRIVATE_OUTGOING_CHAT = 15;
|
||||
const int NOTIFY_LIST_GROUPLIST = 16;
|
||||
|
||||
const int NOTIFY_TYPE_SAME = 0x01;
|
||||
const int NOTIFY_TYPE_MOD = 0x02; /* general purpose, check all */
|
||||
|
|
|
@ -61,6 +61,15 @@ const uint32_t RS_PEER_STATE_ONLINE = 0x0002;
|
|||
const uint32_t RS_PEER_STATE_CONNECTED = 0x0004;
|
||||
const uint32_t RS_PEER_STATE_UNREACHABLE= 0x0008;
|
||||
|
||||
/* Groups */
|
||||
#define RS_GROUP_ID_FRIENDS "Friends"
|
||||
#define RS_GROUP_ID_FAMILY "Family"
|
||||
#define RS_GROUP_ID_COWORKERS "Co-Workers"
|
||||
#define RS_GROUP_ID_OTHERS "Other Contacts"
|
||||
#define RS_GROUP_ID_FAVORITES "Favorites"
|
||||
|
||||
const uint32_t RS_GROUP_FLAG_STANDARD = 0x0001;
|
||||
|
||||
/* A couple of helper functions for translating the numbers games */
|
||||
|
||||
std::string RsPeerTrustString(uint32_t trustLvl);
|
||||
|
@ -119,6 +128,18 @@ class RsPeerDetails
|
|||
uint32_t connectPeriod;
|
||||
};
|
||||
|
||||
class RsGroupInfo
|
||||
{
|
||||
public:
|
||||
RsGroupInfo();
|
||||
|
||||
std::string id;
|
||||
std::string name;
|
||||
uint32_t flag;
|
||||
|
||||
std::list<std::string> peerIds;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
||||
|
||||
class RsPeers
|
||||
|
@ -191,6 +212,16 @@ virtual bool setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptanc
|
|||
virtual bool signGPGCertificate(std::string gpg_id) = 0;
|
||||
virtual bool trustGPGCertificate(std::string gpg_id, uint32_t trustlvl) = 0;
|
||||
|
||||
/* Group Stuff */
|
||||
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool removeGroup(const std::string &groupId) = 0;
|
||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
||||
// groupId == "" && assign == false -> remove from all groups
|
||||
virtual bool assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign) = 0;
|
||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1150,8 +1150,68 @@ int ensureExtension(std::string &name, std::string def_ext)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Group Stuff */
|
||||
bool p3Peers::addGroup(RsGroupInfo &groupInfo)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::addGroup()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->addGroup(groupInfo);
|
||||
}
|
||||
|
||||
bool p3Peers::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::editGroup()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->editGroup(groupId, groupInfo);
|
||||
}
|
||||
|
||||
bool p3Peers::removeGroup(const std::string &groupId)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::removeGroup()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->removeGroup(groupId);
|
||||
}
|
||||
|
||||
bool p3Peers::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getGroupInfo()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->getGroupInfo(groupId, groupInfo);
|
||||
}
|
||||
|
||||
bool p3Peers::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getGroupInfoList()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->getGroupInfoList(groupInfoList);
|
||||
}
|
||||
|
||||
bool p3Peers::assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign)
|
||||
{
|
||||
std::list<std::string> 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)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::assignPeersToGroup()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->assignPeersToGroup(groupId, peerIds, assign);
|
||||
}
|
||||
|
||||
|
||||
RsPeerDetails::RsPeerDetails()
|
||||
|
@ -1214,3 +1274,8 @@ std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail)
|
|||
|
||||
return out;
|
||||
}
|
||||
|
||||
RsGroupInfo::RsGroupInfo()
|
||||
{
|
||||
flag = 0;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,15 @@ virtual bool setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptanc
|
|||
virtual bool signGPGCertificate(std::string id);
|
||||
virtual bool trustGPGCertificate(std::string id, uint32_t trustlvl);
|
||||
|
||||
/* Group Stuff */
|
||||
virtual bool addGroup(RsGroupInfo &groupInfo);
|
||||
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);
|
||||
|
||||
private:
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
/***
|
||||
#define RSSERIAL_DEBUG 1
|
||||
|
@ -664,6 +665,7 @@ uint32_t RsPeerConfigSerialiser::size(RsItem *i)
|
|||
RsPeerOldNetItem *oldpni;
|
||||
RsPeerStunItem *psi;
|
||||
RsPeerNetItem *pni;
|
||||
RsPeerGroupItem *pgi;
|
||||
|
||||
if (NULL != (oldpni = dynamic_cast<RsPeerOldNetItem *>(i)))
|
||||
{
|
||||
|
@ -677,6 +679,10 @@ uint32_t RsPeerConfigSerialiser::size(RsItem *i)
|
|||
{
|
||||
return sizeStun(psi);
|
||||
}
|
||||
else if (NULL != (pgi = dynamic_cast<RsPeerGroupItem *>(i)))
|
||||
{
|
||||
return sizeGroup(pgi);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -687,6 +693,7 @@ bool RsPeerConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsi
|
|||
RsPeerOldNetItem *oldpni;
|
||||
RsPeerNetItem *pni;
|
||||
RsPeerStunItem *psi;
|
||||
RsPeerGroupItem *pgi;
|
||||
|
||||
if (NULL != (oldpni = dynamic_cast<RsPeerOldNetItem *>(i)))
|
||||
{
|
||||
|
@ -700,6 +707,10 @@ bool RsPeerConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsi
|
|||
{
|
||||
return serialiseStun(psi, data, pktsize);
|
||||
}
|
||||
else if (NULL != (pgi = dynamic_cast<RsPeerGroupItem *>(i)))
|
||||
{
|
||||
return serialiseGroup(pgi, data, pktsize);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -726,16 +737,14 @@ RsItem *RsPeerConfigSerialiser::deserialise(void *data, uint32_t *pktsize)
|
|||
old = deserialiseOldNet(data, pktsize);
|
||||
/* upgrade mechanism */
|
||||
return convertToNetItem(old);
|
||||
break;
|
||||
case RS_PKT_SUBTYPE_PEER_NET:
|
||||
return deserialiseNet(data, pktsize);
|
||||
break;
|
||||
case RS_PKT_SUBTYPE_PEER_STUN:
|
||||
return deserialiseStun(data, pktsize);
|
||||
break;
|
||||
case RS_PKT_SUBTYPE_PEER_GROUP:
|
||||
return deserialiseGroup(data, pktsize);
|
||||
default:
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1302,6 +1311,186 @@ RsPeerStunItem *RsPeerConfigSerialiser::deserialiseStun(void *data, uint32_t *si
|
|||
return item;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
RsPeerGroupItem::RsPeerGroupItem() : RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_PEER_GROUP)
|
||||
{
|
||||
}
|
||||
|
||||
RsPeerGroupItem::~RsPeerGroupItem()
|
||||
{
|
||||
}
|
||||
|
||||
void RsPeerGroupItem::clear()
|
||||
{
|
||||
id.clear();
|
||||
name.clear();
|
||||
flag = 0;
|
||||
peerIds.clear();
|
||||
}
|
||||
|
||||
std::ostream &RsPeerGroupItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsPeerGroupItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "groupId: " << id << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "groupName: " << name << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "groupFlag: " << flag << std::endl;
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
for (it = peerIds.begin(); it != peerIds.end(); it++) {
|
||||
printIndent(out, int_Indent);
|
||||
out << "peerId: " << *it << std::endl;
|
||||
}
|
||||
|
||||
printRsItemEnd(out, "RsPeerGroupItem", indent);
|
||||
return out;
|
||||
}
|
||||
|
||||
/* set data from RsGroupInfo to RsPeerGroupItem */
|
||||
void RsPeerGroupItem::set(RsGroupInfo &groupInfo)
|
||||
{
|
||||
id = groupInfo.id;
|
||||
name = groupInfo.name;
|
||||
flag = groupInfo.flag;
|
||||
peerIds = groupInfo.peerIds;
|
||||
}
|
||||
|
||||
/* get data from RsGroupInfo to RsPeerGroupItem */
|
||||
void RsPeerGroupItem::get(RsGroupInfo &groupInfo)
|
||||
{
|
||||
groupInfo.id = id;
|
||||
groupInfo.name = name;
|
||||
groupInfo.flag = flag;
|
||||
groupInfo.peerIds = peerIds;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
uint32_t RsPeerConfigSerialiser::sizeGroup(RsPeerGroupItem *i)
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += 4; /* version */
|
||||
s += GetTlvStringSize(i->id);
|
||||
s += GetTlvStringSize(i->name);
|
||||
s += 4; /* flag */
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
for (it = i->peerIds.begin(); it != i->peerIds.end(); it++) {
|
||||
s += GetTlvStringSize(*it);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool RsPeerConfigSerialiser::serialiseGroup(RsPeerGroupItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
uint32_t tlvsize = RsPeerConfigSerialiser::sizeGroup(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
if(*size < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
*size = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
// serialise header
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseGroup() Header: " << ok << std::endl;
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseGroup() Header: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, 0);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_KEY, item->id);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
for (it = item->peerIds.begin(); it != item->peerIds.end(); it++) {
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, *it);
|
||||
}
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseGroup() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsPeerGroupItem *RsPeerConfigSerialiser::deserialiseGroup(void *data, uint32_t *size)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
if ((RS_PKT_VERSION1 != getRsItemVersion(rstype)) ||
|
||||
(RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) ||
|
||||
(RS_PKT_TYPE_PEER_CONFIG != getRsItemType(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_PEER_GROUP != getRsItemSubType(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*size < rssize) /* check size */
|
||||
return NULL; /* not enough data */
|
||||
|
||||
/* set the packet length */
|
||||
*size = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
RsPeerGroupItem *item = new RsPeerGroupItem();
|
||||
item->clear();
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* get mandatory parts first */
|
||||
uint32_t version;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &version);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_KEY, item->id);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
||||
|
||||
std::string peerId;
|
||||
while (offset != rssize) {
|
||||
peerId.erase();
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, peerId);
|
||||
|
||||
item->peerIds.push_back(peerId);
|
||||
}
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include "serialiser/rstlvtypes.h"
|
||||
#include "serialiser/rstlvaddrs.h"
|
||||
|
||||
class RsGroupInfo;
|
||||
|
||||
const uint8_t RS_PKT_TYPE_GENERAL_CONFIG = 0x01;
|
||||
const uint8_t RS_PKT_TYPE_PEER_CONFIG = 0x02;
|
||||
const uint8_t RS_PKT_TYPE_CACHE_CONFIG = 0x03;
|
||||
|
@ -47,6 +49,7 @@ const uint8_t RS_PKT_SUBTYPE_KEY_VALUE = 0x01;
|
|||
const uint8_t RS_PKT_SUBTYPE_PEER_OLD_NET = 0x01;
|
||||
const uint8_t RS_PKT_SUBTYPE_PEER_STUN = 0x02;
|
||||
const uint8_t RS_PKT_SUBTYPE_PEER_NET = 0x03; /* replacement for OLD_NET */
|
||||
const uint8_t RS_PKT_SUBTYPE_PEER_GROUP = 0x04;
|
||||
|
||||
/* FILE CONFIG SUBTYPES */
|
||||
const uint8_t RS_PKT_SUBTYPE_FILE_TRANSFER = 0x01;
|
||||
|
@ -114,6 +117,28 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
|||
RsTlvIpAddrSet extAddrList;
|
||||
};
|
||||
|
||||
class RsPeerGroupItem : public RsItem
|
||||
{
|
||||
public:
|
||||
RsPeerGroupItem();
|
||||
virtual ~RsPeerGroupItem();
|
||||
|
||||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
/* set data from RsGroupInfo to RsPeerGroupItem */
|
||||
void set(RsGroupInfo &groupInfo);
|
||||
/* get data from RsGroupInfo to RsPeerGroupItem */
|
||||
void get(RsGroupInfo &groupInfo);
|
||||
|
||||
/* Mandatory */
|
||||
std::string id;
|
||||
std::string name;
|
||||
uint32_t flag;
|
||||
|
||||
std::list<std::string> peerIds;
|
||||
};
|
||||
|
||||
|
||||
class RsPeerStunItem: public RsItem
|
||||
{
|
||||
|
@ -160,6 +185,10 @@ virtual uint32_t sizeStun(RsPeerStunItem *);
|
|||
virtual bool serialiseStun (RsPeerStunItem *item, void *data, uint32_t *size);
|
||||
virtual RsPeerStunItem * deserialiseStun(void *data, uint32_t *size);
|
||||
|
||||
virtual uint32_t sizeGroup(RsPeerGroupItem *);
|
||||
virtual bool serialiseGroup (RsPeerGroupItem *item, void *data, uint32_t *size);
|
||||
virtual RsPeerGroupItem * deserialiseGroup(void *data, uint32_t *size);
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
|
@ -281,6 +281,7 @@ HEADERS += rshare.h \
|
|||
gui/common/html.h \
|
||||
gui/common/StatusDefs.h \
|
||||
gui/common/TagDefs.h \
|
||||
gui/common/GroupDefs.h \
|
||||
gui/common/Emoticons.h \
|
||||
gui/common/RSTreeWidgetItem.h \
|
||||
gui/MessagesDialog.h \
|
||||
|
@ -478,6 +479,7 @@ SOURCES += main.cpp \
|
|||
gui/common/html.cpp \
|
||||
gui/common/StatusDefs.cpp \
|
||||
gui/common/TagDefs.cpp \
|
||||
gui/common/GroupDefs.cpp \
|
||||
gui/common/Emoticons.cpp \
|
||||
gui/common/RSTreeWidgetItem.cpp \
|
||||
gui/settings/rsharesettings.cpp \
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <QFileDialog>
|
||||
#include "common/vmessagebox.h"
|
||||
#include "common/StatusDefs.h"
|
||||
#include "common/GroupDefs.h"
|
||||
#include "common/Emoticons.h"
|
||||
#include <gui/mainpagestack.h>
|
||||
|
||||
|
@ -81,6 +82,7 @@
|
|||
#define IMAGE_AVAILABLE ":/images/user/identityavaiblecyan24.png"
|
||||
#define IMAGE_CONNECT2 ":/images/reload24.png"
|
||||
#define IMAGE_PASTELINK ":/images/pasterslink.png"
|
||||
#define IMAGE_GROUP ":/images/group24.png"
|
||||
|
||||
#define COLUMN_COUNT 3
|
||||
#define COLUMN_NAME 0
|
||||
|
@ -91,6 +93,11 @@
|
|||
|
||||
#define ROLE_SORT Qt::UserRole
|
||||
#define ROLE_ID Qt::UserRole + 1
|
||||
#define ROLE_STANDARD Qt::UserRole + 2
|
||||
|
||||
#define TYPE_GPG 0
|
||||
#define TYPE_SSL 1
|
||||
#define TYPE_GROUP 2
|
||||
|
||||
/******
|
||||
* #define PEERS_DEBUG 1
|
||||
|
@ -105,8 +112,10 @@ PeersDialog::PeersDialog(QWidget *parent)
|
|||
ui.setupUi(this);
|
||||
|
||||
last_status_send_time = 0 ;
|
||||
groupsHasChanged = false;
|
||||
|
||||
m_compareRole = new RSTreeWidgetItemCompareRole;
|
||||
m_compareRole->addRole(COLUMN_NAME, ROLE_SORT);
|
||||
m_compareRole->addRole(COLUMN_STATE, ROLE_SORT);
|
||||
|
||||
connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peertreeWidgetCostumPopupMenu( QPoint ) ) );
|
||||
|
@ -265,6 +274,15 @@ void PeersDialog::processSettings(bool bLoad)
|
|||
// state of splitter
|
||||
ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
|
||||
ui.splitter_2->restoreState(Settings->value("GroupChatSplitter").toByteArray());
|
||||
|
||||
// open groups
|
||||
openGroups.clear();
|
||||
int arrayIndex = Settings->beginReadArray("Groups");
|
||||
for (int index = 0; index < arrayIndex; index++) {
|
||||
Settings->setArrayIndex(index);
|
||||
openGroups.push_back(Settings->value("open").toString().toStdString());
|
||||
}
|
||||
Settings->endArray();
|
||||
} else {
|
||||
// save settings
|
||||
|
||||
|
@ -280,6 +298,19 @@ void PeersDialog::processSettings(bool bLoad)
|
|||
// state of splitter
|
||||
Settings->setValue("Splitter", ui.splitter->saveState());
|
||||
Settings->setValue("GroupChatSplitter", ui.splitter_2->saveState());
|
||||
|
||||
// open groups
|
||||
Settings->beginWriteArray("Groups");
|
||||
int arrayIndex = 0;
|
||||
int itemCount = ui.peertreeWidget->topLevelItemCount();
|
||||
for (int index = 0; index < itemCount; index++) {
|
||||
QTreeWidgetItem *item = ui.peertreeWidget->topLevelItem(index);
|
||||
if (item->type() == TYPE_GROUP && item->isExpanded()) {
|
||||
Settings->setArrayIndex(arrayIndex++);
|
||||
Settings->setValue("open", item->data(COLUMN_DATA, ROLE_ID).toString());
|
||||
}
|
||||
}
|
||||
Settings->endArray();
|
||||
}
|
||||
|
||||
Settings->endGroup();
|
||||
|
@ -327,35 +358,35 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
|
|||
connect( collapseAll , SIGNAL( triggered() ), ui.peertreeWidget, SLOT(collapseAll()) );
|
||||
|
||||
QAction* chatAct = new QAction(QIcon(IMAGE_CHAT), tr( "Chat" ), &contextMnu );
|
||||
if (c) {
|
||||
QAction* msgAct = new QAction(QIcon(IMAGE_MSG), tr( "Message Friend" ), &contextMnu );
|
||||
QAction* connectfriendAct = new QAction(QIcon(IMAGE_CONNECT), tr( "Connect To Friend" ), &contextMnu );
|
||||
QAction* configurefriendAct = new QAction(QIcon(IMAGE_PEERINFO), tr( "Peer Details" ), &contextMnu );
|
||||
// QAction* exportfriendAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Export Friend" ), &contextMnu );
|
||||
QAction* removefriendAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Deny Friend" ), &contextMnu );
|
||||
|
||||
if (c && c->type() != TYPE_GROUP) {
|
||||
connect( chatAct , SIGNAL( triggered() ), this, SLOT( chatfriendproxy() ) );
|
||||
connect( msgAct , SIGNAL( triggered() ), this, SLOT( msgfriend() ) );
|
||||
connect( connectfriendAct , SIGNAL( triggered() ), this, SLOT( connectfriend() ) );
|
||||
connect( configurefriendAct , SIGNAL( triggered() ), this, SLOT( configurefriend() ) );
|
||||
// connect( exportfriendAct , SIGNAL( triggered() ), this, SLOT( exportfriend() ) );
|
||||
|
||||
if (c->type() == TYPE_SSL) {
|
||||
//this is a SSL key
|
||||
removefriendAct->setText(tr( "Remove Friend Location"));
|
||||
}
|
||||
connect( removefriendAct , SIGNAL( triggered() ), this, SLOT( removefriend() ) );
|
||||
} else {
|
||||
chatAct->setDisabled(true);
|
||||
}
|
||||
|
||||
QAction* msgAct = new QAction(QIcon(IMAGE_MSG), tr( "Message Friend" ), &contextMnu );
|
||||
if (c) {
|
||||
connect( msgAct , SIGNAL( triggered() ), this, SLOT( msgfriend() ) );
|
||||
} else {
|
||||
msgAct->setDisabled(true);
|
||||
}
|
||||
|
||||
QAction* connectfriendAct = new QAction(QIcon(IMAGE_CONNECT), tr( "Connect To Friend" ), &contextMnu );
|
||||
if (c) {
|
||||
connect( connectfriendAct , SIGNAL( triggered() ), this, SLOT( connectfriend() ) );
|
||||
} else {
|
||||
connectfriendAct->setDisabled(true);
|
||||
}
|
||||
|
||||
QAction* configurefriendAct = new QAction(QIcon(IMAGE_PEERINFO), tr( "Peer Details" ), &contextMnu );
|
||||
if (c) {
|
||||
connect( configurefriendAct , SIGNAL( triggered() ), this, SLOT( configurefriend() ) );
|
||||
} else {
|
||||
configurefriendAct->setDisabled(true);
|
||||
// exportfriendAct->setDisabled(true);
|
||||
removefriendAct->setDisabled(true);
|
||||
}
|
||||
|
||||
QAction* recommendfriendAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Recomend this Friend to..." ), &contextMnu );
|
||||
if (c && c->type() == 0) {
|
||||
if (c && c->type() == TYPE_GPG) {
|
||||
connect( recommendfriendAct , SIGNAL( triggered() ), this, SLOT( recommendfriend() ) );
|
||||
} else {
|
||||
recommendfriendAct->setDisabled(true);
|
||||
|
@ -368,29 +399,86 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
|
|||
pastePersonAct->setDisabled(true);
|
||||
}
|
||||
|
||||
QAction* profileviewAct = new QAction(QIcon(IMAGE_PEERINFO), tr( "Profile View" ), &contextMnu );
|
||||
// QAction* profileviewAct = new QAction(QIcon(IMAGE_PEERINFO), tr( "Profile View" ), &contextMnu );
|
||||
// if (c) {
|
||||
// connect( profileviewAct , SIGNAL( triggered() ), this, SLOT( viewprofile() ) );
|
||||
// } else {
|
||||
// profileviewAct->setDisabled(true);
|
||||
// }
|
||||
|
||||
|
||||
QMenu* groupsMenu = NULL;
|
||||
QAction *removeGroupAction = NULL;
|
||||
if (c) {
|
||||
connect( profileviewAct , SIGNAL( triggered() ), this, SLOT( viewprofile() ) );
|
||||
if (c->type() == TYPE_GPG) {
|
||||
QMenu* addToGroupMenu = NULL;
|
||||
QMenu* moveToGroupMenu = NULL;
|
||||
|
||||
std::list<RsGroupInfo> groupInfoList;
|
||||
rsPeers->getGroupInfoList(groupInfoList);
|
||||
|
||||
GroupDefs::sortByName(groupInfoList);
|
||||
|
||||
std::string gpgId = c->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
|
||||
bool foundGroup = false;
|
||||
// add action for all groups, except the own group
|
||||
for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) {
|
||||
if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpgId) == groupIt->peerIds.end()) {
|
||||
if (addToGroupMenu == NULL) {
|
||||
addToGroupMenu = new QMenu(tr("Add to group"), &contextMnu );
|
||||
}
|
||||
QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu);
|
||||
addToGroupAction->setData(QString::fromStdString(groupIt->id));
|
||||
connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup()));
|
||||
addToGroupMenu->addAction(addToGroupAction);
|
||||
|
||||
if (moveToGroupMenu == NULL) {
|
||||
moveToGroupMenu = new QMenu(tr("Move to group"), &contextMnu );
|
||||
}
|
||||
QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu);
|
||||
moveToGroupAction->setData(QString::fromStdString(groupIt->id));
|
||||
connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup()));
|
||||
moveToGroupMenu->addAction(moveToGroupAction);
|
||||
} else {
|
||||
profileviewAct->setDisabled(true);
|
||||
foundGroup = true;
|
||||
}
|
||||
}
|
||||
|
||||
QAction* exportfriendAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Export Friend" ), &contextMnu );
|
||||
if (c) {
|
||||
connect( exportfriendAct , SIGNAL( triggered() ), this, SLOT( exportfriend() ) );
|
||||
} else {
|
||||
exportfriendAct->setDisabled(true);
|
||||
if (addToGroupMenu || moveToGroupMenu || foundGroup) {
|
||||
groupsMenu = new QMenu(tr("Groups"), &contextMnu);
|
||||
|
||||
if (addToGroupMenu) {
|
||||
groupsMenu->addMenu(addToGroupMenu);
|
||||
}
|
||||
|
||||
QAction* removefriendAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Deny Friend" ), &contextMnu );
|
||||
if (c) {
|
||||
if (c->type() == 1) {
|
||||
//this is a SSL key
|
||||
removefriendAct->setText(tr( "Remove Friend Location"));
|
||||
if (moveToGroupMenu) {
|
||||
groupsMenu->addMenu(moveToGroupMenu);
|
||||
}
|
||||
connect( removefriendAct , SIGNAL( triggered() ), this, SLOT( removefriend() ) );
|
||||
|
||||
if (foundGroup) {
|
||||
// add remove group
|
||||
QTreeWidgetItem *parent = c->parent();
|
||||
if (parent && parent->type() == TYPE_GROUP) {
|
||||
QAction *removeFromGroup = groupsMenu->addAction(tr("Remove from group"));
|
||||
removeFromGroup->setData(parent->data(COLUMN_DATA, ROLE_ID));
|
||||
connect(removeFromGroup, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
|
||||
}
|
||||
|
||||
QAction *removeFromAllGroups = groupsMenu->addAction(tr("Remove from all groups"));
|
||||
removeFromAllGroups->setData("");
|
||||
connect(removeFromAllGroups, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c->type() == TYPE_GROUP) {
|
||||
removeGroupAction = new QAction(tr("Remove group"), &contextMnu);
|
||||
if (c->data(COLUMN_DATA, ROLE_STANDARD).toBool() == true) {
|
||||
removeGroupAction->setDisabled(true);
|
||||
} else {
|
||||
removefriendAct->setDisabled(true);
|
||||
connect(removeGroupAction, SIGNAL(triggered()), this, SLOT(removeGroup()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *widget = new QWidget(&contextMnu);
|
||||
|
@ -406,7 +494,7 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
|
|||
hbox->addWidget(iconLabel);
|
||||
|
||||
textLabel = new QLabel( tr("<strong>RetroShare instance</strong>"), widget );
|
||||
if (c && c->type() == 0) {
|
||||
if (c && c->type() == TYPE_GPG) {
|
||||
//this is a GPG key
|
||||
textLabel->setText(tr("<strong>GPG Key</strong>"));
|
||||
}
|
||||
|
@ -431,6 +519,12 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
|
|||
contextMnu.addAction(pastePersonAct);
|
||||
contextMnu.addAction( removefriendAct);
|
||||
//contextMnu.addAction( exportfriendAct);
|
||||
if (groupsMenu) {
|
||||
contextMnu.addMenu(groupsMenu);
|
||||
}
|
||||
if (removeGroupAction) {
|
||||
contextMnu.addAction(removeGroupAction);
|
||||
}
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction( expandAll);
|
||||
contextMnu.addAction( collapseAll);
|
||||
|
@ -463,7 +557,7 @@ void PeersDialog::insertPeers()
|
|||
#endif
|
||||
|
||||
std::list<std::string> gpgFriends;
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<std::string>::iterator gpgIt;
|
||||
|
||||
std::list<StatusInfo> statusInfo;
|
||||
rsStatus->getStatusList(statusInfo);
|
||||
|
@ -476,9 +570,15 @@ void PeersDialog::insertPeers()
|
|||
|
||||
bool bHideUnconnected = ui.action_Hide_Offline_Friends->isChecked();
|
||||
|
||||
// get ids of existing private chat messages
|
||||
std::list<std::string> privateChatIds;
|
||||
rsMsgs->getPrivateChatQueueIds(true, privateChatIds);
|
||||
|
||||
// get existing groups
|
||||
std::list<RsGroupInfo> groupInfoList;
|
||||
std::list<RsGroupInfo>::iterator groupIt;
|
||||
rsPeers->getGroupInfoList(groupInfoList);
|
||||
|
||||
rsPeers->getGPGAcceptedList(gpgFriends);
|
||||
|
||||
//add own gpg id, if we have more than on location (ssl client)
|
||||
|
@ -492,75 +592,229 @@ void PeersDialog::insertPeers()
|
|||
/* get a link to the table */
|
||||
QTreeWidget *peertreeWidget = ui.peertreeWidget;
|
||||
|
||||
// remove items don't exist anymore
|
||||
QTreeWidgetItemIterator itemIterator(peertreeWidget);
|
||||
QTreeWidgetItem *item;
|
||||
while ((item = *itemIterator) != NULL) {
|
||||
itemIterator++;
|
||||
switch (item->type()) {
|
||||
case TYPE_GPG:
|
||||
{
|
||||
QTreeWidgetItem *parent = item->parent();
|
||||
std::string gpg_widget_id = item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
|
||||
// remove items that are not friends anymore
|
||||
int itemCount = peertreeWidget->topLevelItemCount();
|
||||
int index = 0;
|
||||
while (index < itemCount) {
|
||||
std::string gpg_widget_id = (peertreeWidget->topLevelItem(index))->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
if (std::find(gpgFriends.begin(), gpgFriends.end(), gpg_widget_id) == gpgFriends.end()) {
|
||||
delete (peertreeWidget->takeTopLevelItem(index));
|
||||
// count again
|
||||
itemCount = peertreeWidget->topLevelItemCount();
|
||||
if (parent) {
|
||||
delete(parent->takeChild(parent->indexOfChild(item)));
|
||||
} else {
|
||||
index++;
|
||||
delete(peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(item)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (groupsHasChanged) {
|
||||
if (parent) {
|
||||
if (parent->type() == TYPE_GROUP) {
|
||||
std::string groupId = parent->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
|
||||
// the parent is a group, check if the gpg id is assigned to the group
|
||||
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) {
|
||||
if (groupIt->id == groupId) {
|
||||
if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpg_widget_id) == groupIt->peerIds.end()) {
|
||||
delete(parent->takeChild(parent->indexOfChild(item)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// gpg item without group, check if the gpg id is assigned to the group
|
||||
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) {
|
||||
if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpg_widget_id) != groupIt->peerIds.end()) {
|
||||
delete(peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(item)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TYPE_GROUP:
|
||||
{
|
||||
if (groupsHasChanged) {
|
||||
// remove deleted groups
|
||||
std::string groupId = item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) {
|
||||
if (groupIt->id == groupId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (groupIt == groupInfoList.end() || groupIt->peerIds.size() == 0) {
|
||||
if (item->parent()) {
|
||||
delete(item->parent()->takeChild(item->parent()->indexOfChild(item)));
|
||||
} else {
|
||||
delete(peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(item)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::list<std::string> fillGpgIds;
|
||||
|
||||
// start with groups
|
||||
groupIt = groupInfoList.begin();
|
||||
while (true) {
|
||||
QTreeWidgetItem *groupItem = NULL;
|
||||
RsGroupInfo *groupInfo = NULL;
|
||||
int onlineCount = 0;
|
||||
int availableCount = 0;
|
||||
if (groupIt != groupInfoList.end()) {
|
||||
groupInfo = &(*groupIt);
|
||||
|
||||
if (groupInfo->peerIds.size() == 0) {
|
||||
groupIt++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// search existing group item
|
||||
int itemCount = peertreeWidget->topLevelItemCount();
|
||||
for (int index = 0; index < itemCount; index++) {
|
||||
QTreeWidgetItem *groupItemLoop = peertreeWidget->topLevelItem(index);
|
||||
if (groupItemLoop->type() == TYPE_GROUP && groupItemLoop->data(COLUMN_DATA, ROLE_ID).toString().toStdString() == groupInfo->id) {
|
||||
groupItem = groupItemLoop;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (groupItem == NULL) {
|
||||
// add group item
|
||||
groupItem = new RSTreeWidgetItem(m_compareRole, TYPE_GROUP);
|
||||
|
||||
/* Add item to the list. Add here, because for setHidden the item must be added */
|
||||
peertreeWidget->addTopLevelItem(groupItem);
|
||||
|
||||
groupItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||
groupItem->setSizeHint(COLUMN_NAME, QSize(26, 26));
|
||||
groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
|
||||
groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP));
|
||||
|
||||
/* used to find back the item */
|
||||
groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id));
|
||||
groupItem->setData(COLUMN_DATA, ROLE_STANDARD, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? true : false);
|
||||
|
||||
if (openGroups.size()) {
|
||||
if (std::find(openGroups.begin(), openGroups.end(), groupInfo->id) != openGroups.end()) {
|
||||
groupItem->setExpanded(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// remove all gpg items that are not more assigned
|
||||
int childCount = groupItem->childCount();
|
||||
int childIndex = 0;
|
||||
while (childIndex < childCount) {
|
||||
QTreeWidgetItem *gpgItemLoop = groupItem->child(childIndex);
|
||||
if (gpgItemLoop->type() == TYPE_GPG) {
|
||||
if (std::find(groupInfo->peerIds.begin(), groupInfo->peerIds.end(), gpgItemLoop->data(COLUMN_DATA, ROLE_ID).toString().toStdString()) == groupInfo->peerIds.end()) {
|
||||
delete(groupItem->takeChild(groupItem->indexOfChild(gpgItemLoop)));
|
||||
childCount = groupItem->childCount();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
childIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
// name is set after calculation of online/offline items
|
||||
}
|
||||
|
||||
// iterate through gpg friends
|
||||
for (gpgIt = gpgFriends.begin(); gpgIt != gpgFriends.end(); gpgIt++) {
|
||||
std::string gpgId = *gpgIt;
|
||||
|
||||
if (groupInfo) {
|
||||
// we fill a group, check if gpg id is assigned
|
||||
if (std::find(groupInfo->peerIds.begin(), groupInfo->peerIds.end(), gpgId) == groupInfo->peerIds.end()) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// we fill the not assigned gpg ids
|
||||
if (std::find(fillGpgIds.begin(), fillGpgIds.end(), gpgId) != fillGpgIds.end()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// add equal too, its no problem
|
||||
fillGpgIds.push_back(gpgId);
|
||||
|
||||
//add the gpg friends
|
||||
for(it = gpgFriends.begin(); it != gpgFriends.end(); it++) {
|
||||
#ifdef PEERS_DEBUG
|
||||
std::cerr << "PeersDialog::insertPeers() inserting gpg_id : " << *it << std::endl;
|
||||
#endif
|
||||
|
||||
/* make a widget per friend */
|
||||
QTreeWidgetItem *gpg_item = NULL;
|
||||
QTreeWidgetItem *gpg_item_loop = NULL;
|
||||
QString gpgid = QString::fromStdString(*it);
|
||||
itemCount = peertreeWidget->topLevelItemCount();
|
||||
for (int nIndex = 0; nIndex < itemCount; nIndex++) {
|
||||
gpg_item_loop = peertreeWidget->topLevelItem(nIndex);
|
||||
if (gpg_item_loop->data(COLUMN_DATA, ROLE_ID).toString() == gpgid) {
|
||||
gpg_item = gpg_item_loop;
|
||||
QTreeWidgetItem *gpgItem = NULL;
|
||||
QTreeWidgetItem *gpgItemLoop = NULL;
|
||||
|
||||
// search existing gpg item
|
||||
int itemCount = groupItem ? groupItem->childCount() : peertreeWidget->topLevelItemCount();
|
||||
for (int index = 0; index < itemCount; index++) {
|
||||
gpgItemLoop = groupItem ? groupItem->child(index) : peertreeWidget->topLevelItem(index);
|
||||
if (gpgItemLoop->type() == TYPE_GPG && gpgItemLoop->data(COLUMN_DATA, ROLE_ID).toString().toStdString() == gpgId) {
|
||||
gpgItem = gpgItemLoop;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RsPeerDetails detail;
|
||||
if ((!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection)
|
||||
&& detail.gpg_id != ownId) {
|
||||
if ((!rsPeers->getPeerDetails(gpgId, detail) || !detail.accept_connection) && detail.gpg_id != ownId) {
|
||||
// don't accept anymore connection, remove from the view
|
||||
if (gpg_item) {
|
||||
delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item)));
|
||||
if (gpgItem) {
|
||||
if (groupItem) {
|
||||
delete(groupItem->takeChild(groupItem->indexOfChild(gpgItem)));
|
||||
} else {
|
||||
delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpgItem)));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gpg_item == NULL) {
|
||||
gpg_item = new RSTreeWidgetItem(m_compareRole, 0); //set type to 0 for custom popup menu
|
||||
if (gpgItem == NULL) {
|
||||
// create gpg item and add it to tree
|
||||
gpgItem = new RSTreeWidgetItem(m_compareRole, TYPE_GPG); //set type to 0 for custom popup menu
|
||||
|
||||
/* Add gpg item to the list. Add here, because for setHidden the item must be added */
|
||||
peertreeWidget->addTopLevelItem(gpg_item);
|
||||
|
||||
gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||
if (groupItem) {
|
||||
groupItem->addChild(gpgItem);
|
||||
} else {
|
||||
peertreeWidget->addTopLevelItem(gpgItem);
|
||||
}
|
||||
|
||||
gpg_item -> setText(COLUMN_NAME, QString::fromStdString(detail.name));
|
||||
gpg_item -> setSizeHint(COLUMN_NAME, QSize( 26,26 ) );
|
||||
|
||||
gpg_item -> setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter );
|
||||
gpgItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||
gpgItem->setSizeHint(COLUMN_NAME, QSize(26, 26));
|
||||
gpgItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
/* not displayed, used to find back the item */
|
||||
gpg_item -> setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
|
||||
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
|
||||
}
|
||||
|
||||
availableCount++;
|
||||
|
||||
gpgItem->setText(COLUMN_NAME, QString::fromStdString(detail.name));
|
||||
gpgItem->setData(COLUMN_NAME, ROLE_SORT, "1 " + QString::fromStdString(detail.name));
|
||||
|
||||
// remove items that are not friends anymore
|
||||
int childCount = gpg_item->childCount();
|
||||
int childCount = gpgItem->childCount();
|
||||
int childIndex = 0;
|
||||
while (childIndex < childCount) {
|
||||
std::string ssl_id = gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
std::string ssl_id = gpgItem->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
if (!rsPeers->isFriend(ssl_id)) {
|
||||
delete (gpg_item->takeChild(childIndex));
|
||||
delete (gpgItem->takeChild(childIndex));
|
||||
// count again
|
||||
childCount = gpg_item->childCount();
|
||||
childCount = gpgItem->childCount();
|
||||
} else {
|
||||
childIndex++;
|
||||
}
|
||||
|
@ -575,40 +829,41 @@ void PeersDialog::insertPeers()
|
|||
rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslContacts);
|
||||
for (std::list<std::string>::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) {
|
||||
QTreeWidgetItem *sslItem = NULL;
|
||||
std::string sslId = *sslIt;
|
||||
|
||||
//find the corresponding sslItem child item of the gpg item
|
||||
bool newChild = true;
|
||||
childCount = gpg_item->childCount();
|
||||
childCount = gpgItem->childCount();
|
||||
for (int childIndex = 0; childIndex < childCount; childIndex++) {
|
||||
if (gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString() == *sslIt) {
|
||||
sslItem = gpg_item->child(childIndex);
|
||||
// we assume, that only ssl items are child of the gpg item, so we don't need to test the type
|
||||
if (gpgItem->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString() == sslId) {
|
||||
sslItem = gpgItem->child(childIndex);
|
||||
newChild = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RsPeerDetails sslDetail;
|
||||
if (!rsPeers->getPeerDetails(*sslIt, sslDetail) || !rsPeers->isFriend(*sslIt)) {
|
||||
if (!rsPeers->getPeerDetails(sslId, sslDetail) || !rsPeers->isFriend(sslId)) {
|
||||
#ifdef PEERS_DEBUG
|
||||
std::cerr << "Removing widget from the view : id : " << *sslIt << std::endl;
|
||||
std::cerr << "Removing widget from the view : id : " << sslId << std::endl;
|
||||
#endif
|
||||
//child has disappeared, remove it from the gpg_item
|
||||
if (sslItem) {
|
||||
gpg_item->removeChild(sslItem);
|
||||
gpgItem->removeChild(sslItem);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newChild) {
|
||||
sslItem = new RSTreeWidgetItem(m_compareRole, 1); //set type to 1 for custom popup menu
|
||||
sslItem = new RSTreeWidgetItem(m_compareRole, TYPE_SSL); //set type to 1 for custom popup menu
|
||||
|
||||
#ifdef PEERS_DEBUG
|
||||
std::cerr << "PeersDialog::insertPeers() inserting sslItem." << std::endl;
|
||||
#endif
|
||||
|
||||
/* Add ssl child to the list. Add here, because for setHidden the item must be added */
|
||||
gpg_item->addChild(sslItem);
|
||||
// gpg_item->setExpanded(true);
|
||||
gpgItem->addChild(sslItem);
|
||||
}
|
||||
|
||||
/* not displayed, used to find back the item */
|
||||
|
@ -678,7 +933,9 @@ void PeersDialog::insertPeers()
|
|||
int i = 0;
|
||||
QIcon gpgIcon;
|
||||
if (gpg_connected) {
|
||||
gpg_item->setHidden(false);
|
||||
gpgItem->setHidden(false);
|
||||
|
||||
onlineCount++;
|
||||
|
||||
int bestPeerState = 0; // for gpg item
|
||||
std::string bestSslId; // for gpg item
|
||||
|
@ -695,7 +952,7 @@ void PeersDialog::insertPeers()
|
|||
|
||||
int peerState = 0;
|
||||
|
||||
gpg_item -> setText(COLUMN_INFO, StatusDefs::name(it->status));
|
||||
gpgItem->setText(COLUMN_INFO, StatusDefs::name(it->status));
|
||||
|
||||
switch (it->status) {
|
||||
case RS_STATUS_INACTIVE:
|
||||
|
@ -742,37 +999,39 @@ void PeersDialog::insertPeers()
|
|||
QColor textColor = StatusDefs::textColor(bestRSState);
|
||||
QFont font = StatusDefs::font(bestRSState);
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i, textColor);
|
||||
gpg_item -> setFont(i, font);
|
||||
gpgItem->setTextColor(i, textColor);
|
||||
gpgItem->setFont(i, font);
|
||||
}
|
||||
|
||||
gpgIcon = QIcon(StatusDefs::imageUser(bestRSState));
|
||||
|
||||
gpg_item -> setText(COLUMN_STATE, StatusDefs::name(bestRSState));
|
||||
gpg_item -> setToolTip(COLUMN_NAME, StatusDefs::tooltip(bestRSState));
|
||||
gpg_item -> setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), bestPeerState));
|
||||
gpgItem->setText(COLUMN_STATE, StatusDefs::name(bestRSState));
|
||||
gpgItem->setToolTip(COLUMN_NAME, StatusDefs::tooltip(bestRSState));
|
||||
gpgItem->setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpgItem->text(COLUMN_NAME), bestPeerState));
|
||||
} else if (gpg_online) {
|
||||
gpg_item->setHidden(bHideUnconnected);
|
||||
onlineCount++;
|
||||
gpgItem->setHidden(bHideUnconnected);
|
||||
gpgIcon = QIcon(IMAGE_AVAILABLE);
|
||||
gpg_item -> setText(COLUMN_STATE, tr("Available"));
|
||||
gpg_item -> setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_AVAILABLE));
|
||||
gpgItem->setText(COLUMN_STATE, tr("Available"));
|
||||
gpgItem->setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpgItem->text(COLUMN_NAME), PEER_STATE_AVAILABLE));
|
||||
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i,(Qt::black));
|
||||
gpg_item -> setFont(i,font);
|
||||
gpgItem->setTextColor(i,(Qt::black));
|
||||
gpgItem->setFont(i,font);
|
||||
}
|
||||
} else {
|
||||
gpg_item->setHidden(bHideUnconnected);
|
||||
gpgItem->setHidden(bHideUnconnected);
|
||||
gpgIcon = QIcon(StatusDefs::imageUser(RS_STATUS_OFFLINE));
|
||||
gpg_item -> setText(COLUMN_STATE, StatusDefs::name(RS_STATUS_OFFLINE));
|
||||
gpg_item -> setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_OFFLINE));
|
||||
gpgItem->setText(COLUMN_STATE, StatusDefs::name(RS_STATUS_OFFLINE));
|
||||
gpgItem->setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpgItem->text(COLUMN_NAME), PEER_STATE_OFFLINE));
|
||||
|
||||
QColor textColor = StatusDefs::textColor(RS_STATUS_OFFLINE);
|
||||
QFont font = StatusDefs::font(RS_STATUS_OFFLINE);
|
||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpg_item -> setTextColor(i, textColor);
|
||||
gpg_item -> setFont(i, font);
|
||||
gpgItem->setTextColor(i, textColor);
|
||||
gpgItem->setFont(i, font);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -780,7 +1039,25 @@ void PeersDialog::insertPeers()
|
|||
gpgIcon = QIcon(":/images/chat.png");
|
||||
}
|
||||
|
||||
gpg_item -> setIcon(COLUMN_NAME, gpgIcon);
|
||||
gpgItem->setIcon(COLUMN_NAME, gpgIcon);
|
||||
}
|
||||
|
||||
if (groupInfo && groupItem) {
|
||||
if (groupItem->childCount() == 0) {
|
||||
// there are some dead id's assigned
|
||||
groupItem->setHidden(true);
|
||||
} else {
|
||||
groupItem->setText(COLUMN_NAME, QString("%1 (%2/%3)").arg(GroupDefs::name(*groupInfo)).arg(onlineCount).arg(availableCount));
|
||||
groupItem->setData(COLUMN_NAME, ROLE_SORT, "0 " + QString::fromUtf8(groupInfo->name.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
if (groupIt != groupInfoList.end()) {
|
||||
groupIt++;
|
||||
} else {
|
||||
// all done
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem *c = getCurrentPeer();
|
||||
|
@ -788,6 +1065,9 @@ void PeersDialog::insertPeers()
|
|||
// active item is hidden, deselect it
|
||||
ui.peertreeWidget->setCurrentItem(NULL);
|
||||
}
|
||||
|
||||
groupsHasChanged = false;
|
||||
openGroups.clear();
|
||||
}
|
||||
|
||||
/* Utility Fns */
|
||||
|
@ -958,11 +1238,11 @@ void PeersDialog::connectfriend()
|
|||
|
||||
if (rsPeers)
|
||||
{
|
||||
if (c->type() == 0) {
|
||||
if (c->type() == TYPE_GPG) {
|
||||
int childCount = c->childCount();
|
||||
for (int childIndex = 0; childIndex < childCount; childIndex++) {
|
||||
QTreeWidgetItem *item = c->child(childIndex);
|
||||
if (item->type() == 1) {
|
||||
if (item->type() == TYPE_SSL) {
|
||||
rsPeers->connectAttempt(getPeerRsCertId(item));
|
||||
item->setIcon(COLUMN_NAME,(QIcon(IMAGE_CONNECT2)));
|
||||
}
|
||||
|
@ -1718,6 +1998,106 @@ void PeersDialog::on_actionMessageHistory_triggered()
|
|||
|
||||
void PeersDialog::on_actionAdd_Group_activated()
|
||||
{
|
||||
CreateGroup createGrpDialog (this);
|
||||
CreateGroup createGrpDialog ("", this);
|
||||
createGrpDialog.exec();
|
||||
}
|
||||
|
||||
void PeersDialog::addToGroup()
|
||||
{
|
||||
QTreeWidgetItem *c = getCurrentPeer();
|
||||
if (c == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->type() != TYPE_GPG) {
|
||||
// wrong type
|
||||
return;
|
||||
}
|
||||
|
||||
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString();
|
||||
std::string gpgId = c->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
|
||||
if (gpgId.empty() || groupId.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add to group
|
||||
rsPeers->assignPeerToGroup(groupId, gpgId, true);
|
||||
}
|
||||
|
||||
void PeersDialog::moveToGroup()
|
||||
{
|
||||
QTreeWidgetItem *c = getCurrentPeer();
|
||||
if (c == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->type() != TYPE_GPG) {
|
||||
// wrong type
|
||||
return;
|
||||
}
|
||||
|
||||
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString();
|
||||
std::string gpgId = c->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
|
||||
if (gpgId.empty() || groupId.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove from all groups
|
||||
rsPeers->assignPeerToGroup("", gpgId, false);
|
||||
|
||||
// add to group
|
||||
rsPeers->assignPeerToGroup(groupId, gpgId, true);
|
||||
}
|
||||
|
||||
void PeersDialog::removeFromGroup()
|
||||
{
|
||||
QTreeWidgetItem *c = getCurrentPeer();
|
||||
if (c == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->type() != TYPE_GPG) {
|
||||
// wrong type
|
||||
return;
|
||||
}
|
||||
|
||||
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString();
|
||||
std::string gpgId = c->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
|
||||
if (gpgId.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove from (all) group(s)
|
||||
rsPeers->assignPeerToGroup(groupId, gpgId, false);
|
||||
}
|
||||
|
||||
void PeersDialog::removeGroup()
|
||||
{
|
||||
QTreeWidgetItem *c = getCurrentPeer();
|
||||
if (c == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->type() != TYPE_GROUP) {
|
||||
// wrong type
|
||||
return;
|
||||
}
|
||||
|
||||
std::string groupId = c->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
|
||||
if (groupId.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
rsPeers->removeGroup(groupId);
|
||||
}
|
||||
|
||||
void PeersDialog::groupsChanged(int type)
|
||||
{
|
||||
Q_UNUSED(type);
|
||||
|
||||
groupsHasChanged = true;
|
||||
}
|
||||
|
|
|
@ -93,6 +93,8 @@ public slots:
|
|||
void updatePeersAvatar(const QString& peer_id);
|
||||
void updateAvatar(); // called by notifyQt to update the avatar when it gets changed by another component
|
||||
|
||||
void groupsChanged(int type);
|
||||
|
||||
protected:
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
|
@ -121,7 +123,10 @@ private slots:
|
|||
void msgfriend();
|
||||
void recommendfriend();
|
||||
void pastePerson();
|
||||
|
||||
void addToGroup();
|
||||
void moveToGroup();
|
||||
void removeFromGroup();
|
||||
void removeGroup();
|
||||
|
||||
void configurefriend();
|
||||
void viewprofile();
|
||||
|
@ -161,7 +166,6 @@ private slots:
|
|||
void displayMenu();
|
||||
void statusColumn();
|
||||
|
||||
|
||||
signals:
|
||||
void friendsUpdated() ;
|
||||
void notifyGroupChat(const QString&,const QString&) ;
|
||||
|
@ -181,6 +185,8 @@ private:
|
|||
void playsound();
|
||||
|
||||
QString fileName;
|
||||
bool groupsHasChanged;
|
||||
std::list<std::string> openGroups;
|
||||
|
||||
/* Worker Functions */
|
||||
/* (1) Update Display */
|
||||
|
|
65
retroshare-gui/src/gui/common/GroupDefs.cpp
Normal file
65
retroshare-gui/src/gui/common/GroupDefs.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "GroupDefs.h"
|
||||
|
||||
const QString GroupDefs::name(const RsGroupInfo &groupInfo)
|
||||
{
|
||||
if ((groupInfo.flag & RS_GROUP_FLAG_STANDARD) == 0) {
|
||||
/* no need to be translated */
|
||||
return QString::fromUtf8(groupInfo.name.c_str());
|
||||
}
|
||||
|
||||
if (groupInfo.id == RS_GROUP_ID_FRIENDS) {
|
||||
return qApp->translate("GroupDefs", "Friends");
|
||||
}
|
||||
if (groupInfo.id == RS_GROUP_ID_FAMILY) {
|
||||
return qApp->translate("GroupDefs", "Family");
|
||||
}
|
||||
if (groupInfo.id == RS_GROUP_ID_COWORKERS) {
|
||||
return qApp->translate("GroupDefs", "Co-Workers");
|
||||
}
|
||||
if (groupInfo.id == RS_GROUP_ID_OTHERS) {
|
||||
return qApp->translate("GroupDefs", "Other Contacts");
|
||||
}
|
||||
if (groupInfo.id == RS_GROUP_ID_FAVORITES) {
|
||||
return qApp->translate("GroupDefs", "Favorites");
|
||||
}
|
||||
|
||||
std::cerr << "GroupDefs::name: Unknown group id requested " << groupInfo.id;
|
||||
return "";
|
||||
}
|
||||
|
||||
static bool sortGroupInfo(const RsGroupInfo &groupInfo1, const RsGroupInfo &groupInfo2)
|
||||
{
|
||||
return (GroupDefs::name(groupInfo1).compare(GroupDefs::name(groupInfo2), Qt::CaseInsensitive) < 0);
|
||||
}
|
||||
|
||||
void GroupDefs::sortByName(std::list<RsGroupInfo> &groupInfoList)
|
||||
{
|
||||
groupInfoList.sort(sortGroupInfo);
|
||||
}
|
37
retroshare-gui/src/gui/common/GroupDefs.h
Normal file
37
retroshare-gui/src/gui/common/GroupDefs.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifndef _GROUPDEFS_H
|
||||
#define _GROUPDEFS_H
|
||||
|
||||
class RsGroupInfo;
|
||||
|
||||
class GroupDefs
|
||||
{
|
||||
public:
|
||||
static const QString name(const RsGroupInfo &groupInfo);
|
||||
|
||||
static void sortByName(std::list<RsGroupInfo> &groupInfoList);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -19,16 +19,42 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include "CreateGroup.h"
|
||||
#include "gui/common/GroupDefs.h"
|
||||
|
||||
/** Default constructor */
|
||||
CreateGroup::CreateGroup(QWidget *parent, Qt::WFlags flags)
|
||||
CreateGroup::CreateGroup(const std::string groupId, QWidget *parent, Qt::WFlags flags)
|
||||
: QDialog(parent, flags)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
m_groupId = groupId;
|
||||
|
||||
if (m_groupId.empty() == false) {
|
||||
/* edit exisiting group */
|
||||
RsGroupInfo groupInfo;
|
||||
if (rsPeers->getGroupInfo(m_groupId, groupInfo)) {
|
||||
ui.groupname->setText(QString::fromUtf8(groupInfo.name.c_str()));
|
||||
} else {
|
||||
/* Group not found, create new */
|
||||
m_groupId.clear();
|
||||
}
|
||||
}
|
||||
|
||||
std::list<RsGroupInfo> groupInfoList;
|
||||
rsPeers->getGroupInfoList(groupInfoList);
|
||||
|
||||
std::list<RsGroupInfo>::iterator groupIt;
|
||||
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) {
|
||||
usedGroupNames.append(GroupDefs::name(*groupIt));
|
||||
}
|
||||
|
||||
on_groupname_textChanged(ui.groupname->text());
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
|
@ -36,3 +62,31 @@ CreateGroup::~CreateGroup()
|
|||
{
|
||||
}
|
||||
|
||||
void CreateGroup::on_groupname_textChanged(QString text)
|
||||
{
|
||||
if (text.isEmpty() || usedGroupNames.contains(text)) {
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
} else {
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateGroup::on_buttonBox_accepted()
|
||||
{
|
||||
RsGroupInfo groupInfo;
|
||||
|
||||
if (m_groupId.empty()) {
|
||||
// add new group
|
||||
groupInfo.name = ui.groupname->text().toUtf8().constData();
|
||||
if (rsPeers->addGroup(groupInfo)) {
|
||||
close();
|
||||
}
|
||||
} else {
|
||||
if (rsPeers->getGroupInfo(m_groupId, groupInfo) == true) {
|
||||
groupInfo.name = ui.groupname->text().toUtf8().constData();
|
||||
if (rsPeers->editGroup(m_groupId, groupInfo)) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,21 +32,25 @@ class CreateGroup : public QDialog
|
|||
|
||||
public:
|
||||
/** Default constructor */
|
||||
CreateGroup(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
CreateGroup(const std::string groupId, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default destructor */
|
||||
~CreateGroup();
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
private:
|
||||
std::string m_groupId;
|
||||
|
||||
QStringList usedGroupNames;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::CreateGroup ui;
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_groupname_textChanged(QString );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -114,11 +114,7 @@ p, li { white-space: pre-wrap; }
|
|||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:9pt;">Group Name</span></p></body></html></string>
|
||||
<string>Group Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -177,9 +173,6 @@ p, li { white-space: pre-wrap; }
|
|||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
|
|
@ -226,6 +226,7 @@
|
|||
<file>images/informations_24x24.png</file>
|
||||
<file>images/invite-friend24.png</file>
|
||||
<file>images/connect_friend.png</file>
|
||||
<file>images/group24.png</file>
|
||||
<file>images/kalarm.png</file>
|
||||
<file>images/kbackgammon.png</file>
|
||||
<file>images/kblogger.png</file>
|
||||
|
|
BIN
retroshare-gui/src/gui/images/group24.png
Normal file
BIN
retroshare-gui/src/gui/images/group24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -239,6 +239,12 @@ void NotifyQt::notifyListChange(int list, int type)
|
|||
#endif
|
||||
emit privateChatChanged(list, type);
|
||||
break;
|
||||
case NOTIFY_LIST_GROUPLIST:
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "received groups changed" << std::endl ;
|
||||
#endif
|
||||
emit groupsChanged(type);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ class NotifyQt: public QObject, public NotifyBase
|
|||
void peerStatusChangedSummary() const;
|
||||
void publicChatChanged(int type) const ;
|
||||
void privateChatChanged(int list, int type) const ;
|
||||
void groupsChanged(int type) const ;
|
||||
|
||||
/* Notify from GUI */
|
||||
void chatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
||||
|
|
Binary file not shown.
|
@ -2405,7 +2405,7 @@ p, li { white-space: pre-wrap; }
|
|||
<message>
|
||||
<location filename="../gui/groups/CreateGroup.ui" line="+14"/>
|
||||
<source>Create a Group</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Gruppe erstellen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+72"/>
|
||||
|
@ -2414,21 +2414,22 @@ p, li { white-space: pre-wrap; }
|
|||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:18pt; font-weight:600; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:400; color:#ffffff;">Create a Group</span></p></body></html></source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translatorcomment>ruppe erstellen</translatorcomment>
|
||||
<translation><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:18pt; font-weight:600; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:400; color:#ffffff;">Gruppe erstellen</span></p></body></html></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+31"/>
|
||||
<source><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:9pt;">Group Name</span></p></body></html></source>
|
||||
<translation type="unfinished"></translation>
|
||||
<source>Group Name</source>
|
||||
<translation>Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+11"/>
|
||||
<location line="+7"/>
|
||||
<source>Enter a name for your group</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Gib einen Namen für Deine Gruppe ein</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -4098,6 +4099,34 @@ Fill in your GPG password when asked, to sign your new key.</source>
|
|||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GroupDefs</name>
|
||||
<message>
|
||||
<location filename="../gui/common/GroupDefs.cpp" line="+38"/>
|
||||
<source>Friends</source>
|
||||
<translation>Freunde</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+3"/>
|
||||
<source>Family</source>
|
||||
<translation>Familie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+3"/>
|
||||
<source>Co-Workers</source>
|
||||
<translation>Mitarbeiter</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+3"/>
|
||||
<source>Other Contacts</source>
|
||||
<translation>Andere Kontakte</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+3"/>
|
||||
<source>Favorites</source>
|
||||
<translation>Favoriten</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>HelpBrowser</name>
|
||||
<message>
|
||||
|
@ -4781,16 +4810,17 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>Kanäle</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Blogs</source>
|
||||
<translation type="obsolete">Blogs</translation>
|
||||
<translation type="unfinished">Blogs</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+540"/>
|
||||
<location line="+539"/>
|
||||
<source>Internal Error</source>
|
||||
<translation>Interener Fehler</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/MainWindow.ui" line="+83"/>
|
||||
<location filename="../gui/MainWindow.ui" line="+82"/>
|
||||
<location filename="../gui/MainWindow.cpp" line="-43"/>
|
||||
<source>Options</source>
|
||||
<translation>Optionen</translation>
|
||||
|
@ -4815,12 +4845,12 @@ p, li { white-space: pre-wrap; }
|
|||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/MainWindow.ui" line="-69"/>
|
||||
<location filename="../gui/MainWindow.ui" line="-68"/>
|
||||
<source>MainWindow</source>
|
||||
<translation>Hauptfenster</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+48"/>
|
||||
<location line="+47"/>
|
||||
<source>Add Friend</source>
|
||||
<translation>Freund hinzufügen</translation>
|
||||
</message>
|
||||
|
@ -4841,12 +4871,7 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>Schnellstart Assistent</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>Add Group</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/MainWindow.cpp" line="-261"/>
|
||||
<location filename="../gui/MainWindow.cpp" line="-264"/>
|
||||
<source>Search</source>
|
||||
<translation>Suchen</translation>
|
||||
</message>
|
||||
|
@ -4856,12 +4881,12 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>Dateien</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/MainWindow.ui" line="-47"/>
|
||||
<location filename="../gui/MainWindow.ui" line="-38"/>
|
||||
<source>Messenger</source>
|
||||
<translation>Messenger</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/MainWindow.cpp" line="+148"/>
|
||||
<location filename="../gui/MainWindow.cpp" line="+151"/>
|
||||
<source>Show/Hide</source>
|
||||
<translation>Anzeigen/Verbergen</translation>
|
||||
</message>
|
||||
|
@ -4938,12 +4963,12 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>Foren</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-66"/>
|
||||
<location line="-69"/>
|
||||
<source>RetroShare %1 a secure decentralised communication platform</source>
|
||||
<translation>RetroShare %1 eine sichere und dezentralisierte Kommunikationsplattform</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+567"/>
|
||||
<location line="+570"/>
|
||||
<source>Open Messages</source>
|
||||
<translation>Öffne Nachrichten</translation>
|
||||
</message>
|
||||
|
@ -6852,17 +6877,12 @@ p, li { white-space: pre-wrap; }
|
|||
<context>
|
||||
<name>PeersDialog</name>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.cpp" line="+329"/>
|
||||
<location filename="../gui/PeersDialog.cpp" line="+360"/>
|
||||
<source>Chat</source>
|
||||
<translation>Chat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+49"/>
|
||||
<source>Export Friend</source>
|
||||
<translation>Zertifikat des Freundes exportieren</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+439"/>
|
||||
<location line="+737"/>
|
||||
<source>Save Certificate</source>
|
||||
<translation>Zertifikat speichern</translation>
|
||||
</message>
|
||||
|
@ -6877,12 +6897,12 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>Status</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-475"/>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-736"/>
|
||||
<source>Connect To Friend</source>
|
||||
<translation>Verbinde zum Freund</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-217"/>
|
||||
<location line="-227"/>
|
||||
<source>Profile</source>
|
||||
<translation>Profil</translation>
|
||||
</message>
|
||||
|
@ -6902,7 +6922,7 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>ich</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+93"/>
|
||||
<location line="+115"/>
|
||||
<source>Expand all</source>
|
||||
<translation>Alle erweitern</translation>
|
||||
</message>
|
||||
|
@ -6912,27 +6932,57 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>Alle reduzieren</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<location line="+4"/>
|
||||
<source>Message Friend</source>
|
||||
<translation>Freund anschreiben</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+14"/>
|
||||
<location line="+2"/>
|
||||
<source>Peer Details</source>
|
||||
<translation>Peer-Details</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+35"/>
|
||||
<location line="+2"/>
|
||||
<source>Deny Friend</source>
|
||||
<translation>Blockiere Freund</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+11"/>
|
||||
<source>Remove Friend Location</source>
|
||||
<translation>Freund entfernen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+22"/>
|
||||
<location line="+53"/>
|
||||
<source>Add to group</source>
|
||||
<translation>Hinzufügen zur Gruppe</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+8"/>
|
||||
<source>Move to group</source>
|
||||
<translation>Verschiebe in Gruppe</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+12"/>
|
||||
<source>Groups</source>
|
||||
<translation>Gruppen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+14"/>
|
||||
<source>Remove from group</source>
|
||||
<translation>Aus Gruppe entfernen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>Remove from all groups</source>
|
||||
<translation>Aus allen Gruppen entfernen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+7"/>
|
||||
<source>Remove group</source>
|
||||
<translation>Gruppe entfernen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+24"/>
|
||||
<source><strong>GPG Key</strong></source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
|
@ -6942,12 +6992,12 @@ p, li { white-space: pre-wrap; }
|
|||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+349"/>
|
||||
<location line="+519"/>
|
||||
<source>Available</source>
|
||||
<translation>Verfügbar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+736"/>
|
||||
<location line="+758"/>
|
||||
<source>Add Extra File</source>
|
||||
<translation>Zusätzliche Datei hinzufügen</translation>
|
||||
</message>
|
||||
|
@ -7061,7 +7111,7 @@ p, li { white-space: pre-wrap; }
|
|||
<location line="+41"/>
|
||||
<location line="+3"/>
|
||||
<source>Add a new Group</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Neue Gruppe hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-107"/>
|
||||
|
@ -7107,18 +7157,13 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>Verlauf löschen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-1225"/>
|
||||
<source>Profile View</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.ui" line="+85"/>
|
||||
<location line="+85"/>
|
||||
<location line="+3"/>
|
||||
<source>Save Chat History</source>
|
||||
<translation>Chat Verlauf speichern</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.cpp" line="+564"/>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-661"/>
|
||||
<source>RetroShare</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
|
@ -7161,17 +7206,17 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>Status Spalte ausblenden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-1528"/>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-1799"/>
|
||||
<source>Friends Storm</source>
|
||||
<translation>Aktivitäten</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+230"/>
|
||||
<location line="+252"/>
|
||||
<source>Recomend this Friend to...</source>
|
||||
<translation>Freund weiterempfehlen...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+645"/>
|
||||
<location line="+894"/>
|
||||
<source>is typing...</source>
|
||||
<translation>tippt...</translation>
|
||||
</message>
|
||||
|
@ -7191,12 +7236,12 @@ p, li { white-space: pre-wrap; }
|
|||
<translation>Freunde</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-638"/>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-887"/>
|
||||
<source>Paste Friend Link</source>
|
||||
<translation>RetroShare Link einfügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+258"/>
|
||||
<location line="+482"/>
|
||||
<source>location</source>
|
||||
<translation>Standort</translation>
|
||||
</message>
|
||||
|
@ -7654,11 +7699,6 @@ Do you want to send them a Message instead</source>
|
|||
<source>apears to be Offline.</source>
|
||||
<translation>ist Offline.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Messages you send will be lost and not delivered, rs-Mail this contact instead.</source>
|
||||
<translation type="obsolete">Nachrichten, die Du versendest gehen bei diesem Kontakt nicht ein.
|
||||
Diesem Kontakt stattdessen eine RS-Mail senden.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-693"/>
|
||||
<source>is typing...</source>
|
||||
|
@ -7820,7 +7860,7 @@ Diesem Kontakt stattdessen eine RS-Mail senden.</translation>
|
|||
<context>
|
||||
<name>ProfileView</name>
|
||||
<message>
|
||||
<location filename="../gui/profile/ProfileView.cpp" line="+77"/>
|
||||
<location filename="../gui/profile/ProfileView.cpp" line="+76"/>
|
||||
<source>Clear Photo</source>
|
||||
<translation>Photo entfernen</translation>
|
||||
</message>
|
||||
|
|
|
@ -189,6 +189,7 @@ int main(int argc, char *argv[])
|
|||
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
|
||||
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->peersDialog ,SLOT(insertPeers() )) ;
|
||||
QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->peersDialog ,SLOT(publicChatChanged(int) ));
|
||||
QObject::connect(notify,SIGNAL(groupsChanged(int)) ,w->peersDialog ,SLOT(groupsChanged(int) ));
|
||||
QObject::connect(notify,SIGNAL(privateChatChanged(int, int)) ,w ,SLOT(privateChatChanged(int, int) ));
|
||||
QObject::connect(notify,SIGNAL(neighborsChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
|
||||
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue