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)
<< makeKeyValueReference("gxs_id", id)
<< makeKeyValueReference("is_own", vit->mIsOwnId)
<< makeKeyValueReference("name", vit->mNickname)
<< makeKeyValueReference("pgp_linked", vit->mPgpLinked)
<< makeKeyValueReference("pgp_known", vit->mPgpKnown);
<< makeKeyValueReference("flags", vit->mFlags)
<< makeKeyValueReference("name", vit->mNickname);
return;
}
}

View file

@ -177,7 +177,7 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
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;
@ -688,7 +688,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
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;
@ -1727,7 +1727,7 @@ bool DistributedChatService::setIdentityForChatLobby(const ChatLobbyId& lobby_id
// 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()) ;
}

View file

@ -33,6 +33,7 @@
#include "retroshare/rsgxsflags.h"
#include "retroshare/rsgxscircles.h"
#include "retroshare/rsgrouter.h"
#include "retroshare/rsidentity.h"
#include "retroshare/rspeers.h"
#include "rsgixs.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
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)
{

View file

@ -65,6 +65,11 @@ extern RsIdentity *rsIdentity;
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
{
public:
@ -115,8 +120,9 @@ class RsGxsIdGroup
time_t mLastUsageTS ;
// Not Serialised - for GUI's benefit.
bool mPgpKnown;
RsPgpId mPgpId;
bool mPgpKnown;
bool mIsAContact; // change that into flags one day
RsPgpId mPgpId;
GxsReputation mReputation;
};
@ -154,22 +160,20 @@ class RsRecognTagDetails
bool is_pending;
};
class RsIdentityDetails
{
public:
RsIdentityDetails()
:mIsOwnId(false), mPgpLinked(false), mPgpKnown(false), mLastUsageTS(0) { return; }
: mFlags(0), mLastUsageTS(0) { return; }
RsGxsId mId;
// identity details.
std::string mNickname;
bool mIsOwnId;
uint32_t mFlags ;
// PGP Stuff.
bool mPgpLinked;
bool mPgpKnown;
RsPgpId mPgpId;
// 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,
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 Service Data */
/* 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_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
{
RsGxsId to_id ;
@ -425,8 +431,8 @@ virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags) = 0;
/* Private distant messages */
/****************************************/
virtual void enableDistantMessaging(bool b) = 0;
virtual bool distantMessagingEnabled() = 0;
virtual uint32_t getDistantMessagingPermissionFlags()=0 ;
virtual void setDistantMessagingPermissionFlags(uint32_t flags)=0 ;
/****************************************/
/* 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)
{
@ -298,15 +308,6 @@ bool p3Msgs::MessageSend(MessageInfo &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)
{
return mMsgSrv->SystemMessage(title, message, systemFlag);

View file

@ -80,8 +80,8 @@ class p3Msgs: public RsMsgs
virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags);
virtual void enableDistantMessaging(bool b) ;
virtual bool distantMessagingEnabled() ;
virtual uint32_t getDistantMessagingPermissionFlags() ;
virtual void setDistantMessagingPermissionFlags(uint32_t flags) ;
/*!
* 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
s += 4 ; // number of items
s += mTimeStamps.size() * (RsGxsId::SIZE_IN_BYTES + 8) ;
s += 4 ; // number of contacts
s += mContacts.size() * RsGxsId::SIZE_IN_BYTES ;
return s;
}
@ -176,6 +178,11 @@ bool RsGxsIdLocalInfoItem::serialise(void *data, uint32_t& size)
ok &= it->first.serialise(data,tlvsize,offset) ;
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)
{
#ifdef GXSID_DEBUG
@ -386,6 +393,19 @@ RsGxsIdLocalInfoItem *RsGxsIdSerialiser::deserialise_GxsIdLocalInfoItem(void *da
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)
{
#ifdef GXSID_DEBUG

View file

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

View file

@ -932,7 +932,7 @@ bool p3GxsCircles::cache_load_for_token(uint32_t token)
RsIdentityDetails 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
std::cerr << "p3GxsCircles::cache_load_for_token() Is Known -> AllowedPeer: " << *pit;
@ -1115,7 +1115,7 @@ bool p3GxsCircles::cache_reloadids(const RsGxsCircleId &circleId)
RsIdentityDetails 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);

View file

@ -248,8 +248,8 @@ void p3GxsReputation::updateIdentityFlags()
}
it->second.mIdentityFlags = 0 ;
if(details.mPgpLinked) 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_LINKED) it->second.mIdentityFlags |= REPUTATION_IDENTITY_FLAG_PGP_LINKED ;
if(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN ) it->second.mIdentityFlags |= REPUTATION_IDENTITY_FLAG_PGP_KNOWN ;
#ifdef DEBUG_REPUTATION
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;
}
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()
{
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)
if( (lii = dynamic_cast<RsGxsIdLocalInfoItem*>(*it)) != NULL)
{
for(std::map<RsGxsId,time_t>::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2)
mKeysTS.insert(*it2) ;
mContacts = lii->mContacts ;
}
return true ;
}
@ -265,6 +289,7 @@ bool p3IdService::saveList(bool& cleanup,std::list<RsItem*>& items)
cleanup = true ;
RsGxsIdLocalInfoItem *item = new RsGxsIdLocalInfoItem ;
item->mTimeStamps = mKeysTS ;
item->mContacts = mContacts ;
items.push_back(item) ;
return true ;
@ -411,6 +436,9 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
details = data.details;
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 !!!
if(details.mNickname.length() > RSID_MAXIMUM_NICKNAME_SIZE*4)
details.mNickname = "[too long a name]" ;
@ -426,6 +454,9 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
details = data.details;
details.mLastUsageTS = locked_getLastUsageTS(id) ;
if(mContacts.find(id) != mContacts.end())
details.mFlags |= RS_IDENTITY_FLAGS_IS_A_CONTACT ;
rsReputations->getReputationInfo(id,details.mReputation) ;
return true;
@ -1029,33 +1060,33 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
if (item)
{
#ifdef DEBUG_IDS
std::cerr << "p3IdService::getGroupData() Item is:";
std::cerr << std::endl;
item->print(std::cerr);
std::cerr << std::endl;
std::cerr << "p3IdService::getGroupData() Item is:";
std::cerr << std::endl;
item->print(std::cerr);
std::cerr << std::endl;
#endif // DEBUG_IDS
RsGxsIdGroup group ;
item->toGxsIdGroup(group,false) ;
RsGxsIdGroup group ;
item->toGxsIdGroup(group,false) ;
{
RS_STACK_MUTEX(mIdMtx) ;
group.mLastUsageTS = locked_getLastUsageTS(RsGxsId(group.mMeta.mGroupId)) ;
}
{
RS_STACK_MUTEX(mIdMtx) ;
group.mLastUsageTS = locked_getLastUsageTS(RsGxsId(group.mMeta.mGroupId)) ;
}
// Decode information from serviceString.
SSGxsIdGroup ssdata;
if (ssdata.load(group.mMeta.mServiceString))
{
group.mPgpKnown = ssdata.pgp.idKnown;
group.mPgpId = ssdata.pgp.pgpId;
group.mReputation = ssdata.score.rep;
// Decode information from serviceString.
SSGxsIdGroup ssdata;
if (ssdata.load(group.mMeta.mServiceString))
{
group.mPgpKnown = ssdata.pgp.idKnown;
group.mPgpId = ssdata.pgp.pgpId;
group.mReputation = ssdata.score.rep;
#ifdef DEBUG_IDS
std::cerr << "p3IdService::getGroupData() Success decoding ServiceString";
std::cerr << std::endl;
std::cerr << "\t mGpgKnown: " << group.mPgpKnown;
std::cerr << std::endl;
std::cerr << "\t mGpgId: " << group.mPgpId;
std::cerr << std::endl;
std::cerr << "p3IdService::getGroupData() Success decoding ServiceString";
std::cerr << std::endl;
std::cerr << "\t mGpgKnown: " << group.mPgpKnown;
std::cerr << std::endl;
std::cerr << "\t mGpgId: " << group.mPgpId;
std::cerr << std::endl;
#endif // DEBUG_IDS
}
else
@ -1063,13 +1094,15 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
group.mPgpKnown = false;
group.mPgpId.clear();
std::cerr << "p3IdService::getGroupData() Failed to decode ServiceString \""
<< group.mMeta.mServiceString << "\"" ;
std::cerr << "p3IdService::getGroupData() Failed to decode ServiceString \""
<< group.mMeta.mServiceString << "\"" ;
std::cerr << std::endl;
}
group.mIsAContact = (mContacts.find(RsGxsId(group.mMeta.mGroupId)) != mContacts.end());
groups.push_back(group);
delete(item);
delete(item);
}
else
{
@ -1600,8 +1633,10 @@ RsGxsIdCache::RsGxsIdCache(const RsGxsIdGroupItem *item, const RsTlvSecurityKey
std::cerr << std::endl;
#endif // DEBUG_IDS
details.mIsOwnId = (item->meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
details.mPgpLinked = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
details.mFlags = 0 ;
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 */
updateServiceString(item->meta.mServiceString);
@ -1610,21 +1645,19 @@ RsGxsIdCache::RsGxsIdCache(const RsGxsIdGroupItem *item, const RsTlvSecurityKey
void RsGxsIdCache::updateServiceString(std::string serviceString)
{
details.mRecognTags.clear();
details.mFlags = 0 ;
SSGxsIdGroup ssdata;
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;
}
else
{
details.mPgpId.clear();
}
}
@ -1680,7 +1713,7 @@ void RsGxsIdCache::updateServiceString(std::string serviceString)
}
else
{
details.mPgpKnown = false;
details.mFlags &= ~RS_IDENTITY_FLAGS_PGP_KNOWN ;
details.mPgpId.clear();
//details.mReputation.updateIdScore(false, false);
//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,
uint16_t tag_class, uint16_t tag_type, std::string &tag);
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
/**************** RsGixs Implementation ***************/
virtual bool getOwnIds(std::list<RsGxsId> &ownIds);
@ -495,8 +497,11 @@ std::string genRandomId(int len = 20);
std::map<uint32_t, std::set<RsGxsGroupId> > mIdsPendingCache;
std::map<uint32_t, std::list<RsGxsGroupId> > mGroupNotPresent;
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
std::map<RsGxsId,time_t> mKeysTS ;
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
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;
/**************************

View file

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

View file

@ -235,7 +235,7 @@ static bool trimAnonIds(std::list<RsGxsId>& lst)
RsIdentityDetails idd ;
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) ;
removed= true ;
@ -269,7 +269,7 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
{
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());
bool removed = false ;
@ -725,7 +725,7 @@ void ChatLobbyWidget::subscribeChatLobbyAs()
return ;
RsGxsId gxs_id(action->data().toString().toStdString());
uint32_t error_code ;
//uint32_t error_code ;
if(rsMsgs->joinVisibleChatLobby(id,gxs_id))
ChatDialog::chatFriend(ChatId(id),true) ;
@ -795,7 +795,7 @@ void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
if(!rsIdentity->getIdDetails(gxs_id,idd))
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.")) ;
return ;
@ -844,11 +844,13 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
QString text = tr("You're not subscribed to this lobby; Double click-it to enter and chat.") ;
if(my_ids.empty())
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.") ;
else
text += "\n\n"+tr("You will need to create an identity in order to join chat lobbies.") ;
if(my_ids.empty())
{
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.") ;
else
text += "\n\n"+tr("You will need to create an identity in order to join chat lobbies.") ;
}
ui.lobbyInfoLabel->setText(text);
return ;

View file

@ -82,6 +82,13 @@ IdDialog::IdDialog(QWidget *parent) :
mIdQueue = NULL;
allItem = new QTreeWidgetItem();
allItem->setText(0, tr("All"));
contactsItem = new QTreeWidgetItem();
contactsItem->setText(0, tr("Contacts"));
/* Setup UI helper */
mStateHelper = new UIStateHelper(this);
// mStateHelper->addWidget(IDDIALOG_IDLIST, ui->idTreeWidget);
@ -123,7 +130,6 @@ IdDialog::IdDialog(QWidget *parent) :
/* Connect signals */
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->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity()));
@ -162,8 +168,7 @@ IdDialog::IdDialog(QWidget *parent) :
QTreeWidgetItem *headerItem = ui->idTreeWidget->headerItem();
QString headerText = headerItem->text(RSID_COL_NICKNAME);
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(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RSID_COL_KEYID, tr("Search ID"));
/* Setup tree */
ui->idTreeWidget->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
@ -171,6 +176,8 @@ IdDialog::IdDialog(QWidget *parent) :
ui->idTreeWidget->enableColumnCustomize(true);
ui->idTreeWidget->setColumnCustomizable(RSID_COL_NICKNAME, false);
ui->idTreeWidget->setColumnHidden(RSID_COL_IDTYPE, true);
ui->idTreeWidget->setColumnHidden(RSID_COL_KEYID, true);
/* Set initial column width */
int fontWidth = QFontMetricsF(ui->idTreeWidget->font()).width("W");
ui->idTreeWidget->setColumnWidth(RSID_COL_NICKNAME, 14 * fontWidth);
@ -185,12 +192,6 @@ IdDialog::IdDialog(QWidget *parent) :
mStateHelper->setActive(IDDIALOG_IDDETAILS, 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(
" <h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Identities</h1> \
@ -214,9 +215,6 @@ IdDialog::IdDialog(QWidget *parent) :
// load settings
processSettings(true);
// hide reputation sice it's currently unused
//ui->reputationGroupBox->hide();
//ui->tweakGroupBox->hide();
}
IdDialog::~IdDialog()
@ -228,14 +226,6 @@ IdDialog::~IdDialog()
delete(mIdQueue);
}
void IdDialog::todo()
{
QMessageBox::information(this, "Todo",
"<b>Open points:</b><ul>"
"<li>Reputation"
"</ul>");
}
void IdDialog::processSettings(bool load)
{
Settings->beginGroup("IdDialog");
@ -452,6 +442,7 @@ void IdDialog::insertIdList(uint32_t token)
RsGxsIdGroup data;
std::vector<RsGxsIdGroup> datavector;
std::vector<RsGxsIdGroup>::iterator vit;
if (!rsIdentity->getGroupData(token, datavector))
{
#ifdef ID_DEBUG
@ -465,52 +456,68 @@ void IdDialog::insertIdList(uint32_t token)
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);
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);
QTreeWidgetItem *item = NULL;
while ((item = *itemIterator) != NULL) {
++itemIterator;
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
while ((item = *itemIterator) != NULL)
{
++itemIterator;
std::map<RsGxsGroupId,RsGxsIdGroup>::iterator it = ids_set.find(RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString())) ;
if(it == ids_set.end())
{
if (vit->mMeta.mGroupId == RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString()))
{
break;
}
}
if (vit == datavector.end())
{
delete(item);
} else {
if (!fillIdListItem(*vit, item, ownPgpId, accept))
{
if(item != allItem && item != contactsItem)
delete(item);
}
datavector.erase(vit);
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);
ids_set.erase(it); // erase, so it is not considered to be a new item
}
/* 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;
if (fillIdListItem(*vit, item, ownPgpId, accept))
{
ui->idTreeWidget->addTopLevelItem(item);
}
ui->idTreeWidget->insertTopLevelItem(0, contactsItem );
ui->idTreeWidget->insertTopLevelItem(0, allItem);
if (fillIdListItem(vit->second, item, ownPgpId, accept))
if(vit->second.mIsAContact)
contactsItem->addChild(item);
else
allItem->addChild(item);
}
/* count items */
ui->label_count->setText( "(" + QString::number(ui->idTreeWidget->topLevelItemCount()) + ")" );
filterIds();
updateSelection();
}
@ -916,7 +923,8 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
rsIdentity->getOwnIds(own_identities) ;
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
if (item) {
if(item != allItem && item != contactsItem) {
uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
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.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();
RsReputations::ReputationInfo info ;
@ -974,12 +1004,13 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
}
}
contextMnu.addSeparator();
contextMnu.addAction(ui->editIdentity);
contextMnu.addAction(ui->removeIdentity);
}
contextMnu.addSeparator();
contextMnu.addAction(ui->editIdentity);
contextMnu.addAction(ui->removeIdentity);
contextMnu.addSeparator();
@ -1064,3 +1095,34 @@ void IdDialog::unbanPerson()
requestIdDetails();
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 todo();
void modifyReputation();
/** Create the context popup menu and it's submenus */
void IdListCustomPopupMenu( QPoint point );
void addtoContacts();
void removefromContacts();
void banPerson();
void unbanPerson();
@ -100,6 +102,9 @@ private:
TokenQueue *mIdQueue;
UIStateHelper *mStateHelper;
QTreeWidgetItem *contactsItem;
QTreeWidgetItem *allItem;
RsGxsGroupId mId;
/* UI - Designer */

View file

@ -111,13 +111,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="todoPushButton">
<property name="text">
<string>Todo</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="helpButton">
<property name="focusPolicy">
@ -221,6 +214,18 @@
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</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">
<bool>true</bool>
</property>
@ -229,7 +234,7 @@
</attribute>
<column>
<property name="text">
<string>Identity name</string>
<string>Persons</string>
</property>
</column>
<column>
@ -713,7 +718,6 @@ p, li { white-space: pre-wrap; }
</customwidget>
</customwidgets>
<tabstops>
<tabstop>todoPushButton</tabstop>
<tabstop>idTreeWidget</tabstop>
<tabstop>lineEdit_Nickname</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_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?"));
break ;

View file

@ -110,7 +110,7 @@ void CreateLobbyDialog::checkTextFields()
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) ;
}

View file

@ -285,6 +285,10 @@ void FriendSelectionWidget::secured_fillList()
if (mShowTypes & SHOW_GXS)
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
std::set<RsGxsId> gxsIdsSelected2;
if (mShowTypes & SHOW_CONTACTS)
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected2,true);
// remove old items
ui->friendList->clear();
@ -525,6 +529,7 @@ void FriendSelectionWidget::secured_fillList()
// 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;
@ -570,6 +575,61 @@ void FriendSelectionWidget::secured_fillList()
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()) {
++groupIt;
} else {

View file

@ -65,7 +65,8 @@ public:
SHOW_GPG = 2,
SHOW_SSL = 4,
SHOW_NON_FRIEND_GPG = 8,
SHOW_GXS =16
SHOW_GXS =16,
SHOW_CONTACTS =32
};
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->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;
chooser->setEntryEnabled(index,false) ;

View file

@ -912,11 +912,11 @@ QString nickname ;
QApplication::translate("GxsIdDetails", "Identity&nbsp;Id"),
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"));
if (details.mPgpKnown)
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)
{
/* look up real name */
std::string authorName = rsPeers->getGPGName(details.mPgpId);
@ -962,9 +962,9 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icon
{
// ICON Logic.
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);
else
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) ;
/* 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("Distant peer identities"));
ui.filterComboBox->setCurrentIndex(0);
ui.filterComboBox->addItem(tr("All people"));
ui.filterComboBox->addItem(tr("My contacts"));
ui.filterComboBox->setCurrentIndex(3);
connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(changeFormatType(int)));
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) ;
break ;
case 3: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_CONTACTS) ;
break ;
default: ;
}

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>925</width>
<height>747</height>
<width>1679</width>
<height>951</height>
</rect>
</property>
<property name="windowTitle">
@ -56,14 +56,14 @@
<set>QDockWidget::DockWidgetClosable</set>
</property>
<property name="windowTitle">
<string>Contacts</string>
<string>Address list:</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_4">
<property name="margin">
<number>1</number>
</property>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="filterComboBox"/>
</item>
<item>
<widget class="FriendSelectionWidget" name="friendSelectionWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
@ -100,25 +100,8 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item>
<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>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@ -130,7 +113,20 @@
</sizepolicy>
</property>
<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>
</widget>
</item>
@ -143,7 +139,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&gt;&gt; Bcc</string>
<string>Bcc</string>
</property>
</widget>
</item>
@ -160,7 +156,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&gt;&gt; Recommend</string>
<string>Recommend this friend</string>
</property>
</widget>
</item>
@ -168,23 +164,6 @@
</item>
</layout>
</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>
</widget>
</widget>
@ -1105,8 +1084,8 @@ border-image: url(:/images/closepressed.png)
<rect>
<x>0</x>
<y>0</y>
<width>925</width>
<height>21</height>
<width>1679</width>
<height>37</height>
</rect>
</property>
</widget>
@ -1238,8 +1217,6 @@ border-image: url(:/images/closepressed.png)
<tabstop>titleEdit</tabstop>
<tabstop>msgText</tabstop>
<tabstop>msgFileList</tabstop>
<tabstop>addToButton</tabstop>
<tabstop>addCcButton</tabstop>
<tabstop>addBccButton</tabstop>
<tabstop>addRecommendButton</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 */
ui.setupUi(this);
connect(ui.distantChatcomboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantChatComboBoxChanged(int)));
#if QT_VERSION < 0x040600
ui.minimumContrastLabel->hide();
ui.minimumContrast->hide();
@ -120,6 +122,8 @@ ChatPage::save(QString &/*errmsg*/)
Settings->setValue("EnableItalics", ui.checkBox_enableItalics->isChecked());
Settings->setValue("MinimumContrast", ui.minimumContrast->value());
Settings->endGroup();
// state of distant Chat combobox
Settings->setValue("DistantChat", ui.distantChatcomboBox->currentIndex());
Settings->setChatScreenFont(fontTempChat.toString());
NotifyQt::getInstance()->notifyChatFontChanged();
@ -226,6 +230,10 @@ ChatPage::load()
ui.minimumContrast->setValue(Settings->value("MinimumContrast", 4.5).toDouble());
Settings->endGroup();
// state of distant Chat combobox
int index = Settings->value("DistantChat", 0).toInt();
ui.distantChatcomboBox->setCurrentIndex(index);
fontTempChat.fromString(Settings->getChatScreenFont());
ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn());
@ -493,3 +501,22 @@ void ChatPage::on_btSearch_FoundColor_clicked()
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_btSearch_FoundColor_clicked();
void distantChatComboBoxChanged(int);
private:
void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser);

View file

@ -20,8 +20,43 @@
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<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>
<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">
<item>
<widget class="QGroupBox" name="groupBox">
@ -240,7 +275,7 @@
</item>
</layout>
</item>
<item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<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.deletepushButton, SIGNAL(clicked(bool)), this, SLOT (deleteTag()));
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)));
@ -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 window"), RshareSettings::MSG_OPEN_WINDOW);
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantMsgsComboBoxChanged(int)));
//ui.encryptedMsgs_CB->setEnabled(false) ;
}
@ -57,9 +60,23 @@ MessagePage::~MessagePage()
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 */
@ -70,6 +87,9 @@ MessagePage::save(QString &/*errmsg*/)
Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked());
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;
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
// check for changed tags
@ -99,7 +119,17 @@ MessagePage::load()
ui.loadEmbeddedImages->setChecked(Settings->getMsgLoadEmbeddedImages());
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
rsMail->getMessageTagTypes(*m_pTags);
fillTags();

View file

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

View file

@ -59,21 +59,30 @@
<property name="title">
<string>Distant messages:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<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>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<widget class="QComboBox" name="comboBox">
<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>
<widget class="QCheckBox" name="encryptedMsgs_CB">
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Accept encrypted distant messages from everyone</string>
<string>Accept encrypted distant messages from</string>
</property>
</widget>
</item>