proto.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. //
  2. // proto.h
  3. // proto
  4. //
  5. // Created by WF Chat on 2017/11/8.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #ifndef proto_h
  9. #define proto_h
  10. #include <stdio.h>
  11. #include <string>
  12. #include <list>
  13. #include <map>
  14. #include <vector>
  15. //Content Type. 1000以下为系统内置类型,自定义消息需要使用1000以上
  16. //基本消息类型
  17. #define MESSAGE_CONTENT_TYPE_TEXT 1
  18. #define MESSAGE_CONTENT_TYPE_SOUND 2
  19. #define MESSAGE_CONTENT_TYPE_IMAGE 3
  20. #define MESSAGE_CONTENT_TYPE_LOCATION 4
  21. #define MESSAGE_CONTENT_TYPE_FILE 5
  22. //通知消息类型
  23. #define MESSAGE_CONTENT_TYPE_CREATE_GROUP 104
  24. #define MESSAGE_CONTENT_TYPE_ADD_GROUP_MEMBER 105
  25. #define MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER 106
  26. #define MESSAGE_CONTENT_TYPE_QUIT_GROUP 107
  27. #define MESSAGE_CONTENT_TYPE_DISMISS_GROUP 108
  28. #define MESSAGE_CONTENT_TYPE_TRANSFER_GROUP_OWNER 109
  29. #define MESSAGE_CONTENT_TYPE_CHANGE_GROUP_NAME 110
  30. #define MESSAGE_CONTENT_TYPE_MODIFY_GROUP_ALIAS 111
  31. #define MESSAGE_CONTENT_TYPE_CHANGE_GROUP_PORTRAIT 112
  32. #define MESSAGE_CONTENT_TYPE_CHANGE_MUTE 113
  33. #define MESSAGE_CONTENT_TYPE_CHANGE_JOINTYPE 114
  34. #define MESSAGE_CONTENT_TYPE_CHANGE_PRIVATECHAT 115
  35. #define MESSAGE_CONTENT_TYPE_CHANGE_SEARCHABLE 116
  36. #define MESSAGE_CONTENT_TYPE_SET_MANAGER 117
  37. #define MESSAGE_CONTENT_TYPE_MUTE_MEMBER 118
  38. #if WFCHAT_PROTO_SERIALIZABLE
  39. #include "rapidjson/rapidjson.h"
  40. #include "rapidjson/writer.h"
  41. #include "rapidjson/document.h"
  42. using namespace wfchatjson;
  43. #endif //WFCHAT_PROTO_SERIALIZABLE
  44. namespace mars{
  45. namespace stn{
  46. //error code
  47. enum {
  48. //mars error code
  49. kEcMarsLocalTaskTimeout = -1,
  50. kEcMarsLocalTaskRetry = -2,
  51. kEcMarsLocalStartTaskFail = -3,
  52. kEcMarsLocalAntiAvalanche = -4,
  53. kEcMarsLocalChannelSelect = -5,
  54. kEcMarsLocalNoNet = -6,
  55. kEcMarsLocalCancel = -7,
  56. kEcMarsLocalClear = -8,
  57. kEcMarsLocalReset = -9,
  58. kEcMarsLocalTaskParam = -12,
  59. kEcMarsLocalCgiFrequcencyLimit = -13,
  60. kEcMarsLocalChannelID = -14,
  61. kEcMarsLongFirstPkgTimeout = -500,
  62. kEcMarsLongPkgPkgTimeout = -501,
  63. kEcMarsLongReadWriteTimeout = -502,
  64. kEcMarsLongTaskTimeout = -503,
  65. kEcMarsSocketNetworkChange = -10086,
  66. kEcMarsSocketMakeSocketPrepared = -10087,
  67. kEcMarsSocketWritenWithNonBlock = -10088,
  68. kEcMarsSocketReadOnce = -10089,
  69. kEcMarsSocketRecvErr = -10091,
  70. kEcMarsSocketSendErr = -10092,
  71. kEcMarsSocketNoopTimeout = -10093,
  72. kEcMarsSocketNoopAlarmTooLate = -10094,
  73. kEcMarsHttpSplitHttpHeadAndBody = -10194,
  74. kEcMarsHttpParseStatusLine = -10195,
  75. kEcMarsNetMsgXPHandleBufferErr = -10504,
  76. kEcMarsDnsMakeSocketPrepared = -10606,
  77. //proto error code
  78. kEcProtoCorruptData = -100001,
  79. kEcProtoInvalideParameter = -100002,
  80. //server error code
  81. kEcServerSecrectKeyMismatch = 1,
  82. kEcServerInvalidData = 2,
  83. kEcServerServerError = 4,
  84. kEcServerNotModified = 5,
  85. kEcServerTokenIncorrect = 6,
  86. kEcServerUserForbidden = 8,
  87. kEcServerNotInGroup = 9,
  88. kEcServerInvalidMessage = 10,
  89. kEcServerGroupAlreadyExist = 11,
  90. kEcServerPasswordIncorrect = 15,
  91. kEcServerFriendAlreadyRequested = 16,
  92. kEcServerFriendRequestOverFrequency = 17,
  93. kEcServerFriendRquestBlocked = 18,
  94. kEcServerFriendRequestOvertime = 19,
  95. kEcServerNotInChatroom = 20,
  96. kEcServerNotLicensed = 22,
  97. kEcServerUserIsBlocked = 245,
  98. kEcServerInBlacklist = 246,
  99. kEcServerForbidden_send_msg = 247,
  100. kEcServerNotRight = 248,
  101. kEcServerTimeout = 249,
  102. kEcServerOverFrequence = 250,
  103. kEcServerInvalidParameter = 251,
  104. kEcServerNotExist = 253,
  105. kEcServerNotImplement = 254,
  106. };
  107. class TSerializable {
  108. public:
  109. TSerializable() {}
  110. virtual ~TSerializable() {}
  111. #if WFCHAT_PROTO_SERIALIZABLE
  112. virtual void Serialize(void *writer) const = 0;
  113. virtual void Unserialize(const Value& value) = 0;
  114. bool fromJson(std::string jsonStr);
  115. std::string toJson() const;
  116. static std::string list2Json(std::list<std::string> &strs);
  117. static std::string list2Json(std::list<int> &is);
  118. #endif //WFCHAT_PROTO_SERIALIZABLE
  119. };
  120. class TGroupInfo : public TSerializable {
  121. public:
  122. TGroupInfo() : target(""), type(0), memberCount(0), updateDt(0), mute(0), joinType(0), privateChat(0), searchable(0) {}
  123. std::string target;
  124. std::string name;
  125. std::string portrait;
  126. std::string owner;
  127. int type;
  128. int memberCount;
  129. std::string extra;
  130. int64_t updateDt;
  131. int mute;
  132. int joinType;
  133. int privateChat;
  134. int searchable;
  135. virtual ~TGroupInfo() {}
  136. #if WFCHAT_PROTO_SERIALIZABLE
  137. virtual void Serialize(void *writer) const;
  138. virtual void Unserialize(const Value& value);
  139. #endif //WFCHAT_PROTO_SERIALIZABLE
  140. };
  141. class TGroupMember : public TSerializable {
  142. public:
  143. TGroupMember() : type(0), updateDt(0) {}
  144. std::string groupId;
  145. std::string memberId;
  146. std::string alias;
  147. int type;
  148. int64_t updateDt;
  149. virtual ~TGroupMember() {}
  150. #if WFCHAT_PROTO_SERIALIZABLE
  151. virtual void Serialize(void *writer) const;
  152. virtual void Unserialize(const Value& value);
  153. #endif //WFCHAT_PROTO_SERIALIZABLE
  154. };
  155. class TUserInfo : public TSerializable {
  156. public:
  157. TUserInfo() : gender(0), type(0), deleted(0), updateDt(0) {}
  158. std::string uid;
  159. std::string name;
  160. std::string displayName;
  161. int gender;
  162. std::string portrait;
  163. std::string mobile;
  164. std::string email;
  165. std::string address;
  166. std::string company;
  167. std::string social;
  168. std::string extra;
  169. std::string friendAlias;
  170. std::string groupAlias;
  171. //0 normal; 1 robot; 2 thing;
  172. int type;
  173. int deleted;
  174. int64_t updateDt;
  175. virtual ~TUserInfo() {}
  176. #if WFCHAT_PROTO_SERIALIZABLE
  177. virtual void Serialize(void *writer) const;
  178. virtual void Unserialize(const Value& value);
  179. #endif //WFCHAT_PROTO_SERIALIZABLE
  180. };
  181. class TChatroomInfo : public TSerializable {
  182. public:
  183. TChatroomInfo() : title(""), desc(""), portrait(""), memberCount(0), createDt(0), updateDt(0), extra(""), state(0) {}
  184. std::string title;
  185. std::string desc;
  186. std::string portrait;
  187. int memberCount;
  188. int64_t createDt;
  189. int64_t updateDt;
  190. std::string extra;
  191. //0 normal; 1 not started; 2 end
  192. int state;
  193. virtual ~TChatroomInfo() {}
  194. #if WFCHAT_PROTO_SERIALIZABLE
  195. virtual void Serialize(void *writer) const;
  196. virtual void Unserialize(const Value& value);
  197. #endif //WFCHAT_PROTO_SERIALIZABLE
  198. };
  199. class TChatroomMemberInfo : public TSerializable {
  200. public:
  201. TChatroomMemberInfo() : memberCount(0) {}
  202. int memberCount;
  203. std::list<std::string> olderMembers;
  204. virtual ~TChatroomMemberInfo() {}
  205. #if WFCHAT_PROTO_SERIALIZABLE
  206. virtual void Serialize(void *writer) const;
  207. virtual void Unserialize(const Value& value);
  208. #endif //WFCHAT_PROTO_SERIALIZABLE
  209. };
  210. class TChannelInfo : public TSerializable {
  211. public:
  212. TChannelInfo() : status(0), updateDt(0), automatic(0) {}
  213. std::string channelId;
  214. std::string name;
  215. std::string portrait;
  216. std::string owner;
  217. int status;
  218. std::string desc;
  219. std::string extra;
  220. std::string secret;
  221. std::string callback;
  222. int64_t updateDt;
  223. int automatic;
  224. virtual ~TChannelInfo() {}
  225. #if WFCHAT_PROTO_SERIALIZABLE
  226. virtual void Serialize(void *writer) const;
  227. virtual void Unserialize(const Value& value);
  228. #endif //WFCHAT_PROTO_SERIALIZABLE
  229. };
  230. class TMessageContent : public TSerializable {
  231. public:
  232. TMessageContent() : type(0), mediaType(0), mentionedType(0) {}
  233. TMessageContent(const TMessageContent &c) :
  234. type(c.type),
  235. searchableContent(c.searchableContent),
  236. pushContent(c.pushContent),
  237. content(c.content),
  238. binaryContent(c.binaryContent),
  239. localContent(c.localContent),
  240. mediaType(c.mediaType),
  241. remoteMediaUrl(c.remoteMediaUrl),
  242. localMediaPath(c.localMediaPath),
  243. mentionedType(c.mentionedType),
  244. mentionedTargets(c.mentionedTargets),
  245. extra(c.extra) {}
  246. TMessageContent operator=(const TMessageContent &c) {
  247. type = c.type;
  248. searchableContent = c.searchableContent;
  249. pushContent = c.pushContent;
  250. content = c.content;
  251. binaryContent = c.binaryContent;
  252. localContent = c.localContent;
  253. mediaType = c.mediaType;
  254. remoteMediaUrl = c.remoteMediaUrl;
  255. localMediaPath = c.localMediaPath;
  256. mentionedType = c.mentionedType;
  257. mentionedTargets = c.mentionedTargets;
  258. extra = c.extra;
  259. return *this;
  260. }
  261. int type;
  262. std::string searchableContent;
  263. std::string pushContent;
  264. std::string content;
  265. std::string binaryContent;
  266. std::string localContent;
  267. int mediaType;
  268. std::string remoteMediaUrl;
  269. std::string localMediaPath;
  270. int mentionedType;
  271. std::list<std::string> mentionedTargets;
  272. std::string extra;
  273. virtual ~TMessageContent(){
  274. }
  275. #if WFCHAT_PROTO_SERIALIZABLE
  276. virtual void Serialize(void *writer) const;
  277. virtual void Unserialize(const Value& value);
  278. #endif //WFCHAT_PROTO_SERIALIZABLE
  279. };
  280. typedef enum {
  281. Message_Status_Sending,
  282. Message_Status_Sent,
  283. Message_Status_Send_Failure,
  284. Message_Status_Mentioned,
  285. Message_Status_AllMentioned,
  286. Message_Status_Unread,
  287. Message_Status_Readed,
  288. Message_Status_Played
  289. } MessageStatus;
  290. class TMessage : public TSerializable {
  291. public:
  292. TMessage() : conversationType(0), line(0), messageId(-1), direction(0), status(Message_Status_Sending), messageUid(0), timestamp(0) {}
  293. int conversationType;
  294. std::string target;
  295. int line;
  296. std::string from;
  297. TMessageContent content;
  298. long messageId;
  299. int direction;
  300. MessageStatus status;
  301. int64_t messageUid;
  302. int64_t timestamp;
  303. std::list<std::string> to;
  304. virtual ~TMessage(){}
  305. #if WFCHAT_PROTO_SERIALIZABLE
  306. virtual void Serialize(void *writer) const;
  307. virtual void Unserialize(const Value& value);
  308. #endif //WFCHAT_PROTO_SERIALIZABLE
  309. };
  310. class TUnreadCount : public TSerializable {
  311. public:
  312. TUnreadCount():unread(0),unreadMention(0),unreadMentionAll(0){}
  313. int unread;
  314. int unreadMention;
  315. int unreadMentionAll;
  316. #if WFCHAT_PROTO_SERIALIZABLE
  317. virtual void Serialize(void *writer) const;
  318. virtual void Unserialize(const Value& value);
  319. #endif //WFCHAT_PROTO_SERIALIZABLE
  320. };
  321. class TConversation : public TSerializable {
  322. public:
  323. TConversation() : conversationType(0), line(0), lastMessage() , timestamp(0), unreadCount(), isTop(false), isSilent(false) {}
  324. int conversationType;
  325. std::string target;
  326. int line;
  327. TMessage lastMessage;
  328. int64_t timestamp;
  329. std::string draft;
  330. TUnreadCount unreadCount;
  331. bool isTop;
  332. bool isSilent;
  333. virtual ~TConversation(){}
  334. #if WFCHAT_PROTO_SERIALIZABLE
  335. virtual void Serialize(void *writer) const;
  336. virtual void Unserialize(const Value& value);
  337. #endif //WFCHAT_PROTO_SERIALIZABLE
  338. };
  339. class TConversationSearchresult : public TSerializable {
  340. public:
  341. TConversationSearchresult() : conversationType(0), line(0), marchedMessage(), timestamp(0), marchedCount(0) {}
  342. int conversationType;
  343. std::string target;
  344. int line;
  345. //only marchedCount == 1, load the message
  346. TMessage marchedMessage;
  347. int64_t timestamp;
  348. int marchedCount;
  349. virtual ~TConversationSearchresult(){}
  350. #if WFCHAT_PROTO_SERIALIZABLE
  351. virtual void Serialize(void *writer) const;
  352. virtual void Unserialize(const Value& value);
  353. #endif //WFCHAT_PROTO_SERIALIZABLE
  354. };
  355. class TGroupSearchResult : public TSerializable {
  356. public:
  357. TGroupSearchResult() : marchedType(-1) {}
  358. TGroupInfo groupInfo;
  359. int marchedType; //0 march name, 1 march group member, 2 both
  360. std::list<std::string> marchedMemberNames;
  361. virtual ~TGroupSearchResult(){}
  362. #if WFCHAT_PROTO_SERIALIZABLE
  363. virtual void Serialize(void *writer) const;
  364. virtual void Unserialize(const Value& value);
  365. #endif //WFCHAT_PROTO_SERIALIZABLE
  366. };
  367. class TFriendRequest : public TSerializable {
  368. public:
  369. TFriendRequest() : direction(0), status(0), readStatus(0), timestamp(0) {}
  370. int direction;
  371. std::string target;
  372. std::string reason;
  373. int status;
  374. int readStatus;
  375. int64_t timestamp;
  376. virtual ~TFriendRequest(){}
  377. #if WFCHAT_PROTO_SERIALIZABLE
  378. virtual void Serialize(void *writer) const;
  379. virtual void Unserialize(const Value& value);
  380. #endif //WFCHAT_PROTO_SERIALIZABLE
  381. };
  382. enum UserSettingScope {
  383. kUserSettingConversationSilent = 1,
  384. kUserSettingGlobalSilent = 2,
  385. kUserSettingConversationTop = 3,
  386. kUserSettingHiddenNotificationDetail = 4,
  387. kUserSettinGroupHideNickname = 5,
  388. kUserSettingFavouriteGroup = 6,
  389. kUserSettingConversationSync = 7,
  390. kUserSettingMyChannels = 8,
  391. kUserSettingListenedChannels = 9,
  392. kUserSettingPCOnline = 10,
  393. kUserSettingConversationReaded = 11,
  394. kUserSettingWebOnline = 12,
  395. kUserSettingDisableRecipt = 13,
  396. kUserSettingCustomBegin = 1000
  397. };
  398. class TUserSettingEntry : public TSerializable {
  399. public:
  400. TUserSettingEntry() : scope(kUserSettingCustomBegin), updateDt(0) {}
  401. UserSettingScope scope;
  402. std::string key;
  403. std::string value;
  404. int64_t updateDt;
  405. virtual ~TUserSettingEntry(){}
  406. #if WFCHAT_PROTO_SERIALIZABLE
  407. virtual void Serialize(void *writer) const;
  408. virtual void Unserialize(const Value& value);
  409. #endif //WFCHAT_PROTO_SERIALIZABLE
  410. };
  411. class TReadEntry : public TSerializable {
  412. public:
  413. TReadEntry() : conversationType(0), line(0), readDt(0) {}
  414. std::string userId;
  415. int conversationType;
  416. std::string target;
  417. int line;
  418. int64_t readDt;
  419. virtual ~TReadEntry(){}
  420. #if WFCHAT_PROTO_SERIALIZABLE
  421. virtual void Serialize(void *writer) const;
  422. virtual void Unserialize(const Value& value);
  423. #endif //WFCHAT_PROTO_SERIALIZABLE
  424. };
  425. class TDeliveryEntry : public TSerializable {
  426. public:
  427. TDeliveryEntry() : rcvdDt(0) {}
  428. std::string userId;
  429. int64_t rcvdDt;
  430. virtual ~TDeliveryEntry(){}
  431. #if WFCHAT_PROTO_SERIALIZABLE
  432. virtual void Serialize(void *writer) const;
  433. virtual void Unserialize(const Value& value);
  434. #endif //WFCHAT_PROTO_SERIALIZABLE
  435. };
  436. class GeneralStringCallback {
  437. public:
  438. virtual void onSuccess(std::string key) = 0;
  439. virtual void onFalure(int errorCode) = 0;
  440. virtual ~GeneralStringCallback() {}
  441. };
  442. class UploadMediaCallback {
  443. public:
  444. virtual void onSuccess(std::string key) = 0;
  445. virtual void onFalure(int errorCode) = 0;
  446. virtual void onProgress(int current, int total) = 0;
  447. virtual ~UploadMediaCallback() {}
  448. };
  449. class SendMsgCallback {
  450. public:
  451. virtual void onPrepared(long messageId, int64_t savedTime) = 0;
  452. virtual void onMediaUploaded(std::string remoteUrl) = 0;
  453. virtual void onSuccess(long long messageUid, long long timestamp) = 0;
  454. virtual void onFalure(int errorCode) = 0;
  455. virtual void onProgress(int uploaded, int total) = 0;
  456. virtual ~SendMsgCallback() {}
  457. };
  458. class UpdateMediaCallback {
  459. public:
  460. virtual void onSuccess(const std::string &remoteUrl) = 0;
  461. virtual void onFalure(int errorCode) = 0;
  462. virtual void onProgress(int current, int total) = 0;
  463. virtual ~UpdateMediaCallback() {}
  464. };
  465. class SearchUserCallback {
  466. public:
  467. virtual void onSuccess(const std::list<TUserInfo> &users, const std::string &keyword, int page) = 0;
  468. virtual void onFalure(int errorCode) = 0;
  469. virtual ~SearchUserCallback() {}
  470. };
  471. class SearchChannelCallback {
  472. public:
  473. virtual void onSuccess(const std::list<TChannelInfo> &channels, const std::string &keyword) = 0;
  474. virtual void onFalure(int errorCode) = 0;
  475. virtual ~SearchChannelCallback() {}
  476. };
  477. class CreateGroupCallback {
  478. public:
  479. virtual void onSuccess(std::string groupId) = 0;
  480. virtual void onFalure(int errorCode) = 0;
  481. virtual ~CreateGroupCallback() {}
  482. };
  483. class CreateChannelCallback {
  484. public:
  485. virtual void onSuccess(const TChannelInfo &channelInfo) = 0;
  486. virtual void onFalure(int errorCode) = 0;
  487. virtual ~CreateChannelCallback() {}
  488. };
  489. class GeneralOperationCallback {
  490. public:
  491. virtual void onSuccess() = 0;
  492. virtual void onFalure(int errorCode) = 0;
  493. virtual ~GeneralOperationCallback() {}
  494. };
  495. class LoadRemoteMessagesCallback {
  496. public:
  497. virtual void onSuccess(const std::list<TMessage> &messageList) = 0;
  498. virtual void onFalure(int errorCode) = 0;
  499. virtual ~LoadRemoteMessagesCallback() {}
  500. };
  501. class GetChatroomInfoCallback {
  502. public:
  503. virtual void onSuccess(const TChatroomInfo &info) = 0;
  504. virtual void onFalure(int errorCode) = 0;
  505. virtual ~GetChatroomInfoCallback() {}
  506. };
  507. class GetChatroomMemberInfoCallback {
  508. public:
  509. virtual void onSuccess(const TChatroomMemberInfo &info) = 0;
  510. virtual void onFalure(int errorCode) = 0;
  511. virtual ~GetChatroomMemberInfoCallback() {}
  512. };
  513. class GetGroupInfoCallback {
  514. public:
  515. virtual void onSuccess(const std::list<mars::stn::TGroupInfo> &groupInfoList) = 0;
  516. virtual void onFalure(int errorCode) = 0;
  517. virtual ~GetGroupInfoCallback() {}
  518. };
  519. class GetGroupMembersCallback {
  520. public:
  521. virtual void onSuccess(const std::string &groupId, const std::list<mars::stn::TGroupMember> &groupMemberList) = 0;
  522. virtual void onFalure(int errorCode) = 0;
  523. virtual ~GetGroupMembersCallback() {}
  524. };
  525. class GetChannelInfoCallback {
  526. public:
  527. virtual void onSuccess(const std::list<mars::stn::TChannelInfo> &channelInfoList) = 0;
  528. virtual void onFalure(int errorCode) = 0;
  529. virtual ~GetChannelInfoCallback() {}
  530. };
  531. class GetUserInfoCallback {
  532. public:
  533. virtual void onSuccess(const std::list<TUserInfo> &userInfoList) = 0;
  534. virtual void onFalure(int errorCode) = 0;
  535. virtual ~GetUserInfoCallback() {}
  536. };
  537. class GetMyFriendsCallback {
  538. public:
  539. virtual void onSuccess(std::list<std::string> friendIdList) = 0;
  540. virtual void onFalure(int errorCode) = 0;
  541. virtual ~GetMyFriendsCallback() {}
  542. };
  543. class GetFriendRequestCallback {
  544. public:
  545. virtual void onSuccess(bool hasNewRequest) = 0;
  546. virtual void onFalure(int errorCode) = 0;
  547. virtual ~GetFriendRequestCallback() {}
  548. };
  549. class GetSettingCallback {
  550. public:
  551. virtual void onSuccess(bool hasNewRequest) = 0;
  552. virtual void onFalure(int errorCode) = 0;
  553. virtual ~GetSettingCallback() {}
  554. };
  555. enum ConnectionStatus {
  556. kConnectionStatusSecretKeyMismatch = -6,
  557. kConnectionStatusTokenIncorrect = -5,
  558. kConnectionStatusServerDown = -4,
  559. kConnectionStatusRejected = -3,
  560. kConnectionStatusLogout = -2,
  561. kConnectionStatusUnconnected = -1,
  562. kConnectionStatusConnecting = 0,
  563. kConnectionStatusConnected = 1,
  564. kConnectionStatusReceiving = 2
  565. };
  566. class ConnectionStatusCallback {
  567. public:
  568. virtual void onConnectionStatusChanged(ConnectionStatus connectionStatus) = 0;
  569. };
  570. class ReceiveMessageCallback {
  571. public:
  572. virtual void onReceiveMessage(const std::list<TMessage> &messageList, bool hasMore) = 0;
  573. virtual void onRecallMessage(const std::string &operatorId, long long messageUid) = 0;
  574. virtual void onDeleteMessage(long long messageUid) = 0;
  575. virtual void onUserReceivedMessage(const std::map<std::string, int64_t> &userReceived) = 0;
  576. virtual void onUserReadedMessage(const std::list<TReadEntry> &userReceived) = 0;
  577. };
  578. extern bool setAuthInfo(const std::string &userId, const std::string &token);
  579. extern void Disconnect(uint8_t flag);
  580. extern bool Connect(const std::string& host);
  581. extern void AppWillTerminate();
  582. extern void setConnectionStatusCallback(ConnectionStatusCallback *callback);
  583. extern void setReceiveMessageCallback(ReceiveMessageCallback *callback);
  584. extern void setDNSResult(std::vector<std::string> serverIPs);
  585. extern void setRefreshUserInfoCallback(GetUserInfoCallback *callback);
  586. extern void setRefreshGroupInfoCallback(GetGroupInfoCallback *callback);
  587. extern void setRefreshGroupMemberCallback(GetGroupMembersCallback *callback);
  588. extern void setRefreshChannelInfoCallback(GetChannelInfoCallback *callback);
  589. extern void setRefreshFriendListCallback(GetMyFriendsCallback *callback);
  590. extern void setRefreshFriendRequestCallback(GetFriendRequestCallback *callback);
  591. extern void setRefreshSettingCallback(GetSettingCallback *callback);
  592. extern ConnectionStatus getConnectionStatus();
  593. extern int64_t getServerDeltaTime();
  594. extern void setDeviceToken(const std::string &appName, const std::string &deviceToken, int pushType);
  595. extern long (*sendMessage)(TMessage &tmsg, SendMsgCallback *callback, int expireDuration);
  596. extern bool (*sendMessageEx)(long messageId, SendMsgCallback *callback, int expireDuration);
  597. extern void recallMessage(long long messageUid, GeneralOperationCallback *callback);
  598. extern void deleteRemoteMessage(long long messageUid, GeneralOperationCallback *callback);
  599. //请使用loadRemoteConversationMessages
  600. extern void loadRemoteMessages(const TConversation &conv, long long beforeUid, int count, LoadRemoteMessagesCallback *callback);
  601. extern void loadRemoteConversationMessages(const TConversation &conv, long long beforeUid, int count, LoadRemoteMessagesCallback *callback);
  602. extern void loadRemoteLineMessages(int type, long long beforeUid, int count, LoadRemoteMessagesCallback *callback);
  603. extern int uploadGeneralMedia(const std::string fileName, const std::string &mediaData, int mediaType, UpdateMediaCallback *callback);
  604. extern void getAuthorizedMediaUrl(int mediaType, const std::string &mediaUrl, GeneralStringCallback *callback);
  605. extern int modifyMyInfo(const std::list<std::pair<int, std::string>> &infos, GeneralOperationCallback *callback);
  606. extern int modifyUserSetting(int scope, const std::string &key, const std::string &value, GeneralOperationCallback *callback);
  607. extern void searchUser(const std::string &keyword, int searchType, int page, SearchUserCallback *callback);
  608. extern void sendFriendRequest(const std::string &userId, const std::string &reason, GeneralOperationCallback *callback);
  609. extern void loadFriendRequestFromRemote();
  610. extern void loadFriendFromRemote();
  611. extern void handleFriendRequest(const std::string &userId, bool accept, const std::string &extra, GeneralOperationCallback *callback);
  612. extern void deleteFriend(const std::string &userId, GeneralOperationCallback *callback);
  613. extern void setFriendAlias(const std::string &userId, const std::string &alias, GeneralOperationCallback *callback);
  614. extern void blackListRequest(const std::string &userId, bool blacked, GeneralOperationCallback *callback);
  615. extern void (*createGroup)(const std::string &groupId, const std::string &groupName, const std::string &groupPortrait, int groupType, const std::list<std::string> &groupMembers, const std::list<int> &notifyLines, TMessageContent &content, CreateGroupCallback *callback);
  616. extern void (*addMembers)(const std::string &groupId, const std::list<std::string> &members, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  617. extern void (*kickoffMembers)(const std::string &groupId, const std::list<std::string> &members, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  618. extern void (*quitGroup)(const std::string &groupId, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  619. extern void (*dismissGroup)(const std::string &groupId, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  620. extern void (*getGroupInfo)(const std::list<std::pair<std::string, int64_t>> &groupIdList, GetGroupInfoCallback *callback);
  621. extern void (*modifyGroupInfo)(const std::string &groupId, int type, const std::string &newValue, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  622. extern void (*modifyGroupAlias)(const std::string &groupId, const std::string &newAlias, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  623. extern void (*getGroupMembers)(const std::string &groupId, int64_t updateDt);
  624. extern void (*transferGroup)(const std::string &groupId, const std::string &newOwner, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  625. extern void SetGroupManager(const std::string &groupId, const std::list<std::string> userIds, int setOrDelete, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  626. extern void MuteGroupMember(const std::string &groupId, const std::list<std::string> userIds, int setOrDelete, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  627. extern void (*getUserInfo)(const std::list<std::pair<std::string, int64_t>> &userReqList, GetUserInfoCallback *callback);
  628. extern void reloadGroupInfoFromRemote(const std::list<std::pair<std::string, int64_t>> &groupReqList);
  629. extern void reloadUserInfoFromRemote(const std::list<std::pair<std::string, int64_t>> &userReqList);
  630. extern void reloadGroupMembersFromRemote(const std::string &groupId, int64_t updateDt);
  631. extern void clearFriendRequestUnread(int64_t maxDt);
  632. extern std::string getJoinedChatroom();
  633. extern void joinChatroom(const std::string &chatroomId, GeneralOperationCallback *callback);
  634. extern void quitChatroom(const std::string &chatroomId, GeneralOperationCallback *callback);
  635. extern void getChatroomInfo(const std::string &chatroomId, int64_t lastUpdateDt, GetChatroomInfoCallback *callback);
  636. extern void getChatroomMemberInfo(const std::string &chatroomId, int maxCount, GetChatroomMemberInfoCallback *callback);
  637. extern void syncConversationReadDt(int conversatinType, const std::string &target, int ine, int64_t readedDt, const std::list<std::string> &senders = std::list<std::string>(), long syncId = -1);
  638. extern void createChannel(const std::string &channelId, const std::string &channelName, const std::string &channelPortrait, int status, const std::string desc, const std::string &extra, const std::string &secret, const std::string &cb, CreateChannelCallback *callback);
  639. extern void modifyChannelInfo(const std::string &channelId, int type, const std::string &newValue, GeneralOperationCallback *callback);
  640. extern void transferChannel(const std::string &channelId, const std::string &newOwner, GeneralOperationCallback *callback);
  641. extern void destoryChannel(const std::string &channelId, GeneralOperationCallback *callback);
  642. extern void searchChannel(const std::string &keyword, bool puzzy, SearchChannelCallback *callback);
  643. extern void listenChannel(const std::string &channelId, bool listen, GeneralOperationCallback *callback);
  644. extern std::string GetImageThumbPara();
  645. extern void GetApplicationToken(const std::string &applicationId, GeneralStringCallback *callback);
  646. extern void KickoffPCClient(const std::string &pcClientId, GeneralOperationCallback *callback);
  647. extern bool IsCommercialServer();
  648. extern bool IsReceiptEnabled();
  649. extern bool filesystem_exists(const std::string &path);
  650. extern bool filesystem_create_directories(const std::string &path);
  651. extern bool filesystem_copy_file(const std::string &source, const std::string &dest, bool overwrite);
  652. extern bool filesystem_copy_files(const std::string &source, const std::string &dest);
  653. extern bool filesystem_remove(const std::string &path);
  654. extern void filesystem_copy_directory(const std::string &strSourceDir, const std::string &strDestDir);
  655. }
  656. }
  657. #endif /* proto_h */