Merge pull request #218 from csoler/v0.6-ContactList

V0.6 contact list
This commit is contained in:
Cyril Soler 2015-12-23 18:07:10 -05:00
commit f30f71db8e
32 changed files with 1011 additions and 716 deletions

View file

@ -103,10 +103,8 @@ void GxsResponseTask::streamGxsId(RsGxsId id, StreamBase &stream)
{ {
stream << makeKeyValueReference("id", id) stream << makeKeyValueReference("id", id)
<< makeKeyValueReference("gxs_id", id) << makeKeyValueReference("gxs_id", id)
<< makeKeyValueReference("is_own", vit->mIsOwnId) << makeKeyValueReference("flags", vit->mFlags)
<< makeKeyValueReference("name", vit->mNickname) << makeKeyValueReference("name", vit->mNickname);
<< makeKeyValueReference("pgp_linked", vit->mPgpLinked)
<< makeKeyValueReference("pgp_known", vit->mPgpKnown);
return; return;
} }
} }

View file

@ -177,7 +177,7 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
return false; return false;
} }
if(!details.mPgpLinked) if(!(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
{ {
std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (id=" << cli->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl; std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (id=" << cli->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl;
@ -688,7 +688,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
return ; return ;
} }
if(!details.mPgpLinked) if(!(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
{ {
std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (ID=" << item->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl; std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (ID=" << item->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl;
@ -1727,7 +1727,7 @@ bool DistributedChatService::setIdentityForChatLobby(const ChatLobbyId& lobby_id
// Only send a nickname change event if the two Identities are not anonymous // Only send a nickname change event if the two Identities are not anonymous
if(rsIdentity->getIdDetails(nick,det1) && rsIdentity->getIdDetails(it->second.gxs_id,det2) && det1.mPgpLinked && det2.mPgpLinked) if(rsIdentity->getIdDetails(nick,det1) && rsIdentity->getIdDetails(it->second.gxs_id,det2) && (det1.mFlags & det2.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
sendLobbyStatusPeerChangedNickname(lobby_id, nick.toStdString()) ; sendLobbyStatusPeerChangedNickname(lobby_id, nick.toStdString()) ;
} }

View file

@ -33,6 +33,7 @@
#include "retroshare/rsgxsflags.h" #include "retroshare/rsgxsflags.h"
#include "retroshare/rsgxscircles.h" #include "retroshare/rsgxscircles.h"
#include "retroshare/rsgrouter.h" #include "retroshare/rsgrouter.h"
#include "retroshare/rsidentity.h"
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
#include "rsgixs.h" #include "rsgixs.h"
#include "rsgxsutil.h" #include "rsgxsutil.h"
@ -910,7 +911,7 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin
{ {
// now check reputation of the message author // now check reputation of the message author
float reputation_threshold = ( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) && !details.mPgpLinked) ? (RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM): (RsReputations::REPUTATION_THRESHOLD_DEFAULT) ; float reputation_threshold = ( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)) ? (RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM): (RsReputations::REPUTATION_THRESHOLD_DEFAULT) ;
if(details.mReputation.mOverallReputationScore < reputation_threshold) if(details.mReputation.mOverallReputationScore < reputation_threshold)
{ {

View file

@ -65,6 +65,11 @@ extern RsIdentity *rsIdentity;
std::string rsIdTypeToString(uint32_t idtype); std::string rsIdTypeToString(uint32_t idtype);
static const uint32_t RS_IDENTITY_FLAGS_IS_A_CONTACT = 0x0001;
static const uint32_t RS_IDENTITY_FLAGS_PGP_LINKED = 0x0002;
static const uint32_t RS_IDENTITY_FLAGS_PGP_KNOWN = 0x0004;
static const uint32_t RS_IDENTITY_FLAGS_IS_OWN_ID = 0x0008;
class GxsReputation class GxsReputation
{ {
public: public:
@ -116,6 +121,7 @@ class RsGxsIdGroup
// Not Serialised - for GUI's benefit. // Not Serialised - for GUI's benefit.
bool mPgpKnown; bool mPgpKnown;
bool mIsAContact; // change that into flags one day
RsPgpId mPgpId; RsPgpId mPgpId;
GxsReputation mReputation; GxsReputation mReputation;
}; };
@ -154,22 +160,20 @@ class RsRecognTagDetails
bool is_pending; bool is_pending;
}; };
class RsIdentityDetails class RsIdentityDetails
{ {
public: public:
RsIdentityDetails() RsIdentityDetails()
:mIsOwnId(false), mPgpLinked(false), mPgpKnown(false), mLastUsageTS(0) { return; } : mFlags(0), mLastUsageTS(0) { return; }
RsGxsId mId; RsGxsId mId;
// identity details. // identity details.
std::string mNickname; std::string mNickname;
bool mIsOwnId;
uint32_t mFlags ;
// PGP Stuff. // PGP Stuff.
bool mPgpLinked;
bool mPgpKnown;
RsPgpId mPgpId; RsPgpId mPgpId;
// Recogn details. // Recogn details.
@ -245,6 +249,8 @@ virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment, virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
uint16_t tag_class, uint16_t tag_type, std::string &tag) = 0; uint16_t tag_class, uint16_t tag_type, std::string &tag) = 0;
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
// Specific RsIdentity Functions.... // Specific RsIdentity Functions....
/* Specific Service Data */ /* Specific Service Data */
/* We expose these initially for testing / GUI purposes. /* We expose these initially for testing / GUI purposes.

View file

@ -264,6 +264,12 @@ public:
#define RS_DISTANT_CHAT_FLAG_SIGNED 0x0001 #define RS_DISTANT_CHAT_FLAG_SIGNED 0x0001
#define RS_DISTANT_CHAT_FLAG_SIGNATURE_OK 0x0002 #define RS_DISTANT_CHAT_FLAG_SIGNATURE_OK 0x0002
// flags to define who we accept to talk to
#define RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_NONE 0x0000
#define RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_EVERYBODY 0x0001
#define RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST 0x0002
struct DistantChatPeerInfo struct DistantChatPeerInfo
{ {
RsGxsId to_id ; RsGxsId to_id ;
@ -425,8 +431,8 @@ virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags) = 0;
/* Private distant messages */ /* Private distant messages */
/****************************************/ /****************************************/
virtual void enableDistantMessaging(bool b) = 0; virtual uint32_t getDistantMessagingPermissionFlags()=0 ;
virtual bool distantMessagingEnabled() = 0; virtual void setDistantMessagingPermissionFlags(uint32_t flags)=0 ;
/****************************************/ /****************************************/
/* Chat */ /* Chat */

View file

@ -279,6 +279,16 @@ bool p3Msgs::getMessageSummaries(std::list<MsgInfoSummary> &msgList)
} }
uint32_t p3Msgs::getDistantMessagingPermissionFlags()
{
return mMsgSrv->getDistantMessagingPermissionFlags();
}
void p3Msgs::setDistantMessagingPermissionFlags(uint32_t flags)
{
return mMsgSrv->setDistantMessagingPermissionFlags(flags);
}
bool p3Msgs::getMessage(const std::string &mid, MessageInfo &msg) bool p3Msgs::getMessage(const std::string &mid, MessageInfo &msg)
{ {
@ -298,15 +308,6 @@ bool p3Msgs::MessageSend(MessageInfo &info)
return mMsgSrv->MessageSend(info); return mMsgSrv->MessageSend(info);
} }
void p3Msgs::enableDistantMessaging(bool b)
{
mMsgSrv->enableDistantMessaging(b);
}
bool p3Msgs::distantMessagingEnabled()
{
return mMsgSrv->distantMessagingEnabled();
}
bool p3Msgs::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) bool p3Msgs::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)
{ {
return mMsgSrv->SystemMessage(title, message, systemFlag); return mMsgSrv->SystemMessage(title, message, systemFlag);

View file

@ -80,8 +80,8 @@ class p3Msgs: public RsMsgs
virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags); virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags);
virtual void enableDistantMessaging(bool b) ; virtual uint32_t getDistantMessagingPermissionFlags() ;
virtual bool distantMessagingEnabled() ; virtual void setDistantMessagingPermissionFlags(uint32_t flags) ;
/*! /*!
* gets avatar from peer, image data in jpeg format * gets avatar from peer, image data in jpeg format

View file

@ -101,6 +101,8 @@ uint32_t RsGxsIdLocalInfoItem::serial_size()
uint32_t s = 8 ; // header uint32_t s = 8 ; // header
s += 4 ; // number of items s += 4 ; // number of items
s += mTimeStamps.size() * (RsGxsId::SIZE_IN_BYTES + 8) ; s += mTimeStamps.size() * (RsGxsId::SIZE_IN_BYTES + 8) ;
s += 4 ; // number of contacts
s += mContacts.size() * RsGxsId::SIZE_IN_BYTES ;
return s; return s;
} }
@ -176,6 +178,11 @@ bool RsGxsIdLocalInfoItem::serialise(void *data, uint32_t& size)
ok &= it->first.serialise(data,tlvsize,offset) ; ok &= it->first.serialise(data,tlvsize,offset) ;
ok &= setRawTimeT(data,tlvsize,&offset,it->second) ; ok &= setRawTimeT(data,tlvsize,&offset,it->second) ;
} }
ok &= setRawUInt32(data, tlvsize, &offset, mContacts.size()) ;
for(std::set<RsGxsId>::const_iterator it(mContacts.begin());it!=mContacts.end();++it)
ok &= (*it).serialise(data,tlvsize,offset) ;
if(offset != tlvsize) if(offset != tlvsize)
{ {
#ifdef GXSID_DEBUG #ifdef GXSID_DEBUG
@ -386,6 +393,19 @@ RsGxsIdLocalInfoItem *RsGxsIdSerialiser::deserialise_GxsIdLocalInfoItem(void *da
item->mTimeStamps[gxsid] = TS ; item->mTimeStamps[gxsid] = TS ;
} }
if (offset < rssize) // backward compatibility, making that section optional.
{
ok &= getRawUInt32(data, rssize, &offset, &n) ;
RsGxsId gxsid ;
for(int i=0;ok && i<n;++i)
{
ok &= gxsid.deserialise(data,rssize,offset) ;
item->mContacts.insert(gxsid) ;
}
}
if (offset != rssize) if (offset != rssize)
{ {
#ifdef GXSID_DEBUG #ifdef GXSID_DEBUG

View file

@ -97,6 +97,7 @@ public:
virtual uint32_t serial_size() ; virtual uint32_t serial_size() ;
std::map<RsGxsId,time_t> mTimeStamps ; std::map<RsGxsId,time_t> mTimeStamps ;
std::set<RsGxsId> mContacts ;
}; };
#if 0 #if 0

View file

@ -932,7 +932,7 @@ bool p3GxsCircles::cache_load_for_token(uint32_t token)
RsIdentityDetails details; RsIdentityDetails details;
if (mIdentities->getIdDetails(*pit, details)) if (mIdentities->getIdDetails(*pit, details))
{ {
if (details.mPgpLinked && details.mPgpKnown) if ((details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) &&(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN))
{ {
#ifdef DEBUG_CIRCLES #ifdef DEBUG_CIRCLES
std::cerr << "p3GxsCircles::cache_load_for_token() Is Known -> AllowedPeer: " << *pit; std::cerr << "p3GxsCircles::cache_load_for_token() Is Known -> AllowedPeer: " << *pit;
@ -1115,7 +1115,7 @@ bool p3GxsCircles::cache_reloadids(const RsGxsCircleId &circleId)
RsIdentityDetails details; RsIdentityDetails details;
if (mIdentities->getIdDetails(*pit, details)) if (mIdentities->getIdDetails(*pit, details))
{ {
if (details.mPgpLinked && details.mPgpKnown) if ((details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) &&(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN))
{ {
cache.addAllowedPeer(details.mPgpId, *pit); cache.addAllowedPeer(details.mPgpId, *pit);

View file

@ -248,8 +248,8 @@ void p3GxsReputation::updateIdentityFlags()
} }
it->second.mIdentityFlags = 0 ; it->second.mIdentityFlags = 0 ;
if(details.mPgpLinked) it->second.mIdentityFlags |= REPUTATION_IDENTITY_FLAG_PGP_LINKED ; if(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) it->second.mIdentityFlags |= REPUTATION_IDENTITY_FLAG_PGP_LINKED ;
if(details.mPgpKnown ) it->second.mIdentityFlags |= REPUTATION_IDENTITY_FLAG_PGP_KNOWN ; if(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN ) it->second.mIdentityFlags |= REPUTATION_IDENTITY_FLAG_PGP_KNOWN ;
#ifdef DEBUG_REPUTATION #ifdef DEBUG_REPUTATION
std::cerr << " updated flags for " << *rit << " to " << std::hex << it->second.mIdentityFlags << std::dec << std::endl; std::cerr << " updated flags for " << *rit << " to " << std::hex << it->second.mIdentityFlags << std::dec << std::endl;

View file

@ -212,6 +212,25 @@ uint32_t p3IdService::idAuthenPolicy()
return policy; return policy;
} }
bool p3IdService::setAsRegularContact(const RsGxsId& id,bool b)
{
std::set<RsGxsId>::iterator it = mContacts.find(id) ;
if(b && (it == mContacts.end()))
{
mContacts.insert(id) ;
slowIndicateConfigChanged() ;
}
if( (!b) &&(it != mContacts.end()))
{
mContacts.erase(it) ;
slowIndicateConfigChanged() ;
}
return true ;
}
void p3IdService::slowIndicateConfigChanged() void p3IdService::slowIndicateConfigChanged()
{ {
time_t now = time(NULL) ; time_t now = time(NULL) ;
@ -250,8 +269,13 @@ bool p3IdService::loadList(std::list<RsItem*>& items)
for(std::list<RsItem*>::const_iterator it = items.begin();it!=items.end();++it) for(std::list<RsItem*>::const_iterator it = items.begin();it!=items.end();++it)
if( (lii = dynamic_cast<RsGxsIdLocalInfoItem*>(*it)) != NULL) if( (lii = dynamic_cast<RsGxsIdLocalInfoItem*>(*it)) != NULL)
{
for(std::map<RsGxsId,time_t>::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2) for(std::map<RsGxsId,time_t>::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2)
mKeysTS.insert(*it2) ; mKeysTS.insert(*it2) ;
mContacts = lii->mContacts ;
}
return true ; return true ;
} }
@ -265,6 +289,7 @@ bool p3IdService::saveList(bool& cleanup,std::list<RsItem*>& items)
cleanup = true ; cleanup = true ;
RsGxsIdLocalInfoItem *item = new RsGxsIdLocalInfoItem ; RsGxsIdLocalInfoItem *item = new RsGxsIdLocalInfoItem ;
item->mTimeStamps = mKeysTS ; item->mTimeStamps = mKeysTS ;
item->mContacts = mContacts ;
items.push_back(item) ; items.push_back(item) ;
return true ; return true ;
@ -411,6 +436,9 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
details = data.details; details = data.details;
details.mLastUsageTS = locked_getLastUsageTS(id) ; details.mLastUsageTS = locked_getLastUsageTS(id) ;
if(mContacts.find(id) != mContacts.end())
details.mFlags |= RS_IDENTITY_FLAGS_IS_A_CONTACT ;
// one utf8 symbol can be at most 4 bytes long - would be better to measure real unicode length !!! // one utf8 symbol can be at most 4 bytes long - would be better to measure real unicode length !!!
if(details.mNickname.length() > RSID_MAXIMUM_NICKNAME_SIZE*4) if(details.mNickname.length() > RSID_MAXIMUM_NICKNAME_SIZE*4)
details.mNickname = "[too long a name]" ; details.mNickname = "[too long a name]" ;
@ -426,6 +454,9 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
details = data.details; details = data.details;
details.mLastUsageTS = locked_getLastUsageTS(id) ; details.mLastUsageTS = locked_getLastUsageTS(id) ;
if(mContacts.find(id) != mContacts.end())
details.mFlags |= RS_IDENTITY_FLAGS_IS_A_CONTACT ;
rsReputations->getReputationInfo(id,details.mReputation) ; rsReputations->getReputationInfo(id,details.mReputation) ;
return true; return true;
@ -1068,6 +1099,8 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
std::cerr << std::endl; std::cerr << std::endl;
} }
group.mIsAContact = (mContacts.find(RsGxsId(group.mMeta.mGroupId)) != mContacts.end());
groups.push_back(group); groups.push_back(group);
delete(item); delete(item);
} }
@ -1600,8 +1633,10 @@ RsGxsIdCache::RsGxsIdCache(const RsGxsIdGroupItem *item, const RsTlvSecurityKey
std::cerr << std::endl; std::cerr << std::endl;
#endif // DEBUG_IDS #endif // DEBUG_IDS
details.mIsOwnId = (item->meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); details.mFlags = 0 ;
details.mPgpLinked = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
if(item->meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) details.mFlags |= RS_IDENTITY_FLAGS_IS_OWN_ID;
if(item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) details.mFlags |= RS_IDENTITY_FLAGS_PGP_LINKED;
/* rest must be retrived from ServiceString */ /* rest must be retrived from ServiceString */
updateServiceString(item->meta.mServiceString); updateServiceString(item->meta.mServiceString);
@ -1610,22 +1645,20 @@ RsGxsIdCache::RsGxsIdCache(const RsGxsIdGroupItem *item, const RsTlvSecurityKey
void RsGxsIdCache::updateServiceString(std::string serviceString) void RsGxsIdCache::updateServiceString(std::string serviceString)
{ {
details.mRecognTags.clear(); details.mRecognTags.clear();
details.mFlags = 0 ;
SSGxsIdGroup ssdata; SSGxsIdGroup ssdata;
if (ssdata.load(serviceString)) if (ssdata.load(serviceString))
{ {
if (details.mPgpLinked) if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)
{
details.mPgpKnown = ssdata.pgp.idKnown;
if (details.mPgpKnown)
{ {
if(ssdata.pgp.idKnown) details.mFlags |= RS_IDENTITY_FLAGS_PGP_KNOWN ;
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)
details.mPgpId = ssdata.pgp.pgpId; details.mPgpId = ssdata.pgp.pgpId;
}
else else
{
details.mPgpId.clear(); details.mPgpId.clear();
} }
}
// process RecognTags. // process RecognTags.
@ -1680,7 +1713,7 @@ void RsGxsIdCache::updateServiceString(std::string serviceString)
} }
else else
{ {
details.mPgpKnown = false; details.mFlags &= ~RS_IDENTITY_FLAGS_PGP_KNOWN ;
details.mPgpId.clear(); details.mPgpId.clear();
//details.mReputation.updateIdScore(false, false); //details.mReputation.updateIdScore(false, false);
//details.mReputation.update(); //details.mReputation.update();

View file

@ -265,6 +265,8 @@ virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment, virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
uint16_t tag_class, uint16_t tag_type, std::string &tag); uint16_t tag_class, uint16_t tag_type, std::string &tag);
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
/**************** RsGixs Implementation ***************/ /**************** RsGixs Implementation ***************/
virtual bool getOwnIds(std::list<RsGxsId> &ownIds); virtual bool getOwnIds(std::list<RsGxsId> &ownIds);
@ -497,6 +499,9 @@ std::string genRandomId(int len = 20);
std::map<uint32_t, std::list<RsGxsGroupId> > mGroupNotPresent; std::map<uint32_t, std::list<RsGxsGroupId> > mGroupNotPresent;
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent; std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
std::map<RsGxsId,time_t> mKeysTS ; std::map<RsGxsId,time_t> mKeysTS ;
// keep a list of regular contacts. This is useful to sort IDs, and allow some services to priviledged ids only.
std::set<RsGxsId> mContacts;
RsNetworkExchangeService* mNes; RsNetworkExchangeService* mNes;
/************************** /**************************

View file

@ -90,6 +90,7 @@ class p3MsgService: public p3Service, public p3Config, public pqiServiceMonitor,
void loadWelcomeMsg(); /* startup message */ void loadWelcomeMsg(); /* startup message */
//std::list<RsMsgItem *> &getMsgList(); //std::list<RsMsgItem *> &getMsgList();
//std::list<RsMsgItem *> &getMsgOutList(); //std::list<RsMsgItem *> &getMsgOutList();
@ -125,6 +126,8 @@ class p3MsgService: public p3Service, public p3Config, public pqiServiceMonitor,
}; };
void enableDistantMessaging(bool b) ; void enableDistantMessaging(bool b) ;
bool distantMessagingEnabled() ; bool distantMessagingEnabled() ;
void setDistantMessagingPermissionFlags(uint32_t flags) {}
uint32_t getDistantMessagingPermissionFlags() { return 0 ;}
private: private:
void sendDistantMsgItem(RsMsgItem *msgitem) ; void sendDistantMsgItem(RsMsgItem *msgitem) ;

View file

@ -235,7 +235,7 @@ static bool trimAnonIds(std::list<RsGxsId>& lst)
RsIdentityDetails idd ; RsIdentityDetails idd ;
for(std::list<RsGxsId>::iterator it = lst.begin();it!=lst.end();) for(std::list<RsGxsId>::iterator it = lst.begin();it!=lst.end();)
if(!rsIdentity->getIdDetails(*it,idd) || !idd.mPgpLinked) if(!rsIdentity->getIdDetails(*it,idd) || !(idd.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
{ {
it = lst.erase(it) ; it = lst.erase(it) ;
removed= true ; removed= true ;
@ -269,7 +269,7 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
{ {
QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem(); QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem();
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong(); //ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
ChatLobbyFlags flags(item->data(COLUMN_DATA, ROLE_FLAGS).toUInt()); ChatLobbyFlags flags(item->data(COLUMN_DATA, ROLE_FLAGS).toUInt());
bool removed = false ; bool removed = false ;
@ -725,7 +725,7 @@ void ChatLobbyWidget::subscribeChatLobbyAs()
return ; return ;
RsGxsId gxs_id(action->data().toString().toStdString()); RsGxsId gxs_id(action->data().toString().toStdString());
uint32_t error_code ; //uint32_t error_code ;
if(rsMsgs->joinVisibleChatLobby(id,gxs_id)) if(rsMsgs->joinVisibleChatLobby(id,gxs_id))
ChatDialog::chatFriend(ChatId(id),true) ; ChatDialog::chatFriend(ChatId(id),true) ;
@ -795,7 +795,7 @@ void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
if(!rsIdentity->getIdDetails(gxs_id,idd)) if(!rsIdentity->getIdDetails(gxs_id,idd))
return ; return ;
if( (flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) && !idd.mPgpLinked) if( (flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) && !(idd.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
{ {
QMessageBox::warning(NULL,tr("Default identity is anonymous"),tr("You cannot join this lobby with your default identity, since it is anonymous and the lobby forbids it.")) ; QMessageBox::warning(NULL,tr("Default identity is anonymous"),tr("You cannot join this lobby with your default identity, since it is anonymous and the lobby forbids it.")) ;
return ; return ;
@ -845,10 +845,12 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
QString text = tr("You're not subscribed to this lobby; Double click-it to enter and chat.") ; QString text = tr("You're not subscribed to this lobby; Double click-it to enter and chat.") ;
if(my_ids.empty()) if(my_ids.empty())
{
if( (*it).lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) if( (*it).lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)
text += "\n\n"+tr("You will need to create a non anonymous identity in order to join this chat lobby.") ; text += "\n\n"+tr("You will need to create a non anonymous identity in order to join this chat lobby.") ;
else else
text += "\n\n"+tr("You will need to create an identity in order to join chat lobbies.") ; text += "\n\n"+tr("You will need to create an identity in order to join chat lobbies.") ;
}
ui.lobbyInfoLabel->setText(text); ui.lobbyInfoLabel->setText(text);
return ; return ;

View file

@ -82,6 +82,13 @@ IdDialog::IdDialog(QWidget *parent) :
mIdQueue = NULL; mIdQueue = NULL;
allItem = new QTreeWidgetItem();
allItem->setText(0, tr("All"));
contactsItem = new QTreeWidgetItem();
contactsItem->setText(0, tr("Contacts"));
/* Setup UI helper */ /* Setup UI helper */
mStateHelper = new UIStateHelper(this); mStateHelper = new UIStateHelper(this);
// mStateHelper->addWidget(IDDIALOG_IDLIST, ui->idTreeWidget); // mStateHelper->addWidget(IDDIALOG_IDLIST, ui->idTreeWidget);
@ -123,7 +130,6 @@ IdDialog::IdDialog(QWidget *parent) :
/* Connect signals */ /* Connect signals */
connect(ui->toolButton_NewId, SIGNAL(clicked()), this, SLOT(addIdentity())); connect(ui->toolButton_NewId, SIGNAL(clicked()), this, SLOT(addIdentity()));
connect(ui->todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
connect(ui->removeIdentity, SIGNAL(triggered()), this, SLOT(removeIdentity())); connect(ui->removeIdentity, SIGNAL(triggered()), this, SLOT(removeIdentity()));
connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity())); connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity()));
@ -162,8 +168,7 @@ IdDialog::IdDialog(QWidget *parent) :
QTreeWidgetItem *headerItem = ui->idTreeWidget->headerItem(); QTreeWidgetItem *headerItem = ui->idTreeWidget->headerItem();
QString headerText = headerItem->text(RSID_COL_NICKNAME); QString headerText = headerItem->text(RSID_COL_NICKNAME);
ui->filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText)); ui->filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText));
headerText = headerItem->text(RSID_COL_KEYID); ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RSID_COL_KEYID, tr("Search ID"));
ui->filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
/* Setup tree */ /* Setup tree */
ui->idTreeWidget->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder); ui->idTreeWidget->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
@ -171,6 +176,8 @@ IdDialog::IdDialog(QWidget *parent) :
ui->idTreeWidget->enableColumnCustomize(true); ui->idTreeWidget->enableColumnCustomize(true);
ui->idTreeWidget->setColumnCustomizable(RSID_COL_NICKNAME, false); ui->idTreeWidget->setColumnCustomizable(RSID_COL_NICKNAME, false);
ui->idTreeWidget->setColumnHidden(RSID_COL_IDTYPE, true); ui->idTreeWidget->setColumnHidden(RSID_COL_IDTYPE, true);
ui->idTreeWidget->setColumnHidden(RSID_COL_KEYID, true);
/* Set initial column width */ /* Set initial column width */
int fontWidth = QFontMetricsF(ui->idTreeWidget->font()).width("W"); int fontWidth = QFontMetricsF(ui->idTreeWidget->font()).width("W");
ui->idTreeWidget->setColumnWidth(RSID_COL_NICKNAME, 14 * fontWidth); ui->idTreeWidget->setColumnWidth(RSID_COL_NICKNAME, 14 * fontWidth);
@ -185,12 +192,6 @@ IdDialog::IdDialog(QWidget *parent) :
mStateHelper->setActive(IDDIALOG_IDDETAILS, false); mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
mStateHelper->setActive(IDDIALOG_REPLIST, false); mStateHelper->setActive(IDDIALOG_REPLIST, false);
// Hiding RepList until that part is finished.
//ui->treeWidget_RepList->setVisible(false);
#ifndef UNFINISHED
ui->todoPushButton->hide() ;
#endif
QString hlp_str = tr( QString hlp_str = tr(
" <h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Identities</h1> \ " <h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Identities</h1> \
@ -214,9 +215,6 @@ IdDialog::IdDialog(QWidget *parent) :
// load settings // load settings
processSettings(true); processSettings(true);
// hide reputation sice it's currently unused
//ui->reputationGroupBox->hide();
//ui->tweakGroupBox->hide();
} }
IdDialog::~IdDialog() IdDialog::~IdDialog()
@ -228,14 +226,6 @@ IdDialog::~IdDialog()
delete(mIdQueue); delete(mIdQueue);
} }
void IdDialog::todo()
{
QMessageBox::information(this, "Todo",
"<b>Open points:</b><ul>"
"<li>Reputation"
"</ul>");
}
void IdDialog::processSettings(bool load) void IdDialog::processSettings(bool load)
{ {
Settings->beginGroup("IdDialog"); Settings->beginGroup("IdDialog");
@ -452,6 +442,7 @@ void IdDialog::insertIdList(uint32_t token)
RsGxsIdGroup data; RsGxsIdGroup data;
std::vector<RsGxsIdGroup> datavector; std::vector<RsGxsIdGroup> datavector;
std::vector<RsGxsIdGroup>::iterator vit; std::vector<RsGxsIdGroup>::iterator vit;
if (!rsIdentity->getGroupData(token, datavector)) if (!rsIdentity->getGroupData(token, datavector))
{ {
#ifdef ID_DEBUG #ifdef ID_DEBUG
@ -465,52 +456,68 @@ void IdDialog::insertIdList(uint32_t token)
return; return;
} }
// turn that vector into a std::set, to avoid a linear search
std::map<RsGxsGroupId,RsGxsIdGroup> ids_set ;
for(uint32_t i=0;i<datavector.size();++i)
ids_set[datavector[i].mMeta.mGroupId] = datavector[i] ;
mStateHelper->setActive(IDDIALOG_IDLIST, true); mStateHelper->setActive(IDDIALOG_IDLIST, true);
RsPgpId ownPgpId = rsPeers->getGPGOwnId(); RsPgpId ownPgpId = rsPeers->getGPGOwnId();
/* Update existing and remove not existing items */ // Update existing and remove not existing items
// Also remove items that do not have the correct parent
QTreeWidgetItemIterator itemIterator(ui->idTreeWidget); QTreeWidgetItemIterator itemIterator(ui->idTreeWidget);
QTreeWidgetItem *item = NULL; QTreeWidgetItem *item = NULL;
while ((item = *itemIterator) != NULL) {
++itemIterator;
for (vit = datavector.begin(); vit != datavector.end(); ++vit) while ((item = *itemIterator) != NULL)
{ {
if (vit->mMeta.mGroupId == RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString())) ++itemIterator;
{ std::map<RsGxsGroupId,RsGxsIdGroup>::iterator it = ids_set.find(RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString())) ;
break;
} if(it == ids_set.end())
}
if (vit == datavector.end())
{ {
if(item != allItem && item != contactsItem)
delete(item); delete(item);
} else {
if (!fillIdListItem(*vit, item, ownPgpId, accept)) continue ;
}
QTreeWidgetItem *parent_item = item->parent() ;
if( (parent_item == allItem && it->second.mIsAContact) || (parent_item == contactsItem && !it->second.mIsAContact))
{ {
delete item ; // do not remove from the list, so that it is added again in the correct place.
continue ;
}
if (!fillIdListItem(it->second, item, ownPgpId, accept))
delete(item); delete(item);
}
datavector.erase(vit); ids_set.erase(it); // erase, so it is not considered to be a new item
}
} }
/* Insert new items */ /* Insert new items */
for (vit = datavector.begin(); vit != datavector.end(); ++vit) for (std::map<RsGxsGroupId,RsGxsIdGroup>::const_iterator vit = ids_set.begin(); vit != ids_set.end(); ++vit)
{ {
data = (*vit); data = vit->second ;
item = NULL; item = NULL;
if (fillIdListItem(*vit, item, ownPgpId, accept))
{
ui->idTreeWidget->addTopLevelItem(item);
}
}
/* count items */ ui->idTreeWidget->insertTopLevelItem(0, contactsItem );
ui->label_count->setText( "(" + QString::number(ui->idTreeWidget->topLevelItemCount()) + ")" ); ui->idTreeWidget->insertTopLevelItem(0, allItem);
if (fillIdListItem(vit->second, item, ownPgpId, accept))
if(vit->second.mIsAContact)
contactsItem->addChild(item);
else
allItem->addChild(item);
}
filterIds(); filterIds();
updateSelection(); updateSelection();
} }
@ -916,7 +923,8 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
rsIdentity->getOwnIds(own_identities) ; rsIdentity->getOwnIds(own_identities) ;
QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
if (item) {
if(item != allItem && item != contactsItem) {
uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ; uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
if(!(item_flags & RSID_FILTER_OWNED_BY_YOU)) if(!(item_flags & RSID_FILTER_OWNED_BY_YOU))
@ -951,6 +959,28 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg())); contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg()));
contextMnu.addSeparator();
RsIdentityDetails details;
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
rsIdentity->getIdDetails(RsGxsId(keyId), details);
QAction *addContact = contextMnu.addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts()));
QAction *removeContact = contextMnu.addAction(QIcon(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts()));
if(details.mFlags & RS_IDENTITY_FLAGS_IS_A_CONTACT)
{
addContact->setVisible(false);
removeContact->setVisible(true);
}
else
{
addContact->setVisible(true);
removeContact->setVisible(false);
}
contextMnu.addSeparator(); contextMnu.addSeparator();
RsReputations::ReputationInfo info ; RsReputations::ReputationInfo info ;
@ -974,12 +1004,13 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
} }
} }
}
contextMnu.addSeparator(); contextMnu.addSeparator();
contextMnu.addAction(ui->editIdentity); contextMnu.addAction(ui->editIdentity);
contextMnu.addAction(ui->removeIdentity); contextMnu.addAction(ui->removeIdentity);
}
contextMnu.addSeparator(); contextMnu.addSeparator();
@ -1064,3 +1095,34 @@ void IdDialog::unbanPerson()
requestIdDetails(); requestIdDetails();
requestIdList(); requestIdList();
} }
void IdDialog::addtoContacts()
{
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
if (!item)
{
return;
}
std::string Id = item->text(RSID_COL_KEYID).toStdString();
rsIdentity->setAsRegularContact(RsGxsId(Id),true);
requestIdList();
}
void IdDialog::removefromContacts()
{
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
if (!item)
{
return;
}
std::string Id = item->text(RSID_COL_KEYID).toStdString();
rsIdentity->setAsRegularContact(RsGxsId(Id),false);
requestIdList();
}

View file

@ -69,12 +69,14 @@ private slots:
void updateSelection(); void updateSelection();
void todo();
void modifyReputation(); void modifyReputation();
/** Create the context popup menu and it's submenus */ /** Create the context popup menu and it's submenus */
void IdListCustomPopupMenu( QPoint point ); void IdListCustomPopupMenu( QPoint point );
void addtoContacts();
void removefromContacts();
void banPerson(); void banPerson();
void unbanPerson(); void unbanPerson();
@ -100,6 +102,9 @@ private:
TokenQueue *mIdQueue; TokenQueue *mIdQueue;
UIStateHelper *mStateHelper; UIStateHelper *mStateHelper;
QTreeWidgetItem *contactsItem;
QTreeWidgetItem *allItem;
RsGxsGroupId mId; RsGxsGroupId mId;
/* UI - Designer */ /* UI - Designer */

View file

@ -111,13 +111,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="todoPushButton">
<property name="text">
<string>Todo</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QToolButton" name="helpButton"> <widget class="QToolButton" name="helpButton">
<property name="focusPolicy"> <property name="focusPolicy">
@ -221,6 +214,18 @@
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="indentation">
<number>24</number>
</property>
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -229,7 +234,7 @@
</attribute> </attribute>
<column> <column>
<property name="text"> <property name="text">
<string>Identity name</string> <string>Persons</string>
</property> </property>
</column> </column>
<column> <column>
@ -713,7 +718,6 @@ p, li { white-space: pre-wrap; }
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>todoPushButton</tabstop>
<tabstop>idTreeWidget</tabstop> <tabstop>idTreeWidget</tabstop>
<tabstop>lineEdit_Nickname</tabstop> <tabstop>lineEdit_Nickname</tabstop>
<tabstop>lineEdit_KeyId</tabstop> <tabstop>lineEdit_KeyId</tabstop>

View file

@ -1335,7 +1335,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details)) if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details))
{ {
if(gxs_details.mIsOwnId) if(gxs_details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID)
{ {
QMessageBox::warning(NULL,QString("Cannot send message to yourself"),QString("This identity is owned by you. You wouldn't want to send yourself a message right?")); QMessageBox::warning(NULL,QString("Cannot send message to yourself"),QString("This identity is owned by you. You wouldn't want to send yourself a message right?"));
break ; break ;

View file

@ -110,7 +110,7 @@ void CreateLobbyDialog::checkTextFields()
rsIdentity->getIdDetails(id,idd) ; rsIdentity->getIdDetails(id,idd) ;
if( (!idd.mPgpKnown) && ui->pgp_signed_CB->isChecked()) if( (!(idd.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)) && ui->pgp_signed_CB->isChecked())
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false) ; ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false) ;
} }

View file

@ -285,6 +285,10 @@ void FriendSelectionWidget::secured_fillList()
if (mShowTypes & SHOW_GXS) if (mShowTypes & SHOW_GXS)
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true); selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
std::set<RsGxsId> gxsIdsSelected2;
if (mShowTypes & SHOW_CONTACTS)
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected2,true);
// remove old items // remove old items
ui->friendList->clear(); ui->friendList->clear();
@ -525,6 +529,7 @@ void FriendSelectionWidget::secured_fillList()
// iterate through gpg ids // iterate through gpg ids
for (std::vector<RsGxsGroupId>::const_iterator gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); ++gxsIt) for (std::vector<RsGxsGroupId>::const_iterator gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); ++gxsIt)
{ {
// we fill the not assigned gpg ids // we fill the not assigned gpg ids
if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end()) if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end())
continue; continue;
@ -570,6 +575,61 @@ void FriendSelectionWidget::secured_fillList()
setSelected(mListModus, gxsItem, true); setSelected(mListModus, gxsItem, true);
} }
} }
if(mShowTypes & SHOW_CONTACTS)
{
// iterate through gpg ids
for (std::vector<RsGxsGroupId>::const_iterator gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); ++gxsIt)
{
// we fill the not assigned gpg ids
if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end())
continue;
// add equal too, its no problem
filledIds.push_back((*gxsIt).toStdString());
RsIdentityDetails detail;
if (!rsIdentity->getIdDetails(RsGxsId(*gxsIt), detail))
continue; /* BAD */
QList<QIcon> icons ;
GxsIdDetails::getIcons(detail,icons,GxsIdDetails::ICON_TYPE_AVATAR) ;
QIcon identicon = icons.front() ;
if(detail.mFlags & RS_IDENTITY_FLAGS_IS_A_CONTACT)
{
// make a widget per friend
gxsItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GXS);
QString name = QString::fromUtf8(detail.mNickname.c_str());
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
//gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
gxsItem->setIcon(COLUMN_NAME, identicon);
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
gxsItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1);
gxsItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0);
//TODO: online state for gxs items
gxsItem->setData(COLUMN_NAME, ROLE_SORT_STATE, 1);
gxsItem->setData(COLUMN_NAME, ROLE_SORT_NAME, name);
if (mListModus == MODUS_CHECK)
gxsItem->setCheckState(0, Qt::Unchecked);
ui->friendList->addTopLevelItem(gxsItem);
gxsItem->setExpanded(true);
emit itemAdded(IDTYPE_GXS, QString::fromStdString(detail.mId.toStdString()), gxsItem);
if (std::find(gxsIdsSelected.begin(), gxsIdsSelected.end(), detail.mId) != gxsIdsSelected.end())
setSelected(mListModus, gxsItem, true);
}
}
}
if (groupIt != groupInfoList.end()) { if (groupIt != groupInfoList.end()) {
++groupIt; ++groupIt;
} else { } else {

View file

@ -65,7 +65,8 @@ public:
SHOW_GPG = 2, SHOW_GPG = 2,
SHOW_SSL = 4, SHOW_SSL = 4,
SHOW_NON_FRIEND_GPG = 8, SHOW_NON_FRIEND_GPG = 8,
SHOW_GXS =16 SHOW_GXS =16,
SHOW_CONTACTS =32
}; };
Q_DECLARE_FLAGS(ShowTypes, ShowType) Q_DECLARE_FLAGS(ShowTypes, ShowType)

View file

@ -160,9 +160,9 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
chooser->setItemData(index, (type == GXS_ID_DETAILS_TYPE_DONE) ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID, ROLE_TYPE); chooser->setItemData(index, (type == GXS_ID_DETAILS_TYPE_DONE) ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID, ROLE_TYPE);
chooser->setItemIcon(index, icons.empty() ? QIcon() : icons[0]); chooser->setItemIcon(index, icons.empty() ? QIcon() : icons[0]);
std::cerr << "ID=" << details.mId << ", chooser->flags()=" << chooser->flags() << ", pgpLinked=" << details.mPgpLinked ; std::cerr << "ID=" << details.mId << ", chooser->flags()=" << chooser->flags() << ", flags=" << details.mFlags ;
if((chooser->flags() & IDCHOOSER_NON_ANONYMOUS) && !(details.mPgpLinked)) if((chooser->flags() & IDCHOOSER_NON_ANONYMOUS) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
{ {
std::cerr << " - disabling ID - entry = " << index << std::endl; std::cerr << " - disabling ID - entry = " << index << std::endl;
chooser->setEntryEnabled(index,false) ; chooser->setEntryEnabled(index,false) ;

View file

@ -912,11 +912,11 @@ QString nickname ;
QApplication::translate("GxsIdDetails", "Identity&nbsp;Id"), QApplication::translate("GxsIdDetails", "Identity&nbsp;Id"),
QString::fromStdString(details.mId.toStdString())); QString::fromStdString(details.mId.toStdString()));
if (details.mPgpLinked) if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)
{ {
comment += QString("<br/>%1:%2 ").arg(QApplication::translate("GxsIdDetails", "Authentication"), QApplication::translate("GxsIdDetails", "Signed&nbsp;by")); comment += QString("<br/>%1:%2 ").arg(QApplication::translate("GxsIdDetails", "Authentication"), QApplication::translate("GxsIdDetails", "Signed&nbsp;by"));
if (details.mPgpKnown) if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)
{ {
/* look up real name */ /* look up real name */
std::string authorName = rsPeers->getGPGName(details.mPgpId); std::string authorName = rsPeers->getGPGName(details.mPgpId);
@ -962,9 +962,9 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icon
{ {
// ICON Logic. // ICON Logic.
QIcon baseIcon; QIcon baseIcon;
if (details.mPgpLinked) if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)
{ {
if (details.mPgpKnown) if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)
baseIcon = QIcon(IMAGE_PGPKNOWN); baseIcon = QIcon(IMAGE_PGPKNOWN);
else else
baseIcon = QIcon(IMAGE_PGPUNKNOWN); baseIcon = QIcon(IMAGE_PGPUNKNOWN);

View file

@ -266,10 +266,11 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
ui.respond_to_CB->setFlags(IDCHOOSER_ID_REQUIRED) ; ui.respond_to_CB->setFlags(IDCHOOSER_ID_REQUIRED) ;
/* Add filter types */ /* Add filter types */
ui.filterComboBox->addItem(tr("All")); ui.filterComboBox->addItem(tr("All addresses (mixed)"));
ui.filterComboBox->addItem(tr("Friend Nodes")); ui.filterComboBox->addItem(tr("Friend Nodes"));
ui.filterComboBox->addItem(tr("Distant peer identities")); ui.filterComboBox->addItem(tr("All people"));
ui.filterComboBox->setCurrentIndex(0); ui.filterComboBox->addItem(tr("My contacts"));
ui.filterComboBox->setCurrentIndex(3);
connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(changeFormatType(int))); connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(changeFormatType(int)));
connect(ui.comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &))); connect(ui.comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &)));
@ -2569,6 +2570,11 @@ void MessageComposer::filterComboBoxChanged(int i)
case 2: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GXS) ; case 2: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GXS) ;
break ; break ;
case 3: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_CONTACTS) ;
break ;
default: ; default: ;
} }

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>925</width> <width>1679</width>
<height>747</height> <height>951</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -56,14 +56,14 @@
<set>QDockWidget::DockWidgetClosable</set> <set>QDockWidget::DockWidgetClosable</set>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Contacts</string> <string>Address list:</string>
</property> </property>
<widget class="QWidget" name="dockWidgetContents"> <widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin"> <item>
<number>1</number> <widget class="QComboBox" name="filterComboBox"/>
</property> </item>
<item row="1" column="0"> <item>
<widget class="FriendSelectionWidget" name="friendSelectionWidget" native="true"> <widget class="FriendSelectionWidget" name="friendSelectionWidget" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
@ -100,25 +100,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="addToButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&gt;&gt; To</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
@ -130,7 +113,20 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&gt;&gt; Cc</string> <string>Cc</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addToButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>To</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -143,7 +139,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&gt;&gt; Bcc</string> <string>Bcc</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -160,7 +156,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&gt;&gt; Recommend</string> <string>Recommend this friend</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -168,23 +164,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Show:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="filterComboBox"/>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@ -1105,8 +1084,8 @@ border-image: url(:/images/closepressed.png)
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>925</width> <width>1679</width>
<height>21</height> <height>37</height>
</rect> </rect>
</property> </property>
</widget> </widget>
@ -1238,8 +1217,6 @@ border-image: url(:/images/closepressed.png)
<tabstop>titleEdit</tabstop> <tabstop>titleEdit</tabstop>
<tabstop>msgText</tabstop> <tabstop>msgText</tabstop>
<tabstop>msgFileList</tabstop> <tabstop>msgFileList</tabstop>
<tabstop>addToButton</tabstop>
<tabstop>addCcButton</tabstop>
<tabstop>addBccButton</tabstop> <tabstop>addBccButton</tabstop>
<tabstop>addRecommendButton</tabstop> <tabstop>addRecommendButton</tabstop>
<tabstop>comboSize</tabstop> <tabstop>comboSize</tabstop>

View file

@ -100,6 +100,8 @@ ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
connect(ui.distantChatcomboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantChatComboBoxChanged(int)));
#if QT_VERSION < 0x040600 #if QT_VERSION < 0x040600
ui.minimumContrastLabel->hide(); ui.minimumContrastLabel->hide();
ui.minimumContrast->hide(); ui.minimumContrast->hide();
@ -120,6 +122,8 @@ ChatPage::save(QString &/*errmsg*/)
Settings->setValue("EnableItalics", ui.checkBox_enableItalics->isChecked()); Settings->setValue("EnableItalics", ui.checkBox_enableItalics->isChecked());
Settings->setValue("MinimumContrast", ui.minimumContrast->value()); Settings->setValue("MinimumContrast", ui.minimumContrast->value());
Settings->endGroup(); Settings->endGroup();
// state of distant Chat combobox
Settings->setValue("DistantChat", ui.distantChatcomboBox->currentIndex());
Settings->setChatScreenFont(fontTempChat.toString()); Settings->setChatScreenFont(fontTempChat.toString());
NotifyQt::getInstance()->notifyChatFontChanged(); NotifyQt::getInstance()->notifyChatFontChanged();
@ -226,6 +230,10 @@ ChatPage::load()
ui.minimumContrast->setValue(Settings->value("MinimumContrast", 4.5).toDouble()); ui.minimumContrast->setValue(Settings->value("MinimumContrast", 4.5).toDouble());
Settings->endGroup(); Settings->endGroup();
// state of distant Chat combobox
int index = Settings->value("DistantChat", 0).toInt();
ui.distantChatcomboBox->setCurrentIndex(index);
fontTempChat.fromString(Settings->getChatScreenFont()); fontTempChat.fromString(Settings->getChatScreenFont());
ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn()); ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn());
@ -493,3 +501,22 @@ void ChatPage::on_btSearch_FoundColor_clicked()
ui.btSearch_FoundColor->setIcon(pix); ui.btSearch_FoundColor->setIcon(pix);
} }
} }
void ChatPage::distantChatComboBoxChanged(int i)
{
switch(i)
{
case 0: ;
break ;
case 1: ;
break ;
case 2: ;
break ;
default: ;
}
}

View file

@ -56,6 +56,8 @@ class ChatPage : public ConfigPage
void on_cbSearch_WithoutLimit_toggled(bool); void on_cbSearch_WithoutLimit_toggled(bool);
void on_btSearch_FoundColor_clicked(); void on_btSearch_FoundColor_clicked();
void distantChatComboBoxChanged(int);
private: private:
void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser); void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser);

View file

@ -20,8 +20,43 @@
<attribute name="title"> <attribute name="title">
<string>General</string> <string>General</string>
</attribute> </attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Distant Chat</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="2">
<widget class="QComboBox" name="distantChatcomboBox">
<item> <item>
<property name="text">
<string>Everyone</string>
</property>
</item>
<item>
<property name="text">
<string>Contacts</string>
</property>
</item>
<item>
<property name="text">
<string>Nobody</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="distantchatlabel">
<property name="text">
<string>Accept encrypted distant chat from</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
@ -240,7 +275,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item> <item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">

View file

@ -39,7 +39,7 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
connect (ui.editpushButton, SIGNAL(clicked(bool)), this, SLOT (editTag())); connect (ui.editpushButton, SIGNAL(clicked(bool)), this, SLOT (editTag()));
connect (ui.deletepushButton, SIGNAL(clicked(bool)), this, SLOT (deleteTag())); connect (ui.deletepushButton, SIGNAL(clicked(bool)), this, SLOT (deleteTag()));
connect (ui.defaultTagButton, SIGNAL(clicked(bool)), this, SLOT (defaultTag())); connect (ui.defaultTagButton, SIGNAL(clicked(bool)), this, SLOT (defaultTag()));
connect (ui.encryptedMsgs_CB, SIGNAL(toggled(bool)), this, SLOT (toggleEnableEncryptedDistantMsgs(bool))); //connect (ui.encryptedMsgs_CB, SIGNAL(toggled(bool)), this, SLOT (toggleEnableEncryptedDistantMsgs(bool)));
connect (ui.tags_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentRowChangedTag(int))); connect (ui.tags_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentRowChangedTag(int)));
@ -49,6 +49,9 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB); ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB);
ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW); ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW);
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantMsgsComboBoxChanged(int)));
//ui.encryptedMsgs_CB->setEnabled(false) ; //ui.encryptedMsgs_CB->setEnabled(false) ;
} }
@ -57,9 +60,23 @@ MessagePage::~MessagePage()
delete(m_pTags); delete(m_pTags);
} }
void MessagePage::toggleEnableEncryptedDistantMsgs(bool b) void MessagePage::distantMsgsComboBoxChanged(int i)
{ {
rsMail->enableDistantMessaging(b) ; switch(i)
{
case 0: rsMail->setDistantMessagingPermissionFlags(RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_EVERYBODY |RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST) ;
break ;
case 1: rsMail->setDistantMessagingPermissionFlags(RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST) ;
break ;
case 2: rsMail->setDistantMessagingPermissionFlags(RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_NONE) ;
break ;
default: ;
}
} }
/** Saves the changes on this page */ /** Saves the changes on this page */
@ -70,6 +87,9 @@ MessagePage::save(QString &/*errmsg*/)
Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked());
Settings->setMsgOpen((RshareSettings::enumMsgOpen) ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt()); Settings->setMsgOpen((RshareSettings::enumMsgOpen) ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt());
// state of distant Message combobox
Settings->setValue("DistantMessages", ui.comboBox->currentIndex());
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag; std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) { for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
// check for changed tags // check for changed tags
@ -99,7 +119,17 @@ MessagePage::load()
ui.loadEmbeddedImages->setChecked(Settings->getMsgLoadEmbeddedImages()); ui.loadEmbeddedImages->setChecked(Settings->getMsgLoadEmbeddedImages());
ui.openComboBox->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen())); ui.openComboBox->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen()));
ui.encryptedMsgs_CB->setChecked(rsMail->distantMessagingEnabled()) ; // state of filter combobox
uint32_t flags = rsMail->getDistantMessagingPermissionFlags() ;
if(flags == (RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST | RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_EVERYBODY))
ui.comboBox->setCurrentIndex(2);
else if(flags == RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST)
ui.comboBox->setCurrentIndex(1);
else
ui.comboBox->setCurrentIndex(0);
// fill items // fill items
rsMail->getMessageTagTypes(*m_pTags); rsMail->getMessageTagTypes(*m_pTags);
fillTags(); fillTags();

View file

@ -54,7 +54,8 @@ private slots:
void defaultTag(); void defaultTag();
void currentRowChangedTag(int row); void currentRowChangedTag(int row);
void toggleEnableEncryptedDistantMsgs(bool) ; void distantMsgsComboBoxChanged(int);
private: private:
void fillTags(); void fillTags();

View file

@ -59,21 +59,30 @@
<property name="title"> <property name="title">
<string>Distant messages:</string> <string>Distant messages:</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<widget class="QComboBox" name="comboBox">
<item> <item>
<widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;The link below allows people in the network to send encrypted messages to you, using tunnels. To do that, they need your public PGP key, which they will get using the Retroshare discovery system. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>Everyone</string>
</property> </property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="encryptedMsgs_CB">
<property name="text"> <property name="text">
<string>Accept encrypted distant messages from everyone</string> <string>Contacts</string>
</property>
</item>
<item>
<property name="text">
<string>Nobody</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Accept encrypted distant messages from</string>
</property> </property>
</widget> </widget>
</item> </item>