单军华
2018-07-12 3e8437ae559487362fae3525beb79c534c213a51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
//
//  TencentMessageObject.h
//  TencentOpenApi_IOS
//
//  Created by qqconnect on 13-5-27.
//  Copyright (c) 2013年 Tencent. All rights reserved.
//
 
#ifndef QQ_OPEN_SDK_LITE
 
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "sdkdef.h"
 
#define kTextLimit (1024 * 1024)
#define kDataLimit (1024 * 1024 * 10)
#define kPreviewDataLimit (1024 * 1024)
 
@class TencentApiReq;
@class TencentApiResp;
 
/**
 * 必填的NSArray型参数
 */
typedef NSArray *TCRequiredArray;
 
/**
 * 必填的NSDictionary型参数
 */
typedef NSDictionary *TCRequiredDictionary;
 
/**
 * 必填的TencentApiReq型参数
 */
typedef TencentApiReq *TCRequiredReq;
 
/**
 * 可选的UIImage类型参数
 */
typedef NSData *TCOptionalData;
 
 
/**
 * 可选的NSArray型参数
 */
typedef NSArray *TCOptionalArray;
 
/**
 * 可选的TencentApiReq型参数
 */
typedef TencentApiReq *TCOptionalReq;
 
/** 
 * TencentReqMessageType 请求类型枚举参数
 */
typedef enum
{
    /** TX APP请求内容填充(需要第三方开发者填充完成内容后需要主动调用sendRespMessageToTencentApp)*/
    ReqFromTencentAppQueryContent,
    /** TX APP请求展现内容 (不用调用答复) */
    ReqFromTencentAppShowContent,
    /** 第三方 APP 请求内容 */
    ReqFromThirdAppQueryContent,
    /** 第三方 APP 请求展现内容(类似分享)*/
    ReqFromThirdAppShowContent,
}
TencentReqMessageType;
 
typedef enum
{
    RespFromTencentAppQueryContent,
    RespFromTencentAppShowContent,
    RespFromThirdAppQueryContent,
    RespFromThirdAppShowContent,
}
TencentRespMessageType;
 
/** 
 * TencentObjVersion 腾讯API消息类型枚举
 */
typedef enum
{
    /** 文本类型 */
    TencentTextObj,
    /** 图片类型 */
    TencentImageObj,
    /** 音频类型 */
    TencentAudioObj,
    /** 视频类型 */
    TencentVideoObj,
    /** 图片视频类 */
    TencentImageAndVideoObj,
}
TencentObjVersion;
 
/**
 * \brief 请求包
 *
 * TencentApiReq用来向其他业务发送请求包
 */
@interface TencentApiReq  : NSObject<NSCoding>
 
/**
 * 根据序列号生成一个请求包 
 * \param apiSeq 请求序列号
 * \param type   请求类型
 * \return tencentApiReq实例
 */
+ (TencentApiReq *)reqFromSeq:(NSInteger)apiSeq type:(TencentReqMessageType)type;
 
/** 请求类型 */
@property (readonly, assign, nonatomic)TCRequiredInt nMessageType;
 
/** 请求平台 */
@property (readonly, assign, nonatomic)NSInteger nPlatform;
 
/** 请求的SDK版本号 */
@property (readonly, assign, nonatomic)NSInteger nSdkVersion;
 
/** 请求序列号 */
@property (readonly, assign, nonatomic)TCRequiredInt nSeq;
 
/** 第三方的APPID */
@property (nonatomic, retain)TCRequiredStr sAppID;
 
/** 请求内容 TencentBaseMessageObj对象数组 */
@property (nonatomic, retain)TCOptionalArray arrMessage;
 
/** 请求的描述 可以用于告诉对方这个请求的特定场景 */
@property (nonatomic, retain)TCOptionalStr sDescription;
 
@end
 
/**
 * \brief 答复包
 *
 * TencentApiResp用来向其他业务发送答复包
 */
@interface TencentApiResp : NSObject<NSCoding>
 
/**
 * 根据序列号生成一个答复包
 * \param req 答复对应的请求包(如果req不是TencentApiReq或者他的子类,会抛出异常)
 * \return 答复包体
 */
+ (TencentApiResp *)respFromReq:(TencentApiReq *)req;
 
/** 返回码 */
@property (nonatomic, assign)TCOptionalInt  nRetCode;
 
/** 返回消息 */
@property (nonatomic, retain)TCOptionalStr  sRetMsg;
 
/** 答复对应的请求包 */
@property (nonatomic, retain)TCOptionalReq  objReq;
 
@end
 
/**
 * \brief 消息体
 *
 * TencentBaseMessageObj 应用之间传递消息体
 */
@interface TencentBaseMessageObj : NSObject<NSCoding>
 
/** 消息类型 */
@property (nonatomic, assign)NSInteger nVersion;
 
/** 消息描述 */
@property (nonatomic, retain)NSString  *sName;
 
/** 消息的扩展信息 主要是可以用来进行一些请求消息体的描述 譬如图片要求的width height 文字的关键字什么的, 也可以不用填写*/
@property (nonatomic, retain)NSDictionary *dictExpandInfo;
 
/** 
 * 消息是否有效 
 */
- (BOOL)isVaild;
 
@end
 
#pragma mark TencentTextMessage
/**
 * \brief 文本的消息体
 *
 * TencentTextMessageObjV1 应用之间传递的文本消息体
 */
@interface TencentTextMessageObjV1 : TencentBaseMessageObj
 
/** 
 * 文本
 * \note 文本长度不能超过4096个字
 */
@property (nonatomic, retain)  NSString   *sText;
 
 
/**
 * 初始化文本消息
 * \param text 文本
 * \return 初始化返回的文本消息
 */
- (id)initWithText:(NSString *)text;
 
@end
 
 
#pragma mark TecentImageMessage
 
/**
 * TencentApiImageSourceType 图片数据类型(请求方对数据类型可能会有限制)
 */
typedef enum
{
    /** 图片数据是url或二进制数据 */
    AllImage,
    /** 图片数据是url */
    UrlImage,
    /** 图片数据是二进制数据 */
    DataImage,
}TencentApiImageSourceType;
 
/**
 * \brief 图片的消息体
 *
 * TencentImageMessageObjV1 应用之间传递的图片消息体
 */
@interface TencentImageMessageObjV1 : TencentBaseMessageObj
 
/** 
 * 图片数据
 * \note 图片不能大于10M
 */
@property (nonatomic, retain)  NSData *dataImage;
 
/** 
 * 缩略图的数据
 * \note 图片不能大于1M 
 */
@property (nonatomic, retain)  NSData *dataThumbImage;
 
/** 图片URL */
@property (nonatomic, retain)  NSString   *sUrl;
 
/** 图片的描述 */
@property (nonatomic, retain)  NSString   *sDescription;
 
/** 图片的size */
@property (nonatomic, assign)  CGSize   szImage;
 
/** 
 * 图片来源
 * \note TencentApiImageSourceType对应的类型
 */
@property (readonly, assign)  NSInteger  nType;
 
/**
 * 初始化图片消息
 * \param dataImage 图片类型
 * \return 初始化返回的图片消息
 */
- (id)initWithImageData:(NSData *)dataImage;
 
/**
 * 初始化图片消息
 * \param url 图片url
 * \return 初始化返回的图片消息
 */
- (id)initWithImageUrl:(NSString *)url;
 
/**
 * 初始化图片消息
 * \param type 图片类型
 * \return 初始化返回的图片消息
 */
- (id)initWithType:(TencentApiImageSourceType)type;
@end
 
 
#pragma mark TencentAudioMessage
/**
 * \brief 音频的消息体
 *
 * TencentAudioMessageObjV1 应用之间传递的音频消息体
 */
@interface TencentAudioMessageObjV1 : TencentBaseMessageObj
 
/** 音频URL */
@property (nonatomic, retain)  NSString   *sUrl;
 
/** 
 * 音频的预览图
 * \note图片不能大于1M 
 */
@property (nonatomic, retain)  NSData     *dataImagePreview;
 
/** 音频的预览图URL */
@property (nonatomic, retain)  NSString   *sImagePreviewUrl;
 
/** 音频的描述 */
@property (nonatomic, retain)  NSString   *sDescription;
 
/**
 * 初始化图片消息
 * \param url 音频URL
 * \return 初始化返回的音频消息
 */
- (id)initWithAudioUrl:(NSString *)url;
 
@end
 
 
#pragma mark TencentVideoMessage
 
/**
 * TencentApiVideoSourceType 视频数据类型(请求方对数据类型可能会有限制)
 */
 
typedef enum
{
    /** 视频来源于本地或网络 */
    AllVideo,
    /** 视频来源于本地 */
    LocalVideo,
    /** 视频来源于网络 */
    NetVideo,
}TencentApiVideoSourceType;
 
/**
 * \brief 视频的消息体
 *
 * TencentVideoMessageV1 应用之间传递的视频消息体
 */
@interface TencentVideoMessageV1 : TencentBaseMessageObj
 
/** 
 * 视频URL 
 * \note 不能超过1024
 */
@property (nonatomic, retain)  NSString   *sUrl;
 
/** 
 * 视频来源 主要是用来让发起方指定视频的来源
 * \note TencentApiVideoSourceType 对应的类型 只读参数
 */
@property (readonly, assign, nonatomic)  NSInteger nType;
 
/** 
 * 视频的预览图 
 * \note 图片不能大于1M 
 */
@property (nonatomic, retain)  NSData     *dataImagePreview;
 
/** 视频的预览图URL */
@property (nonatomic, retain)  NSString   *sImagePreviewUrl;
 
/** 视频的描述 */
@property (nonatomic, retain)  NSString   *sDescription;
 
/**
 * 初始化视频消息
 * \param url  视频URL
 * \param type 视频来源类型
 * \return 初始化返回的视频消息
 */
- (id)initWithVideoUrl:(NSString *)url type:(TencentApiVideoSourceType)type;
 
 
/**
 * 初始化视频消息
 * \param type 视频来源类型
 * \return 初始化返回的视频消息
 */
- (id)initWithType:(TencentApiVideoSourceType)type;
@end
 
#pragma mark TencentImageMessageObj
/**
 * \brief 视频图片消息体
 *
 * TencentVideoMessageV1 这是一个扩展的类 是一个图片视频类 
 * \note 图片视频可以任选一个内容填充 但是注意只能填一个 当有一种类型被填充后 另外一个种类型就无法填充了
 */
@interface TencentImageAndVideoMessageObjV1 : TencentBaseMessageObj
 
/** 图片消息 */
@property (nonatomic, retain) TencentImageMessageObjV1 *objImageMessage;
 
/** 视频消息 */
@property (nonatomic, retain) TencentVideoMessageV1 *objVideoMessage;
 
/**
 * 初始化图片消息
 * \param dataImage 图片数据
 * \param url       视频url
 * \return 初始化返回的图片视频消息
 */
- (id)initWithMessage:(NSData *)dataImage videoUrl:(NSString *)url;
 
/** 
 * 设置图片
 * \param dataImage 图片数据
 */
- (void)setDataImage:(NSData *)dataImage;
 
/**
 * 设置视频
 * \param videoUrl 视频URL
 */
- (void)setVideoUrl:(NSString *)videoUrl;
@end
 
#endif