proto.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  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), historyMessage(0), maxMemberCount(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. int historyMessage;
  136. int maxMemberCount;
  137. virtual ~TGroupInfo() {}
  138. #if WFCHAT_PROTO_SERIALIZABLE
  139. virtual void Serialize(void *writer) const;
  140. virtual void Unserialize(const Value& value);
  141. #endif //WFCHAT_PROTO_SERIALIZABLE
  142. };
  143. class TGroupMember : public TSerializable {
  144. public:
  145. TGroupMember() : type(0), updateDt(0), createDt(0) {}
  146. std::string groupId;
  147. std::string memberId;
  148. std::string alias;
  149. int type;
  150. int64_t updateDt;
  151. int64_t createDt;
  152. virtual ~TGroupMember() {}
  153. #if WFCHAT_PROTO_SERIALIZABLE
  154. virtual void Serialize(void *writer) const;
  155. virtual void Unserialize(const Value& value);
  156. #endif //WFCHAT_PROTO_SERIALIZABLE
  157. };
  158. class TUserInfo : public TSerializable {
  159. public:
  160. TUserInfo() : gender(0), type(0), deleted(0), updateDt(0) {}
  161. std::string uid;
  162. std::string name;
  163. std::string displayName;
  164. int gender;
  165. std::string portrait;
  166. std::string mobile;
  167. std::string email;
  168. std::string address;
  169. std::string company;
  170. std::string social;
  171. std::string extra;
  172. std::string friendAlias;
  173. std::string groupAlias;
  174. //0 normal; 1 robot; 2 thing;
  175. int type;
  176. int deleted;
  177. int64_t updateDt;
  178. virtual ~TUserInfo() {}
  179. #if WFCHAT_PROTO_SERIALIZABLE
  180. virtual void Serialize(void *writer) const;
  181. virtual void Unserialize(const Value& value);
  182. #endif //WFCHAT_PROTO_SERIALIZABLE
  183. };
  184. class TChatroomInfo : public TSerializable {
  185. public:
  186. TChatroomInfo() : title(""), desc(""), portrait(""), memberCount(0), createDt(0), updateDt(0), extra(""), state(0) {}
  187. std::string title;
  188. std::string desc;
  189. std::string portrait;
  190. int memberCount;
  191. int64_t createDt;
  192. int64_t updateDt;
  193. std::string extra;
  194. //0 normal; 1 not started; 2 end
  195. int state;
  196. virtual ~TChatroomInfo() {}
  197. #if WFCHAT_PROTO_SERIALIZABLE
  198. virtual void Serialize(void *writer) const;
  199. virtual void Unserialize(const Value& value);
  200. #endif //WFCHAT_PROTO_SERIALIZABLE
  201. };
  202. class TChatroomMemberInfo : public TSerializable {
  203. public:
  204. TChatroomMemberInfo() : memberCount(0) {}
  205. int memberCount;
  206. std::list<std::string> olderMembers;
  207. virtual ~TChatroomMemberInfo() {}
  208. #if WFCHAT_PROTO_SERIALIZABLE
  209. virtual void Serialize(void *writer) const;
  210. virtual void Unserialize(const Value& value);
  211. #endif //WFCHAT_PROTO_SERIALIZABLE
  212. };
  213. class TChannelInfo : public TSerializable {
  214. public:
  215. TChannelInfo() : status(0), updateDt(0), automatic(0) {}
  216. std::string channelId;
  217. std::string name;
  218. std::string portrait;
  219. std::string owner;
  220. int status;
  221. std::string desc;
  222. std::string extra;
  223. std::string secret;
  224. std::string callback;
  225. int64_t updateDt;
  226. int automatic;
  227. virtual ~TChannelInfo() {}
  228. #if WFCHAT_PROTO_SERIALIZABLE
  229. virtual void Serialize(void *writer) const;
  230. virtual void Unserialize(const Value& value);
  231. #endif //WFCHAT_PROTO_SERIALIZABLE
  232. };
  233. class TMessageContent : public TSerializable {
  234. public:
  235. TMessageContent() : type(0), mediaType(0), mentionedType(0) {}
  236. TMessageContent(const TMessageContent &c) :
  237. type(c.type),
  238. searchableContent(c.searchableContent),
  239. pushContent(c.pushContent),
  240. content(c.content),
  241. binaryContent(c.binaryContent),
  242. localContent(c.localContent),
  243. mediaType(c.mediaType),
  244. remoteMediaUrl(c.remoteMediaUrl),
  245. localMediaPath(c.localMediaPath),
  246. mentionedType(c.mentionedType),
  247. mentionedTargets(c.mentionedTargets),
  248. extra(c.extra) {}
  249. TMessageContent operator=(const TMessageContent &c) {
  250. type = c.type;
  251. searchableContent = c.searchableContent;
  252. pushContent = c.pushContent;
  253. content = c.content;
  254. binaryContent = c.binaryContent;
  255. localContent = c.localContent;
  256. mediaType = c.mediaType;
  257. remoteMediaUrl = c.remoteMediaUrl;
  258. localMediaPath = c.localMediaPath;
  259. mentionedType = c.mentionedType;
  260. mentionedTargets = c.mentionedTargets;
  261. extra = c.extra;
  262. return *this;
  263. }
  264. int type;
  265. std::string searchableContent;
  266. std::string pushContent;
  267. std::string content;
  268. std::string binaryContent;
  269. std::string localContent;
  270. int mediaType;
  271. std::string remoteMediaUrl;
  272. std::string localMediaPath;
  273. int mentionedType;
  274. std::list<std::string> mentionedTargets;
  275. std::string extra;
  276. virtual ~TMessageContent(){
  277. }
  278. #if WFCHAT_PROTO_SERIALIZABLE
  279. virtual void Serialize(void *writer) const;
  280. virtual void Unserialize(const Value& value);
  281. #endif //WFCHAT_PROTO_SERIALIZABLE
  282. };
  283. typedef enum {
  284. Message_Status_Sending,
  285. Message_Status_Sent,
  286. Message_Status_Send_Failure,
  287. Message_Status_Mentioned,
  288. Message_Status_AllMentioned,
  289. Message_Status_Unread,
  290. Message_Status_Readed,
  291. Message_Status_Played
  292. } MessageStatus;
  293. class TMessage : public TSerializable {
  294. public:
  295. TMessage() : conversationType(0), line(0), messageId(-1), direction(0), status(Message_Status_Sending), messageUid(0), timestamp(0) {}
  296. int conversationType;
  297. std::string target;
  298. int line;
  299. std::string from;
  300. TMessageContent content;
  301. long messageId;
  302. int direction;
  303. MessageStatus status;
  304. int64_t messageUid;
  305. int64_t timestamp;
  306. std::list<std::string> to;
  307. virtual ~TMessage(){}
  308. #if WFCHAT_PROTO_SERIALIZABLE
  309. virtual void Serialize(void *writer) const;
  310. virtual void Unserialize(const Value& value);
  311. #endif //WFCHAT_PROTO_SERIALIZABLE
  312. };
  313. class TUnreadCount : public TSerializable {
  314. public:
  315. TUnreadCount():unread(0),unreadMention(0),unreadMentionAll(0){}
  316. int unread;
  317. int unreadMention;
  318. int unreadMentionAll;
  319. #if WFCHAT_PROTO_SERIALIZABLE
  320. virtual void Serialize(void *writer) const;
  321. virtual void Unserialize(const Value& value);
  322. #endif //WFCHAT_PROTO_SERIALIZABLE
  323. };
  324. class TConversation : public TSerializable {
  325. public:
  326. TConversation() : conversationType(0), line(0), lastMessage() , timestamp(0), unreadCount(), isTop(false), isSilent(false) {}
  327. int conversationType;
  328. std::string target;
  329. int line;
  330. TMessage lastMessage;
  331. int64_t timestamp;
  332. std::string draft;
  333. TUnreadCount unreadCount;
  334. bool isTop;
  335. bool isSilent;
  336. virtual ~TConversation(){}
  337. #if WFCHAT_PROTO_SERIALIZABLE
  338. virtual void Serialize(void *writer) const;
  339. virtual void Unserialize(const Value& value);
  340. #endif //WFCHAT_PROTO_SERIALIZABLE
  341. };
  342. class TConversationSearchresult : public TSerializable {
  343. public:
  344. TConversationSearchresult() : conversationType(0), line(0), marchedMessage(), timestamp(0), marchedCount(0) {}
  345. int conversationType;
  346. std::string target;
  347. int line;
  348. //only marchedCount == 1, load the message
  349. TMessage marchedMessage;
  350. int64_t timestamp;
  351. int marchedCount;
  352. virtual ~TConversationSearchresult(){}
  353. #if WFCHAT_PROTO_SERIALIZABLE
  354. virtual void Serialize(void *writer) const;
  355. virtual void Unserialize(const Value& value);
  356. #endif //WFCHAT_PROTO_SERIALIZABLE
  357. };
  358. class TGroupSearchResult : public TSerializable {
  359. public:
  360. TGroupSearchResult() : marchedType(-1) {}
  361. TGroupInfo groupInfo;
  362. int marchedType; //0 march name, 1 march group member, 2 both
  363. std::list<std::string> marchedMemberNames;
  364. virtual ~TGroupSearchResult(){}
  365. #if WFCHAT_PROTO_SERIALIZABLE
  366. virtual void Serialize(void *writer) const;
  367. virtual void Unserialize(const Value& value);
  368. #endif //WFCHAT_PROTO_SERIALIZABLE
  369. };
  370. class TFriendRequest : public TSerializable {
  371. public:
  372. TFriendRequest() : direction(0), status(0), readStatus(0), timestamp(0) {}
  373. int direction;
  374. std::string target;
  375. std::string reason;
  376. int status;
  377. int readStatus;
  378. int64_t timestamp;
  379. virtual ~TFriendRequest(){}
  380. #if WFCHAT_PROTO_SERIALIZABLE
  381. virtual void Serialize(void *writer) const;
  382. virtual void Unserialize(const Value& value);
  383. #endif //WFCHAT_PROTO_SERIALIZABLE
  384. };
  385. enum UserSettingScope {
  386. kUserSettingConversationSilent = 1,
  387. kUserSettingGlobalSilent = 2,
  388. kUserSettingConversationTop = 3,
  389. kUserSettingHiddenNotificationDetail = 4,
  390. kUserSettinGroupHideNickname = 5,
  391. kUserSettingFavouriteGroup = 6,
  392. kUserSettingConversationSync = 7,
  393. kUserSettingMyChannels = 8,
  394. kUserSettingListenedChannels = 9,
  395. kUserSettingPCOnline = 10,
  396. kUserSettingConversationReaded = 11,
  397. kUserSettingWebOnline = 12,
  398. kUserSettingDisableRecipt = 13,
  399. kUserSettingCustomBegin = 1000
  400. };
  401. class TUserSettingEntry : public TSerializable {
  402. public:
  403. TUserSettingEntry() : scope(kUserSettingCustomBegin), updateDt(0) {}
  404. UserSettingScope scope;
  405. std::string key;
  406. std::string value;
  407. int64_t updateDt;
  408. virtual ~TUserSettingEntry(){}
  409. #if WFCHAT_PROTO_SERIALIZABLE
  410. virtual void Serialize(void *writer) const;
  411. virtual void Unserialize(const Value& value);
  412. #endif //WFCHAT_PROTO_SERIALIZABLE
  413. };
  414. class TReadEntry : public TSerializable {
  415. public:
  416. TReadEntry() : conversationType(0), line(0), readDt(0) {}
  417. std::string userId;
  418. int conversationType;
  419. std::string target;
  420. int line;
  421. int64_t readDt;
  422. virtual ~TReadEntry(){}
  423. #if WFCHAT_PROTO_SERIALIZABLE
  424. virtual void Serialize(void *writer) const;
  425. virtual void Unserialize(const Value& value);
  426. #endif //WFCHAT_PROTO_SERIALIZABLE
  427. };
  428. class TDeliveryEntry : public TSerializable {
  429. public:
  430. TDeliveryEntry() : rcvdDt(0) {}
  431. std::string userId;
  432. int64_t rcvdDt;
  433. virtual ~TDeliveryEntry(){}
  434. #if WFCHAT_PROTO_SERIALIZABLE
  435. virtual void Serialize(void *writer) const;
  436. virtual void Unserialize(const Value& value);
  437. #endif //WFCHAT_PROTO_SERIALIZABLE
  438. };
  439. class GeneralStringCallback {
  440. public:
  441. virtual void onSuccess(std::string key) = 0;
  442. virtual void onFalure(int errorCode) = 0;
  443. virtual ~GeneralStringCallback() {}
  444. };
  445. class UploadMediaCallback {
  446. public:
  447. virtual void onSuccess(std::string key) = 0;
  448. virtual void onFalure(int errorCode) = 0;
  449. virtual void onProgress(int current, int total) = 0;
  450. virtual ~UploadMediaCallback() {}
  451. };
  452. class SendMsgCallback {
  453. public:
  454. virtual void onPrepared(long messageId, int64_t savedTime) = 0;
  455. virtual void onMediaUploaded(std::string remoteUrl) = 0;
  456. virtual void onSuccess(long long messageUid, long long timestamp) = 0;
  457. virtual void onFalure(int errorCode) = 0;
  458. virtual void onProgress(int uploaded, int total) = 0;
  459. virtual ~SendMsgCallback() {}
  460. };
  461. class UpdateMediaCallback {
  462. public:
  463. virtual void onSuccess(const std::string &remoteUrl) = 0;
  464. virtual void onFalure(int errorCode) = 0;
  465. virtual void onProgress(int current, int total) = 0;
  466. virtual ~UpdateMediaCallback() {}
  467. };
  468. class SearchUserCallback {
  469. public:
  470. virtual void onSuccess(const std::list<TUserInfo> &users, const std::string &keyword, int page) = 0;
  471. virtual void onFalure(int errorCode) = 0;
  472. virtual ~SearchUserCallback() {}
  473. };
  474. class SearchChannelCallback {
  475. public:
  476. virtual void onSuccess(const std::list<TChannelInfo> &channels, const std::string &keyword) = 0;
  477. virtual void onFalure(int errorCode) = 0;
  478. virtual ~SearchChannelCallback() {}
  479. };
  480. class CreateGroupCallback {
  481. public:
  482. virtual void onSuccess(std::string groupId) = 0;
  483. virtual void onFalure(int errorCode) = 0;
  484. virtual ~CreateGroupCallback() {}
  485. };
  486. class CreateChannelCallback {
  487. public:
  488. virtual void onSuccess(const TChannelInfo &channelInfo) = 0;
  489. virtual void onFalure(int errorCode) = 0;
  490. virtual ~CreateChannelCallback() {}
  491. };
  492. class GeneralOperationCallback {
  493. public:
  494. virtual void onSuccess() = 0;
  495. virtual void onFalure(int errorCode) = 0;
  496. virtual ~GeneralOperationCallback() {}
  497. };
  498. class LoadRemoteMessagesCallback {
  499. public:
  500. virtual void onSuccess(const std::list<TMessage> &messageList) = 0;
  501. virtual void onFalure(int errorCode) = 0;
  502. virtual ~LoadRemoteMessagesCallback() {}
  503. };
  504. class GetChatroomInfoCallback {
  505. public:
  506. virtual void onSuccess(const TChatroomInfo &info) = 0;
  507. virtual void onFalure(int errorCode) = 0;
  508. virtual ~GetChatroomInfoCallback() {}
  509. };
  510. class GetChatroomMemberInfoCallback {
  511. public:
  512. virtual void onSuccess(const TChatroomMemberInfo &info) = 0;
  513. virtual void onFalure(int errorCode) = 0;
  514. virtual ~GetChatroomMemberInfoCallback() {}
  515. };
  516. class GetGroupInfoCallback {
  517. public:
  518. virtual void onSuccess(const std::list<mars::stn::TGroupInfo> &groupInfoList) = 0;
  519. virtual void onFalure(int errorCode) = 0;
  520. virtual ~GetGroupInfoCallback() {}
  521. };
  522. class GetGroupMembersCallback {
  523. public:
  524. virtual void onSuccess(const std::string &groupId, const std::list<mars::stn::TGroupMember> &groupMemberList) = 0;
  525. virtual void onFalure(int errorCode) = 0;
  526. virtual ~GetGroupMembersCallback() {}
  527. };
  528. class GetChannelInfoCallback {
  529. public:
  530. virtual void onSuccess(const std::list<mars::stn::TChannelInfo> &channelInfoList) = 0;
  531. virtual void onFalure(int errorCode) = 0;
  532. virtual ~GetChannelInfoCallback() {}
  533. };
  534. class GetUserInfoCallback {
  535. public:
  536. virtual void onSuccess(const std::list<TUserInfo> &userInfoList) = 0;
  537. virtual void onFalure(int errorCode) = 0;
  538. virtual ~GetUserInfoCallback() {}
  539. };
  540. class GetMyFriendsCallback {
  541. public:
  542. virtual void onSuccess(std::list<std::string> friendIdList) = 0;
  543. virtual void onFalure(int errorCode) = 0;
  544. virtual ~GetMyFriendsCallback() {}
  545. };
  546. class GetFriendRequestCallback {
  547. public:
  548. virtual void onSuccess(bool hasNewRequest) = 0;
  549. virtual void onFalure(int errorCode) = 0;
  550. virtual ~GetFriendRequestCallback() {}
  551. };
  552. class GetSettingCallback {
  553. public:
  554. virtual void onSuccess(bool hasNewRequest) = 0;
  555. virtual void onFalure(int errorCode) = 0;
  556. virtual ~GetSettingCallback() {}
  557. };
  558. enum ConnectionStatus {
  559. kConnectionStatusSecretKeyMismatch = -6,
  560. kConnectionStatusTokenIncorrect = -5,
  561. kConnectionStatusServerDown = -4,
  562. kConnectionStatusRejected = -3,
  563. kConnectionStatusLogout = -2,
  564. kConnectionStatusUnconnected = -1,
  565. kConnectionStatusConnecting = 0,
  566. kConnectionStatusConnected = 1,
  567. kConnectionStatusReceiving = 2
  568. };
  569. class ConnectionStatusCallback {
  570. public:
  571. virtual void onConnectionStatusChanged(ConnectionStatus connectionStatus) = 0;
  572. };
  573. class ReceiveMessageCallback {
  574. public:
  575. virtual void onReceiveMessage(const std::list<TMessage> &messageList, bool hasMore) = 0;
  576. virtual void onRecallMessage(const std::string &operatorId, long long messageUid) = 0;
  577. virtual void onDeleteMessage(long long messageUid) = 0;
  578. virtual void onUserReceivedMessage(const std::map<std::string, int64_t> &userReceived) = 0;
  579. virtual void onUserReadedMessage(const std::list<TReadEntry> &userReceived) = 0;
  580. };
  581. extern bool setAuthInfo(const std::string &userId, const std::string &token);
  582. extern void Disconnect(uint8_t flag);
  583. extern bool Connect(const std::string& host);
  584. extern void AppWillTerminate();
  585. extern void setConnectionStatusCallback(ConnectionStatusCallback *callback);
  586. extern void setReceiveMessageCallback(ReceiveMessageCallback *callback);
  587. extern void setDNSResult(std::vector<std::string> serverIPs);
  588. extern void setRefreshUserInfoCallback(GetUserInfoCallback *callback);
  589. extern void setRefreshGroupInfoCallback(GetGroupInfoCallback *callback);
  590. extern void setRefreshGroupMemberCallback(GetGroupMembersCallback *callback);
  591. extern void setRefreshChannelInfoCallback(GetChannelInfoCallback *callback);
  592. extern void setRefreshFriendListCallback(GetMyFriendsCallback *callback);
  593. extern void setRefreshFriendRequestCallback(GetFriendRequestCallback *callback);
  594. extern void setRefreshSettingCallback(GetSettingCallback *callback);
  595. extern ConnectionStatus getConnectionStatus();
  596. extern int64_t getServerDeltaTime();
  597. extern void setDeviceToken(const std::string &appName, const std::string &deviceToken, int pushType);
  598. extern long (*sendMessage)(TMessage &tmsg, SendMsgCallback *callback, int expireDuration);
  599. extern bool (*sendMessageEx)(long messageId, SendMsgCallback *callback, int expireDuration);
  600. extern void recallMessage(long long messageUid, GeneralOperationCallback *callback);
  601. extern void deleteRemoteMessage(long long messageUid, GeneralOperationCallback *callback);
  602. //请使用loadRemoteConversationMessages
  603. extern void loadRemoteMessages(const TConversation &conv, long long beforeUid, int count, LoadRemoteMessagesCallback *callback);
  604. extern void loadRemoteConversationMessages(const TConversation &conv, long long beforeUid, int count, LoadRemoteMessagesCallback *callback);
  605. extern void loadRemoteLineMessages(int type, long long beforeUid, int count, LoadRemoteMessagesCallback *callback);
  606. extern int uploadGeneralMedia(const std::string fileName, const std::string &mediaData, int mediaType, UpdateMediaCallback *callback);
  607. extern void getAuthorizedMediaUrl(int mediaType, const std::string &mediaUrl, GeneralStringCallback *callback);
  608. extern int modifyMyInfo(const std::list<std::pair<int, std::string>> &infos, GeneralOperationCallback *callback);
  609. extern int modifyUserSetting(int scope, const std::string &key, const std::string &value, GeneralOperationCallback *callback);
  610. extern void searchUser(const std::string &keyword, int searchType, int page, SearchUserCallback *callback);
  611. extern void sendFriendRequest(const std::string &userId, const std::string &reason, GeneralOperationCallback *callback);
  612. extern void loadFriendRequestFromRemote();
  613. extern void loadFriendFromRemote();
  614. extern void handleFriendRequest(const std::string &userId, bool accept, const std::string &extra, GeneralOperationCallback *callback);
  615. extern void deleteFriend(const std::string &userId, GeneralOperationCallback *callback);
  616. extern void setFriendAlias(const std::string &userId, const std::string &alias, GeneralOperationCallback *callback);
  617. extern void blackListRequest(const std::string &userId, bool blacked, GeneralOperationCallback *callback);
  618. 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);
  619. extern void (*addMembers)(const std::string &groupId, const std::list<std::string> &members, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  620. extern void (*kickoffMembers)(const std::string &groupId, const std::list<std::string> &members, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  621. extern void (*quitGroup)(const std::string &groupId, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  622. extern void (*dismissGroup)(const std::string &groupId, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  623. extern void (*getGroupInfo)(const std::list<std::pair<std::string, int64_t>> &groupIdList, GetGroupInfoCallback *callback);
  624. extern void (*modifyGroupInfo)(const std::string &groupId, int type, const std::string &newValue, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  625. extern void (*modifyGroupAlias)(const std::string &groupId, const std::string &newAlias, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  626. extern void (*getGroupMembers)(const std::string &groupId, int64_t updateDt);
  627. extern void (*transferGroup)(const std::string &groupId, const std::string &newOwner, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  628. extern void SetGroupManager(const std::string &groupId, const std::list<std::string> userIds, int setOrDelete, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  629. extern void MuteGroupMember(const std::string &groupId, const std::list<std::string> userIds, int setOrDelete, const std::list<int> &notifyLines, TMessageContent &content, GeneralOperationCallback *callback);
  630. extern void (*getUserInfo)(const std::list<std::pair<std::string, int64_t>> &userReqList, GetUserInfoCallback *callback);
  631. extern void reloadGroupInfoFromRemote(const std::list<std::pair<std::string, int64_t>> &groupReqList);
  632. extern void reloadUserInfoFromRemote(const std::list<std::pair<std::string, int64_t>> &userReqList);
  633. extern void reloadGroupMembersFromRemote(const std::string &groupId, int64_t updateDt);
  634. extern void clearFriendRequestUnread(int64_t maxDt);
  635. extern std::string getJoinedChatroom();
  636. extern void joinChatroom(const std::string &chatroomId, GeneralOperationCallback *callback);
  637. extern void quitChatroom(const std::string &chatroomId, GeneralOperationCallback *callback);
  638. extern void getChatroomInfo(const std::string &chatroomId, int64_t lastUpdateDt, GetChatroomInfoCallback *callback);
  639. extern void getChatroomMemberInfo(const std::string &chatroomId, int maxCount, GetChatroomMemberInfoCallback *callback);
  640. 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);
  641. 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);
  642. extern void modifyChannelInfo(const std::string &channelId, int type, const std::string &newValue, GeneralOperationCallback *callback);
  643. extern void transferChannel(const std::string &channelId, const std::string &newOwner, GeneralOperationCallback *callback);
  644. extern void destoryChannel(const std::string &channelId, GeneralOperationCallback *callback);
  645. extern void searchChannel(const std::string &keyword, bool puzzy, SearchChannelCallback *callback);
  646. extern void listenChannel(const std::string &channelId, bool listen, GeneralOperationCallback *callback);
  647. extern std::string GetImageThumbPara();
  648. extern void GetApplicationToken(const std::string &applicationId, GeneralStringCallback *callback);
  649. extern void KickoffPCClient(const std::string &pcClientId, GeneralOperationCallback *callback);
  650. extern bool IsCommercialServer();
  651. extern bool IsReceiptEnabled();
  652. extern bool filesystem_exists(const std::string &path);
  653. extern bool filesystem_create_directories(const std::string &path);
  654. extern bool filesystem_copy_file(const std::string &source, const std::string &dest, bool overwrite);
  655. extern bool filesystem_copy_files(const std::string &source, const std::string &dest);
  656. extern bool filesystem_remove(const std::string &path);
  657. extern void filesystem_copy_directory(const std::string &strSourceDir, const std::string &strDestDir);
  658. }
  659. }
  660. #endif /* proto_h */