Skip to content

Commit

Permalink
Finish Initial implemention of GxsContactList and GxsContact(Invite/A…
Browse files Browse the repository at this point in the history
…ccept/Reject/) with sending Certificates over DistantService Protocol.

sequence:
Contact A-->Add/Invite Contact B.
B Contact-->Approved A's Request or confirm that B has received Certificate with response ACK_REQUEST
If B accepts/approves A's Request -> B send its Certificate to A with APPROVE_REQUEST.
A's receive B's APPROVE_REQUEST, A send back the ACK after add's B as friend.
  • Loading branch information
vivo010 committed Mar 19, 2020
1 parent cf62970 commit f668090
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 204 deletions.
2 changes: 1 addition & 1 deletion libretroshare/src/chat/distantchat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTun
return true ;

if(mDistantChatPermissions & RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS)
res = (rsIdentity!=NULL) && (rsIdentity->isARegularContact(gxs_id) || rsIdentity->acceptFriendContact(gxs_id));
res = (rsIdentity!=NULL) && (rsIdentity->isARegularContact(gxs_id) || rsIdentity->validContact(gxs_id));

if(mDistantChatPermissions & RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_EVERYBODY)
res = false ;
Expand Down
4 changes: 2 additions & 2 deletions libretroshare/src/gxstunnel/p3gxstunnel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1262,10 +1262,10 @@ bool p3GxsTunnelService::locked_sendEncryptedTunnelData(RsGxsTunnelItem *item)
}
if(it->second.status != RS_GXS_TUNNEL_STATUS_CAN_TALK)
{
//#ifdef DEBUG_GXS_TUNNEL
#ifdef DEBUG_GXS_TUNNEL
std::cerr << "(EE) Cannot talk to tunnel id " << tunnel_id
<< ". Tunnel status is: " << it->second.status << std::endl;
//#endif
#endif
return false;
}

Expand Down
1 change: 1 addition & 0 deletions libretroshare/src/pqi/p3notify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ void p3Notify::notifyOwnAvatarChanged ()
void p3Notify::notifyOwnStatusMessageChanged() { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyOwnStatusMessageChanged() ; }
void p3Notify::notifyDiskFull (uint32_t location , uint32_t size_limit_in_MB ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiskFull (location,size_limit_in_MB) ; }
void p3Notify::notifyPeerStatusChanged (const std::string& peer_id , uint32_t status ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChanged (peer_id,status) ; }
void p3Notify::notifyGxsContactStatusChanged (const std::string& gxs_id , uint32_t status ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyGxsContactStatusChanged (gxs_id,status) ; }
void p3Notify::notifyGxsChange (const RsGxsChanges& changes) {FOR_ALL_NOTIFY_CLIENTS (*it)->notifyGxsChange(changes) ;}
void p3Notify::notifyConnectionWithoutCert () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyConnectionWithoutCert(); }

Expand Down
1 change: 1 addition & 0 deletions libretroshare/src/pqi/p3notify.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class p3Notify: public RsNotify
void notifyOwnStatusMessageChanged () ;
void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) ;
void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) ;
void notifyGxsContactStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) ;
void notifyGxsChange (const RsGxsChanges& /* changes */);
void notifyConnectionWithoutCert ();

Expand Down
12 changes: 5 additions & 7 deletions libretroshare/src/retroshare/rsidentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ std::ostream &operator<<(std::ostream &out, const RsGxsIdGroup &group);
class RsGxsMyContact: RsSerializable
{
public:
enum STATUS {UNKNOWN,PENDING,PENDING_REQ, PENDING_ACCEPT, REQUEST,ACCEPT, APPROVE, TRUSTED, BANNED, ACK};
enum STATUS {UNKNOWN,PENDING,PENDING_REQ, PENDING_ACCEPT, REQUEST,ACCEPT, APPROVE, TRUSTED, BANNED, REJECT,ACK};
/* PENDING=NOT READY, PENDING_REQ=ALREADY SENT REQUEST, PENDING_ACCEPT=ALREADY RECEIVE REQ
* ACCEPT= APPROVE already add Friend.
* BANNED = REJECT TO BE FRIEND
Expand Down Expand Up @@ -456,13 +456,11 @@ struct RsIdentity : RsGxsIfaceHelper
virtual bool removeMyContact(const RsGxsMyContact& contact) =0;
virtual void getMyContacts(std::set<RsGxsMyContact>& contactList) =0;

virtual bool acceptFriendContact(const RsGxsId &id) =0;
virtual bool addFriendContact(RsGxsMyContact &contact)=0;
virtual bool addFriendContact(RsGxsId &id)=0;
virtual bool approveFriendContact(RsGxsId &id, bool denied=false)=0;
virtual bool approveFriendContact(RsGxsMyContact &contact, bool denied=false)=0;
virtual bool validContact(const RsGxsId &id) =0;
virtual bool inviteContact(RsGxsId &id)=0;
virtual bool approveContact(RsGxsId &id, bool denied=false)=0;
virtual bool approveContact(RsGxsMyContact &contact, bool denied=false)=0;
virtual void processContactPendingRequest()=0;
virtual void processContactPendingApproval()=0;


virtual bool serialiseIdentityToMemory( const RsGxsId& id,
Expand Down
8 changes: 8 additions & 0 deletions libretroshare/src/retroshare/rsnotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const uint32_t RS_FEED_TYPE_PEER = 0x0010;
const uint32_t RS_FEED_TYPE_CHANNEL = 0x0020;
const uint32_t RS_FEED_TYPE_FORUM = 0x0040;
const uint32_t RS_FEED_TYPE_GXSCHAT = 0x0080;
const uint32_t RS_FEED_TYPE_IDENTITY = 0x00A0;

const uint32_t RS_FEED_TYPE_CHAT = 0x0100;
const uint32_t RS_FEED_TYPE_MSG = 0x0200;
Expand Down Expand Up @@ -103,6 +104,12 @@ const uint32_t RS_FEED_ITEM_CHATS_MSG = RS_FEED_TYPE_GXSCHAT | 0x
const uint32_t RS_FEED_ITEM_CHATS_PUBLISHKEY = RS_FEED_TYPE_GXSCHAT | 0x0014;
const uint32_t RS_FEED_ITEM_CHATS_NOTIFY = RS_FEED_TYPE_GXSCHAT | 0x0015;

const uint32_t RS_FEED_ITEM_IDENTITY_NEW = RS_FEED_TYPE_IDENTITY | 0x0001;
const uint32_t RS_FEED_ITEM_IDENTITY_MSG = RS_FEED_TYPE_IDENTITY | 0x0002;
const uint32_t RS_FEED_ITEM_IDENTITYCONTACT_ADD = RS_FEED_TYPE_IDENTITY | 0x0003;
const uint32_t RS_FEED_ITEM_IDENTITYCONTACT_UPDATE = RS_FEED_TYPE_IDENTITY | 0x0004;


const uint32_t RS_FEED_ITEM_FORUM_NEW = RS_FEED_TYPE_FORUM | 0x0001;
//const uint32_t RS_FEED_ITEM_FORUM_UPDATE = RS_FEED_TYPE_FORUM | 0x0002;
const uint32_t RS_FEED_ITEM_FORUM_MSG = RS_FEED_TYPE_FORUM | 0x0003;
Expand Down Expand Up @@ -238,6 +245,7 @@ class NotifyClient
virtual void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) {}
virtual void notifyGxsChange (const RsGxsChanges& /* changes */) {}
virtual void notifyConnectionWithoutCert () {}
virtual void notifyGxsContactStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) {}

/* one or more peers has changed the states */
virtual void notifyPeerStatusChangedSummary () {}
Expand Down
Loading

0 comments on commit f668090

Please sign in to comment.