floo2
bmx_roster_service.h
1 //-------------------------------------------------------------------------------------------------
2 // File : bmx_roster_service.h
3 // Author : Eric Liang <eric@bmxlabs.com>
4 // Purpose : bmx roster 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_roster_service_h
15 #define bmx_roster_service_h
16 
17 #include <vector>
18 #include <functional>
19 #include "bmx_base_object.h"
20 #include "bmx_roster_item.h"
21 #include "bmx_result_page.h"
22 
23 namespace floo {
24 
25 class BMXRosterServiceListener;
26 
30 class EXPORT_API BMXRosterService {
31 public:
32 
36  enum class ApplicationStatus {
38  Pending,
40  Accepted,
42  Declined
43  };
44 
48  struct Application {
49  Application() {}
50  virtual ~Application() {}
51 
52  int64_t mRosterId;
53  std::string mReason;
54  ApplicationStatus mStatus;
55  int64_t mExpire;
56  };
57  typedef std::shared_ptr<Application> ApplicationPtr;
58  typedef std::vector<ApplicationPtr> ApplicationList;
60  typedef std::shared_ptr<BMXRosterApplicationResultPage> BMXRosterApplicationResultPagePtr;
61 
62  virtual ~BMXRosterService() {}
63 
64  typedef std::function<void(int percent)> Callback;
65 
72  virtual BMXErrorCode get(std::vector<int64_t>& list, bool forceRefresh) = 0;
73 
81  virtual BMXErrorCode fetchRosterById(int64_t rosterId, bool forceRefresh, BMXRosterItemPtr& item) = 0;
82 
91  virtual BMXErrorCode search(int64_t rosterId, bool forceRefresh, BMXRosterItemPtr& item) = 0;
92 
100  virtual BMXErrorCode fetchRosterByName(const std::string& name, bool forceRefresh, BMXRosterItemPtr& item) = 0;
101 
110  virtual BMXErrorCode search(const std::string& name, bool forceRefresh, BMXRosterItemPtr& item) = 0;
111 
119  virtual BMXErrorCode fetchRostersByIdList(const std::vector<int64_t>& rosterIdList, BMXRosterList& list, bool forceRefresh) = 0;
120 
129  virtual BMXErrorCode search(const std::vector<int64_t>& rosterIdList, BMXRosterList& list, bool forceRefresh) = 0;
130 
137  virtual BMXErrorCode setItemLocalExtension(BMXRosterItemPtr item, const JSON& extension) = 0;
138 
145  virtual BMXErrorCode setItemExtension(BMXRosterItemPtr item, const JSON& extension) = 0;
146 
153  virtual BMXErrorCode setItemAlias(BMXRosterItemPtr item, const JSON& alias) = 0;
154 
161  virtual BMXErrorCode setItemMuteNotification(BMXRosterItemPtr item, bool status) = 0;
162 
170  virtual BMXErrorCode getApplicationList(BMXRosterApplicationResultPagePtr& result, const std::string& cursor, int pageSize = 10) = 0;
171 
178  virtual BMXErrorCode apply(int64_t rosterId, const std::string& message, const std::string& authAnswer = "") = 0;
179 
185  virtual BMXErrorCode remove(int64_t rosterId) = 0;
186 
192  virtual BMXErrorCode accept(int64_t rosterId) = 0;
193 
200  virtual BMXErrorCode decline(int64_t rosterId, const std::string& reason) = 0;
201 
207  virtual BMXErrorCode block(int64_t rosterId) = 0;
208 
214  virtual BMXErrorCode unblock(int64_t rosterId) = 0;
215 
222  virtual BMXErrorCode getBlockList(std::vector<int64_t>& list, bool forceRefresh) = 0;
223 
231  virtual BMXErrorCode downloadAvatar(BMXRosterItemPtr item, bool thumbnail = true, Callback callback = [](int){}) = 0;
232 
237  virtual void addRosterListener(BMXRosterServiceListener* listener) = 0;
238 
243  virtual void removeRosterListener(BMXRosterServiceListener* listener) = 0;
244 
245 protected:
246  BMXRosterService() {}
247 };
248 
249 }
250 
251 #endif /* bmx_roster_service_h */
好友Service
Definition: bmx_roster_service.h:30
好友邀请
Definition: bmx_roster_service.h:48
分页结果
Definition: bmx_result_page.h:30
ApplicationStatus
请求状态
Definition: bmx_roster_service.h:36