diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index d71544d15..2a8aadbfb 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -269,6 +269,16 @@ 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_ANONYMOUS 0x0001 +#define RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST 0x0002 + +#define RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_NONE 0x0000 +#define RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_ANONYMOUS 0x0001 +#define RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_CONTACT_LIST 0x0002 + // Identifier for an chat endpoint like // neighbour peer, distant peer, chatlobby, broadcast class ChatId @@ -430,9 +440,9 @@ 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 */ /****************************************/ diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index 6ce2d4830..8791b275a 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -278,6 +278,16 @@ bool p3Msgs::getMessageSummaries(std::list &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) { @@ -297,15 +307,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); diff --git a/libretroshare/src/rsserver/p3msgs.h b/libretroshare/src/rsserver/p3msgs.h index 5599a8ee1..a83b4ae94 100644 --- a/libretroshare/src/rsserver/p3msgs.h +++ b/libretroshare/src/rsserver/p3msgs.h @@ -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 diff --git a/libretroshare/src/services/p3msgservice.h b/libretroshare/src/services/p3msgservice.h index 78c738318..66c14e209 100644 --- a/libretroshare/src/services/p3msgservice.h +++ b/libretroshare/src/services/p3msgservice.h @@ -90,6 +90,7 @@ class p3MsgService: public p3Service, public p3Config, public pqiServiceMonitor, void loadWelcomeMsg(); /* startup message */ + //std::list &getMsgList(); //std::list &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) ; diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index 4c13a6999..2dfe0a310 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -60,22 +60,17 @@ MessagePage::~MessagePage() delete(m_pTags); } -void MessagePage::toggleEnableEncryptedDistantMsgs(bool b) -{ - rsMail->enableDistantMessaging(b) ; -} - void MessagePage::distantMsgsComboBoxChanged(int i) { switch(i) { - case 0: rsMail->enableDistantMessaging(true) ; + case 0: rsMail->setDistantMessagingPermissionFlags(RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_ANONYMOUS |RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST) ; break ; - case 1: ; + case 1: rsMail->setDistantMessagingPermissionFlags(RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST) ; break ; - case 2: rsMail->enableDistantMessaging(false) ; + case 2: rsMail->setDistantMessagingPermissionFlags(RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_NONE) ; break ; @@ -124,11 +119,16 @@ 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 - int index = Settings->value("DistantMessages", 0).toInt(); - ui.comboBox->setCurrentIndex(index); + + uint32_t flags = rsMail->getDistantMessagingPermissionFlags() ; + + if(flags == (RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST | RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_ANONYMOUS)) + 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); diff --git a/retroshare-gui/src/gui/settings/MessagePage.h b/retroshare-gui/src/gui/settings/MessagePage.h index 8ee3bf128..e79405ae8 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.h +++ b/retroshare-gui/src/gui/settings/MessagePage.h @@ -54,7 +54,6 @@ private slots: void defaultTag(); void currentRowChangedTag(int row); - void toggleEnableEncryptedDistantMsgs(bool) ; void distantMsgsComboBoxChanged(int);