floo2
bmx_group_service.h
1 //-------------------------------------------------------------------------------------------------
2 // File : bmx_group_service.h
3 // Author : Eric Liang <eric@bmxlabs.com>
4 // Purpose : bmx group service define file.
5 // Created : 12 Nov 2018 by Eric Liang <eric@bmxlabs.com>
6 //-------------------------------------------------------------------------------------------------
7 //
8 // Copyright (C) 2018-2019 MaxIM.Top
9 //
10 // You may obtain a copy of the licence at http://www.maxim.top/LICENCE-MAXIM.md
11 //
12 //-------------------------------------------------------------------------------------------------
13 
14 #ifndef bmx_group_service_h
15 #define bmx_group_service_h
16 
17 #include <functional>
18 #include "bmx_group.h"
19 #include "bmx_error.h"
20 #include "bmx_result_page.h"
21 
22 namespace floo {
23 
24 class BMXGroupServiceListener;
25 
29 class EXPORT_API BMXGroupService {
30 public:
31 
32  typedef std::function<void(int percent)> Callback;
33 
39  CreateGroupOptions(const std::string& name, const std::string& description, bool isPublic = false) :
40  mName(name), mDescription(description), mIsPublic(isPublic) {
41  }
42 
43  std::string mName; // 群组名称
44  std::string mDescription; // 群组描述
45  bool mIsPublic; // 是否公开群
46  std::string mMessage; // 建群时成员收到的邀请信息
47  std::vector<int64_t> mMembers; // 建群时添加的成员
48  };
49 
50  typedef std::shared_ptr<CreateGroupOptions> CreateGroupOptionsPtr;
51 
52  virtual ~BMXGroupService() {}
53 
60  virtual BMXErrorCode get(BMXGroupList& list, bool forceRefresh) = 0;
61 
69  virtual BMXErrorCode search(BMXGroupList& list, bool forceRefresh) = 0;
70 
78  virtual BMXErrorCode fetchGroupsByIdList(const std::vector<int64_t>& groupIdList, BMXGroupList& list, bool forceRefresh) = 0;
79 
88  virtual BMXErrorCode search(const std::vector<int64_t>& groupIdList, BMXGroupList& list, bool forceRefresh) = 0;
89 
97  virtual BMXErrorCode fetchGroupById(int64_t groupId, BMXGroupPtr& group, bool forceRefresh) = 0;
98 
107  virtual BMXErrorCode search(int64_t groupId, BMXGroupPtr& group, bool forceRefresh) = 0;
108 
115  virtual BMXErrorCode fetchLocalGroupsByName(BMXGroupList& list, const std::string& name) = 0;
116 
124  virtual BMXErrorCode search(BMXGroupList& list, const std::string& name) = 0;
125 
132  virtual BMXErrorCode create(const CreateGroupOptions& options, BMXGroupPtr& group) = 0;
133 
139  virtual BMXErrorCode destroy(BMXGroupPtr group) = 0;
140 
147  virtual BMXErrorCode join(BMXGroupPtr group, const std::string& message) = 0;
148 
154  virtual BMXErrorCode leave(BMXGroupPtr group) = 0;
155 
161  virtual BMXErrorCode getInfo(BMXGroupPtr group) = 0;
162 
170  virtual BMXErrorCode getMembersNickname(BMXGroupPtr group, const std::vector<int64_t>& members, BMXGroup::MemberList& list) = 0;
171 
179  virtual BMXErrorCode getInvitationList(BMXGroupInvitationPagePtr& result, const std::string& cursor = "", int pageSize = 10) = 0;
180 
189  virtual BMXErrorCode getApplicationList(BMXGroupList list, BMXGroupApplicationPagePtr& result, const std::string& cursor = "", int pageSize = 10) = 0;
190 
199  virtual BMXErrorCode getMembers(BMXGroupPtr group, BMXGroupMemberResultPagePtr& result, const std::string& cursor = "", int pageSize = 200) = 0;
200 
208  virtual BMXErrorCode getMembers(BMXGroupPtr group, BMXGroup::MemberList& list, bool forceRefresh) = 0;
209 
217  virtual BMXErrorCode addMembers(BMXGroupPtr group, const std::vector<int64_t>& members, const std::string& message) = 0;
218 
226  virtual BMXErrorCode removeMembers(BMXGroupPtr group, const std::vector<int64_t>& members, const std::string& reason) = 0;
227 
235  virtual BMXErrorCode addAdmins(BMXGroupPtr group, const std::vector<int64_t>& admins, const std::string& message) = 0;
236 
244  virtual BMXErrorCode removeAdmins(BMXGroupPtr group, const std::vector<int64_t>& admins, const std::string& reason) = 0;
245 
253  virtual BMXErrorCode getAdmins(BMXGroupPtr group, BMXGroup::MemberList& list, bool forceRefresh) = 0;
254 
261  virtual BMXErrorCode blockMembers(BMXGroupPtr group, const std::vector<int64_t>& members) = 0;
262 
269  virtual BMXErrorCode unblockMembers(BMXGroupPtr group, const std::vector<int64_t>& members) = 0;
270 
279  virtual BMXErrorCode getBlockList(BMXGroupPtr group, BMXGroupMemberResultPagePtr& result, const std::string& cursor = "", int pageSize = 200) = 0;
280 
288  virtual BMXErrorCode getBlockList(BMXGroupPtr group, BMXGroup::MemberList& list, bool forceRefresh) = 0;
289 
298  virtual BMXErrorCode banMembers(BMXGroupPtr group, const std::vector<int64_t>& members, int64_t duration, const std::string& reason = "") = 0;
299 
306  virtual BMXErrorCode unbanMembers(BMXGroupPtr group, const std::vector<int64_t>& members) = 0;
307 
316  virtual BMXErrorCode getBannedMembers(BMXGroupPtr group, BMXGroupBannedMemberResultPagePtr& result, const std::string& cursor = "", int pageSize = 200) = 0;
317 
324  virtual BMXErrorCode getBannedMembers(BMXGroupPtr group, BMXGroup::BannedMemberList& list) = 0;
325 
332  virtual BMXErrorCode muteMessage(BMXGroupPtr group, BMXGroup::MsgMuteMode mode) = 0;
333 
340  virtual BMXErrorCode acceptApplication(BMXGroupPtr group, int64_t applicantId) = 0;
341 
349  virtual BMXErrorCode declineApplication(BMXGroupPtr group, int64_t applicantId, const std::string& reason = "") = 0;
350 
357  virtual BMXErrorCode acceptInvitation(BMXGroupPtr group, int64_t inviter) = 0;
358 
366  virtual BMXErrorCode declineInvitation(BMXGroupPtr group, int64_t inviter, const std::string& reason = "") = 0;
367 
374  virtual BMXErrorCode transferOwner(BMXGroupPtr group, int64_t newOwnerId) = 0;
375 
385  virtual BMXErrorCode uploadSharedFile(BMXGroupPtr group, const std::string& filePath, const std::string& displayName, const std::string& extensionName, Callback) = 0;
386 
393  virtual BMXErrorCode cancelUploadSharedFile(BMXGroupPtr group, const std::string& filePath) = 0;
394 
401  virtual BMXErrorCode removeSharedFile(BMXGroupPtr group, BMXGroup::SharedFilePtr sharedFile) = 0;
402 
410  virtual BMXErrorCode downloadSharedFile(BMXGroupPtr group, BMXGroup::SharedFilePtr sharedFile, Callback) = 0;
411 
418  virtual BMXErrorCode cancelDownloadSharedFile(BMXGroupPtr group, BMXGroup::SharedFilePtr sharedFile) = 0;
419 
427  virtual BMXErrorCode getSharedFilesList(BMXGroupPtr group, BMXGroup::SharedFileList& list, bool forceRefresh) = 0;
428 
436  virtual BMXErrorCode changeSharedFileName(BMXGroupPtr group, BMXGroup::SharedFilePtr sharedFile, const std::string& name) = 0;
437 
445  virtual BMXErrorCode getLatestAnnouncement(BMXGroupPtr group, BMXGroup::AnnouncementPtr& announcement, bool forceRefresh) = 0;
446 
454  virtual BMXErrorCode getAnnouncementList(BMXGroupPtr group, BMXGroup::AnnouncementList& list, bool forceRefresh) = 0;
455 
463  virtual BMXErrorCode editAnnouncement(BMXGroupPtr group, const std::string& title, const std::string& content) = 0;
464 
471  virtual BMXErrorCode deleteAnnouncement(BMXGroupPtr group, int64_t announcementId) = 0;
472 
479  virtual BMXErrorCode setName(BMXGroupPtr group, const std::string& name) = 0;
480 
487  virtual BMXErrorCode setDescription(BMXGroupPtr group, const std::string& description) = 0;
488 
495  virtual BMXErrorCode setExtension(BMXGroupPtr group, const std::string& extension) = 0;
496 
503  virtual BMXErrorCode setMyNickname(BMXGroupPtr group, const std::string& nickname) = 0;
504 
511  virtual BMXErrorCode setMsgPushMode(BMXGroupPtr group, BMXGroup::MsgPushMode mode) = 0;
512 
519  virtual BMXErrorCode setJoinAuthMode(BMXGroupPtr group, BMXGroup::JoinAuthMode mode) = 0;
520 
527  virtual BMXErrorCode setInviteMode(BMXGroupPtr group, BMXGroup::InviteMode mode) = 0;
528 
535  virtual BMXErrorCode setAllowMemberModify(BMXGroupPtr group, bool enable) = 0;
536 
543  virtual BMXErrorCode setEnableReadAck(BMXGroupPtr group, bool enable) = 0;
544 
551  virtual BMXErrorCode setHistoryVisible(BMXGroupPtr group, bool enable) = 0;
552 
560  virtual BMXErrorCode setAvatar(BMXGroupPtr group, const std::string& avatarPath, Callback) = 0;
561 
569  virtual BMXErrorCode downloadAvatar(BMXGroupPtr group, bool thumbnail = true, Callback callback = [](int){}) = 0;
570 
575  virtual void addGroupListener(BMXGroupServiceListener* listener) = 0;
576 
581  virtual void removeGroupListener(BMXGroupServiceListener* listener) = 0;
582 
583 protected:
584  BMXGroupService() {}
585 };
586 
587 }
588 
589 #endif /* bmx_group_service_h */
MsgMuteMode
群组消息屏蔽模式
Definition: bmx_group.h:247
创建群组选项
Definition: bmx_group_service.h:37
InviteMode
邀请入群模式
Definition: bmx_group.h:193
JoinAuthMode
进群验证方式
Definition: bmx_group.h:181
MsgPushMode
消息通知类型
Definition: bmx_group.h:155
群组Service
Definition: bmx_group_service.h:29