Skip to content

Commit 00a6403

Browse files
authored
Merge pull request #276 from jolavillette/FixTheWire
TheWire: Add token-free subscribe API for UI simplification
2 parents d88a7ad + 3da7eba commit 00a6403

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/retroshare/rswire.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ virtual bool getPulseFocus(const RsGxsGroupId &groupId, const RsGxsMessageId &ms
274274
std::vector<RsMsgMetaData>& summaries ) = 0;
275275

276276
virtual bool subscribeToGroup(uint32_t& token, const RsGxsGroupId& groupId, bool subscribe) = 0;
277+
278+
// Simple subscribe/unsubscribe API without token management (for UI use)
279+
// Tokens are handled internally by libretroshare
280+
virtual bool subscribe(const RsGxsGroupId& groupId, bool subscribe) = 0;
281+
277282
virtual uint32_t getFollowingCount() = 0;
278283
virtual bool getSubscribedGroups(std::list<RsGxsGroupId>& groupIds) = 0;
279284

src/services/p3wire.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,18 @@ bool p3Wire::subscribeToGroup(uint32_t& token, const RsGxsGroupId& groupId, bool
19191919
return response;
19201920
}
19211921

1922+
bool p3Wire::subscribe(const RsGxsGroupId& groupId, bool subscribe)
1923+
{
1924+
#ifdef WIRE_DEBUG
1925+
std::cerr << "p3Wire::subscribe() id: " << groupId << " subscribe: " << subscribe;
1926+
std::cerr << std::endl;
1927+
#endif
1928+
1929+
// Token is managed internally - UI doesn't need to handle it
1930+
uint32_t token;
1931+
return subscribeToGroup(token, groupId, subscribe);
1932+
}
1933+
19221934
void p3Wire::refreshSubscribedGroups()
19231935
{
19241936
uint32_t token;

src/services/p3wire.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ class p3Wire: public RsGenExchange, public RsWire, public p3Config
9494
void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) override;
9595

9696
bool subscribeToGroup(uint32_t& token, const RsGxsGroupId& groupId, bool subscribe) override;
97+
98+
// Simple subscribe/unsubscribe API without token management (for UI use)
99+
bool subscribe(const RsGxsGroupId& groupId, bool subscribe) override;
100+
97101
uint32_t getFollowingCount() override;
98102
bool getSubscribedGroups(std::list<RsGxsGroupId>& groupIds) override;
99103

0 commit comments

Comments
 (0)