NIM 跨平台 C++ SDK
载入中...
搜索中...
未找到
nim_msglog_helper.h
浏览该文件的文档.
1
7#ifndef _NIM_SDK_CPP_MSGLOG_HELPER_H_
8#define _NIM_SDK_CPP_MSGLOG_HELPER_H_
9
10#include <functional>
11#include <list>
12#include <string>
19namespace nim {
20
24 int count_;
28 std::list<IMMessage> msglogs_;
29
32 : count_(0)
33 , source_(kNIMMsglogQuerySourceLocal) {}
34 std::string ToJsonString() const {
36 for (auto& it : msglogs_) {
37 nim_cpp_wrapper_util::Json::Value value = it.ToJsonObject(false);
38 values.append(value);
39 }
40 return nim::GetJsonStringWithNoStyled(values);
41 }
42};
43
48 std::string session_id;
52 bool reliable{true};
54 std::vector<IMMessage> messages;
55 GetMessagesResult() = default;
56};
57
60 std::string session_id_; /*会话id */
61 std::string client_id_; /*消息ID */
62 std::string ext_; /*自定义字段 */
63};
67 std::list<DeleteMsglogSelfNotifyItemInfo> item_list;
68};
69
75 std::string talk_id_;
77 int64_t msg_timetag_;
78
80 : msg_timetag_(0) {}
81};
82
88 std::list<MessageStatusChanged> results_;
89
90 MessageStatusChangedResult(int rescode, std::string& result) {
91 rescode_ = (NIMResCode)rescode;
93 if (nim::ParseJsonValue(result, values) && values.isArray()) {
94 int size = values.size();
95 for (int i = 0; i < size; i++) {
97 changed.status_ = (NIMMsgLogStatus)values[i][kNIMMsglogStatusChangedKeyStatus].asUInt();
100 results_.push_back(changed);
101 }
102 }
103 }
104};
107public:
109 : cloned_(false) {
110 ExportBackupToRemotePackageCallback = [](const std::string& file_path, void* user_data) {
111 return file_path;
112 };
113 ExportBackupToRemoteEncryptCallback = [](const std::string& file_path, const std::string& encrypt_key, void* user_data) {
114 return file_path;
115 };
116 ExportBackupToRemoteLogFiter = [](const IMMessage& msg, void* user_data) {
117 return true;
118 };
119 LogsBackupProgressCallback = [](LogsBackupRemoteOperate, float, void* user_data) {};
120 LogsBackupCompleteCallback = [](LogsBackupRemoteOperate, LogsBackupRemoteState state, void* user_data) {
121 if (state >= LogsBackupRemoteState::LogsBackupRemoteState_FinalState_Begin)
122 delete CastToCPP(user_data);
123 };
124 }
125
126public:
127 void SetEncryptKey(const std::string& encrypt_key) { encrypt_key_ = encrypt_key; }
128 std::string GetEncryptKey() const { return encrypt_key_; }
129 void SetUserData(void* user_data) { NIMLogsBackupExportInfo::user_data_ = user_data; }
133 temp->SetUserData(GetUserData());
134 temp->cloned_ = true;
135 return temp->ToCStruct_i();
136 }
137
138private:
139 static inline LogsBackupExportInfo* CastToCPP(void* data) { return ((LogsBackupExportInfo*)(data)); }
140 NIMLogsBackupExportInfo* ToCStruct_i();
141
142public:
148 std::function<std::string(const std::string& file_path, void* user_data)> ExportBackupToRemotePackageCallback;
149
156 std::function<std::string(const std::string& file_path, const std::string& encrypt_key, void* user_data)> ExportBackupToRemoteEncryptCallback;
157
163 std::function<bool(const IMMessage& msg, void* user_data)> ExportBackupToRemoteLogFiter;
170 std::function<void(LogsBackupRemoteOperate op, float progress, void* user_data)> LogsBackupProgressCallback;
177 std::function<void(LogsBackupRemoteOperate op, LogsBackupRemoteState state, void* user_data)> LogsBackupCompleteCallback;
178
179 std::string encrypt_key_;
182};
183
186public:
188 ImportBackupFromRemoteUnPackageCallback = [](const std::string& file_path, void* user_data) {
189 return file_path;
190 };
191 ImportBackupFromRemoteDecryptCallback = [](const std::string& file_path, const std::string& encrypt_key, void* user_data) {
192 return file_path;
193 };
194 LogsBackupProgressCallback = [](LogsBackupRemoteOperate, float, void* user_data) {};
195 LogsBackupCompleteCallback = [](LogsBackupRemoteOperate, LogsBackupRemoteState state, void* user_data) {
196 if (state >= LogsBackupRemoteState::LogsBackupRemoteState_FinalState_Begin)
197 delete CastToCPP(user_data);
198 };
199 }
200
201public:
202 void SetUserData(void* user_data) { NIMLogsBackupImportInfo::user_data_ = user_data; }
206 temp->SetUserData(GetUserData());
207 temp->cloned_ = true;
208 return temp->ToCStruct_i();
209 }
210
211private:
212 NIMLogsBackupImportInfo* ToCStruct_i();
213 static inline LogsBackupImportInfo* CastToCPP(void* data) { return ((LogsBackupImportInfo*)(data)); }
214
215public:
221 std::function<std::string(const std::string& file_path, void* user_data)> ImportBackupFromRemoteUnPackageCallback;
222
229 std::function<std::string(const std::string& file_path, const std::string& encrypt_key, void* user_data)> ImportBackupFromRemoteDecryptCallback;
230
237 std::function<void(LogsBackupRemoteOperate, float, void* user_data)> LogsBackupProgressCallback;
238
246
249};
256NIM_SDK_CPPWRAPPER_DLL_API bool ParseMsglogs(const std::string& msgs_json, QueryMsglogResult& res);
257
258} // namespace nim
259
260#endif //_NIM_SDK_CPP_MSGLOG_HELPER_H_
导出消息记录到云端参数定义
Definition: nim_msglog_helper.h:106
std::function< bool(const IMMessage &msg, void *user_data)> ExportBackupToRemoteLogFiter
Definition: nim_msglog_helper.h:163
void * src_user_data_
Definition: nim_msglog_helper.h:180
NIMLogsBackupExportInfo * ToCStruct() const
Definition: nim_msglog_helper.h:131
void SetEncryptKey(const std::string &encrypt_key)
Definition: nim_msglog_helper.h:127
std::function< std::string(const std::string &file_path, const std::string &encrypt_key, void *user_data)> ExportBackupToRemoteEncryptCallback
Definition: nim_msglog_helper.h:156
std::function< void(LogsBackupRemoteOperate op, float progress, void *user_data)> LogsBackupProgressCallback
Definition: nim_msglog_helper.h:170
std::function< std::string(const std::string &file_path, void *user_data)> ExportBackupToRemotePackageCallback
Definition: nim_msglog_helper.h:148
std::string GetEncryptKey() const
Definition: nim_msglog_helper.h:128
std::string encrypt_key_
Definition: nim_msglog_helper.h:179
void * GetUserData() const
Definition: nim_msglog_helper.h:130
bool cloned_
Definition: nim_msglog_helper.h:181
std::function< void(LogsBackupRemoteOperate op, LogsBackupRemoteState state, void *user_data)> LogsBackupCompleteCallback
Definition: nim_msglog_helper.h:177
static LogsBackupExportInfo * CastToCPP(void *data)
Definition: nim_msglog_helper.h:139
LogsBackupExportInfo()
Definition: nim_msglog_helper.h:108
NIMLogsBackupExportInfo * ToCStruct_i()
Definition: nim_msglog_helper.cpp:27
void SetUserData(void *user_data)
Definition: nim_msglog_helper.h:129
从云端导入消息记录参数定义
Definition: nim_msglog_helper.h:185
LogsBackupImportInfo()
Definition: nim_msglog_helper.h:187
void SetUserData(void *user_data)
Definition: nim_msglog_helper.h:202
std::function< void(LogsBackupRemoteOperate, float, void *user_data)> LogsBackupProgressCallback
Definition: nim_msglog_helper.h:237
NIMLogsBackupImportInfo * ToCStruct() const
Definition: nim_msglog_helper.h:204
std::function< std::string(const std::string &file_path, void *user_data)> ImportBackupFromRemoteUnPackageCallback
Definition: nim_msglog_helper.h:221
void * GetUserData() const
Definition: nim_msglog_helper.h:203
static LogsBackupImportInfo * CastToCPP(void *data)
Definition: nim_msglog_helper.h:213
bool cloned_
Definition: nim_msglog_helper.h:247
void * src_user_data_
Definition: nim_msglog_helper.h:248
std::function< void(LogsBackupRemoteOperate, LogsBackupRemoteState, void *user_data)> LogsBackupCompleteCallback
Definition: nim_msglog_helper.h:245
std::function< std::string(const std::string &file_path, const std::string &encrypt_key, void *user_data)> ImportBackupFromRemoteDecryptCallback
Definition: nim_msglog_helper.h:229
NIMLogsBackupImportInfo * ToCStruct_i()
Definition: nim_msglog_helper.cpp:70
Represents a JSON value.
Definition: value.h:196
bool isArray() const
Definition: json_value.cpp:1386
Value & append(const Value &value)
Append value to array at the end.
Definition: json_value.cpp:1142
String asString() const
Embedded zeroes are possible.
Definition: json_value.cpp:632
ArrayIndex size() const
Number of values in array or object
Definition: json_value.cpp:885
namespace nim
bool ParseJsonValue(const std::string &content, nim_cpp_wrapper_util::Json::Value &values)
解析JsonString
Definition: nim_json_util.cpp:70
bool ParseMsglogs(const std::string &msgs_json, QueryMsglogResult &res)
解析查询到的消息历史结果
Definition: nim_msglog_helper.cpp:11
std::string GetJsonStringWithNoStyled(const nim_cpp_wrapper_util::Json::Value &values)
获得非格式化的Json string,传入SDK的json string格式要求为非格式化的,如果是格式化的json string可能会影响功能
Definition: nim_json_util.cpp:89
LogsBackupRemoteOperate
Definition: nim_msglog_def.h:484
NIMMsgLogStatus
Definition: nim_msglog_def.h:351
NIMMsglogQuerySource
Definition: nim_msglog_def.h:301
@ kNIMMsglogQuerySourceLocal
本地查询
Definition: nim_msglog_def.h:303
static const char * kNIMMsglogStatusChangedKeyMsgTimetag
临界的消息的时间戳
Definition: nim_msglog_def.h:275
static const char * kNIMMsglogStatusChangedKeyStatus
变更后的状态
Definition: nim_msglog_def.h:277
LogsBackupRemoteState
Definition: nim_msglog_def.h:491
static const char * kNIMMsglogStatusChangedKeyTalkID
会话ID
Definition: nim_msglog_def.h:273
定义导出宏
#define NIM_SDK_CPPWRAPPER_DLL_API
Definition: nim_sdk_cpp_wrapper.h:38
NIMSessionType
Definition: nim_session_def.h:16
@ kNIMSessionTypeP2P
个人,即点对点
Definition: nim_session_def.h:18
Talk 辅助方法和数据结构定义
NIMResCode
Definition: public_defines.h:21
@ kNIMResSuccess
没有错误,一切正常
Definition: public_defines.h:26
#define false
Definition: stdbool.h:33
unsigned char bool
Definition: stdbool.h:25
导出消息记录到云端参数定义
Definition: nim_msglog_def.h:547
void * user_data_
APP的自定义用户数据,SDK只负责传回给回调函数,不做任何处理!
Definition: nim_msglog_def.h:589
从云端导入消息记录参数定义
Definition: nim_msglog_def.h:592
void * user_data_
APP的自定义用户数据,SDK只负责传回给回调函数,不做任何处理!
Definition: nim_msglog_def.h:626
单向删除消息记录回调参数
Definition: nim_msglog_helper.h:59
std::string session_id_
Definition: nim_msglog_helper.h:60
std::string client_id_
Definition: nim_msglog_helper.h:61
std::string ext_
Definition: nim_msglog_helper.h:62
单向删除消息记录回调参数
Definition: nim_msglog_helper.h:65
std::list< DeleteMsglogSelfNotifyItemInfo > item_list
被删除的消息基本信息
Definition: nim_msglog_helper.h:67
Definition: nim_msglog_helper.h:44
std::string session_id
会话ID
Definition: nim_msglog_helper.h:48
std::vector< IMMessage > messages
历史消息列表
Definition: nim_msglog_helper.h:54
Definition: nim_talk_helper.h:339
发送消息已读回执
Definition: nim_msglog_helper.h:71
NIMMsgLogStatus status_
变更后的状态
Definition: nim_msglog_helper.h:73
MessageStatusChanged()
Definition: nim_msglog_helper.h:79
int64_t msg_timetag_
临界的消息的时间戳
Definition: nim_msglog_helper.h:77
std::string talk_id_
会话ID
Definition: nim_msglog_helper.h:75
发送消息已读回执
Definition: nim_msglog_helper.h:84
NIMResCode rescode_
错误码
Definition: nim_msglog_helper.h:86
MessageStatusChangedResult(int rescode, std::string &result)
Definition: nim_msglog_helper.h:90
std::list< MessageStatusChanged > results_
结果
Definition: nim_msglog_helper.h:88
查询到消息历史结果
Definition: nim_msglog_helper.h:22
int count_
消息历史数
Definition: nim_msglog_helper.h:24
std::list< IMMessage > msglogs_
消息历史
Definition: nim_msglog_helper.h:28
NIMMsglogQuerySource source_
消息历史查询来源
Definition: nim_msglog_helper.h:26
QueryMsglogResult()
Definition: nim_msglog_helper.h:31
std::string ToJsonString() const
Definition: nim_msglog_helper.h:34