connected GUI to distant chat permission flags system

This commit is contained in:
csoler 2015-12-27 21:10:20 -05:00
parent b32eb6e0c8
commit 9dfac71822
4 changed files with 17 additions and 12 deletions

View file

@ -60,6 +60,12 @@ static const uint32_t DISTANT_CHAT_GXS_TUNNEL_SERVICE_ID = 0xa0001 ;
typedef RsGxsTunnelService::RsGxsTunnelId RsGxsTunnelId; typedef RsGxsTunnelService::RsGxsTunnelId RsGxsTunnelId;
DistantChatService::DistantChatService() : mDistantChatMtx("distant chat")
{
mGxsTunnels = NULL ;
mDistantChatPermissions = RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NONE ; // default: accept everyone
}
void DistantChatService::connectToGxsTunnelService(RsGxsTunnelService *tr) void DistantChatService::connectToGxsTunnelService(RsGxsTunnelService *tr)
{ {
mGxsTunnels = tr ; mGxsTunnels = tr ;
@ -111,10 +117,10 @@ void DistantChatService::handleRecvChatStatusItem(RsChatStatusItem *cs)
bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id) bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id)
{ {
if(mDistantChatPermissions & RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS) if(mDistantChatPermissions & RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS)
return (rsIdentity!=NULL) && rsIdentity->isARegularContact(gxs_id) ; return (rsIdentity!=NULL) && rsIdentity->isARegularContact(gxs_id) ;
if(mDistantChatPermissions & RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_FILTER_EVERYBODY) if(mDistantChatPermissions & RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_EVERYBODY)
return false ; return false ;
return true ; return true ;

View file

@ -39,11 +39,7 @@ public:
// So, public interface only uses DistandChatPeerId, but internally, this is converted into a RsGxsTunnelService::RsGxsTunnelId // So, public interface only uses DistandChatPeerId, but internally, this is converted into a RsGxsTunnelService::RsGxsTunnelId
DistantChatService() : mDistantChatMtx("distant chat") DistantChatService() ;
{
mGxsTunnels = NULL ;
mDistantChatPermissions = RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_FILTER_NONE ; // default: accept everyone
}
virtual void triggerConfigSave()=0 ; virtual void triggerConfigSave()=0 ;
bool processLoadListItem(const RsItem *item) ; bool processLoadListItem(const RsItem *item) ;

View file

@ -270,6 +270,10 @@ public:
#define RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS 0x0001 #define RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS 0x0001
#define RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_FILTER_EVERYBODY 0x0002 #define RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_FILTER_EVERYBODY 0x0002
#define RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NONE 0x0000
#define RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS 0x0001
#define RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_EVERYBODY 0x0002
struct DistantChatPeerInfo struct DistantChatPeerInfo
{ {
RsGxsId to_id ; RsGxsId to_id ;

View file

@ -506,16 +506,15 @@ void ChatPage::distantChatComboBoxChanged(int i)
{ {
switch(i) switch(i)
{ {
case 0: ; default:
case 0: rsMsgs->setDistantChatPermissionFlags(RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NONE) ;
break ; break ;
case 1: ; case 1: rsMsgs->setDistantChatPermissionFlags(RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS) ;
break ; break ;
case 2: ; case 2: rsMsgs->setDistantChatPermissionFlags(RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_EVERYBODY) ;
break ; break ;
default: ;
} }
} }