Easemob Windows SDK
emconversation.h
1 /************************************************************
2  * * EaseMob CONFIDENTIAL
3  * __________________
4  * Copyright (C) 2015 EaseMob Technologies. All rights reserved.
5  *
6  * NOTICE: All information contained herein is, and remains
7  * the property of EaseMob Technologies.
8  * Dissemination of this information or reproduction of this material
9  * is strictly forbidden unless prior written permission is obtained
10  * from EaseMob Technologies.
11  */
12 //
13 // emconversation.h
14 //
15 // Copyright (c) 2015 EaseMob Inc. All rights reserved.
16 //
17 
18 #ifndef __easemob__emconversation__
19 #define __easemob__emconversation__
20 
21 #include <string>
22 #include <vector>
23 
24 #include "message/emmessage.h"
25 #include "embaseobject.h"
26 
27 namespace easemob
28 {
29 
30 class EMConversationPrivate;
31 class EMConversationManager;
32 class EMChatManager;
33 class EMDatabase;
34 
35 class EASEMOB_API EMConversation : public EMBaseObject
36 {
37 public:
38 
42  typedef enum {
43  CHAT, //single chat
44  GROUPCHAT, //group chat
45  CHATROOM, //chatroom chat
46  DISCUSSIONGROUP, //discussion group chat
47  HELPDESK, //help desk chat
49 
53  typedef enum {
54  UP, //Search older messages than reference
55  DOWN, //Search newer messages than reference
57 
64  virtual ~EMConversation();
65 
73  const std::string& conversationId() const;
74 
81  EMConversationType conversationType () const;
82 
90  bool removeMessage(const std::string &msgId);
91 
100  bool removeMessage(const EMMessagePtr msg);
101 
110  bool insertMessage(const EMMessagePtr msg);
111 
120  bool appendMessage(const EMMessagePtr msg);
121 
130  bool updateMessage(const EMMessagePtr msg);
131 
138  bool clearAllMessages();
139 
147  bool markMessageAsRead(const std::string &msgId, bool isRead = true);
148 
155  bool markAllMessagesAsRead(bool isRead = true);
156 
163  int unreadMessagesCount() const;
164 
171  int messagesCount() const;
172 
179  EMMessagePtr loadMessage(const std::string &msgId) const;
180 
187  EMMessagePtr latestMessage() const;
188 
195  EMMessagePtr latestMessageFromOthers() const;
196 
209  EMMessageList loadMoreMessages(const std::string &refMsgId, int count, EMMessageSearchDirection direction = UP);
210 
220  EMMessageList loadMoreMessages(int64_t timeStamp, int count, EMMessageSearchDirection direction = UP);
221 
233  EMMessageList loadMoreMessages(EMMessageBody::EMMessageBodyType type, int64_t timeStamp = -1, int count = -1, const std::string &from = "", EMMessageSearchDirection direction = UP);
234 
246  EMMessageList loadMoreMessages(const std::string& keywords, int64_t timeStamp = -1, int count = -1, const std::string &from = "", EMMessageSearchDirection direction = UP);
247 
259  EMMessageList loadMoreMessages(int64_t startTimeStamp, int64_t endTimeStamp, int maxCount);
260 
267  const std::string& extField() const;
268 
275  bool setExtField(const std::string &ext);
276 
277  friend EMConversationManager;
278  friend EMChatManager;
279  friend EMDatabase;
280 private:
290  EMConversation(const std::string &conversationId, EMConversationType type, const std::string& ext = "");
291 
295  EMConversation& operator=(const EMConversation&);
297 
298  EMConversationPrivate *mPrivate;
299 };
300 
301 typedef std::shared_ptr<EMConversation> EMConversationPtr;
302 typedef std::vector<EMConversationPtr> EMConversationList;
303 
304 }
305 
306 #endif /* defined(__easemob__emconversation__) */
EMConversationType
Definition: emconversation.h:42
EMMessageSearchDirection
Definition: emconversation.h:53
Definition: emconversation.h:35
Definition: emattributevalue.h:28
Definition: embaseobject.h:28