Aucune description

IEMContactManager.h 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /*!
  2. * \~chinese
  3. * @header IEMContactManager.h
  4. * @abstract 此协议定义了好友相关操作
  5. * @author Hyphenate
  6. * @version 3.00
  7. *
  8. * \~english
  9. * @header IEMContactManager.h
  10. * @abstract The protocol defines the operations of contact
  11. * @author Hyphenate
  12. * @version 3.00
  13. */
  14. #import <Foundation/Foundation.h>
  15. #import "EMContactManagerDelegate.h"
  16. @class EMError;
  17. /*!
  18. * \~chinese
  19. * 好友相关操作
  20. *
  21. * \~english
  22. * Contact Management
  23. */
  24. @protocol IEMContactManager <NSObject>
  25. @required
  26. #pragma mark - Delegate
  27. /*!
  28. * \~chinese
  29. * 添加回调代理
  30. *
  31. * @param aDelegate 要添加的代理
  32. * @param aQueue 执行代理方法的队列
  33. *
  34. * \~english
  35. * Add delegate
  36. *
  37. * @param aDelegate Delegate
  38. * @param aQueue The queue of call delegate method
  39. */
  40. - (void)addDelegate:(id<EMContactManagerDelegate>)aDelegate
  41. delegateQueue:(dispatch_queue_t)aQueue;
  42. /*!
  43. * \~chinese
  44. * 添加回调代理
  45. *
  46. * @param aDelegate 要添加的代理
  47. *
  48. * \~english
  49. * Add delegate
  50. *
  51. * @param aDelegate Delegate
  52. */
  53. - (void)addDelegate:(id<EMContactManagerDelegate>)aDelegate;
  54. /*!
  55. * \~chinese
  56. * 移除回调代理
  57. *
  58. * @param aDelegate 要移除的代理
  59. *
  60. * \~english
  61. * Remove delegate
  62. *
  63. * @param aDelegate Delegate
  64. */
  65. - (void)removeDelegate:(id)aDelegate;
  66. /*!
  67. * \~chinese
  68. * 获取本地存储的所有好友
  69. *
  70. * @result 好友列表<NSString>
  71. *
  72. * \~english
  73. * Get all contacts
  74. *
  75. * @result Contact list<EMGroup>
  76. */
  77. - (NSArray *)getContacts;
  78. /*!
  79. * \~chinese
  80. * 从本地获取黑名单列表
  81. *
  82. * @result 黑名单列表<NSString>
  83. *
  84. * \~english
  85. * Get the blacklist of blocked users
  86. *
  87. * @result Blacklist<EMGroup>
  88. */
  89. - (NSArray *)getBlackList;
  90. #pragma mark - Sync method
  91. /*!
  92. * \~chinese
  93. * 从服务器获取所有的好友
  94. *
  95. * 同步方法,会阻塞当前线程
  96. *
  97. * @param pError 错误信息
  98. *
  99. * @return 好友列表<NSString>
  100. *
  101. * \~english
  102. * Get all the contacts from the server
  103. *
  104. * @param pError Error
  105. *
  106. * @return Contact list<NSString>
  107. */
  108. - (NSArray *)getContactsFromServerWithError:(EMError **)pError;
  109. /*!
  110. * \~chinese
  111. * 添加好友
  112. *
  113. * 同步方法,会阻塞当前线程
  114. *
  115. * @param aUsername 要添加的用户
  116. * @param aMessage 邀请信息
  117. *
  118. * @return 错误信息
  119. *
  120. * \~english
  121. * Add a contact with invitation message
  122. *
  123. * @param aUsername The user to add
  124. * @param aMessage Invitation message
  125. *
  126. * @return Error
  127. */
  128. - (EMError *)addContact:(NSString *)aUsername
  129. message:(NSString *)aMessage;
  130. /*!
  131. * \~chinese
  132. * 删除好友
  133. *
  134. * 同步方法,会阻塞当前线程
  135. *
  136. * @param aUsername 要删除的好友
  137. * @param aIsDeleteConversation 是否删除会话
  138. *
  139. * @return 错误信息
  140. *
  141. * \~english
  142. * Delete a contact
  143. *
  144. * @param aUsername The user to delete
  145. * @param aIsDeleteConversation Delete the conversation or not
  146. *
  147. * @return Error
  148. */
  149. - (EMError *)deleteContact:(NSString *)aUsername
  150. isDeleteConversation:(BOOL)aIsDeleteConversation;
  151. #pragma mark - Black List
  152. /*!
  153. * \~chinese
  154. * 从服务器获取黑名单列表
  155. *
  156. * 同步方法,会阻塞当前线程
  157. *
  158. * @param pError 错误信息
  159. *
  160. * @return 黑名单列表<NSString>
  161. *
  162. * \~english
  163. * Get the blacklist from the server
  164. *
  165. * @param pError Error
  166. *
  167. * @return Blacklist<NSString>
  168. */
  169. - (NSArray *)getBlackListFromServerWithError:(EMError **)pError;
  170. /*!
  171. * \~chinese
  172. * 将用户加入黑名单
  173. *
  174. * 同步方法,会阻塞当前线程
  175. *
  176. * @param aUsername 要加入黑命单的用户
  177. * @param aBoth 是否同时屏蔽发给对方的消息
  178. *
  179. * @return 错误信息
  180. *
  181. * \~english
  182. * Add a user to blacklist
  183. *
  184. * @param aUsername Block user
  185. * @param aBoth if aBoth is YES, then hide user and block messages from blocked user; if NO, then hide user from blocked user
  186. *
  187. * @return Error
  188. */
  189. - (EMError *)addUserToBlackList:(NSString *)aUsername
  190. relationshipBoth:(BOOL)aBoth;
  191. /*!
  192. * \~chinese
  193. * 将用户移出黑名单
  194. *
  195. * 同步方法,会阻塞当前线程
  196. *
  197. * @param aUsername 要移出黑命单的用户
  198. *
  199. * @return 错误信息
  200. *
  201. * \~english
  202. * Remove user out of blacklist
  203. *
  204. * @param aUsername Unblock user
  205. *
  206. * @return Error
  207. */
  208. - (EMError *)removeUserFromBlackList:(NSString *)aUsername;
  209. /*!
  210. * \~chinese
  211. * 同意加好友的申请
  212. *
  213. * 同步方法,会阻塞当前线程
  214. *
  215. * @param aUsername 申请者
  216. *
  217. * @return 错误信息
  218. *
  219. * \~english
  220. * Accept a friend request
  221. *
  222. * @param aUsername User who initiated the friend request
  223. *
  224. * @return Error
  225. */
  226. - (EMError *)acceptInvitationForUsername:(NSString *)aUsername;
  227. /*!
  228. * \~chinese
  229. * 拒绝加好友的申请
  230. *
  231. * 同步方法,会阻塞当前线程
  232. *
  233. * @param aUsername 申请者
  234. *
  235. * @return 错误信息
  236. *
  237. * \~english
  238. * Decline a friend request
  239. *
  240. * @param aUsername User who initiated the friend request
  241. *
  242. * @return Error
  243. *
  244. * Please use the new method
  245. * - (void)declineFriendRequestFromUser:(NSString *)aUsername
  246. * completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  247. */
  248. - (EMError *)declineInvitationForUsername:(NSString *)aUsername;
  249. #pragma mark - Async method
  250. /*!
  251. * \~chinese
  252. * 从服务器获取所有的好友
  253. *
  254. * @param aCompletionBlock 完成的回调
  255. *
  256. * \~english
  257. * Get all contacts from the server
  258. *
  259. * @param aCompletionBlock The callback block of completion
  260. *
  261. */
  262. - (void)getContactsFromServerWithCompletion:(void (^)(NSArray *aList, EMError *aError))aCompletionBlock;
  263. /*!
  264. * \~chinese
  265. * 添加好友
  266. *
  267. * @param aUsername 要添加的用户
  268. * @param aMessage 邀请信息
  269. * @param aCompletionBlock 完成的回调
  270. *
  271. * \~english
  272. * Add a contact
  273. *
  274. * @param aUsername The user to be added
  275. * @param aMessage Friend request message
  276. * @param aCompletionBlock The callback block of completion
  277. *
  278. */
  279. - (void)addContact:(NSString *)aUsername
  280. message:(NSString *)aMessage
  281. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  282. /*!
  283. * \~chinese
  284. * 删除好友
  285. *
  286. * @param aUsername 要删除的好友
  287. * @param aDeleteConversation 是否删除会话
  288. * @param aCompletionBlock 完成的回调
  289. *
  290. * \~english
  291. * Delete a contact
  292. *
  293. * @param aUsername The user to be deleted
  294. * @param aIsDeleteConversation Delete the conversation or not
  295. * @param aCompletionBlock The callback block of completion
  296. *
  297. */
  298. - (void)deleteContact:(NSString *)aUsername
  299. isDeleteConversation:(BOOL)aIsDeleteConversation
  300. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  301. /*!
  302. * \~chinese
  303. * 从服务器获取黑名单列表
  304. *
  305. * @param aCompletionBlock 完成的回调
  306. *
  307. * \~english
  308. * Get the blacklist from the server
  309. *
  310. * @param aCompletionBlock The callback block of completion
  311. *
  312. */
  313. - (void)getBlackListFromServerWithCompletion:(void (^)(NSArray *aList, EMError *aError))aCompletionBlock;
  314. /*!
  315. * \~chinese
  316. * 将用户加入黑名单
  317. *
  318. * @param aUsername 要加入黑命单的用户
  319. * @param aCompletionBlock 完成的回调
  320. *
  321. * \~english
  322. * Add a user to blacklist
  323. *
  324. * @param aUsername Block user
  325. * @param aCompletionBlock The callback block of completion
  326. *
  327. */
  328. - (void)addUserToBlackList:(NSString *)aUsername
  329. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  330. /*!
  331. * \~chinese
  332. * 将用户移出黑名单
  333. *
  334. * @param aUsername 要移出黑命单的用户
  335. * @param aCompletionBlock 完成的回调
  336. *
  337. * \~english
  338. * Remove a user from blacklist
  339. *
  340. * @param aUsername Unblock user
  341. * @param aCompletionBlock The callback block of completion
  342. *
  343. */
  344. - (void)removeUserFromBlackList:(NSString *)aUsername
  345. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  346. /*!
  347. * \~chinese
  348. * 同意加好友的申请
  349. *
  350. * @param aUsername 申请者
  351. * @param aCompletionBlock 完成的回调
  352. *
  353. * \~english
  354. * Apporove a friend request
  355. *
  356. * @param aUsername User who initiated the friend request
  357. * @param aCompletionBlock The callback block of completion
  358. *
  359. */
  360. - (void)approveFriendRequestFromUser:(NSString *)aUsername
  361. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  362. /*!
  363. * \~chinese
  364. * 拒绝加好友的申请
  365. *
  366. * @param aUsername 申请者
  367. * @param aCompletionBlock 完成的回调
  368. *
  369. * \~english
  370. * Decline a friend request
  371. *
  372. * @param aUsername User who initiated the friend request
  373. * @param aCompletionBlock The callback block of completion
  374. *
  375. */
  376. - (void)declineFriendRequestFromUser:(NSString *)aUsername
  377. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  378. #pragma mark - Deprecated methods
  379. /*!
  380. * \~chinese
  381. * 从数据库获取所有的好友
  382. *
  383. * @return 好友列表<NSString>
  384. *
  385. * \~english
  386. * Get all the friends from the DB
  387. *
  388. * @return Contact list<NSString>
  389. */
  390. - (NSArray *)getContactsFromDB __deprecated_msg("Use -getContacts");
  391. /*!
  392. * \~chinese
  393. * 从数据库获取黑名单列表
  394. *
  395. * @return 黑名单列表<NSString>
  396. *
  397. * \~english
  398. * Get the blacklist from the DB
  399. *
  400. * @return Blacklist<NSString>
  401. */
  402. - (NSArray *)getBlackListFromDB __deprecated_msg("Use -getBlackList");
  403. /*!
  404. * \~chinese
  405. * 从服务器获取所有的好友
  406. *
  407. * @param aSuccessBlock 成功的回调
  408. * @param aFailureBlock 失败的回调
  409. *
  410. * \~english
  411. * Get all the friends from the server
  412. *
  413. * @param aSuccessBlock The callback block of success
  414. * @param aFailureBlock The callback block of failure
  415. *
  416. */
  417. - (void)asyncGetContactsFromServer:(void (^)(NSArray *aList))aSuccessBlock
  418. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -getContactsFromServerWithCompletion:");
  419. /*!
  420. * \~chinese
  421. * 添加好友
  422. *
  423. * @param aUsername 要添加的用户
  424. * @param aMessage 邀请信息
  425. * @param aSuccessBlock 成功的回调
  426. * @param aFailureBlock 失败的回调
  427. *
  428. * \~english
  429. * Add a contact
  430. *
  431. * @param aUsername The user to add
  432. * @param aMessage Friend invitation message
  433. * @param aSuccessBlock The callback block of success
  434. * @param aFailureBlock The callback block of failure
  435. *
  436. */
  437. - (void)asyncAddContact:(NSString *)aUsername
  438. message:(NSString *)aMessage
  439. success:(void (^)())aSuccessBlock
  440. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -addContact:message:completion:");
  441. /*!
  442. * \~chinese
  443. * 删除好友
  444. *
  445. * 同步方法,会阻塞当前线程
  446. *
  447. * @param aUsername 要删除的好友
  448. *
  449. * @return 错误信息
  450. *
  451. * \~english
  452. * Delete a contact
  453. *
  454. * @param aUsername The user to delete
  455. *
  456. * @return Error
  457. */
  458. - (EMError *)deleteContact:(NSString *)aUsername __deprecated_msg("Use -deleteContact:username:isDeleteConversation:");
  459. /*!
  460. * \~chinese
  461. * 删除好友
  462. *
  463. * @param aUsername 要删除的好友
  464. * @param aCompletionBlock 完成的回调
  465. *
  466. * \~english
  467. * Delete a contact
  468. *
  469. * @param aUsername The user to be deleted
  470. * @param aCompletionBlock The callback block of completion
  471. *
  472. */
  473. - (void)deleteContact:(NSString *)aUsername
  474. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock __deprecated_msg("Use -deleteContact:username:isDeleteConversation:");
  475. /*!
  476. * \~chinese
  477. * 删除好友
  478. *
  479. * @param aUsername 要删除的好友
  480. * @param aSuccessBlock 成功的回调
  481. * @param aFailureBlock 失败的回调
  482. *
  483. * \~english
  484. * Delete friend
  485. *
  486. * @param aUsername The user to delete
  487. * @param aSuccessBlock The callback block of success
  488. * @param aFailureBlock The callback block of failure
  489. *
  490. */
  491. - (void)asyncDeleteContact:(NSString *)aUsername
  492. success:(void (^)())aSuccessBlock
  493. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -deleteContact:completion:");
  494. /*!
  495. * \~chinese
  496. * 从服务器获取黑名单列表
  497. *
  498. * @param aSuccessBlock 成功的回调
  499. * @param aFailureBlock 失败的回调
  500. *
  501. * \~english
  502. * Get the blacklist from the server
  503. *
  504. * @param aSuccessBlock The callback block of success
  505. * @param aFailureBlock The callback block of failure
  506. *
  507. */
  508. - (void)asyncGetBlackListFromServer:(void (^)(NSArray *aList))aSuccessBlock
  509. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -getBlackListFromServerWithCompletion:");
  510. /*!
  511. * \~chinese
  512. * 将用户加入黑名单
  513. *
  514. * @param aUsername 要加入黑命单的用户
  515. * @param aBoth 是否同时屏蔽发给对方的消息
  516. * @param aSuccessBlock 成功的回调
  517. * @param aFailureBlock 失败的回调
  518. *
  519. * \~english
  520. * Add user to blacklist
  521. *
  522. * @param aUsername The user to add
  523. * @param aBoth Whether block messages from me to the user which is added to the black list
  524. * @param aSuccessBlock The callback block of success
  525. * @param aFailureBlock The callback block of failure
  526. *
  527. */
  528. - (void)asyncAddUserToBlackList:(NSString *)aUsername
  529. relationshipBoth:(BOOL)aBoth
  530. success:(void (^)())aSuccessBlock
  531. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -addUserToBlackList:completion:");
  532. /*!
  533. * \~chinese
  534. * 将用户移出黑名单
  535. *
  536. * @param aUsername 要移出黑命单的用户
  537. * @param aSuccessBlock 成功的回调
  538. * @param aFailureBlock 失败的回调
  539. *
  540. * \~english
  541. * Remove user from blacklist
  542. *
  543. * @param aUsername The user to remove from blacklist
  544. * @param aSuccessBlock The callback block of success
  545. * @param aFailureBlock The callback block of failure
  546. *
  547. */
  548. - (void)asyncRemoveUserFromBlackList:(NSString *)aUsername
  549. success:(void (^)())aSuccessBlock
  550. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -removeUserFromBlackList:completion:");
  551. /*!
  552. * \~chinese
  553. * 同意加好友的申请
  554. *
  555. * @param aUsername 申请者
  556. * @param aSuccessBlock 成功的回调
  557. * @param aFailureBlock 失败的回调
  558. *
  559. * \~english
  560. * Agree invitation
  561. *
  562. * @param aUsername Applicants
  563. * @param aSuccessBlock The callback block of success
  564. * @param aFailureBlock The callback block of failure
  565. *
  566. */
  567. - (void)asyncAcceptInvitationForUsername:(NSString *)aUsername
  568. success:(void (^)())aSuccessBlock
  569. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -approveFriendRequestFromUser:completion:");
  570. /*!
  571. * \~chinese
  572. * 拒绝加好友的申请
  573. *
  574. * @param aUsername 申请者
  575. * @param aSuccessBlock 成功的回调
  576. * @param aFailureBlock 失败的回调
  577. *
  578. * \~english
  579. * Decline invitation
  580. *
  581. * @param aUsername Applicants
  582. * @param aSuccessBlock The callback block of success
  583. * @param aFailureBlock The callback block of failure
  584. *
  585. */
  586. - (void)asyncDeclineInvitationForUsername:(NSString *)aUsername
  587. success:(void (^)())aSuccessBlock
  588. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -declineFriendRequestFromUser:completion:");
  589. @end