CloudAbilityConfig.mm 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // CloudAbilityConfig.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/12/27.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "CloudAbilityConfig.h"
  9. #import "CloudAbilityDataSource.h"
  10. @interface CloudAbilityConfig ()
  11. {
  12. CloudAbilityDataSource *dataSource;
  13. }
  14. @end
  15. @implementation CloudAbilityConfig
  16. - (id)init {
  17. self = [super init];
  18. if (self) {
  19. dataSource = [[CloudAbilityDataSource alloc] init];
  20. }
  21. return self;
  22. }
  23. #pragma mark 请求服务器端云存储能力集
  24. -(void)getCloudAbilityServer{
  25. //这两个接口调用的也是json
  26. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  27. NSArray *caps = @[@"xmc.service.support",@"xmc.service.enable",@"xmc.service.normal"];
  28. NSDictionary *jsonDic = @{@"hw":@"",@"sw":@"",@"tp":@0,@"appType":[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"],@"sn":channel.deviceMac,@"caps":caps};
  29. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDic options:NSJSONWritingPrettyPrinted error:nil];
  30. NSString *pCfgBufString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  31. Fun_SysGetDevAbilitySetFromServer(self.msgHandle, [pCfgBufString UTF8String], 0);
  32. }
  33. #pragma mark - 是否支持云视频或云图片
  34. -(void)getVideoOrPicAbilityServer{
  35. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  36. NSArray *caps = @[@"xmc.css.pic.support",@"xmc.css.vid.support"];
  37. NSDictionary *jsonDic = @{@"hw":@"",@"sw":@"",@"tp":@0,@"appType":[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"],@"sn":channel.deviceMac,@"caps":caps};
  38. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDic options:NSJSONWritingPrettyPrinted error:nil];
  39. NSString *pCfgBufString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  40. Fun_SysGetDevAbilitySetFromServer(self.msgHandle, [pCfgBufString UTF8String], 0);
  41. }
  42. #pragma mark 读取云服务状态
  43. - (NSString*)getCloudState {//获取云存储状态
  44. return [dataSource getCloudString];
  45. }
  46. - (NSString*)getVideoEnable{ //获取云视频支持情况
  47. return [dataSource getVideoString];
  48. }
  49. - (NSString*)getPicEnable{ //获取云图片支持情况
  50. return [dataSource getPicString];
  51. }
  52. -(void)OnFunSDKResult:(NSNumber *)pParam {
  53. NSInteger nAddr = [pParam integerValue];
  54. MsgContent *msg = (MsgContent *)nAddr;
  55. switch (msg->id) {
  56. case EMSG_SYS_GET_ABILITY_SET: {
  57. if (msg->param1 < 0) {
  58. if (msg->seq == 0) {
  59. dataSource.cloudState = CloudState_UnSupport;
  60. }
  61. if ([self.delegate respondsToSelector:@selector(getCloudAbilityResult:)]) {
  62. [self.delegate getCloudAbilityResult:msg->param1];
  63. }
  64. } else {
  65. NSString *content = NSSTR(msg->szStr);
  66. [content stringByReplacingOccurrencesOfString:@"\t" withString:@""];
  67. [content stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  68. NSData *data = [content dataUsingEncoding:NSUTF8StringEncoding];
  69. NSDictionary *tempDictQueryDiamond = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
  70. if ([tempDictQueryDiamond objectForKey:@"xmc.css.pic.support"] || [tempDictQueryDiamond objectForKey:@"xmc.css.vid.support"]) {
  71. if ([[tempDictQueryDiamond objectForKey:@"xmc.css.pic.support"] boolValue]) {
  72. if ([[tempDictQueryDiamond objectForKey:@"xmc.css.vid.support"] boolValue]) {
  73. dataSource.VideoOrPicState = VideoOrPicCloudState_All;
  74. }
  75. else{
  76. dataSource.VideoOrPicState = VideoOrPicCloudState_Pic;
  77. }
  78. }
  79. else{
  80. if ([[tempDictQueryDiamond objectForKey:@"xmc.css.vid.support"] boolValue]) {
  81. dataSource.VideoOrPicState = VideoOrPicCloudState_Video;
  82. }
  83. else{
  84. dataSource.VideoOrPicState = VideoOrPicCloudStateNone;
  85. }
  86. }
  87. if ([self.delegate respondsToSelector:@selector(getVideoOrPicAbilityResult:)]) {
  88. [self.delegate getVideoOrPicAbilityResult:msg->param1];
  89. }
  90. }
  91. else{
  92. dataSource.cloudState = CloudState_UnSupport;
  93. if ([[tempDictQueryDiamond objectForKey:@"xmc.service.support"] boolValue] == YES) {
  94. if ([[tempDictQueryDiamond objectForKey:@"xmc.service.enable"] boolValue]) {
  95. if ([[tempDictQueryDiamond objectForKey:@"xmc.service.support"] boolValue]) {
  96. dataSource.cloudState = CloudState_Open;
  97. }
  98. else{
  99. dataSource.cloudState = CloudState_Open_Expired;
  100. }
  101. }
  102. else{
  103. dataSource.cloudState = CloudState_NotOpen;
  104. }
  105. }
  106. if ([self.delegate respondsToSelector:@selector(getCloudAbilityResult:)]) {
  107. [self.delegate getCloudAbilityResult:msg->param1];
  108. }
  109. }
  110. }
  111. }
  112. break;
  113. default:
  114. break;
  115. }
  116. }
  117. @end