theta-client-react-native 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/README.md +6 -1
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/ricoh360/thetaclientreactnative/Converter.kt +409 -0
  4. package/android/src/main/java/com/ricoh360/thetaclientreactnative/ThetaClientSdkModule.kt +700 -24
  5. package/ios/ThetaClientReactNative.h +6 -0
  6. package/ios/ThetaClientReactNative.mm +1661 -183
  7. package/lib/commonjs/capture/capture.js +118 -0
  8. package/lib/commonjs/capture/capture.js.map +1 -0
  9. package/lib/commonjs/capture/index.js +50 -0
  10. package/lib/commonjs/capture/index.js.map +1 -0
  11. package/lib/commonjs/capture/notify.js +12 -0
  12. package/lib/commonjs/capture/notify.js.map +1 -0
  13. package/lib/commonjs/capture/photo-capture.js +64 -0
  14. package/lib/commonjs/capture/photo-capture.js.map +1 -0
  15. package/lib/commonjs/capture/time-shift-capture.js +91 -0
  16. package/lib/commonjs/capture/time-shift-capture.js.map +1 -0
  17. package/lib/commonjs/capture/video-capture.js +71 -0
  18. package/lib/commonjs/capture/video-capture.js.map +1 -0
  19. package/lib/commonjs/index.js +40 -1041
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/theta-repository/access-point.js +23 -0
  22. package/lib/commonjs/theta-repository/access-point.js.map +1 -0
  23. package/lib/commonjs/theta-repository/digest-auth.js +2 -0
  24. package/lib/commonjs/theta-repository/digest-auth.js.map +1 -0
  25. package/lib/commonjs/theta-repository/index.js +105 -0
  26. package/lib/commonjs/theta-repository/index.js.map +1 -0
  27. package/lib/commonjs/theta-repository/options/index.js +138 -0
  28. package/lib/commonjs/theta-repository/options/index.js.map +1 -0
  29. package/lib/commonjs/theta-repository/options/option-camera-control-source.js +29 -0
  30. package/lib/commonjs/theta-repository/options/option-camera-control-source.js.map +1 -0
  31. package/lib/commonjs/theta-repository/options/option-camera-mode.js +26 -0
  32. package/lib/commonjs/theta-repository/options/option-camera-mode.js.map +1 -0
  33. package/lib/commonjs/theta-repository/options/option-network-type.js +26 -0
  34. package/lib/commonjs/theta-repository/options/option-network-type.js.map +1 -0
  35. package/lib/commonjs/theta-repository/options/option-power-saving.js +24 -0
  36. package/lib/commonjs/theta-repository/options/option-power-saving.js.map +1 -0
  37. package/lib/commonjs/theta-repository/options/option-preview-format.js +32 -0
  38. package/lib/commonjs/theta-repository/options/option-preview-format.js.map +1 -0
  39. package/lib/commonjs/theta-repository/options/option-proxy.js +2 -0
  40. package/lib/commonjs/theta-repository/options/option-proxy.js.map +1 -0
  41. package/lib/commonjs/theta-repository/options/option-shooting-method.js +41 -0
  42. package/lib/commonjs/theta-repository/options/option-shooting-method.js.map +1 -0
  43. package/lib/commonjs/theta-repository/options/option-shutter-speed.js +302 -0
  44. package/lib/commonjs/theta-repository/options/option-shutter-speed.js.map +1 -0
  45. package/lib/commonjs/theta-repository/options/option-time-shift.js +43 -0
  46. package/lib/commonjs/theta-repository/options/option-time-shift.js.map +1 -0
  47. package/lib/commonjs/theta-repository/options/option-white-balance-auto-strength.js +25 -0
  48. package/lib/commonjs/theta-repository/options/option-white-balance-auto-strength.js.map +1 -0
  49. package/lib/commonjs/theta-repository/options/option-wlan-frequency.js +22 -0
  50. package/lib/commonjs/theta-repository/options/option-wlan-frequency.js.map +1 -0
  51. package/lib/commonjs/theta-repository/options/options.js +490 -0
  52. package/lib/commonjs/theta-repository/options/options.js.map +1 -0
  53. package/lib/commonjs/theta-repository/theta-config.js +6 -0
  54. package/lib/commonjs/theta-repository/theta-config.js.map +1 -0
  55. package/lib/commonjs/theta-repository/theta-files.js +35 -0
  56. package/lib/commonjs/theta-repository/theta-files.js.map +1 -0
  57. package/lib/commonjs/theta-repository/theta-info.js +2 -0
  58. package/lib/commonjs/theta-repository/theta-info.js.map +1 -0
  59. package/lib/commonjs/theta-repository/theta-meta.js +2 -0
  60. package/lib/commonjs/theta-repository/theta-meta.js.map +1 -0
  61. package/lib/commonjs/theta-repository/theta-plugin.js +2 -0
  62. package/lib/commonjs/theta-repository/theta-plugin.js.map +1 -0
  63. package/lib/commonjs/theta-repository/theta-repository.js +510 -0
  64. package/lib/commonjs/theta-repository/theta-repository.js.map +1 -0
  65. package/lib/commonjs/theta-repository/theta-state.js +120 -0
  66. package/lib/commonjs/theta-repository/theta-state.js.map +1 -0
  67. package/lib/commonjs/theta-repository/theta-timeout.js +2 -0
  68. package/lib/commonjs/theta-repository/theta-timeout.js.map +1 -0
  69. package/lib/module/capture/capture.js +111 -0
  70. package/lib/module/capture/capture.js.map +1 -0
  71. package/lib/module/capture/index.js +5 -0
  72. package/lib/module/capture/index.js.map +1 -0
  73. package/lib/module/capture/notify.js +6 -0
  74. package/lib/module/capture/notify.js.map +1 -0
  75. package/lib/module/capture/photo-capture.js +56 -0
  76. package/lib/module/capture/photo-capture.js.map +1 -0
  77. package/lib/module/capture/time-shift-capture.js +83 -0
  78. package/lib/module/capture/time-shift-capture.js.map +1 -0
  79. package/lib/module/capture/video-capture.js +63 -0
  80. package/lib/module/capture/video-capture.js.map +1 -0
  81. package/lib/module/index.js +3 -1009
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/theta-repository/access-point.js +16 -0
  84. package/lib/module/theta-repository/access-point.js.map +1 -0
  85. package/lib/module/theta-repository/digest-auth.js +2 -0
  86. package/lib/module/theta-repository/digest-auth.js.map +1 -0
  87. package/lib/module/theta-repository/index.js +10 -0
  88. package/lib/module/theta-repository/index.js.map +1 -0
  89. package/lib/module/theta-repository/options/index.js +13 -0
  90. package/lib/module/theta-repository/options/index.js.map +1 -0
  91. package/lib/module/theta-repository/options/option-camera-control-source.js +22 -0
  92. package/lib/module/theta-repository/options/option-camera-control-source.js.map +1 -0
  93. package/lib/module/theta-repository/options/option-camera-mode.js +19 -0
  94. package/lib/module/theta-repository/options/option-camera-mode.js.map +1 -0
  95. package/lib/module/theta-repository/options/option-network-type.js +19 -0
  96. package/lib/module/theta-repository/options/option-network-type.js.map +1 -0
  97. package/lib/module/theta-repository/options/option-power-saving.js +17 -0
  98. package/lib/module/theta-repository/options/option-power-saving.js.map +1 -0
  99. package/lib/module/theta-repository/options/option-preview-format.js +25 -0
  100. package/lib/module/theta-repository/options/option-preview-format.js.map +1 -0
  101. package/lib/module/theta-repository/options/option-proxy.js +2 -0
  102. package/lib/module/theta-repository/options/option-proxy.js.map +1 -0
  103. package/lib/module/theta-repository/options/option-shooting-method.js +34 -0
  104. package/lib/module/theta-repository/options/option-shooting-method.js.map +1 -0
  105. package/lib/module/theta-repository/options/option-shutter-speed.js +295 -0
  106. package/lib/module/theta-repository/options/option-shutter-speed.js.map +1 -0
  107. package/lib/module/theta-repository/options/option-time-shift.js +36 -0
  108. package/lib/module/theta-repository/options/option-time-shift.js.map +1 -0
  109. package/lib/module/theta-repository/options/option-white-balance-auto-strength.js +18 -0
  110. package/lib/module/theta-repository/options/option-white-balance-auto-strength.js.map +1 -0
  111. package/lib/module/theta-repository/options/option-wlan-frequency.js +15 -0
  112. package/lib/module/theta-repository/options/option-wlan-frequency.js.map +1 -0
  113. package/lib/module/theta-repository/options/options.js +482 -0
  114. package/lib/module/theta-repository/options/options.js.map +1 -0
  115. package/lib/module/theta-repository/theta-config.js +2 -0
  116. package/lib/module/theta-repository/theta-config.js.map +1 -0
  117. package/lib/module/theta-repository/theta-files.js +28 -0
  118. package/lib/module/theta-repository/theta-files.js.map +1 -0
  119. package/lib/module/theta-repository/theta-info.js +2 -0
  120. package/lib/module/theta-repository/theta-info.js.map +1 -0
  121. package/lib/module/theta-repository/theta-meta.js +2 -0
  122. package/lib/module/theta-repository/theta-meta.js.map +1 -0
  123. package/lib/module/theta-repository/theta-plugin.js +2 -0
  124. package/lib/module/theta-repository/theta-plugin.js.map +1 -0
  125. package/lib/module/theta-repository/theta-repository.js +466 -0
  126. package/lib/module/theta-repository/theta-repository.js.map +1 -0
  127. package/lib/module/theta-repository/theta-state.js +113 -0
  128. package/lib/module/theta-repository/theta-state.js.map +1 -0
  129. package/lib/module/theta-repository/theta-timeout.js +2 -0
  130. package/lib/module/theta-repository/theta-timeout.js.map +1 -0
  131. package/lib/typescript/capture/capture.d.ts +71 -0
  132. package/lib/typescript/capture/capture.d.ts.map +1 -0
  133. package/lib/typescript/capture/index.d.ts +5 -0
  134. package/lib/typescript/capture/index.d.ts.map +1 -0
  135. package/lib/typescript/capture/notify.d.ts +13 -0
  136. package/lib/typescript/capture/notify.d.ts.map +1 -0
  137. package/lib/typescript/capture/photo-capture.d.ts +38 -0
  138. package/lib/typescript/capture/photo-capture.d.ts.map +1 -0
  139. package/lib/typescript/capture/time-shift-capture.d.ts +44 -0
  140. package/lib/typescript/capture/time-shift-capture.d.ts.map +1 -0
  141. package/lib/typescript/capture/video-capture.d.ts +43 -0
  142. package/lib/typescript/capture/video-capture.d.ts.map +1 -0
  143. package/lib/typescript/index.d.ts +3 -972
  144. package/lib/typescript/index.d.ts.map +1 -1
  145. package/lib/typescript/theta-repository/access-point.d.ts +36 -0
  146. package/lib/typescript/theta-repository/access-point.d.ts.map +1 -0
  147. package/lib/typescript/theta-repository/digest-auth.d.ts +17 -0
  148. package/lib/typescript/theta-repository/digest-auth.d.ts.map +1 -0
  149. package/lib/typescript/theta-repository/index.d.ts +10 -0
  150. package/lib/typescript/theta-repository/index.d.ts.map +1 -0
  151. package/lib/typescript/theta-repository/options/index.d.ts +13 -0
  152. package/lib/typescript/theta-repository/options/index.d.ts.map +1 -0
  153. package/lib/typescript/theta-repository/options/option-camera-control-source.d.ts +22 -0
  154. package/lib/typescript/theta-repository/options/option-camera-control-source.d.ts.map +1 -0
  155. package/lib/typescript/theta-repository/options/option-camera-mode.d.ts +19 -0
  156. package/lib/typescript/theta-repository/options/option-camera-mode.d.ts.map +1 -0
  157. package/lib/typescript/theta-repository/options/option-network-type.d.ts +19 -0
  158. package/lib/typescript/theta-repository/options/option-network-type.d.ts.map +1 -0
  159. package/lib/typescript/theta-repository/options/option-power-saving.d.ts +16 -0
  160. package/lib/typescript/theta-repository/options/option-power-saving.d.ts.map +1 -0
  161. package/lib/typescript/theta-repository/options/option-preview-format.d.ts +25 -0
  162. package/lib/typescript/theta-repository/options/option-preview-format.d.ts.map +1 -0
  163. package/lib/typescript/theta-repository/options/option-proxy.d.ts +23 -0
  164. package/lib/typescript/theta-repository/options/option-proxy.d.ts.map +1 -0
  165. package/lib/typescript/theta-repository/options/option-shooting-method.d.ts +33 -0
  166. package/lib/typescript/theta-repository/options/option-shooting-method.d.ts.map +1 -0
  167. package/lib/typescript/theta-repository/options/option-shutter-speed.d.ts +295 -0
  168. package/lib/typescript/theta-repository/options/option-shutter-speed.d.ts.map +1 -0
  169. package/lib/typescript/theta-repository/options/option-time-shift.d.ts +54 -0
  170. package/lib/typescript/theta-repository/options/option-time-shift.d.ts.map +1 -0
  171. package/lib/typescript/theta-repository/options/option-white-balance-auto-strength.d.ts +18 -0
  172. package/lib/typescript/theta-repository/options/option-white-balance-auto-strength.d.ts.map +1 -0
  173. package/lib/typescript/theta-repository/options/option-wlan-frequency.d.ts +15 -0
  174. package/lib/typescript/theta-repository/options/option-wlan-frequency.d.ts.map +1 -0
  175. package/lib/typescript/theta-repository/options/options.d.ts +566 -0
  176. package/lib/typescript/theta-repository/options/options.d.ts.map +1 -0
  177. package/lib/typescript/theta-repository/theta-config.d.ts +20 -0
  178. package/lib/typescript/theta-repository/theta-config.d.ts.map +1 -0
  179. package/lib/typescript/theta-repository/theta-files.d.ts +45 -0
  180. package/lib/typescript/theta-repository/theta-files.d.ts.map +1 -0
  181. package/lib/typescript/theta-repository/theta-info.d.ts +34 -0
  182. package/lib/typescript/theta-repository/theta-info.d.ts.map +1 -0
  183. package/lib/typescript/theta-repository/theta-meta.d.ts +38 -0
  184. package/lib/typescript/theta-repository/theta-meta.d.ts.map +1 -0
  185. package/lib/typescript/theta-repository/theta-plugin.d.ts +26 -0
  186. package/lib/typescript/theta-repository/theta-plugin.d.ts.map +1 -0
  187. package/lib/typescript/theta-repository/theta-repository.d.ts +333 -0
  188. package/lib/typescript/theta-repository/theta-repository.d.ts.map +1 -0
  189. package/lib/typescript/theta-repository/theta-state.d.ts +150 -0
  190. package/lib/typescript/theta-repository/theta-state.d.ts.map +1 -0
  191. package/lib/typescript/theta-repository/theta-timeout.d.ts +22 -0
  192. package/lib/typescript/theta-repository/theta-timeout.d.ts.map +1 -0
  193. package/package.json +1 -1
  194. package/src/capture/capture.ts +124 -0
  195. package/src/capture/index.ts +4 -0
  196. package/src/capture/notify.ts +27 -0
  197. package/src/capture/photo-capture.ts +62 -0
  198. package/src/capture/time-shift-capture.ts +99 -0
  199. package/src/capture/video-capture.ts +69 -0
  200. package/src/index.tsx +3 -1243
  201. package/src/theta-repository/access-point.ts +38 -0
  202. package/src/theta-repository/digest-auth.ts +16 -0
  203. package/src/theta-repository/index.ts +9 -0
  204. package/src/theta-repository/options/index.ts +13 -0
  205. package/src/theta-repository/options/option-camera-control-source.ts +24 -0
  206. package/src/theta-repository/options/option-camera-mode.ts +20 -0
  207. package/src/theta-repository/options/option-network-type.ts +20 -0
  208. package/src/theta-repository/options/option-power-saving.ts +18 -0
  209. package/src/theta-repository/options/option-preview-format.ts +27 -0
  210. package/src/theta-repository/options/option-proxy.ts +22 -0
  211. package/src/theta-repository/options/option-shooting-method.ts +36 -0
  212. package/src/theta-repository/options/option-shutter-speed.ts +360 -0
  213. package/src/theta-repository/options/option-time-shift.ts +59 -0
  214. package/src/theta-repository/options/option-white-balance-auto-strength.ts +19 -0
  215. package/src/theta-repository/options/option-wlan-frequency.ts +16 -0
  216. package/src/theta-repository/options/options.ts +622 -0
  217. package/src/theta-repository/theta-config.ts +20 -0
  218. package/src/theta-repository/theta-files.ts +49 -0
  219. package/src/theta-repository/theta-info.ts +35 -0
  220. package/src/theta-repository/theta-meta.ts +39 -0
  221. package/src/theta-repository/theta-plugin.ts +25 -0
  222. package/src/theta-repository/theta-repository.ts +527 -0
  223. package/src/theta-repository/theta-state.ts +164 -0
  224. package/src/theta-repository/theta-timeout.ts +21 -0
  225. package/theta-client-react-native.podspec +1 -1
@@ -2,6 +2,24 @@
2
2
  #import "ThetaClientReactNative.h"
3
3
  #import "RCTConvert.h"
4
4
 
5
+ #define MESSAGE_NOT_INIT @"Not initialized."
6
+ #define ERROR_CODE_ERROR @"error"
7
+
8
+ static NSDictionary* toNotify(NSString *name, NSDictionary *params) {
9
+ NSMutableDictionary *objects = [NSMutableDictionary dictionary];
10
+ [objects setObject:name forKey:@"name"];
11
+ if (params != nil) {
12
+ [objects setObject:params forKey:@"params"];
13
+ }
14
+ return objects;
15
+ }
16
+
17
+ static NSDictionary* toCaptureProgressNotifyParam(NSNumber *value) {
18
+ NSMutableDictionary *result = [NSMutableDictionary dictionary];
19
+ [result setObject:value forKey:@"completion"];
20
+ return toNotify(@"TIME-SHIFT-PROGRESS", result);
21
+ }
22
+
5
23
  /**
6
24
  * converter for int32_t
7
25
  */
@@ -45,7 +63,7 @@ RCT_NUMBER_CONVERTER(int32_t, intValue)
45
63
  */
46
64
  -(void)onErrorException:(THETACThetaRepositoryThetaRepositoryException *)exception
47
65
  {
48
- _reject(@"error", exception.message, nil);
66
+ _reject(ERROR_CODE_ERROR, exception.message, nil);
49
67
  _sdk.photoCapture = nil;
50
68
  }
51
69
 
@@ -58,6 +76,74 @@ RCT_NUMBER_CONVERTER(int32_t, intValue)
58
76
  _resolve(fileUrl);
59
77
  _sdk.photoCapture = nil;
60
78
  }
79
+
80
+ - (void)onProgressCompletion:(float)completion {
81
+ }
82
+
83
+ @end
84
+
85
+ /**
86
+ * time-shift startCapture callback holder
87
+ */
88
+ typedef void (^ TimeShiftOnProgressBlock)(float);
89
+ @interface TimeShiftStartCallback: NSObject <THETACTimeShiftCaptureStartCaptureCallback>
90
+ @end
91
+ @implementation TimeShiftStartCallback {
92
+ RCTPromiseResolveBlock _resolve; ///< start capture resolver
93
+ TimeShiftOnProgressBlock _onProgress; ///< start capture resolver
94
+ RCTPromiseRejectBlock _reject; ///< start capture rejecter
95
+ ThetaClientReactNative *_sdk; ///< theta client sdk instance
96
+ }
97
+
98
+ /**
99
+ * initialize TimeShiftCallback
100
+ * @param sdk theta client sdk instance
101
+ * @param resolve resolver for promise
102
+ * @param reject rejecter for promise
103
+ * @return initialized callback instance
104
+ */
105
+ -(id)initWith:(ThetaClientReactNative *)sdk
106
+ withProgress:(TimeShiftOnProgressBlock)onProgress
107
+ withResolver:(RCTPromiseResolveBlock)resolve
108
+ withRejecter:(RCTPromiseRejectBlock)reject
109
+ {
110
+ self = [super init];
111
+ if (self) {
112
+ _sdk = sdk;
113
+ _onProgress = onProgress;
114
+ _resolve = resolve;
115
+ _reject = reject;
116
+ }
117
+ return self;
118
+ }
119
+
120
+ /**
121
+ * call when error detect
122
+ * @param exception exception object
123
+ */
124
+ -(void)onErrorException:(THETACThetaRepositoryThetaRepositoryException *)exception {
125
+ _reject(@"error", exception.message, nil);
126
+ _sdk.timeShiftCapture = nil;
127
+ _sdk.timeShiftCapturing = nil;
128
+ }
129
+
130
+ /**
131
+ * call when successfully time-shift captured
132
+ * @param fileUrl captured video file url
133
+ */
134
+ - (void)onSuccessFileUrl_:(NSString * _Nullable)fileUrl {
135
+ _resolve(fileUrl != nil ? fileUrl : [NSNull null]);
136
+ _sdk.timeShiftCapture = nil;
137
+ _sdk.timeShiftCapturing = nil;
138
+ }
139
+
140
+ /**
141
+ * call when check time-shift progress
142
+ * @param completion captured video file url
143
+ */
144
+ - (void)onProgressCompletion:(float)completion {
145
+ _onProgress(completion);
146
+ }
61
147
  @end
62
148
 
63
149
  /**
@@ -97,7 +183,7 @@ RCT_NUMBER_CONVERTER(int32_t, intValue)
97
183
  */
98
184
  -(void)onErrorException:(THETACThetaRepositoryThetaRepositoryException *)exception
99
185
  {
100
- _reject(@"error", exception.message, nil);
186
+ _reject(ERROR_CODE_ERROR, exception.message, nil);
101
187
  _sdk.videoCapture = nil;
102
188
  _sdk.videoCapturing = nil;
103
189
  }
@@ -166,24 +252,34 @@ static CFTimeInterval FRAME_INTERVAL = (CFTimeInterval) (1.0/10.0);
166
252
  }
167
253
  @end
168
254
 
255
+ /**
256
+ * check null for object
257
+ */
258
+ static bool isNull(id obj) {
259
+ return (obj == nil || obj == [NSNull null]);
260
+ }
261
+
169
262
  /** opiton converter from theta to react */
170
263
  typedef void (^SetFromTheta)(NSMutableDictionary *, THETACThetaRepositoryOptions *);
171
264
  /** option converter from react to theta */
172
265
  typedef void (^SetToTheta)(NSDictionary *, THETACThetaRepositoryOptions *);
173
266
  /** option converter to set photo option */
174
267
  typedef void (^SetPhotoOption)(NSDictionary *, THETACPhotoCaptureBuilder *);
268
+ /** option converter to set time-shift option */
269
+ typedef void (^SetTimeShiftOption)(NSDictionary *, THETACTimeShiftCaptureBuilder *);
175
270
  /** option converter to set video option */
176
271
  typedef void (^SetVideoOption)(NSDictionary *, THETACVideoCaptureBuilder *);
177
272
 
178
273
  typedef struct _convert_t {
179
- NSDictionary* toTheta; ///< dictionary react to theta
180
- NSDictionary* fromTheta; ///< dictionary theta to react
181
- NSDictionary* photoOption; ///< dictionary photoOption
182
- NSDictionary* videoOption; ///< dictionary videoOption
183
- SetToTheta setToTheta; ///< option setter react to theta
184
- SetFromTheta setFromTheta; ///< option setter theta to react
185
- SetPhotoOption setPhotoOption; ///< photo option setter
186
- SetVideoOption setVideoOption; ///< video option setter
274
+ NSDictionary* toTheta; ///< dictionary react to theta
275
+ NSDictionary* fromTheta; ///< dictionary theta to react
276
+ NSDictionary* photoOption; ///< dictionary photoOption
277
+ NSDictionary* videoOption; ///< dictionary videoOption
278
+ SetToTheta setToTheta; ///< option setter react to theta
279
+ SetFromTheta setFromTheta; ///< option setter theta to react
280
+ SetPhotoOption setPhotoOption; ///< photo option setter
281
+ SetTimeShiftOption setTimeShiftOption; ///< photo option setter
282
+ SetVideoOption setVideoOption; ///< video option setter
187
283
  } convert_t;
188
284
 
189
285
  /**
@@ -197,6 +293,62 @@ static convert_t ChargingStateEnum = {
197
293
  }
198
294
  };
199
295
 
296
+ static convert_t CaptureStatusEnum = {
297
+ .fromTheta = @{
298
+ THETACThetaRepositoryCaptureStatusEnum.shooting: @"SHOOTING",
299
+ THETACThetaRepositoryCaptureStatusEnum.idle: @"IDLE",
300
+ THETACThetaRepositoryCaptureStatusEnum.selfTimerCountdown: @"SELF_TIMER_COUNTDOWN",
301
+ THETACThetaRepositoryCaptureStatusEnum.bracketShooting: @"BRACKET_SHOOTING",
302
+ THETACThetaRepositoryCaptureStatusEnum.converting: @"CONVERTING",
303
+ THETACThetaRepositoryCaptureStatusEnum.timeShiftShooting: @"TIME_SHIFT_SHOOTING",
304
+ THETACThetaRepositoryCaptureStatusEnum.continuousShooting: @"CONTINUOUS_SHOOTING",
305
+ THETACThetaRepositoryCaptureStatusEnum.retrospectiveImageRecording: @"RETROSPECTIVE_IMAGE_RECORDING"
306
+ }
307
+ };
308
+
309
+ static convert_t ShootingFunctionEnum = {
310
+ .fromTheta = @{
311
+ THETACThetaRepositoryShootingFunctionEnum.normal: @"NORMAL",
312
+ THETACThetaRepositoryShootingFunctionEnum.selfTimer: @"SELF_TIMER",
313
+ THETACThetaRepositoryShootingFunctionEnum.mySetting: @"MY_SETTING"
314
+ }
315
+ };
316
+
317
+ static convert_t MicrophoneOptionEnum = {
318
+ .fromTheta = @{
319
+ THETACThetaRepositoryMicrophoneOptionEnum.auto_: @"AUTO",
320
+ THETACThetaRepositoryMicrophoneOptionEnum.internal: @"INTERNAL",
321
+ THETACThetaRepositoryMicrophoneOptionEnum.external: @"EXTERNAL"
322
+ }
323
+ };
324
+
325
+ static convert_t CameraErrorEnum = {
326
+ .fromTheta = @{
327
+ THETACThetaRepositoryCameraErrorEnum.noMemory: @"NO_MEMORY",
328
+ THETACThetaRepositoryCameraErrorEnum.fileNumberOver: @"FILE_NUMBER_OVER",
329
+ THETACThetaRepositoryCameraErrorEnum.noDateSetting: @"NO_DATE_SETTING",
330
+ THETACThetaRepositoryCameraErrorEnum.readError: @"READ_ERROR",
331
+ THETACThetaRepositoryCameraErrorEnum.notSupportedMediaType: @"NOT_SUPPORTED_MEDIA_TYPE",
332
+ THETACThetaRepositoryCameraErrorEnum.notSupportedFileSystem: @"NOT_SUPPORTED_FILE_SYSTEM",
333
+ THETACThetaRepositoryCameraErrorEnum.mediaNotReady: @"MEDIA_NOT_READY",
334
+ THETACThetaRepositoryCameraErrorEnum.notEnoughBattery: @"NOT_ENOUGH_BATTERY",
335
+ THETACThetaRepositoryCameraErrorEnum.invalidFile: @"INVALID_FILE",
336
+ THETACThetaRepositoryCameraErrorEnum.pluginBootError: @"PLUGIN_BOOT_ERROR",
337
+ THETACThetaRepositoryCameraErrorEnum.inProgressError: @"IN_PROGRESS_ERROR",
338
+ THETACThetaRepositoryCameraErrorEnum.cannotRecording: @"CANNOT_RECORDING",
339
+ THETACThetaRepositoryCameraErrorEnum.cannotRecordLowbat: @"CANNOT_RECORD_LOWBAT",
340
+ THETACThetaRepositoryCameraErrorEnum.captureHwFailed: @"CAPTURE_HW_FAILED",
341
+ THETACThetaRepositoryCameraErrorEnum.captureSwFailed: @"CAPTURE_SW_FAILED",
342
+ THETACThetaRepositoryCameraErrorEnum.internalMemAccessFail: @"INTERNAL_MEM_ACCESS_FAIL",
343
+ THETACThetaRepositoryCameraErrorEnum.unexpectedError: @"UNEXPECTED_ERROR",
344
+ THETACThetaRepositoryCameraErrorEnum.batteryChargeFail: @"BATTERY_CHARGE_FAIL",
345
+ THETACThetaRepositoryCameraErrorEnum.highTemperatureWarning: @"HIGH_TEMPERATURE_WARNING",
346
+ THETACThetaRepositoryCameraErrorEnum.highTemperature: @"HIGH_TEMPERATURE",
347
+ THETACThetaRepositoryCameraErrorEnum.batteryHighTemperature: @"BATTERY_HIGH_TEMPERATURE",
348
+ THETACThetaRepositoryCameraErrorEnum.compassCalibration: @"COMPASS_CALIBRATION"
349
+ }
350
+ };
351
+
200
352
  /**
201
353
  * FileTypeEnum converter
202
354
  */
@@ -208,6 +360,17 @@ static convert_t FileTypeEnum = {
208
360
  }
209
361
  };
210
362
 
363
+ /**
364
+ * StorageEnum converter
365
+ */
366
+ static convert_t StorageEnum = {
367
+ .toTheta = @{
368
+ @"INTERNAL": THETACThetaRepositoryStorageEnum.internal,
369
+ @"SD": THETACThetaRepositoryStorageEnum.sd,
370
+ @"CURRENT": THETACThetaRepositoryStorageEnum.current,
371
+ }
372
+ };
373
+
211
374
  /**
212
375
  * AuthModeEnum converter
213
376
  */
@@ -262,6 +425,12 @@ static convert_t ApertureEnum = {
262
425
  [builder setApertureAperture:val];
263
426
  }
264
427
  },
428
+ .setTimeShiftOption = ^(NSDictionary* rct, THETACTimeShiftCaptureBuilder *builder) {
429
+ id val = [ApertureEnum.toTheta objectForKey:[rct objectForKey:@"aperture"]];
430
+ if (val) {
431
+ [builder setApertureAperture:val];
432
+ }
433
+ },
265
434
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
266
435
  id val = [ApertureEnum.toTheta objectForKey:[rct objectForKey:@"aperture"]];
267
436
  if (val) {
@@ -270,6 +439,88 @@ static convert_t ApertureEnum = {
270
439
  }
271
440
  };
272
441
 
442
+ /**
443
+ * BluetoothPowerEnum converter
444
+ */
445
+ static convert_t BluetoothPowerEnum = {
446
+ .toTheta = @{
447
+ @"ON": THETACThetaRepositoryBluetoothPowerEnum.on,
448
+ @"OFF": THETACThetaRepositoryBluetoothPowerEnum.off
449
+ },
450
+ .fromTheta = @{
451
+ THETACThetaRepositoryBluetoothPowerEnum.on: @"ON",
452
+ THETACThetaRepositoryBluetoothPowerEnum.off: @"OFF"
453
+ },
454
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
455
+ id val = [BluetoothPowerEnum.toTheta objectForKey:[rct objectForKey:@"bluetoothPower"]];
456
+ if (val) {
457
+ opt.bluetoothPower = val;
458
+ }
459
+ },
460
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
461
+ id val = [BluetoothPowerEnum.fromTheta objectForKey:opt.bluetoothPower];
462
+ if (val) {
463
+ [rct setObject:val forKey:@"bluetoothPower"];
464
+ }
465
+ }
466
+ };
467
+
468
+ /**
469
+ * CameraControlSourceEnum converter
470
+ */
471
+ static convert_t CameraControlSourceEnum = {
472
+ .toTheta = @{
473
+ @"CAMERA": THETACThetaRepositoryCameraControlSourceEnum.camera,
474
+ @"APP": THETACThetaRepositoryCameraControlSourceEnum.app
475
+ },
476
+ .fromTheta = @{
477
+ THETACThetaRepositoryCameraControlSourceEnum.camera: @"CAMERA",
478
+ THETACThetaRepositoryCameraControlSourceEnum.app: @"APP"
479
+ },
480
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
481
+ id val = [CameraControlSourceEnum.toTheta objectForKey:[rct objectForKey:@"cameraControlSource"]];
482
+ if (val) {
483
+ opt.cameraControlSource = val;
484
+ }
485
+ },
486
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
487
+ id val = [CameraControlSourceEnum.fromTheta objectForKey:opt.cameraControlSource];
488
+ if (val) {
489
+ [rct setObject:val forKey:@"cameraControlSource"];
490
+ }
491
+ }
492
+ };
493
+
494
+ /**
495
+ * CameraModeEnum converter
496
+ */
497
+ static convert_t CameraModeEnum = {
498
+ .toTheta = @{
499
+ @"CAPTURE": THETACThetaRepositoryCameraModeEnum.capture,
500
+ @"PLAYBACK": THETACThetaRepositoryCameraModeEnum.playback,
501
+ @"SETTING": THETACThetaRepositoryCameraModeEnum.setting,
502
+ @"PLUGIN": THETACThetaRepositoryCameraModeEnum.plugin
503
+ },
504
+ .fromTheta = @{
505
+ THETACThetaRepositoryCameraModeEnum.capture: @"CAPTURE",
506
+ THETACThetaRepositoryCameraModeEnum.playback: @"PLAYBACK",
507
+ THETACThetaRepositoryCameraModeEnum.setting: @"SETTING",
508
+ THETACThetaRepositoryCameraModeEnum.plugin: @"PLUGIN"
509
+ },
510
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
511
+ id val = [CameraModeEnum.toTheta objectForKey:[rct objectForKey:@"cameraMode"]];
512
+ if (val) {
513
+ opt.cameraMode = val;
514
+ }
515
+ },
516
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
517
+ id val = [CameraModeEnum.fromTheta objectForKey:opt.cameraMode];
518
+ if (val) {
519
+ [rct setObject:val forKey:@"cameraMode"];
520
+ }
521
+ }
522
+ };
523
+
273
524
  /**
274
525
  * CaptureModeEnum converter
275
526
  */
@@ -350,6 +601,12 @@ static convert_t ExposureCompensationEnum = {
350
601
  [builder setExposureCompensationValue:val];
351
602
  }
352
603
  },
604
+ .setTimeShiftOption = ^(NSDictionary* rct, THETACTimeShiftCaptureBuilder *builder) {
605
+ id val = [ExposureCompensationEnum.toTheta objectForKey:[rct objectForKey:@"exposureCompensation"]];
606
+ if (val) {
607
+ [builder setExposureCompensationValue:val];
608
+ }
609
+ },
353
610
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
354
611
  id val = [ExposureCompensationEnum.toTheta
355
612
  objectForKey:[rct objectForKey:@"exposureCompensation"]];
@@ -407,6 +664,12 @@ static convert_t ExposureDelayEnum = {
407
664
  [builder setExposureDelayDelay:val];
408
665
  }
409
666
  },
667
+ .setTimeShiftOption = ^(NSDictionary* rct, THETACTimeShiftCaptureBuilder *builder) {
668
+ id val = [ExposureDelayEnum.toTheta objectForKey:[rct objectForKey:@"exposureDelay"]];
669
+ if (val) {
670
+ [builder setExposureDelayDelay:val];
671
+ }
672
+ },
410
673
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
411
674
  id val = [ExposureDelayEnum.toTheta objectForKey:[rct objectForKey:@"exposureDelay"]];
412
675
  if (val) {
@@ -453,6 +716,12 @@ static convert_t ExposureProgramEnum = {
453
716
  [builder setExposureProgramProgram:val];
454
717
  }
455
718
  },
719
+ .setTimeShiftOption = ^(NSDictionary* rct, THETACTimeShiftCaptureBuilder *builder) {
720
+ id val = [ExposureProgramEnum.toTheta objectForKey:[rct objectForKey:@"exposureProgram"]];
721
+ if (val) {
722
+ [builder setExposureProgramProgram:val];
723
+ }
724
+ },
456
725
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
457
726
  id val = [ExposureProgramEnum.toTheta
458
727
  objectForKey:[rct objectForKey:@"exposureProgram"]];
@@ -629,6 +898,12 @@ static convert_t GpsTagRecordingEnum = {
629
898
  [builder setGpsTagRecordingValue:val];
630
899
  }
631
900
  },
901
+ .setTimeShiftOption = ^(NSDictionary* rct, THETACTimeShiftCaptureBuilder *builder) {
902
+ id val = [GpsTagRecordingEnum.toTheta objectForKey:[rct objectForKey:@"_gpsTagRecording"]];
903
+ if (val) {
904
+ [builder setGpsTagRecordingValue:val];
905
+ }
906
+ },
632
907
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
633
908
  id val = [GpsTagRecordingEnum.toTheta
634
909
  objectForKey:[rct objectForKey:@"_gpsTagRecording"]];
@@ -710,6 +985,12 @@ static convert_t IsoEnum = {
710
985
  [builder setIsoIso:val];
711
986
  }
712
987
  },
988
+ .setTimeShiftOption = ^(NSDictionary* rct, THETACTimeShiftCaptureBuilder *builder) {
989
+ id val = [IsoEnum.toTheta objectForKey:[rct objectForKey:@"iso"]];
990
+ if (val) {
991
+ [builder setIsoIso:val];
992
+ }
993
+ },
713
994
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
714
995
  id val = [IsoEnum.toTheta objectForKey:[rct objectForKey:@"iso"]];
715
996
  if (val) {
@@ -784,6 +1065,12 @@ static convert_t IsoAutoHighLimitEnum = {
784
1065
  [builder setIsoAutoHighLimitIso:val];
785
1066
  }
786
1067
  },
1068
+ .setTimeShiftOption = ^(NSDictionary* rct, THETACTimeShiftCaptureBuilder *builder) {
1069
+ id val = [IsoAutoHighLimitEnum.toTheta objectForKey:[rct objectForKey:@"isoAutoHighLimit"]];
1070
+ if (val) {
1071
+ [builder setIsoAutoHighLimitIso:val];
1072
+ }
1073
+ },
787
1074
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
788
1075
  id val = [IsoAutoHighLimitEnum.toTheta
789
1076
  objectForKey:[rct objectForKey:@"isoAutoHighLimit"]];
@@ -840,12 +1127,16 @@ static convert_t MaxRecordableTimeEnum = {
840
1127
  .toTheta = @{
841
1128
  @"RECORDABLE_TIME_180": THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime180,
842
1129
  @"RECORDABLE_TIME_300": THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime300,
843
- @"RECORDABLE_TIME_1500": THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime1500
1130
+ @"RECORDABLE_TIME_1500": THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime1500,
1131
+ @"RECORDABLE_TIME_7200": THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime7200,
1132
+ @"DO_NOT_UPDATE_MY_SETTING_CONDITION": THETACThetaRepositoryMaxRecordableTimeEnum.doNotUpdateMySettingCondition
844
1133
  },
845
1134
  .fromTheta = @{
846
1135
  THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime180: @"RECORDABLE_TIME_180",
847
1136
  THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime300: @"RECORDABLE_TIME_300",
848
- THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime1500: @"RECORDABLE_TIME_1500"
1137
+ THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime1500: @"RECORDABLE_TIME_1500",
1138
+ THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime7200: @"RECORDABLE_TIME_7200",
1139
+ THETACThetaRepositoryMaxRecordableTimeEnum.doNotUpdateMySettingCondition: @"DO_NOT_UPDATE_MY_SETTING_CONDITION"
849
1140
  },
850
1141
  .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
851
1142
  id val = [MaxRecordableTimeEnum.toTheta
@@ -911,6 +1202,71 @@ static convert_t OffDelayEnum = {
911
1202
  }
912
1203
  };
913
1204
 
1205
+ /**
1206
+ * PowerSaving convertor
1207
+ */
1208
+ static convert_t PowerSavingEnum = {
1209
+ .toTheta = @{
1210
+ @"ON": THETACThetaRepositoryPowerSavingEnum.on,
1211
+ @"OFF": THETACThetaRepositoryPowerSavingEnum.off
1212
+ },
1213
+ .fromTheta = @{
1214
+ THETACThetaRepositoryPowerSavingEnum.on: @"ON",
1215
+ THETACThetaRepositoryPowerSavingEnum.off: @"OFF"
1216
+ },
1217
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1218
+ id val = [PowerSavingEnum.toTheta objectForKey:[rct objectForKey:@"powerSaving"]];
1219
+ if (val) {
1220
+ opt.powerSaving = val;
1221
+ }
1222
+ },
1223
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1224
+ id val = [PowerSavingEnum.fromTheta objectForKey:opt.powerSaving];
1225
+ if (val) {
1226
+ [rct setObject:val forKey:@"powerSaving"];
1227
+ }
1228
+ }
1229
+ };
1230
+
1231
+ /**
1232
+ * PreviewFormat convertor
1233
+ */
1234
+ static convert_t PreviewFormatEnum = {
1235
+ .toTheta = @{
1236
+ @"W1024_H512_F30": THETACThetaRepositoryPreviewFormatEnum.w1024H512F30,
1237
+ @"W1024_H512_F15": THETACThetaRepositoryPreviewFormatEnum.w1024H512F15,
1238
+ @"W512_H512_F30": THETACThetaRepositoryPreviewFormatEnum.w512H512F30,
1239
+ @"W1920_H960_F8": THETACThetaRepositoryPreviewFormatEnum.w1920H960F8,
1240
+ @"W1024_H512_F8": THETACThetaRepositoryPreviewFormatEnum.w1024H512F8,
1241
+ @"W640_H320_F30": THETACThetaRepositoryPreviewFormatEnum.w640H320F30,
1242
+ @"W640_H320_F8": THETACThetaRepositoryPreviewFormatEnum.w640H320F8,
1243
+ @"W640_H320_F10": THETACThetaRepositoryPreviewFormatEnum.w640H320F10
1244
+ },
1245
+ .fromTheta = @{
1246
+ THETACThetaRepositoryPreviewFormatEnum.w1024H512F30: @"W1024_H512_F30",
1247
+ THETACThetaRepositoryPreviewFormatEnum.w1024H512F15: @"W1024_H512_F15",
1248
+ THETACThetaRepositoryPreviewFormatEnum.w512H512F30: @"W512_H512_F30",
1249
+ THETACThetaRepositoryPreviewFormatEnum.w1920H960F8: @"W1920_H960_F8",
1250
+ THETACThetaRepositoryPreviewFormatEnum.w1024H512F8: @"W1024_H512_F8",
1251
+ THETACThetaRepositoryPreviewFormatEnum.w640H320F30: @"W640_H320_F30",
1252
+ THETACThetaRepositoryPreviewFormatEnum.w640H320F8: @"W640_H320_F8",
1253
+ THETACThetaRepositoryPreviewFormatEnum.w640H320F10: @"W640_H320_F10",
1254
+ },
1255
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1256
+ id val = [PreviewFormatEnum.toTheta objectForKey:[rct objectForKey:@"previewFormat"]];
1257
+ if (val) {
1258
+ opt.previewFormat = val;
1259
+ }
1260
+ },
1261
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1262
+ id val = [PreviewFormatEnum.fromTheta objectForKey:opt.previewFormat];
1263
+ if (val) {
1264
+ [rct setObject:val forKey:@"previewFormat"];
1265
+ }
1266
+ }
1267
+ };
1268
+
1269
+
914
1270
  /**
915
1271
  * WhiteBalanceEnum converter
916
1272
  */
@@ -971,6 +1327,33 @@ static convert_t WhiteBalanceEnum = {
971
1327
  }
972
1328
  };
973
1329
 
1330
+
1331
+ /**
1332
+ * WhiteBalanceAutoStrengthEnum converter
1333
+ */
1334
+ static convert_t WhiteBalanceAutoStrengthEnum = {
1335
+ .toTheta = @{
1336
+ @"ON": THETACThetaRepositoryWhiteBalanceAutoStrengthEnum.on,
1337
+ @"OFF": THETACThetaRepositoryWhiteBalanceAutoStrengthEnum.off
1338
+ },
1339
+ .fromTheta = @{
1340
+ THETACThetaRepositoryWhiteBalanceAutoStrengthEnum.on: @"ON",
1341
+ THETACThetaRepositoryWhiteBalanceAutoStrengthEnum.off: @"OFF"
1342
+ },
1343
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1344
+ id val = [WhiteBalanceAutoStrengthEnum.toTheta objectForKey:[rct objectForKey:@"whiteBalanceAutoStrength"]];
1345
+ if (val) {
1346
+ opt.whiteBalanceAutoStrength = val;
1347
+ }
1348
+ },
1349
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1350
+ id val = [WhiteBalanceAutoStrengthEnum.fromTheta objectForKey:opt.whiteBalanceAutoStrength];
1351
+ if (val) {
1352
+ [rct setObject:val forKey:@"whiteBalanceAutoStrength"];
1353
+ }
1354
+ }
1355
+ };
1356
+
974
1357
  /**
975
1358
  * ColorTemperature converter
976
1359
  */
@@ -978,11 +1361,13 @@ static convert_t ColorTemperatureCvt = {
978
1361
  .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
979
1362
  NSNumber* val = [rct objectForKey:@"colorTemperature"];
980
1363
  if (val) {
981
- opt.colorTemperature = (THETACInt *) val;
1364
+ opt.colorTemperature = [THETACInt numberWithInt:[val intValue]];
982
1365
  }
983
1366
  },
984
1367
  .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
985
- [rct setObject:opt.colorTemperature forKey:@"colorTemperature"];
1368
+ if (opt.colorTemperature) {
1369
+ [rct setObject:opt.colorTemperature forKey:@"colorTemperature"];
1370
+ }
986
1371
  },
987
1372
  .setPhotoOption = ^(NSDictionary* rct, THETACPhotoCaptureBuilder *builder) {
988
1373
  NSNumber *val = (NSNumber*) [rct objectForKey:@"colorTemperature"];
@@ -1022,7 +1407,7 @@ static convert_t IsGpsOnCvt = {
1022
1407
  .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1023
1408
  NSNumber* val = [rct objectForKey:@"isGpsOn"];
1024
1409
  if (val) {
1025
- opt.isGpsOn = (THETACBoolean *) val;
1410
+ opt.isGpsOn = [THETACBoolean numberWithBool:[val boolValue]];
1026
1411
  }
1027
1412
  },
1028
1413
  .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
@@ -1032,6 +1417,44 @@ static convert_t IsGpsOnCvt = {
1032
1417
  }
1033
1418
  };
1034
1419
 
1420
+ /**
1421
+ * ShutterSpeed converter
1422
+ */
1423
+ static convert_t ShutterSpeedEnum = {
1424
+ .toTheta = nil,
1425
+ .fromTheta = nil,
1426
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1427
+ if (!ShutterSpeedEnum.toTheta) {
1428
+ NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
1429
+ THETACKotlinArray* array = THETACThetaRepositoryShutterSpeedEnum.values;
1430
+ for (int i = 0; i < array.size; i++) {
1431
+ THETACThetaRepositorySleepDelayEnum* item = [array getIndex:i];
1432
+ [dictionary setObject:item forKey:item.name];
1433
+ }
1434
+ ShutterSpeedEnum.toTheta = dictionary;
1435
+ }
1436
+ id val = [ShutterSpeedEnum.toTheta objectForKey:[rct objectForKey:@"shutterSpeed"]];
1437
+ if (val) {
1438
+ opt.shutterSpeed = val;
1439
+ }
1440
+ },
1441
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1442
+ if (!ShutterSpeedEnum.fromTheta) {
1443
+ NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
1444
+ THETACKotlinArray* array = THETACThetaRepositoryShutterSpeedEnum.values;
1445
+ for (int i = 0; i < array.size; i++) {
1446
+ THETACThetaRepositorySleepDelayEnum* item = [array getIndex:i];
1447
+ [dictionary setObject:item.name forKey:item];
1448
+ }
1449
+ ShutterSpeedEnum.fromTheta = dictionary;
1450
+ }
1451
+ id val = [ShutterSpeedEnum.fromTheta objectForKey:opt.shutterSpeed];
1452
+ if (val) {
1453
+ [rct setObject:val forKey:@"shutterSpeed"];
1454
+ }
1455
+ }
1456
+ };
1457
+
1035
1458
  /**
1036
1459
  * SleepDelay converter
1037
1460
  */
@@ -1081,7 +1504,7 @@ static convert_t RemainingPicturesCvt = {
1081
1504
  .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1082
1505
  NSNumber* val = [rct objectForKey:@"remainingPictures"];
1083
1506
  if (val) {
1084
- opt.remainingPictures = (THETACInt *) val;
1507
+ opt.remainingPictures = [THETACInt numberWithInt:[val intValue]];
1085
1508
  }
1086
1509
  },
1087
1510
  .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
@@ -1098,7 +1521,7 @@ static convert_t RemainingVideoSecondsCvt = {
1098
1521
  .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1099
1522
  NSNumber* val = [rct objectForKey:@"remainingVideoSeconds"];
1100
1523
  if (val) {
1101
- opt.remainingVideoSeconds = (THETACInt *) val;
1524
+ opt.remainingVideoSeconds = [THETACInt numberWithInt:[val intValue]];
1102
1525
  }
1103
1526
  },
1104
1527
  .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
@@ -1115,7 +1538,7 @@ static convert_t RemainingSpaceCvt = {
1115
1538
  .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1116
1539
  NSNumber* val = [rct objectForKey:@"remainingSpace"];
1117
1540
  if (val) {
1118
- opt.remainingSpace = (THETACLong *) val;
1541
+ opt.remainingSpace = [THETACLong numberWithLongLong:[val longLongValue]];
1119
1542
  }
1120
1543
  },
1121
1544
  .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
@@ -1132,7 +1555,7 @@ static convert_t TotalSpaceCvt = {
1132
1555
  .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1133
1556
  NSNumber* val = [rct objectForKey:@"totalSpace"];
1134
1557
  if (val) {
1135
- opt.totalSpace = (THETACLong *) val;
1558
+ opt.totalSpace = [THETACLong numberWithLongLong:[val longLongValue]];
1136
1559
  }
1137
1560
  },
1138
1561
  .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
@@ -1149,7 +1572,7 @@ static convert_t ShutterVolumeCvt = {
1149
1572
  .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1150
1573
  NSNumber* val = [rct objectForKey:@"shutterVolume"];
1151
1574
  if (val) {
1152
- opt.shutterVolume = (THETACInt *) val;
1575
+ opt.shutterVolume = [THETACInt numberWithInt:[val intValue]];
1153
1576
  }
1154
1577
  },
1155
1578
  .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
@@ -1189,61 +1612,328 @@ static convert_t GpsInfoCvt = {
1189
1612
  };
1190
1613
 
1191
1614
  /**
1192
- * OptionNames converter
1615
+ * NetworkType converter
1193
1616
  */
1194
- static NSDictionary *NameToOptionEnum = @{
1195
- @"Aperture": THETACThetaRepositoryOptionNameEnum.aperture,
1196
- @"CaptureMode": THETACThetaRepositoryOptionNameEnum.capturemode,
1197
- @"ColorTemperature": THETACThetaRepositoryOptionNameEnum.colortemperature,
1198
- @"DateTimeZone": THETACThetaRepositoryOptionNameEnum.datetimezone,
1199
- @"ExposureCompensation": THETACThetaRepositoryOptionNameEnum.exposurecompensation,
1200
- @"ExposureDelay": THETACThetaRepositoryOptionNameEnum.exposuredelay,
1201
- @"ExposureProgram": THETACThetaRepositoryOptionNameEnum.exposureprogram,
1202
- @"FileFormat": THETACThetaRepositoryOptionNameEnum.fileformat,
1203
- @"Filter": THETACThetaRepositoryOptionNameEnum.filter,
1204
- @"GpsInfo": THETACThetaRepositoryOptionNameEnum.gpsinfo,
1205
- @"IsGpsOn": THETACThetaRepositoryOptionNameEnum.isgpson,
1206
- @"Iso": THETACThetaRepositoryOptionNameEnum.iso,
1207
- @"IsoAutoHighLimit": THETACThetaRepositoryOptionNameEnum.isoautohighlimit,
1208
- @"Language": THETACThetaRepositoryOptionNameEnum.language,
1209
- @"MaxRecordableTime": THETACThetaRepositoryOptionNameEnum.maxrecordabletime,
1210
- @"OffDelay": THETACThetaRepositoryOptionNameEnum.offdelay,
1211
- @"SleepDelay": THETACThetaRepositoryOptionNameEnum.sleepdelay,
1212
- @"RemainingPictures": THETACThetaRepositoryOptionNameEnum.remainingpictures,
1213
- @"RemainingVideoSeconds": THETACThetaRepositoryOptionNameEnum.remainingvideoseconds,
1214
- @"RemainingSpace": THETACThetaRepositoryOptionNameEnum.remainingspace,
1215
- @"TotalSpace": THETACThetaRepositoryOptionNameEnum.totalspace,
1216
- @"ShutterVolume": THETACThetaRepositoryOptionNameEnum.shuttervolume,
1217
- @"WhiteBalance": THETACThetaRepositoryOptionNameEnum.whitebalance
1617
+ static convert_t NetworkTypeEnum = {
1618
+ .toTheta = @{
1619
+ @"DIRECT": THETACThetaRepositoryNetworkTypeEnum.direct,
1620
+ @"CLIENT": THETACThetaRepositoryNetworkTypeEnum.client,
1621
+ @"ETHERNET": THETACThetaRepositoryNetworkTypeEnum.ethernet,
1622
+ @"OFF": THETACThetaRepositoryNetworkTypeEnum.off
1623
+ },
1624
+ .fromTheta = @{
1625
+ THETACThetaRepositoryNetworkTypeEnum.direct: @"DIRECT",
1626
+ THETACThetaRepositoryNetworkTypeEnum.client: @"CLIENT",
1627
+ THETACThetaRepositoryNetworkTypeEnum.ethernet: @"ETHERNET",
1628
+ THETACThetaRepositoryNetworkTypeEnum.off: @"OFF"
1629
+ },
1630
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1631
+ id val = [NetworkTypeEnum.toTheta objectForKey:[rct objectForKey:@"networkType"]];
1632
+ if (val) {
1633
+ opt.networkType = val;
1634
+ }
1635
+ },
1636
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1637
+ id val = [NetworkTypeEnum.fromTheta objectForKey:opt.networkType];
1638
+ if (val) {
1639
+ [rct setObject:val forKey:@"networkType"];
1640
+ }
1641
+ }
1218
1642
  };
1219
1643
 
1220
1644
  /**
1221
- * OptionNameEnum to OptionName
1645
+ * WlanFrequency converter
1222
1646
  */
1223
- static NSDictionary *OptionEnumToOption = @{
1224
- @"Aperture": @"aperture",
1225
- @"CaptureMode": @"captureMode",
1226
- @"ColorTemperature": @"colorTemperature",
1227
- @"DateTimeZone": @"dateTimeZone",
1228
- @"ExposureCompensation": @"exposureCompensation",
1229
- @"ExposureDelay": @"exposureDelay",
1230
- @"ExposureProgram": @"exposureProgram",
1231
- @"FileFormat": @"fileFormat",
1232
- @"Filter": @"filter",
1233
- @"GpsInfo": @"gpsInfo",
1234
- @"IsGpsOn": @"isGpsOn",
1647
+ static convert_t WlanFrequencyEnum = {
1648
+ .toTheta = @{
1649
+ @"GHZ_2_4": THETACThetaRepositoryWlanFrequencyEnum.ghz24,
1650
+ @"GHZ_5": THETACThetaRepositoryWlanFrequencyEnum.ghz5
1651
+ },
1652
+ .fromTheta = @{
1653
+ THETACThetaRepositoryWlanFrequencyEnum.ghz24: @"GHZ_2_4",
1654
+ THETACThetaRepositoryWlanFrequencyEnum.ghz5: @"GHZ_5",
1655
+ },
1656
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1657
+ id val = [WlanFrequencyEnum.toTheta objectForKey:[rct objectForKey:@"wlanFrequency"]];
1658
+ if (val) {
1659
+ opt.wlanFrequency = val;
1660
+ }
1661
+ },
1662
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1663
+ id val = [WlanFrequencyEnum.fromTheta objectForKey:opt.wlanFrequency];
1664
+ if (val) {
1665
+ [rct setObject:val forKey:@"wlanFrequency"];
1666
+ }
1667
+ }
1668
+ };
1669
+
1670
+ /**
1671
+ * Password converter
1672
+ */
1673
+ static convert_t PasswordCvt = {
1674
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1675
+ NSString* val = [rct objectForKey:@"password"];
1676
+ if (val) {
1677
+ opt.password = val;
1678
+ }
1679
+ },
1680
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1681
+ if (opt.password) {
1682
+ [rct setObject:opt.password forKey:@"password"];
1683
+ }
1684
+ }
1685
+ };
1686
+
1687
+ /**
1688
+ * Proxy converter
1689
+ */
1690
+ static convert_t ProxyCvt = {
1691
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1692
+ NSDictionary *proxyDic = [rct objectForKey:@"proxy"];
1693
+ if (proxyDic) {
1694
+ opt.proxy = [[THETACThetaRepositoryProxy alloc]
1695
+ initWithUse:!isNull([proxyDic objectForKey:@"use"]) ? ((NSNumber*) [proxyDic objectForKey:@"use"]).boolValue : NO
1696
+ url:!isNull([proxyDic objectForKey:@"url"]) ? [proxyDic objectForKey:@"url"] : nil
1697
+ port:!isNull([proxyDic objectForKey:@"port"]) ? [THETACInt numberWithInt:((NSNumber*) [proxyDic objectForKey:@"port"]).intValue] : nil
1698
+ userid:!isNull([proxyDic objectForKey:@"userid"]) ? [proxyDic objectForKey:@"userid"] : nil
1699
+ password:!isNull([proxyDic objectForKey:@"password"]) ? [proxyDic objectForKey:@"password"] : nil];
1700
+ }
1701
+ },
1702
+
1703
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1704
+ if (opt.proxy) {
1705
+ NSMutableDictionary *proxy = [NSMutableDictionary dictionary];
1706
+
1707
+ [proxy setObject:@(opt.proxy.use) forKey:@"use"];
1708
+
1709
+ if (opt.proxy.url) {
1710
+ [proxy setObject:opt.proxy.url forKey:@"url"];
1711
+ }
1712
+
1713
+ if (opt.proxy.port) {
1714
+ [proxy setObject:@(opt.proxy.port.intValue) forKey:@"port"];
1715
+ }
1716
+
1717
+ if (opt.proxy.userid) {
1718
+ [proxy setObject:opt.proxy.userid forKey:@"userid"];
1719
+ }
1720
+
1721
+ if (opt.proxy.password) {
1722
+ [proxy setObject:opt.proxy.password forKey:@"password"];
1723
+ }
1724
+
1725
+ [rct setObject:proxy forKey:@"proxy"];
1726
+ }
1727
+ }
1728
+ };
1729
+
1730
+ /**
1731
+ * TimeShift converter
1732
+ */
1733
+ static convert_t TimeShiftCvt = {
1734
+ .toTheta = @{
1735
+ @"INTERVAL_0": THETACThetaRepositoryTimeShiftIntervalEnum.interval0,
1736
+ @"INTERVAL_1": THETACThetaRepositoryTimeShiftIntervalEnum.interval1,
1737
+ @"INTERVAL_2": THETACThetaRepositoryTimeShiftIntervalEnum.interval2,
1738
+ @"INTERVAL_3": THETACThetaRepositoryTimeShiftIntervalEnum.interval3,
1739
+ @"INTERVAL_4": THETACThetaRepositoryTimeShiftIntervalEnum.interval4,
1740
+ @"INTERVAL_5": THETACThetaRepositoryTimeShiftIntervalEnum.interval5,
1741
+ @"INTERVAL_6": THETACThetaRepositoryTimeShiftIntervalEnum.interval6,
1742
+ @"INTERVAL_7": THETACThetaRepositoryTimeShiftIntervalEnum.interval7,
1743
+ @"INTERVAL_8": THETACThetaRepositoryTimeShiftIntervalEnum.interval8,
1744
+ @"INTERVAL_9": THETACThetaRepositoryTimeShiftIntervalEnum.interval9,
1745
+ @"INTERVAL_10": THETACThetaRepositoryTimeShiftIntervalEnum.interval10
1746
+ },
1747
+ .fromTheta = @{
1748
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval0: @"INTERVAL_0",
1749
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval1: @"INTERVAL_1",
1750
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval2: @"INTERVAL_2",
1751
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval3: @"INTERVAL_3",
1752
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval4: @"INTERVAL_4",
1753
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval5: @"INTERVAL_5",
1754
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval6: @"INTERVAL_6",
1755
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval7: @"INTERVAL_7",
1756
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval8: @"INTERVAL_8",
1757
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval9: @"INTERVAL_9",
1758
+ THETACThetaRepositoryTimeShiftIntervalEnum.interval10: @"INTERVAL_10"
1759
+ },
1760
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1761
+ NSDictionary *timeshiftDic = [rct objectForKey:@"timeShift"];
1762
+ if (timeshiftDic) {
1763
+ opt.timeShift = [[THETACThetaRepositoryTimeShiftSetting alloc]
1764
+ initWithIsFrontFirst:!isNull([timeshiftDic objectForKey:@"isFrontFirst"]) ? [THETACBoolean numberWithBool:((NSNumber*) [timeshiftDic objectForKey:@"isFrontFirst"]).boolValue] : nil
1765
+ firstInterval:!isNull([timeshiftDic objectForKey:@"firstInterval"]) ? [TimeShiftCvt.toTheta objectForKey:[timeshiftDic objectForKey:@"firstInterval"]] : nil
1766
+ secondInterval:!isNull([timeshiftDic objectForKey:@"secondInterval"]) ? [TimeShiftCvt.toTheta objectForKey:[timeshiftDic objectForKey:@"secondInterval"]] : nil];
1767
+ }
1768
+ },
1769
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1770
+ if (opt.timeShift) {
1771
+ NSMutableDictionary *timeshift = [NSMutableDictionary dictionary];
1772
+
1773
+ if (opt.timeShift.isFrontFirst) {
1774
+ [timeshift setObject:@(((NSNumber *) opt.timeShift.isFrontFirst).boolValue) forKey:@"isFrontFirst"];
1775
+ }
1776
+
1777
+ if (opt.timeShift.firstInterval) {
1778
+ [timeshift setObject:[TimeShiftCvt.fromTheta objectForKey:opt.timeShift.firstInterval] forKey:@"firstInterval"];
1779
+ }
1780
+
1781
+ if (opt.timeShift.secondInterval) {
1782
+ [timeshift setObject:[TimeShiftCvt.fromTheta objectForKey:opt.timeShift.secondInterval] forKey:@"secondInterval"];
1783
+ }
1784
+
1785
+ [rct setObject:timeshift forKey:@"timeShift"];
1786
+ }
1787
+ }
1788
+ };
1789
+
1790
+ /**
1791
+ * ShootingMethod convertor
1792
+ */
1793
+ static convert_t ShootingMethodEnum = {
1794
+ .toTheta = @{
1795
+ @"NORMAL": THETACThetaRepositoryShootingMethodEnum.normal,
1796
+ @"INTERVAL": THETACThetaRepositoryShootingMethodEnum.interval,
1797
+ @"MOVE_INTERVAL": THETACThetaRepositoryShootingMethodEnum.moveInterval,
1798
+ @"FIXED_INTERVAL": THETACThetaRepositoryShootingMethodEnum.fixedInterval,
1799
+ @"BRACKET": THETACThetaRepositoryShootingMethodEnum.bracket,
1800
+ @"COMPOSITE": THETACThetaRepositoryShootingMethodEnum.composite,
1801
+ @"CONTINUOUS": THETACThetaRepositoryShootingMethodEnum.continuous,
1802
+ @"TIME_SHIFT": THETACThetaRepositoryShootingMethodEnum.timeShift,
1803
+ @"BURST": THETACThetaRepositoryShootingMethodEnum.burst,
1804
+ },
1805
+ .fromTheta = @{
1806
+ THETACThetaRepositoryShootingMethodEnum.normal: @"NORMAL",
1807
+ THETACThetaRepositoryShootingMethodEnum.interval: @"INTERVAL",
1808
+ THETACThetaRepositoryShootingMethodEnum.moveInterval: @"MOVE_INTERVAL",
1809
+ THETACThetaRepositoryShootingMethodEnum.fixedInterval: @"FIXED_INTERVAL",
1810
+ THETACThetaRepositoryShootingMethodEnum.bracket: @"BRACKET",
1811
+ THETACThetaRepositoryShootingMethodEnum.composite: @"COMPOSITE",
1812
+ THETACThetaRepositoryShootingMethodEnum.continuous: @"CONTINUOUS",
1813
+ THETACThetaRepositoryShootingMethodEnum.timeShift: @"TIME_SHIFT",
1814
+ THETACThetaRepositoryShootingMethodEnum.burst: @"BURST",
1815
+ },
1816
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1817
+ id val = [ShootingMethodEnum.toTheta objectForKey:[rct objectForKey:@"shootingMethod"]];
1818
+ if (val) {
1819
+ opt.shootingMethod = val;
1820
+ }
1821
+ },
1822
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1823
+ id val = [ShootingMethodEnum.toTheta objectForKey:[rct objectForKey:@"shootingMethod"]];
1824
+ if (val) {
1825
+ opt.shootingMethod = val;
1826
+ }
1827
+ },
1828
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1829
+ id val = [ShootingMethodEnum.fromTheta objectForKey:opt.shootingMethod];
1830
+ if (val) {
1831
+ [rct setObject:val forKey:@"shootingMethod"];
1832
+ }
1833
+ }
1834
+ };
1835
+
1836
+ /**
1837
+ * Username converter
1838
+ */
1839
+ static convert_t UsernameCvt = {
1840
+ .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
1841
+ NSString* val = [rct objectForKey:@"username"];
1842
+ if (val) {
1843
+ opt.username = val;
1844
+ }
1845
+ },
1846
+ .setFromTheta = ^(NSMutableDictionary* rct, THETACThetaRepositoryOptions *opt) {
1847
+ if (opt.username) {
1848
+ [rct setObject:opt.username forKey:@"username"];
1849
+ }
1850
+ }
1851
+ };
1852
+
1853
+ /**
1854
+ * OptionNames converter
1855
+ */
1856
+ static NSDictionary *NameToOptionEnum = @{
1857
+ @"Aperture": THETACThetaRepositoryOptionNameEnum.aperture,
1858
+ @"BluetoothPower": THETACThetaRepositoryOptionNameEnum.bluetoothpower,
1859
+ @"CameraControlSource": THETACThetaRepositoryOptionNameEnum.cameracontrolsource,
1860
+ @"CameraMode": THETACThetaRepositoryOptionNameEnum.cameramode,
1861
+ @"CaptureMode": THETACThetaRepositoryOptionNameEnum.capturemode,
1862
+ @"ColorTemperature": THETACThetaRepositoryOptionNameEnum.colortemperature,
1863
+ @"DateTimeZone": THETACThetaRepositoryOptionNameEnum.datetimezone,
1864
+ @"ExposureCompensation": THETACThetaRepositoryOptionNameEnum.exposurecompensation,
1865
+ @"ExposureDelay": THETACThetaRepositoryOptionNameEnum.exposuredelay,
1866
+ @"ExposureProgram": THETACThetaRepositoryOptionNameEnum.exposureprogram,
1867
+ @"FileFormat": THETACThetaRepositoryOptionNameEnum.fileformat,
1868
+ @"Filter": THETACThetaRepositoryOptionNameEnum.filter,
1869
+ @"GpsInfo": THETACThetaRepositoryOptionNameEnum.gpsinfo,
1870
+ @"IsGpsOn": THETACThetaRepositoryOptionNameEnum.isgpson,
1871
+ @"Iso": THETACThetaRepositoryOptionNameEnum.iso,
1872
+ @"IsoAutoHighLimit": THETACThetaRepositoryOptionNameEnum.isoautohighlimit,
1873
+ @"Language": THETACThetaRepositoryOptionNameEnum.language,
1874
+ @"MaxRecordableTime": THETACThetaRepositoryOptionNameEnum.maxrecordabletime,
1875
+ @"NetworkType": THETACThetaRepositoryOptionNameEnum.networktype,
1876
+ @"OffDelay": THETACThetaRepositoryOptionNameEnum.offdelay,
1877
+ @"Password": THETACThetaRepositoryOptionNameEnum.password,
1878
+ @"PowerSaving": THETACThetaRepositoryOptionNameEnum.powersaving,
1879
+ @"PreviewFormat": THETACThetaRepositoryOptionNameEnum.previewformat,
1880
+ @"Proxy": THETACThetaRepositoryOptionNameEnum.proxy,
1881
+ @"ShootingMethod": THETACThetaRepositoryOptionNameEnum.shootingmethod,
1882
+ @"ShutterSpeed": THETACThetaRepositoryOptionNameEnum.shutterspeed,
1883
+ @"SleepDelay": THETACThetaRepositoryOptionNameEnum.sleepdelay,
1884
+ @"RemainingPictures": THETACThetaRepositoryOptionNameEnum.remainingpictures,
1885
+ @"RemainingVideoSeconds": THETACThetaRepositoryOptionNameEnum.remainingvideoseconds,
1886
+ @"RemainingSpace": THETACThetaRepositoryOptionNameEnum.remainingspace,
1887
+ @"TimeShift": THETACThetaRepositoryOptionNameEnum.timeshift,
1888
+ @"TotalSpace": THETACThetaRepositoryOptionNameEnum.totalspace,
1889
+ @"ShutterVolume": THETACThetaRepositoryOptionNameEnum.shuttervolume,
1890
+ @"Username": THETACThetaRepositoryOptionNameEnum.username,
1891
+ @"WhiteBalance": THETACThetaRepositoryOptionNameEnum.whitebalance,
1892
+ @"WhiteBalanceAutoStrength": THETACThetaRepositoryOptionNameEnum.whitebalanceautostrength,
1893
+ @"WlanFrequency": THETACThetaRepositoryOptionNameEnum.wlanfrequency
1894
+ };
1895
+
1896
+ /**
1897
+ * OptionNameEnum to OptionName
1898
+ */
1899
+ static NSDictionary *OptionEnumToOption = @{
1900
+ @"Aperture": @"aperture",
1901
+ @"BluetoothPower": @"bluetoothPower",
1902
+ @"CameraControlSource": @"cameraControlSource",
1903
+ @"CameraMode": @"cameraMode",
1904
+ @"CaptureMode": @"captureMode",
1905
+ @"ColorTemperature": @"colorTemperature",
1906
+ @"DateTimeZone": @"dateTimeZone",
1907
+ @"ExposureCompensation": @"exposureCompensation",
1908
+ @"ExposureDelay": @"exposureDelay",
1909
+ @"ExposureProgram": @"exposureProgram",
1910
+ @"FileFormat": @"fileFormat",
1911
+ @"Filter": @"filter",
1912
+ @"GpsInfo": @"gpsInfo",
1913
+ @"IsGpsOn": @"isGpsOn",
1235
1914
  @"Iso": @"iso",
1236
1915
  @"IsoAutoHighLimit": @"isoAutoHighLimit",
1237
1916
  @"Language": @"language",
1238
1917
  @"MaxRecordableTime": @"maxRecordableTime",
1918
+ @"NetworkType": @"networkType",
1239
1919
  @"OffDelay": @"offDelay",
1920
+ @"Password": @"password",
1921
+ @"PowerSaving": @"powerSaving",
1922
+ @"PreviewFormat": @"previewFormat",
1923
+ @"Proxy": @"proxy",
1924
+ @"ShootingMethod": @"shootingMethod",
1925
+ @"ShutterSpeed": @"shutterSpeed",
1240
1926
  @"SleepDelay": @"sleepDelay",
1241
1927
  @"RemainingPictures": @"remainingPictures",
1242
1928
  @"RemainingVideoSeconds": @"remainingVideoSeconds",
1243
1929
  @"RemainingSpace": @"remainingSpace",
1930
+ @"TimeShift": @"timeShift",
1244
1931
  @"TotalSpace": @"totalSpace",
1245
1932
  @"ShutterVolume": @"shutterVolume",
1246
- @"WhiteBalance": @"whiteBalance"
1933
+ @"Username": @"username",
1934
+ @"WhiteBalance": @"whiteBalance",
1935
+ @"WhiteBalanceAutoStrength": @"whiteBalanceAutoStrength",
1936
+ @"WlanFrequency": @"wlanFrequency"
1247
1937
  };
1248
1938
 
1249
1939
  /** Option converter builder */
@@ -1254,6 +1944,9 @@ typedef convert_t * (^OptionConverter)();
1254
1944
  */
1255
1945
  static NSDictionary<NSString*, OptionConverter> *NameToConverter = @{
1256
1946
  @"aperture": ^{return &ApertureEnum;},
1947
+ @"bluetoothPower": ^{return &BluetoothPowerEnum;},
1948
+ @"cameraControlSource": ^{return &CameraControlSourceEnum;},
1949
+ @"cameraMode": ^{return &CameraModeEnum;},
1257
1950
  @"captureMode": ^{return &CaptureModeEnum;},
1258
1951
  @"colorTemperature": ^{return &ColorTemperatureCvt;},
1259
1952
  @"dateTimeZone": ^{return &DateTimeZoneCvt;},
@@ -1268,18 +1961,94 @@ static NSDictionary<NSString*, OptionConverter> *NameToConverter = @{
1268
1961
  @"isoAutoHighLimit": ^{return &IsoAutoHighLimitEnum;},
1269
1962
  @"language": ^{return &LanguageEnum;},
1270
1963
  @"maxRecordableTime": ^{return &MaxRecordableTimeEnum;},
1964
+ @"networkType": ^{return &NetworkTypeEnum;},
1271
1965
  @"offDelay": ^{return &OffDelayEnum;},
1966
+ @"password": ^{return &PasswordCvt;},
1967
+ @"powerSaving": ^{return &PowerSavingEnum;},
1968
+ @"previewFormat": ^{return &PreviewFormatEnum;},
1969
+ @"proxy": ^{return &ProxyCvt;},
1970
+ @"shootingMethod": ^{return &ShootingMethodEnum;},
1971
+ @"shutterSpeed": ^{return &ShutterSpeedEnum;},
1272
1972
  @"sleepDelay": ^{return &SleepDelayEnum;},
1273
1973
  @"remainingPictures": ^{return &RemainingPicturesCvt;},
1274
1974
  @"remainingVideoSeconds": ^{return &RemainingVideoSecondsCvt;},
1275
1975
  @"remainingSpace": ^{return &RemainingSpaceCvt;},
1976
+ @"timeShift": ^{return &TimeShiftCvt;},
1276
1977
  @"totalSpace": ^{return &TotalSpaceCvt;},
1277
1978
  @"shutterVolume": ^{return &ShutterVolumeCvt;},
1979
+ @"username": ^{return &UsernameCvt;},
1278
1980
  @"whiteBalance": ^{return &WhiteBalanceEnum;},
1279
- @"_gpsTagRecording": ^{return &GpsTagRecordingEnum;}
1981
+ @"_gpsTagRecording": ^{return &GpsTagRecordingEnum;},
1982
+ @"whiteBalanceAutoStrength": ^{return &WhiteBalanceAutoStrengthEnum;},
1983
+ @"wlanFrequency": ^{return &WlanFrequencyEnum;}
1280
1984
  };
1281
1985
 
1282
1986
  static NSString *EVENT_NAME = @"ThetaFrameEvent";
1987
+ static NSString *EVENT_NOTIFY = @"ThetaNotify";
1988
+
1989
+ THETACDigestAuth* digestAuthToTheta(NSDictionary* objects)
1990
+ {
1991
+ if (!objects) {
1992
+ return nil;
1993
+ }
1994
+ NSString* username = [objects objectForKey:@"username"];
1995
+ if (!username) {
1996
+ return nil;
1997
+ }
1998
+ NSString* password = [objects objectForKey:@"password"];
1999
+ THETACDigestAuth* digestAuth = [[THETACDigestAuth alloc] initWithUsername:username password:password];
2000
+ return digestAuth;
2001
+ }
2002
+
2003
+ THETACThetaRepositoryConfig* configToTheta(NSDictionary* objects)
2004
+ {
2005
+ if (!objects) {
2006
+ return nil;
2007
+ }
2008
+ THETACThetaRepositoryConfig* config = [[THETACThetaRepositoryConfig alloc] init];
2009
+ NSString* datetime = [objects objectForKey:@"dateTime"];
2010
+ if (datetime) {
2011
+ config.dateTime = datetime;
2012
+ }
2013
+ id language = [LanguageEnum.toTheta objectForKey:[objects objectForKey:@"language"]];
2014
+ if (language) {
2015
+ config.language = language;
2016
+ }
2017
+ id offDelay = [OffDelayEnum.toTheta objectForKey:[objects objectForKey:@"offDelay"]];
2018
+ if (offDelay) {
2019
+ config.offDelay = offDelay;
2020
+ }
2021
+ id sleepDelay = [SleepDelayEnum.toTheta objectForKey:[objects objectForKey:@"sleepDelay"]];
2022
+ if (sleepDelay) {
2023
+ config.sleepDelay = sleepDelay;
2024
+ }
2025
+ NSNumber* shutterVolume = [objects objectForKey:@"shutterVolume"];
2026
+ if (shutterVolume) {
2027
+ config.shutterVolume = [THETACInt numberWithInt:[shutterVolume intValue]];
2028
+ }
2029
+
2030
+ config.clientMode = digestAuthToTheta([objects objectForKey:@"clientMode"]);
2031
+
2032
+ return config;
2033
+ }
2034
+
2035
+ THETACThetaRepositoryTimeout* timeoutToTheta(NSDictionary* objects)
2036
+ {
2037
+ if (!objects) {
2038
+ return nil;
2039
+ }
2040
+ NSNumber* connectTimeout = [objects objectForKey:@"connectTimeout"];
2041
+ NSNumber* requestTimeout = [objects objectForKey:@"requestTimeout"];
2042
+ NSNumber* socketTimeout = [objects objectForKey:@"socketTimeout"];
2043
+ if (!connectTimeout || !requestTimeout || !socketTimeout) {
2044
+ return nil;
2045
+ }
2046
+ THETACThetaRepositoryTimeout* timeout = [[THETACThetaRepositoryTimeout alloc]
2047
+ initWithConnectTimeout:[connectTimeout longValue]
2048
+ requestTimeout:[requestTimeout longLongValue]
2049
+ socketTimeout:[socketTimeout longLongValue]];
2050
+ return timeout;
2051
+ }
1283
2052
 
1284
2053
  /**
1285
2054
  * ThetaClientReactNative implementation
@@ -1318,7 +2087,7 @@ RCT_EXPORT_MODULE(ThetaClientReactNative)
1318
2087
  */
1319
2088
  -(NSArray *)supportedEvents
1320
2089
  {
1321
- return @[EVENT_NAME];
2090
+ return @[EVENT_NAME, EVENT_NOTIFY];
1322
2091
  }
1323
2092
 
1324
2093
  /**
@@ -1340,34 +2109,61 @@ RCT_EXPORT_MODULE(ThetaClientReactNative)
1340
2109
  /**
1341
2110
  * initialize ThetaRepository
1342
2111
  * @param endPoint endpoint to connect theta
2112
+ * @param config Configuration of initialize. If null, get from THETA
2113
+ * @param timeout Timeout of HTTP call
1343
2114
  * @param resolve resolver for initilization
1344
2115
  * @param rejecter rejecter for initialization
1345
2116
  */
1346
2117
  RCT_REMAP_METHOD(initialize,
1347
2118
  initializeWithEndpoint:(NSString *)endPoint
2119
+ withConfig:(NSDictionary*)config
2120
+ withTimeout:(NSDictionary*)timeout
1348
2121
  withResolver:(RCTPromiseResolveBlock)resolve
1349
2122
  withRejecter:(RCTPromiseRejectBlock)reject)
1350
2123
  {
2124
+ self.theta = nil;
2125
+ self.photoCaptureBuilder = nil;
2126
+ self.photoCapture = nil;
2127
+ self.timeShiftCaptureBuilder = nil;
2128
+ self.timeShiftCapture = nil;
2129
+ self.timeShiftCapturing = nil;
2130
+ self.videoCaptureBuilder = nil;
2131
+ self.videoCapture = nil;
2132
+ self.videoCapturing = nil;
2133
+ self.previewing = NO;
2134
+
1351
2135
  if (!endPoint) {
1352
2136
  endPoint = @"http://192.168.1.1";
1353
2137
  }
1354
2138
  NSError *error = nil;
1355
2139
  THETACThetaRepositoryCompanion *companion = THETACThetaRepository.companion;
1356
2140
  [companion doNewInstanceEndpoint:endPoint
1357
- config:nil
1358
- timeout:nil
2141
+ config:configToTheta(config)
2142
+ timeout:timeoutToTheta(timeout)
1359
2143
  completionHandler:^(THETACThetaRepository *repo, NSError *error) {
1360
2144
  if (error) {
1361
- reject(@"error", [error localizedDescription], error);
2145
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1362
2146
  } else if (repo) {
1363
2147
  self.theta = repo;
1364
2148
  resolve(@(YES));
1365
2149
  } else {
1366
- reject(@"error", @"can not create repository", nil);
2150
+ reject(ERROR_CODE_ERROR, @"can not create repository", nil);
1367
2151
  }
1368
2152
  }];
1369
2153
  }
1370
2154
 
2155
+ /**
2156
+ * isInitialized - Returns whether it is initialized or not.
2157
+ * @param resolve is initialized
2158
+ * @param rejecter
2159
+ */
2160
+ RCT_REMAP_METHOD(isInitialized,
2161
+ isInitializedWithResolver:(RCTPromiseResolveBlock)resolve
2162
+ withRejecter:(RCTPromiseRejectBlock)reject)
2163
+ {
2164
+ resolve(_theta != nil ? @(YES) : @(NO));
2165
+ }
2166
+
1371
2167
  /**
1372
2168
  * getThetaInfo - retrieve ThetaInfo from THETA via repository
1373
2169
  * @param resolve resolver for getThetaInfo
@@ -1377,21 +2173,39 @@ RCT_REMAP_METHOD(getThetaInfo,
1377
2173
  getThetaInfoWithResolver:(RCTPromiseResolveBlock)resolve
1378
2174
  withRejecter:(RCTPromiseRejectBlock)reject)
1379
2175
  {
2176
+ if (!_theta) {
2177
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2178
+ return;
2179
+ }
1380
2180
  [_theta getThetaInfoWithCompletionHandler:^(THETACThetaRepositoryThetaInfo *info,
1381
2181
  NSError *error) {
1382
- if (error) {
1383
- reject(@"error", [error localizedDescription], error);
1384
- } else if (info) {
1385
- resolve(@{@"model": info.model,
1386
- @"serialNumber":info.serialNumber,
1387
- @"firmwareVersion":info.firmwareVersion,
1388
- @"hasGps":@(info.hasGps),
1389
- @"hasGyro":@(info.hasGyro),
1390
- @"uptime":@(info.uptime)});
1391
- } else {
1392
- reject(@"error", @"no info", nil);
2182
+ if (error) {
2183
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2184
+ } else if (info) {
2185
+ NSMutableArray *apiLevelList = [[NSMutableArray alloc] init];
2186
+ for (THETACInt *element in info.apiLevel) {
2187
+ [apiLevelList addObject:@([element intValue])];
1393
2188
  }
1394
- }];
2189
+ resolve(@{@"manufacturer": info.manufacturer,
2190
+ @"model": info.model,
2191
+ @"serialNumber": info.serialNumber,
2192
+ @"wlanMacAddress": info.wlanMacAddress != nil ? info.wlanMacAddress : [NSNull null],
2193
+ @"bluetoothMacAddress": info.bluetoothMacAddress != nil ? info.bluetoothMacAddress : [NSNull null],
2194
+ @"firmwareVersion": info.firmwareVersion,
2195
+ @"supportUrl": info.supportUrl,
2196
+ @"hasGps": @(info.hasGps),
2197
+ @"hasGyro": @(info.hasGyro),
2198
+ @"uptime": @(info.uptime),
2199
+ @"api": info.api,
2200
+ @"endpoints": @{
2201
+ @"httpPort": @(info.endpoints.httpPort),
2202
+ @"httpUpdatesPort": @(info.endpoints.httpUpdatesPort),
2203
+ },
2204
+ @"apiLevel": apiLevelList});
2205
+ } else {
2206
+ reject(ERROR_CODE_ERROR, @"no info", nil);
2207
+ }
2208
+ }];
1395
2209
  }
1396
2210
 
1397
2211
  /**
@@ -1403,21 +2217,43 @@ RCT_REMAP_METHOD(getThetaState,
1403
2217
  getThetaStateWithResolver:(RCTPromiseResolveBlock)resolve
1404
2218
  withRejecter:(RCTPromiseRejectBlock)reject)
1405
2219
  {
2220
+ if (!_theta) {
2221
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2222
+ return;
2223
+ }
1406
2224
  [_theta getThetaStateWithCompletionHandler:^(THETACThetaRepositoryThetaState *state,
1407
2225
  NSError *error) {
1408
2226
  if (error) {
1409
- reject(@"error", [error localizedDescription], error);
2227
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1410
2228
  } else if (state) {
2229
+ NSMutableArray *cameraErrorList = [[NSMutableArray alloc] init];
2230
+ if (state.cameraError != nil) {
2231
+ for (THETACThetaRepositoryCameraErrorEnum *element in state.cameraError) {
2232
+ [cameraErrorList addObject:[CameraErrorEnum.fromTheta objectForKey:element]];
2233
+ }
2234
+ }
1411
2235
  resolve(@{@"fingerprint": state.fingerprint,
1412
- @"batteryLevel":@(state.batteryLevel),
1413
- @"chargingState":[ChargingStateEnum.fromTheta
1414
- objectForKey:state.chargingState],
1415
- @"isSdCard":@(state.isSdCard),
1416
- @"recordedTime":@(state.recordedTime),
1417
- @"recordableTime":@(state.recordableTime),
1418
- @"latestFileUrl":state.latestFileUrl});
2236
+ @"batteryLevel": @(state.batteryLevel),
2237
+ @"storageUri": state.storageUri != nil ? state.storageUri : [NSNull null],
2238
+ @"storageID": state.storageID != nil ? state.storageID : [NSNull null],
2239
+ @"captureStatus": [CaptureStatusEnum.fromTheta objectForKey:state.captureStatus],
2240
+ @"recordedTime": @(state.recordedTime),
2241
+ @"recordableTime": @(state.recordableTime),
2242
+ @"capturedPictures": state.capturedPictures != nil ? @([state.capturedPictures intValue]): [NSNull null],
2243
+ @"compositeShootingElapsedTime": state.compositeShootingElapsedTime != nil ? @([state.compositeShootingElapsedTime intValue]) : [NSNull null],
2244
+ @"latestFileUrl": state.latestFileUrl,
2245
+ @"chargingState": [ChargingStateEnum.fromTheta objectForKey:state.chargingState],
2246
+ @"apiVersion": @(state.apiVersion),
2247
+ @"isPluginRunning": state.isPluginRunning != nil ? @([state.isPluginRunning boolValue]) : [NSNull null],
2248
+ @"isPluginWebServer": state.isPluginWebServer != nil ? @([state.isPluginWebServer boolValue]) : [NSNull null],
2249
+ @"function": state.function != nil ? [ShootingFunctionEnum.fromTheta objectForKey:state.function] : [NSNull null],
2250
+ @"isMySettingChanged": state.isMySettingChanged != nil? @([state.isMySettingChanged boolValue]) : [NSNull null],
2251
+ @"currentMicrophone": state.currentMicrophone != nil ? [MicrophoneOptionEnum.fromTheta objectForKey:state.currentMicrophone] : [NSNull null],
2252
+ @"isSdCard": @(state.isSdCard),
2253
+ @"cameraError": state.cameraError != nil ? cameraErrorList : [NSNull null],
2254
+ @"isBatteryInsert": state.isBatteryInsert != nil ? @([state.isBatteryInsert boolValue]) : [NSNull null]});
1419
2255
  } else {
1420
- reject(@"error", @"no state", nil);
2256
+ reject(ERROR_CODE_ERROR, @"no state", nil);
1421
2257
  }
1422
2258
  }];
1423
2259
  }
@@ -1427,6 +2263,7 @@ RCT_REMAP_METHOD(getThetaState,
1427
2263
  * @param fileType file type to retrieve
1428
2264
  * @param startPosition start position to retrieve
1429
2265
  * @param entryCount count to retrieve
2266
+ * @param storage Desired storage
1430
2267
  * @param resolve resolver for listFiles
1431
2268
  * @param rejecter rejecter for listFiles
1432
2269
  */
@@ -1434,31 +2271,42 @@ RCT_REMAP_METHOD(listFiles,
1434
2271
  listFilesWithFileTypeEnum:(NSString*)fileType
1435
2272
  withStartPosition:(int32_t)startPosition
1436
2273
  withEntryCount:(int32_t)entryCount
2274
+ withStorage:(NSString*)storage
1437
2275
  withResolver:(RCTPromiseResolveBlock)resolve
1438
2276
  withRejecter:(RCTPromiseRejectBlock)reject)
1439
2277
  {
2278
+ if (!_theta) {
2279
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2280
+ return;
2281
+ }
1440
2282
  [_theta listFilesFileType:[FileTypeEnum.toTheta objectForKey:fileType]
1441
2283
  startPosition:startPosition
1442
2284
  entryCount:entryCount
1443
- completionHandler:^(NSArray<THETACThetaRepositoryFileInfo *> *items,
2285
+ storage:[StorageEnum.toTheta objectForKey:storage]
2286
+ completionHandler:^(THETACThetaRepositoryThetaFiles *items,
1444
2287
  NSError *error) {
1445
2288
  if (error) {
1446
- reject(@"error", [error localizedDescription], error);
2289
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1447
2290
  } else if (items) {
1448
2291
  NSMutableArray *ary = [[NSMutableArray alloc] init];
1449
- for (int i = 0; i < items.count; i++) {
1450
- THETACThetaRepositoryFileInfo *finfo = items[i];
1451
- [ary addObject: @{
1452
- @"name":finfo.name,
1453
- @"size":@(finfo.size),
1454
- @"dateTime":finfo.dateTime,
1455
- @"thumbnailUrl":finfo.thumbnailUrl,
1456
- @"fileUrl":finfo.fileUrl
1457
- }];
2292
+ for (int i = 0; i < items.fileList.count; i++) {
2293
+ THETACThetaRepositoryFileInfo *finfo = items.fileList[i];
2294
+ NSMutableDictionary *fileInfoObject = [[NSMutableDictionary alloc] initWithDictionary:@{
2295
+ @"name":finfo.name,
2296
+ @"size":@(finfo.size),
2297
+ @"dateTime":finfo.dateTime,
2298
+ @"thumbnailUrl":finfo.thumbnailUrl,
2299
+ @"fileUrl":finfo.fileUrl
2300
+ }];
2301
+ if (finfo.storageID) {
2302
+ [fileInfoObject setObject:finfo.storageID forKey:@"storageID"];
2303
+ }
2304
+ [ary addObject:fileInfoObject];
1458
2305
  }
1459
- resolve(ary);
2306
+ resolve(@{@"fileList":ary,
2307
+ @"totalEntries": @(items.totalEntries)});
1460
2308
  } else {
1461
- reject(@"error", @"no items", nil);
2309
+ reject(ERROR_CODE_ERROR, @"no items", nil);
1462
2310
  }
1463
2311
  }];
1464
2312
  }
@@ -1474,9 +2322,13 @@ RCT_REMAP_METHOD(deleteFiles,
1474
2322
  withResolver:(RCTPromiseResolveBlock)resolve
1475
2323
  withRejecter:(RCTPromiseRejectBlock)reject)
1476
2324
  {
2325
+ if (!_theta) {
2326
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2327
+ return;
2328
+ }
1477
2329
  [_theta deleteFilesFileUrls:fileUrls completionHandler:^(NSError *error) {
1478
2330
  if (error) {
1479
- reject(@"error", [error localizedDescription], error);
2331
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1480
2332
  } else {
1481
2333
  resolve(@(YES));
1482
2334
  }
@@ -1492,9 +2344,13 @@ RCT_REMAP_METHOD(deleteAllFiles,
1492
2344
  deleteAllFilesWithResolver:(RCTPromiseResolveBlock)resolve
1493
2345
  withRejecter:(RCTPromiseRejectBlock)reject)
1494
2346
  {
2347
+ if (!_theta) {
2348
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2349
+ return;
2350
+ }
1495
2351
  [_theta deleteAllFilesWithCompletionHandler:^(NSError *error) {
1496
2352
  if (error) {
1497
- reject(@"error", [error localizedDescription], error);
2353
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1498
2354
  } else {
1499
2355
  resolve(@(YES));
1500
2356
  }
@@ -1510,9 +2366,13 @@ RCT_REMAP_METHOD(deleteAllImageFiles,
1510
2366
  deleteAllImageFilesWithResolver:(RCTPromiseResolveBlock)resolve
1511
2367
  withRejecter:(RCTPromiseRejectBlock)reject)
1512
2368
  {
2369
+ if (!_theta) {
2370
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2371
+ return;
2372
+ }
1513
2373
  [_theta deleteAllImageFilesWithCompletionHandler:^(NSError *error) {
1514
2374
  if (error) {
1515
- reject(@"error", [error localizedDescription], error);
2375
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1516
2376
  return;
1517
2377
  }
1518
2378
  resolve(@(YES));
@@ -1528,9 +2388,13 @@ RCT_REMAP_METHOD(deleteAllVideoFiles,
1528
2388
  deleteAllVideoFilesWithResolver:(RCTPromiseResolveBlock)resolve
1529
2389
  withRejecter:(RCTPromiseRejectBlock)reject)
1530
2390
  {
2391
+ if (!_theta) {
2392
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2393
+ return;
2394
+ }
1531
2395
  [_theta deleteAllVideoFilesWithCompletionHandler:^(NSError *error) {
1532
2396
  if (error) {
1533
- reject(@"error", [error localizedDescription], error);
2397
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1534
2398
  } else {
1535
2399
  resolve(@(YES));
1536
2400
  }
@@ -1548,6 +2412,10 @@ RCT_REMAP_METHOD(getOptions,
1548
2412
  withResolver:(RCTPromiseResolveBlock)resolve
1549
2413
  withRejecter:(RCTPromiseRejectBlock)reject)
1550
2414
  {
2415
+ if (!_theta) {
2416
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2417
+ return;
2418
+ }
1551
2419
  NSMutableArray *optionNameList = [[NSMutableArray alloc] init];
1552
2420
  for (id name in optionNames) {
1553
2421
  [optionNameList addObject:[NameToOptionEnum objectForKey:name]];
@@ -1555,7 +2423,7 @@ RCT_REMAP_METHOD(getOptions,
1555
2423
  [_theta getOptionsOptionNames:optionNameList
1556
2424
  completionHandler:^(THETACThetaRepositoryOptions *options, NSError *error) {
1557
2425
  if (error) {
1558
- reject(@"error", [error localizedDescription], error);
2426
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1559
2427
  } else if (options) {
1560
2428
  NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
1561
2429
  for (id name in optionNames) {
@@ -1567,7 +2435,7 @@ RCT_REMAP_METHOD(getOptions,
1567
2435
  }
1568
2436
  resolve(results);
1569
2437
  } else {
1570
- reject(@"error", @"no options", nil);
2438
+ reject(ERROR_CODE_ERROR, @"no options", nil);
1571
2439
  }
1572
2440
  }];
1573
2441
  }
@@ -1583,20 +2451,27 @@ RCT_REMAP_METHOD(setOptions,
1583
2451
  withResolver:(RCTPromiseResolveBlock)resolve
1584
2452
  withRejecter:(RCTPromiseRejectBlock)reject)
1585
2453
  {
2454
+ if (!_theta) {
2455
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2456
+ return;
2457
+ }
1586
2458
  THETACThetaRepositoryOptions *newoptions = [[THETACThetaRepositoryOptions alloc] init];
1587
2459
  for (id option in [options allKeys]) {
1588
- convert_t *convert = [NameToConverter objectForKey:option]();
1589
- if (convert && convert->setToTheta) {
1590
- convert->setToTheta(options, newoptions);
2460
+ OptionConverter converter = [NameToConverter objectForKey:option];
2461
+ if (converter) {
2462
+ convert_t *convert = converter();
2463
+ if (convert && convert->setToTheta) {
2464
+ convert->setToTheta(options, newoptions);
2465
+ }
1591
2466
  }
1592
2467
  }
1593
2468
  [_theta setOptionsOptions:newoptions completionHandler:^(NSError *error) {
1594
- if (error) {
1595
- reject(@"error", [error localizedDescription], error);
1596
- } else {
1597
- resolve(@(YES));
1598
- }
1599
- }];
2469
+ if (error) {
2470
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2471
+ } else {
2472
+ resolve(@(YES));
2473
+ }
2474
+ }];
1600
2475
  }
1601
2476
 
1602
2477
  /**
@@ -1630,6 +2505,10 @@ RCT_REMAP_METHOD(getLivePreview,
1630
2505
  getLivePreviewWithResolver:(RCTPromiseResolveBlock)resolve
1631
2506
  withRejecter:(RCTPromiseRejectBlock)reject)
1632
2507
  {
2508
+ if (!_theta) {
2509
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2510
+ return;
2511
+ }
1633
2512
  FrameHandler *_frameHandler =
1634
2513
  [[FrameHandler alloc] initWith:self withEvent:^(NSData *data) {
1635
2514
  if (self->hasListeners) {
@@ -1642,7 +2521,7 @@ RCT_REMAP_METHOD(getLivePreview,
1642
2521
  self.previewing = YES;
1643
2522
  [_theta getLivePreviewFrameHandler:_frameHandler completionHandler:^(NSError *error) {
1644
2523
  if (error) {
1645
- reject(@"error", [error localizedDescription], error);
2524
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1646
2525
  } else {
1647
2526
  resolve(@(YES));
1648
2527
  }
@@ -1664,6 +2543,10 @@ RCT_REMAP_METHOD(stopLivePreview,
1664
2543
  RCT_REMAP_METHOD(getPhotoCaptureBuilder,
1665
2544
  getPhotoCaptureBuilder)
1666
2545
  {
2546
+ if (!_theta) {
2547
+ [NSException raise:ERROR_CODE_ERROR format:MESSAGE_NOT_INIT];
2548
+ return;
2549
+ }
1667
2550
  self.photoCaptureBuilder = [_theta getPhotoCaptureBuilder];
1668
2551
  }
1669
2552
 
@@ -1678,8 +2561,12 @@ RCT_REMAP_METHOD(buildPhotoCapture,
1678
2561
  withResolver:(RCTPromiseResolveBlock)resolve
1679
2562
  withRejecter:(RCTPromiseRejectBlock)reject)
1680
2563
  {
2564
+ if (!_theta) {
2565
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2566
+ return;
2567
+ }
1681
2568
  if (!self.photoCaptureBuilder) {
1682
- reject(@"error", @"no photo capture pbuilder", nil);
2569
+ reject(ERROR_CODE_ERROR, @"no photo capture pbuilder", nil);
1683
2570
  return;
1684
2571
  }
1685
2572
  for (id photoOption in [options allKeys]) {
@@ -1691,7 +2578,7 @@ RCT_REMAP_METHOD(buildPhotoCapture,
1691
2578
  [self.photoCaptureBuilder
1692
2579
  buildWithCompletionHandler:^(THETACPhotoCapture *photoCapture, NSError *error) {
1693
2580
  if (error) {
1694
- reject(@"error", [error localizedDescription], error);
2581
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1695
2582
  return;
1696
2583
  }
1697
2584
  if (photoCapture) {
@@ -1699,7 +2586,7 @@ RCT_REMAP_METHOD(buildPhotoCapture,
1699
2586
  self.photoCaptureBuilder = nil;
1700
2587
  resolve(@(YES));
1701
2588
  } else {
1702
- reject(@"error", @"no photoCapture", nil);
2589
+ reject(ERROR_CODE_ERROR, @"no photoCapture", nil);
1703
2590
  }
1704
2591
  }];
1705
2592
  }
@@ -1713,8 +2600,12 @@ RCT_REMAP_METHOD(takePicture,
1713
2600
  takePictureWithResolver:(RCTPromiseResolveBlock)resolve
1714
2601
  withRejecter:(RCTPromiseRejectBlock)reject)
1715
2602
  {
2603
+ if (!_theta) {
2604
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2605
+ return;
2606
+ }
1716
2607
  if (!self.photoCapture) {
1717
- reject(@"error", @"no photoCapture", nil);
2608
+ reject(ERROR_CODE_ERROR, @"no photoCapture", nil);
1718
2609
  return;
1719
2610
  }
1720
2611
  PhotoCallback *callback = [[PhotoCallback alloc] initWith:self
@@ -1723,12 +2614,126 @@ RCT_REMAP_METHOD(takePicture,
1723
2614
  [self.photoCapture takePictureCallback:callback];
1724
2615
  }
1725
2616
 
2617
+ /**
2618
+ * getTimeShiftCaptureBuilder - get time-shift builder from repository
2619
+ */
2620
+ RCT_REMAP_METHOD(getTimeShiftCaptureBuilder,
2621
+ getTimeShiftCaptureBuilder)
2622
+ {
2623
+ if (!_theta) {
2624
+ [NSException raise:ERROR_CODE_ERROR format:MESSAGE_NOT_INIT];
2625
+ return;
2626
+ }
2627
+ self.timeShiftCaptureBuilder = [_theta getTimeShiftCaptureBuilder];
2628
+ }
2629
+
2630
+ /**
2631
+ * buildTimeShiftCapture - build time-shift capture
2632
+ * @param options option to execute time-shift
2633
+ * @param interval interval of checking time-shift status
2634
+ * @param resolve resolver for buildTimeShiftCapture
2635
+ * @param rejecter rejecter for buildTimeShiftCapture
2636
+ */
2637
+ RCT_REMAP_METHOD(buildTimeShiftCapture,
2638
+ buildTimeShiftCaptureWithOptions:(NSDictionary*)options
2639
+ withInterval:(int)interval
2640
+ withResolver:(RCTPromiseResolveBlock)resolve
2641
+ withRejecter:(RCTPromiseRejectBlock)reject)
2642
+ {
2643
+ if (!_theta) {
2644
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2645
+ return;
2646
+ }
2647
+ if (!self.timeShiftCaptureBuilder) {
2648
+ reject(@"error", @"no time-shift capture pbuilder", nil);
2649
+ return;
2650
+ }
2651
+
2652
+ for (id option in [options allKeys]) {
2653
+ convert_t *convert = [NameToConverter objectForKey:option]();
2654
+ if (convert && convert->setTimeShiftOption) {
2655
+ convert->setTimeShiftOption(options, self.timeShiftCaptureBuilder);
2656
+ }
2657
+ }
2658
+
2659
+ if (interval >= 0) {
2660
+ [self.timeShiftCaptureBuilder setCheckStatusCommandIntervalTimeMillis: (int64_t)interval];
2661
+ }
2662
+
2663
+ [self.timeShiftCaptureBuilder buildWithCompletionHandler:^(THETACTimeShiftCapture *timeShiftCapture, NSError *error) {
2664
+ if (error) {
2665
+ reject(@"error", [error localizedDescription], error);
2666
+ return;
2667
+ }
2668
+ if (timeShiftCapture) {
2669
+ self.timeShiftCapture = timeShiftCapture;
2670
+ self.timeShiftCaptureBuilder = nil;
2671
+ resolve(@(YES));
2672
+ } else {
2673
+ reject(@"error", @"no timeShiftCapture", nil);
2674
+ }
2675
+ }];
2676
+ }
2677
+
2678
+ /**
2679
+ * startTimeShiftCapture - start time-shift
2680
+ * @param resolve resolver for startTimeShiftCapture
2681
+ * @param rejecter rejecter for startTimeShiftCapture
2682
+ */
2683
+ RCT_REMAP_METHOD(startTimeShiftCapture,
2684
+ startTimeShiftCaptureWithResolver:(RCTPromiseResolveBlock)resolve
2685
+ withRejecter:(RCTPromiseRejectBlock)reject)
2686
+ {
2687
+ if (!_theta) {
2688
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2689
+ return;
2690
+ }
2691
+ if (!self.timeShiftCapture) {
2692
+ reject(@"error", @"no timeShiftCapture", nil);
2693
+ return;
2694
+ }
2695
+
2696
+ TimeShiftStartCallback *callback = [[TimeShiftStartCallback alloc] initWith:self
2697
+ withProgress:^(float completion) {
2698
+ [self sendEventWithName:EVENT_NOTIFY
2699
+ body:toCaptureProgressNotifyParam([NSNumber numberWithFloat:completion])];
2700
+ }
2701
+ withResolver:resolve
2702
+ withRejecter:reject];
2703
+ self.timeShiftCapturing = [self.timeShiftCapture startCaptureCallback:callback];
2704
+ }
2705
+
2706
+ /**
2707
+ * cancelTimeShiftCapture - stop time-shift
2708
+ * @param resolve resolver for stopTimeShiftCapture
2709
+ * @param rejecter rejecter for stopTimeShiftCapture
2710
+ */
2711
+ RCT_REMAP_METHOD(cancelTimeShiftCapture,
2712
+ cancelTimeShiftCaptureWithResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
2713
+ {
2714
+ if (!_theta) {
2715
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2716
+ return;
2717
+ }
2718
+
2719
+ if (!self.timeShiftCapturing) {
2720
+ reject(@"error", @"no timeShiftCapturing", nil);
2721
+ return;
2722
+ }
2723
+
2724
+ [self.timeShiftCapturing cancelCapture];
2725
+ }
2726
+
1726
2727
  /**
1727
2728
  * getVideoCaptureBuilder - get video capture builder
1728
2729
  */
1729
2730
  RCT_REMAP_METHOD(getVideoCaptureBuilder,
1730
2731
  getVideoCaptureBuilder)
1731
2732
  {
2733
+ if (!_theta) {
2734
+ [NSException raise:ERROR_CODE_ERROR format:MESSAGE_NOT_INIT];
2735
+ return;
2736
+ }
1732
2737
  self.videoCaptureBuilder = [_theta getVideoCaptureBuilder];
1733
2738
  }
1734
2739
 
@@ -1743,8 +2748,12 @@ RCT_REMAP_METHOD(buildVideoCapture,
1743
2748
  withResolver:(RCTPromiseResolveBlock)resolve
1744
2749
  withRejecter:(RCTPromiseRejectBlock)reject)
1745
2750
  {
2751
+ if (!_theta) {
2752
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2753
+ return;
2754
+ }
1746
2755
  if (!self.videoCaptureBuilder) {
1747
- reject(@"error", @"no video capture builder", nil);
2756
+ reject(ERROR_CODE_ERROR, @"no video capture builder", nil);
1748
2757
  return;
1749
2758
  }
1750
2759
  for (id videoOption in [options allKeys]) {
@@ -1756,7 +2765,7 @@ RCT_REMAP_METHOD(buildVideoCapture,
1756
2765
  [self.videoCaptureBuilder
1757
2766
  buildWithCompletionHandler:^(THETACVideoCapture *videoCapture, NSError *error) {
1758
2767
  if (error) {
1759
- reject(@"error", @"videoCapture build failed", error);
2768
+ reject(ERROR_CODE_ERROR, @"videoCapture build failed", error);
1760
2769
  return;
1761
2770
  }
1762
2771
  if (videoCapture) {
@@ -1764,7 +2773,7 @@ RCT_REMAP_METHOD(buildVideoCapture,
1764
2773
  self.videoCaptureBuilder = nil;
1765
2774
  resolve(@(YES));
1766
2775
  } else {
1767
- reject(@"error", @"no videoCapture", nil);
2776
+ reject(ERROR_CODE_ERROR, @"no videoCapture", nil);
1768
2777
  }
1769
2778
  }];
1770
2779
  }
@@ -1778,8 +2787,12 @@ RCT_REMAP_METHOD(startCapture,
1778
2787
  startCaptureWithResolver:(RCTPromiseResolveBlock)resolve
1779
2788
  withRejecter:(RCTPromiseRejectBlock)reject)
1780
2789
  {
2790
+ if (!_theta) {
2791
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2792
+ return;
2793
+ }
1781
2794
  if (!self.videoCapture) {
1782
- reject(@"error", @"no videoCapture", nil);
2795
+ reject(ERROR_CODE_ERROR, @"no videoCapture", nil);
1783
2796
  return;
1784
2797
  }
1785
2798
  VideoCallback *callback = [[VideoCallback alloc] initWith:self
@@ -1794,6 +2807,10 @@ RCT_REMAP_METHOD(startCapture,
1794
2807
  RCT_REMAP_METHOD(stopCapture,
1795
2808
  stopCapture)
1796
2809
  {
2810
+ if (!_theta) {
2811
+ [NSException raise:ERROR_CODE_ERROR format:MESSAGE_NOT_INIT];
2812
+ return;
2813
+ }
1797
2814
  if (!self.videoCapturing) {
1798
2815
  // todo warning
1799
2816
  return;
@@ -1811,12 +2828,16 @@ RCT_REMAP_METHOD(getMetadata,
1811
2828
  withResolver:(RCTPromiseResolveBlock)resolve
1812
2829
  withRejecter:(RCTPromiseRejectBlock)reject)
1813
2830
  {
2831
+ if (!_theta) {
2832
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2833
+ return;
2834
+ }
1814
2835
  [_theta getMetadataFileUrl:fileUrl
1815
2836
  completionHandler:^(THETACKotlinPair<THETACThetaRepositoryExif *,
1816
2837
  THETACThetaRepositoryXmp *> *metaData,
1817
2838
  NSError *error) {
1818
2839
  if (error) {
1819
- reject(@"error", [error localizedDescription], error);
2840
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1820
2841
  } else if (metaData) {
1821
2842
  NSDictionary* exif = nil;
1822
2843
  NSDictionary* xmp = nil;
@@ -1839,7 +2860,7 @@ RCT_REMAP_METHOD(getMetadata,
1839
2860
  }
1840
2861
  resolve(@{@"exif": exif, @"xmp": xmp});
1841
2862
  } else {
1842
- reject(@"error", @"no metaData", nil);
2863
+ reject(ERROR_CODE_ERROR, @"no metaData", nil);
1843
2864
  }
1844
2865
  }];
1845
2866
  }
@@ -1853,9 +2874,13 @@ RCT_REMAP_METHOD(reset,
1853
2874
  resetWithResolver:(RCTPromiseResolveBlock)resolve
1854
2875
  withRejecter:(RCTPromiseRejectBlock)reject)
1855
2876
  {
2877
+ if (!_theta) {
2878
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2879
+ return;
2880
+ }
1856
2881
  [_theta resetWithCompletionHandler:^(NSError *error) {
1857
2882
  if (error) {
1858
- reject(@"error", [error localizedDescription], error);
2883
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1859
2884
  } else {
1860
2885
  resolve(@(YES));
1861
2886
  }
@@ -1871,9 +2896,13 @@ RCT_REMAP_METHOD(restoreSettings,
1871
2896
  restoreSettingsWithResolver:(RCTPromiseResolveBlock)resolve
1872
2897
  withRejecter:(RCTPromiseRejectBlock)reject)
1873
2898
  {
2899
+ if (!_theta) {
2900
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2901
+ return;
2902
+ }
1874
2903
  [_theta restoreSettingsWithCompletionHandler:^(NSError *error) {
1875
2904
  if (error) {
1876
- reject(@"error", [error localizedDescription], error);
2905
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1877
2906
  } else {
1878
2907
  resolve(@(YES));
1879
2908
  }
@@ -1889,9 +2918,13 @@ RCT_REMAP_METHOD(stopSelfTimer,
1889
2918
  stopSelfTimerWithResolver:(RCTPromiseResolveBlock)resolve
1890
2919
  withRejecter:(RCTPromiseRejectBlock)reject)
1891
2920
  {
2921
+ if (!_theta) {
2922
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2923
+ return;
2924
+ }
1892
2925
  [_theta stopSelfTimerWithCompletionHandler:^(NSError *error) {
1893
2926
  if (error) {
1894
- reject(@"error", [error localizedDescription], error);
2927
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1895
2928
  } else {
1896
2929
  resolve(@(YES));
1897
2930
  }
@@ -1913,16 +2946,20 @@ RCT_REMAP_METHOD(convertVideoFormats,
1913
2946
  withResolver:(RCTPromiseResolveBlock)resolve
1914
2947
  withRejecter:(RCTPromiseRejectBlock)reject)
1915
2948
  {
2949
+ if (!_theta) {
2950
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2951
+ return;
2952
+ }
1916
2953
  [_theta convertVideoFormatsFileUrl:fileUrl
1917
2954
  toLowResolution:toLowResolution
1918
2955
  applyTopBottomCorrection:applyTopBottomCorrection
1919
2956
  completionHandler:^(NSString *convertedUrl, NSError *error) {
1920
2957
  if (error) {
1921
- reject(@"error", [error localizedDescription], error);
2958
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1922
2959
  } else if (convertedUrl) {
1923
2960
  resolve(convertedUrl);
1924
2961
  } else {
1925
- reject(@"error", @"no convertVideo", nil);
2962
+ reject(ERROR_CODE_ERROR, @"no convertVideo", nil);
1926
2963
  }
1927
2964
  }];
1928
2965
  }
@@ -1936,9 +2973,13 @@ RCT_REMAP_METHOD(cancelVideoConvert,
1936
2973
  cancelVideoConvertWithResolver:(RCTPromiseResolveBlock)resolve
1937
2974
  withRejecter:(RCTPromiseRejectBlock)reject)
1938
2975
  {
2976
+ if (!_theta) {
2977
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2978
+ return;
2979
+ }
1939
2980
  [_theta cancelVideoConvertWithCompletionHandler:^(NSError *error) {
1940
2981
  if (error) {
1941
- reject(@"error", [error localizedDescription], error);
2982
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1942
2983
  } else {
1943
2984
  resolve(@(YES));
1944
2985
  }
@@ -1954,9 +2995,13 @@ RCT_REMAP_METHOD(finishWlan,
1954
2995
  finishWlanWithResolver:(RCTPromiseResolveBlock)resolve
1955
2996
  withRejecter:(RCTPromiseRejectBlock)reject)
1956
2997
  {
2998
+ if (!_theta) {
2999
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3000
+ return;
3001
+ }
1957
3002
  [_theta finishWlanWithCompletionHandler:^(NSError *error) {
1958
3003
  if (error) {
1959
- reject(@"error", [error localizedDescription], error);
3004
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1960
3005
  } else {
1961
3006
  resolve(@(YES));
1962
3007
  }
@@ -1972,28 +3017,50 @@ RCT_REMAP_METHOD(listAccessPoints,
1972
3017
  listAccessPointsWithResolver:(RCTPromiseResolveBlock)resolve
1973
3018
  withRejecter:(RCTPromiseRejectBlock)reject)
1974
3019
  {
1975
- [_theta listAccessPointsWithCompletionHandler:^(NSArray *accessPointList, NSError *error) {
1976
- if (error) {
1977
- reject(@"error", [error localizedDescription], error);
1978
- } else if (accessPointList) {
1979
- NSMutableArray *ary = [[NSMutableArray alloc] init];
1980
- for (int i = 0; i < accessPointList.count; i++) {
1981
- THETACThetaRepositoryAccessPoint *apinfo = accessPointList[i];
1982
- [ary addObject: @{
1983
- @"ssid": apinfo.ssid,
1984
- @"ssidStealth": @(apinfo.ssidStealth),
1985
- @"authMode": [AuthModeEnum.fromTheta objectForKey:apinfo.authMode],
1986
- @"connectionPriority": @(apinfo.connectionPriority),
1987
- @"usingDhcp": @(apinfo.usingDhcp),
1988
- @"ipAddress": apinfo.ipAddress,
1989
- @"subnetMask": apinfo.subnetMask,
1990
- @"defaultGateway": apinfo.defaultGateway
1991
- }];
1992
- }
1993
- resolve(ary);
1994
- } else {
1995
- reject(@"error", @"no access point", nil);
1996
- }
3020
+ if (!_theta) {
3021
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3022
+ return;
3023
+ }
3024
+ [_theta listAccessPointsWithCompletionHandler:^(NSArray *accessPointList, NSError *error) {
3025
+ if (error) {
3026
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3027
+ } else if (accessPointList) {
3028
+ NSMutableArray *ary = [[NSMutableArray alloc] init];
3029
+ for (int i = 0; i < accessPointList.count; i++) {
3030
+ THETACThetaRepositoryAccessPoint *apinfo = accessPointList[i];
3031
+
3032
+ NSMutableDictionary *optionsDic = [[NSMutableDictionary alloc] init];
3033
+ convert_t *convert = &ProxyCvt;
3034
+ if (convert->setFromTheta) {
3035
+ THETACThetaRepositoryOptions *options = [[THETACThetaRepositoryOptions alloc] init];
3036
+ [options setProxy:apinfo.proxy];
3037
+ convert->setFromTheta(optionsDic, options);
3038
+ }
3039
+
3040
+ NSMutableDictionary *item = [[NSMutableDictionary alloc] init];
3041
+ [item setObject:apinfo.ssid forKey:@"ssid"];
3042
+ [item setObject:@(apinfo.ssidStealth) forKey:@"ssidStealth"];
3043
+ [item setObject:[AuthModeEnum.fromTheta objectForKey:apinfo.authMode]forKey:@"authMode"];
3044
+ [item setObject:@(apinfo.connectionPriority) forKey:@"connectionPriority"];
3045
+ [item setObject:@(apinfo.usingDhcp) forKey:@"usingDhcp"];
3046
+ if (apinfo.ipAddress) {
3047
+ [item setObject:apinfo.ipAddress forKey:@"ipAddress"];
3048
+ }
3049
+ if (apinfo.subnetMask) {
3050
+ [item setObject:apinfo.subnetMask forKey:@"subnetMask"];
3051
+ }
3052
+ if (apinfo.defaultGateway) {
3053
+ [item setObject:apinfo.defaultGateway forKey:@"defaultGateway"];
3054
+ }
3055
+ if ([optionsDic objectForKey:@"proxy"]) {
3056
+ [item setObject:[optionsDic objectForKey:@"proxy"] forKey:@"proxy"];
3057
+ }
3058
+ [ary addObject:item];
3059
+ }
3060
+ resolve(ary);
3061
+ } else {
3062
+ reject(ERROR_CODE_ERROR, @"no access point", nil);
3063
+ }
1997
3064
  }];
1998
3065
  }
1999
3066
 
@@ -2004,6 +3071,7 @@ RCT_REMAP_METHOD(listAccessPoints,
2004
3071
  * @param authMode auth mode to connect
2005
3072
  * @param password password to connect with auth
2006
3073
  * @param connectionPriority connection priority
3074
+ * @param proxy Proxy information to be used for the access point.
2007
3075
  * @param resolve resolver for setAccessPointDynamically
2008
3076
  * @param rejecter rejecter for setAccessPointDynamically
2009
3077
  */
@@ -2013,20 +3081,26 @@ RCT_REMAP_METHOD(setAccessPointDynamically,
2013
3081
  withAuthMode:(NSString *)authMode
2014
3082
  withPassword:(NSString *)password
2015
3083
  withConnectionPrioryty:(int32_t)connectionPriority
3084
+ withProxy:(NSDictionary *)proxy
2016
3085
  withResolver:(RCTPromiseResolveBlock)resolve
2017
3086
  withRejecter:(RCTPromiseRejectBlock)reject)
2018
3087
  {
2019
- [_theta setAccessPointDynamicallySsid:ssid
2020
- ssidStealth:ssidStealth
2021
- authMode:[AuthModeEnum.toTheta objectForKey:authMode]
2022
- password:password
2023
- connectionPriority:connectionPriority
2024
- completionHandler:^(NSError *error) {
2025
- if (error) {
2026
- reject(@"error", [error localizedDescription], error);
2027
- } else {
2028
- resolve(@(YES));
2029
- }
3088
+ if (!_theta) {
3089
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3090
+ return;
3091
+ }
3092
+ [_theta setAccessPointDynamicallySsid:ssid
3093
+ ssidStealth:ssidStealth
3094
+ authMode:[AuthModeEnum.toTheta objectForKey:authMode]
3095
+ password:password
3096
+ connectionPriority:connectionPriority
3097
+ proxy:convertDictionaryToProxy(proxy)
3098
+ completionHandler:^(NSError *error) {
3099
+ if (error) {
3100
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3101
+ } else {
3102
+ resolve(@(YES));
3103
+ }
2030
3104
  }];
2031
3105
  }
2032
3106
 
@@ -2040,6 +3114,7 @@ RCT_REMAP_METHOD(setAccessPointDynamically,
2040
3114
  * @param ipAddress static ipaddress to connect
2041
3115
  * @param subnetMask subnet mask for ip address
2042
3116
  * @param defaultGateway default gateway address
3117
+ * @param proxy Proxy information to be used for the access point.
2043
3118
  * @param resolve resolver for setAccessPointStatically
2044
3119
  * @param rejecter rejecter for setAccessPointStatically
2045
3120
  */
@@ -2052,23 +3127,29 @@ RCT_REMAP_METHOD(setAccessPointStatically,
2052
3127
  withIpAddress:(NSString *)ipAddress
2053
3128
  withSubnetMask:(NSString *)subnetMask
2054
3129
  withDefaultGateway:(NSString *)defaultGateway
3130
+ withProxy:(NSDictionary *)proxy
2055
3131
  withResolver:(RCTPromiseResolveBlock)resolve
2056
3132
  withRejecter:(RCTPromiseRejectBlock)reject)
2057
3133
  {
2058
- [_theta setAccessPointStaticallySsid:ssid
2059
- ssidStealth:ssidStealth
2060
- authMode:[AuthModeEnum.toTheta objectForKey:authMode]
2061
- password:password
2062
- connectionPriority:connectionPriority
2063
- ipAddress:ipAddress
2064
- subnetMask:subnetMask
2065
- defaultGateway:defaultGateway
2066
- completionHandler:^(NSError *error) {
2067
- if (error) {
2068
- reject(@"error", [error localizedDescription], error);
2069
- } else {
2070
- resolve(@(YES));
2071
- }
3134
+ if (!_theta) {
3135
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3136
+ return;
3137
+ }
3138
+ [_theta setAccessPointStaticallySsid:ssid
3139
+ ssidStealth:ssidStealth
3140
+ authMode:[AuthModeEnum.toTheta objectForKey:authMode]
3141
+ password:password
3142
+ connectionPriority:connectionPriority
3143
+ ipAddress:ipAddress
3144
+ subnetMask:subnetMask
3145
+ defaultGateway:defaultGateway
3146
+ proxy:convertDictionaryToProxy(proxy)
3147
+ completionHandler:^(NSError *error) {
3148
+ if (error) {
3149
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3150
+ } else {
3151
+ resolve(@(YES));
3152
+ }
2072
3153
  }];
2073
3154
  }
2074
3155
 
@@ -2083,12 +3164,409 @@ RCT_REMAP_METHOD(deleteAccessPoint,
2083
3164
  withResolver:(RCTPromiseResolveBlock)resolve
2084
3165
  withRejecter:(RCTPromiseRejectBlock)reject)
2085
3166
  {
2086
- [_theta deleteAccessPointSsid:ssid
2087
- completionHandler:^(NSError *error) {
3167
+ if (!_theta) {
3168
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3169
+ return;
3170
+ }
3171
+ [_theta deleteAccessPointSsid:ssid
3172
+ completionHandler:^(NSError *error) {
3173
+ if (error) {
3174
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3175
+ } else {
3176
+ resolve(@(YES));
3177
+ }
3178
+ }];
3179
+ }
3180
+
3181
+ /// convert NSDictionary to THETACThetaRepositoryProxy
3182
+ /// @param proxyDic NSDictionary of proxy
3183
+ static THETACThetaRepositoryProxy* convertDictionaryToProxy(NSDictionary *proxyDic) {
3184
+ THETACThetaRepositoryOptions *options = [[THETACThetaRepositoryOptions alloc] init];
3185
+ convert_t *convert = &ProxyCvt;
3186
+ if (convert->setToTheta) {
3187
+ NSMutableDictionary *optionsDic = [[NSMutableDictionary alloc] init];
3188
+ [optionsDic setObject:proxyDic forKey:@"proxy"];
3189
+ convert->setToTheta(optionsDic, options);
3190
+ }
3191
+ return options.proxy;
3192
+ }
3193
+
3194
+ /**
3195
+ * convertOptionsFromTheta - convert resposnse of getMySetting
3196
+ * @param results conversion results
3197
+ * @param options response of getMySetting
3198
+ * @return error during conversion
3199
+ */
3200
+ static NSError* convertOptionsFromTheta(NSMutableDictionary* results, THETACThetaRepositoryOptions* options)
3201
+ {
3202
+ THETACKotlinArray<THETACThetaRepositoryOptionNameEnum *>* optionNames = THETACThetaRepositoryOptionNameEnum.values;
3203
+ for (int i = 0; i < optionNames.size; i++) {
3204
+ THETACThetaRepositoryOptionNameEnum* optionName = [optionNames getIndex:i];
3205
+ NSError* error = nil;
3206
+ id value = [options getValueName:optionName error:&error];
3207
+ if (error) {
3208
+ return error;
3209
+ }
3210
+ if (value != nil) {
3211
+ NSString* name = [OptionEnumToOption objectForKey:optionName.name];
3212
+ convert_t *convert = [NameToConverter objectForKey:name]();
3213
+ if (convert && convert->setFromTheta) {
3214
+ convert->setFromTheta(results, options);
3215
+ }
3216
+ }
3217
+ }
3218
+ return nil;
3219
+ }
3220
+
3221
+ /**
3222
+ * getMySetting - acquires the shooting properties ( just for Theta V and later )
3223
+ * @param captureMode the target shooting mode
3224
+ * @param resolve resolver for getMySetting
3225
+ * @param rejecter rejecter for getMySetting
3226
+ */
3227
+ RCT_REMAP_METHOD(getMySetting,
3228
+ getMySettingWithCaptureMode:(NSString *)captureMode
3229
+ withResolver:(RCTPromiseResolveBlock)resolve
3230
+ withRejecter:(RCTPromiseRejectBlock)reject)
3231
+ {
3232
+ if (!_theta) {
3233
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3234
+ return;
3235
+ }
3236
+ [_theta getMySettingCaptureMode:[CaptureModeEnum.toTheta objectForKey:captureMode]
3237
+ completionHandler:^(THETACThetaRepositoryOptions *options, NSError *error) {
3238
+ if (error) {
3239
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3240
+ } else if (options) {
3241
+ NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
3242
+ NSError *convertError = convertOptionsFromTheta(results, options);
3243
+ if (convertError) {
3244
+ reject(ERROR_CODE_ERROR, [error localizedDescription], convertError);
3245
+ }
3246
+ resolve(results);
3247
+ } else {
3248
+ reject(ERROR_CODE_ERROR, @"no options", nil);
3249
+ }
3250
+ }];
3251
+ }
3252
+
3253
+ /**
3254
+ * getMySetting - acquires the shooting properties ( just for Theta S and SC )
3255
+ * @param optionNames list of option names to acquire
3256
+ * @param resolve resolver for getMySetting
3257
+ * @param rejecter rejecter for getMySetting
3258
+ */
3259
+ RCT_REMAP_METHOD(getMySettingFromOldModel,
3260
+ getMySettingWithOptionNames:(NSArray*)optionNames
3261
+ withResolver:(RCTPromiseResolveBlock)resolve
3262
+ withRejecter:(RCTPromiseRejectBlock)reject)
3263
+ {
3264
+ if (!_theta) {
3265
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3266
+ return;
3267
+ }
3268
+ NSMutableArray *optionNameList = [[NSMutableArray alloc] init];
3269
+ for (id name in optionNames) {
3270
+ [optionNameList addObject:[NameToOptionEnum objectForKey:name]];
3271
+ }
3272
+ [_theta getMySettingOptionNames:optionNameList
3273
+ completionHandler:^(THETACThetaRepositoryOptions *options, NSError *error) {
3274
+ if (error) {
3275
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3276
+ } else if (options) {
3277
+ NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
3278
+ for (id name in optionNames) {
3279
+ id option = [OptionEnumToOption objectForKey:name];
3280
+ OptionConverter converter = [NameToConverter objectForKey:option];
3281
+ if (converter) {
3282
+ convert_t *convert = converter();
3283
+ if (convert && convert->setFromTheta) {
3284
+ convert->setFromTheta(results, options);
3285
+ }
3286
+ }
3287
+ }
3288
+ resolve(results);
3289
+ } else {
3290
+ reject(ERROR_CODE_ERROR, @"no options", nil);
3291
+ }
3292
+ }];
3293
+ }
3294
+
3295
+ /**
3296
+ * setMySetting - registers shooting conditions in My Settings
3297
+ * @param captureMode the target shooting mode. RICOH THETA S and SC do not support My Settings in video capture mode
3298
+ * @param options registered to My Settings
3299
+ * @param resolve resolver for setMySetting
3300
+ * @param rejecter rejecter for setMySetting
3301
+ */
3302
+ RCT_REMAP_METHOD(setMySetting,
3303
+ setMySettingWithCaptureMode:(NSString *)captureMode
3304
+ setMySettingWithOptions:(NSDictionary*)options
3305
+ withResolver:(RCTPromiseResolveBlock)resolve
3306
+ withRejecter:(RCTPromiseRejectBlock)reject)
3307
+ {
3308
+ if (!_theta) {
3309
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3310
+ return;
3311
+ }
3312
+ THETACThetaRepositoryOptions *newoptions = [[THETACThetaRepositoryOptions alloc] init];
3313
+ for (id option in [options allKeys]) {
3314
+ OptionConverter converter = [NameToConverter objectForKey:option];
3315
+ if (converter) {
3316
+ convert_t *convert = converter();
3317
+ if (convert && convert->setToTheta) {
3318
+ convert->setToTheta(options, newoptions);
3319
+ }
3320
+ }
3321
+ }
3322
+ [_theta setMySettingCaptureMode:[CaptureModeEnum.toTheta objectForKey:captureMode]
3323
+ options:newoptions
3324
+ completionHandler:^(NSError *error) {
3325
+ if (error) {
3326
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3327
+ } else {
3328
+ resolve(@(YES));
3329
+ }
3330
+ }];
3331
+ }
3332
+
3333
+ /**
3334
+ * deleteMySetting - delete shooting conditions in My Settings
3335
+ * @param captureMode the target shooting mode
3336
+ * @param resolve resolver for deleteMySetting
3337
+ * @param rejecter rejecter for deleteMySetting
3338
+ */
3339
+ RCT_REMAP_METHOD(deleteMySetting,
3340
+ deleteMySettingWithCaptureMode:(NSString *)captureMode
3341
+ withResolver:(RCTPromiseResolveBlock)resolve
3342
+ withRejecter:(RCTPromiseRejectBlock)reject)
3343
+ {
3344
+ if (!_theta) {
3345
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3346
+ return;
3347
+ }
3348
+ [_theta deleteMySettingCaptureMode:[CaptureModeEnum.toTheta objectForKey:captureMode]
3349
+ completionHandler:^(NSError *error) {
3350
+ if (error) {
3351
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3352
+ } else {
3353
+ resolve(@(YES));
3354
+ }
3355
+ }];
3356
+ }
3357
+
3358
+ /**
3359
+ * listPlugins - acquires a list of installed plugins
3360
+ * @param resolve resolver for listPlugins
3361
+ * @param rejecter rejecter for listPlugins
3362
+ */
3363
+ RCT_REMAP_METHOD(listPlugins,
3364
+ listPluginsWithResolver:(RCTPromiseResolveBlock)resolve
3365
+ withRejecter:(RCTPromiseRejectBlock)reject)
3366
+ {
3367
+ if (!_theta) {
3368
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3369
+ return;
3370
+ }
3371
+ [_theta listPluginsWithCompletionHandler:^(NSArray *pluginList, NSError *error) {
3372
+ if (error) {
3373
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3374
+ } else if (pluginList) {
3375
+ NSMutableArray *ary = [[NSMutableArray alloc] init];
3376
+ for (int i = 0; i < pluginList.count; i++) {
3377
+ THETACThetaRepositoryPluginInfo *plugininfo = pluginList[i];
3378
+ [ary addObject: @{
3379
+ @"name": plugininfo.name,
3380
+ @"packageName": plugininfo.packageName,
3381
+ @"version": plugininfo.version,
3382
+ @"isPreInstalled": @(plugininfo.isPreInstalled),
3383
+ @"isRunning": @(plugininfo.isRunning),
3384
+ @"isForeground": @(plugininfo.isForeground),
3385
+ @"isBoot": @(plugininfo.isBoot),
3386
+ @"hasWebServer": @(plugininfo.hasWebServer),
3387
+ @"exitStatus": plugininfo.exitStatus,
3388
+ @"message": plugininfo.message
3389
+ }];
3390
+ }
3391
+ resolve(ary);
3392
+ } else {
3393
+ reject(ERROR_CODE_ERROR, @"no plugin", nil);
3394
+ }
3395
+ }];
3396
+ }
3397
+
3398
+ /**
3399
+ * setPlugin - sets the installed plugin for boot
3400
+ * @param packageName package name of the target plugin
3401
+ * @param resolve resolver for setPlugin
3402
+ * @param rejecter rejecter for setPlugin
3403
+ */
3404
+ RCT_REMAP_METHOD(setPlugin,
3405
+ setPluginPackageName:(NSString *)packageName
3406
+ withResolver:(RCTPromiseResolveBlock)resolve
3407
+ withRejecter:(RCTPromiseRejectBlock)reject)
3408
+ {
3409
+ if (!_theta) {
3410
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3411
+ return;
3412
+ }
3413
+ [_theta setPluginPackageName:packageName
3414
+ completionHandler:^(NSError *error) {
3415
+ if (error) {
3416
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3417
+ } else {
3418
+ resolve(@(YES));
3419
+ }
3420
+ }];
3421
+ }
3422
+
3423
+ /**
3424
+ * startPlugin - start the plugin specified by the packageName
3425
+ * @param packageName package name of the target plugin
3426
+ * @param resolve resolver for startPlugin
3427
+ * @param rejecter rejecter for startPlugin
3428
+ */
3429
+ RCT_REMAP_METHOD(startPlugin,
3430
+ startPluginPackageName:(NSString *)packageName
3431
+ withResolver:(RCTPromiseResolveBlock)resolve
3432
+ withRejecter:(RCTPromiseRejectBlock)reject)
3433
+ {
3434
+ if (!_theta) {
3435
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3436
+ return;
3437
+ }
3438
+ [_theta startPluginPackageName:packageName
3439
+ completionHandler:^(NSError *error) {
3440
+ if (error) {
3441
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3442
+
3443
+ } else {
3444
+ resolve(@(YES));
3445
+ }
3446
+ }];
3447
+ }
3448
+
3449
+ /**
3450
+ * stopPlugin - stop the running plugin
3451
+ * @param resolve resolver for stopPlugin
3452
+ * @param rejecter rejecter for stopPlugin
3453
+ */
3454
+ RCT_REMAP_METHOD(stopPlugin,
3455
+ stopPluginWithResolver:(RCTPromiseResolveBlock)resolve
3456
+ withRejecter:(RCTPromiseRejectBlock)reject)
3457
+ {
3458
+ if (!_theta) {
3459
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3460
+ return;
3461
+ }
3462
+ [_theta stopPluginWithCompletionHandler:^(NSError *error) {
3463
+ if (error) {
3464
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3465
+
3466
+ } else {
3467
+ resolve(@(YES));
3468
+ }
3469
+ }];
3470
+ }
3471
+
3472
+ /**
3473
+ * getPluginLicense - acquires the license for the installed plugin
3474
+ * @param packageName package name of the target plugin
3475
+ * @param resolve resolver for getPluginLicense
3476
+ * @param rejecter rejecter for getPluginLicense
3477
+ */
3478
+ RCT_REMAP_METHOD(getPluginLicense,
3479
+ getPluginLicensePackageName:(NSString *)packageName
3480
+ withResolver:(RCTPromiseResolveBlock)resolve
3481
+ withRejecter:(RCTPromiseRejectBlock)reject)
3482
+ {
3483
+ if (!_theta) {
3484
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3485
+ return;
3486
+ }
3487
+ [_theta getPluginLicensePackageName:packageName
3488
+ completionHandler:^(NSString *pluginLicense, NSError *error) {
3489
+ if (error) {
3490
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3491
+
3492
+ } else if (pluginLicense) {
3493
+ resolve(pluginLicense);
3494
+ } else {
3495
+ reject(ERROR_CODE_ERROR, @"no plugin lincense", nil);
3496
+ }
3497
+ }];
3498
+ }
3499
+
3500
+ /**
3501
+ * getPluginOrders - return the plugin orders
3502
+ * @param resolve resolver for getPluginOrders
3503
+ * @param rejecter rejecter for getPluginOrders
3504
+ */
3505
+ RCT_REMAP_METHOD(getPluginOrders,
3506
+ getPluginOrdersWithResolver:(RCTPromiseResolveBlock)resolve
3507
+ withRejecter:(RCTPromiseRejectBlock)reject)
3508
+ {
3509
+ if (!_theta) {
3510
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3511
+ return;
3512
+ }
3513
+ [_theta getPluginOrdersWithCompletionHandler:^(NSArray *pluginOrders, NSError *error) {
3514
+ if (error) {
3515
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3516
+ } else if (pluginOrders) {
3517
+ resolve(pluginOrders);
3518
+ } else {
3519
+ reject(ERROR_CODE_ERROR, @"no plugin orders", nil);
3520
+ }
3521
+ }];
3522
+ }
3523
+
3524
+ /**
3525
+ * setPluginOrders - sets the plugin orders
3526
+ * @param list of package names of plugins
3527
+ * @param resolve resolver for setPluginOrders
3528
+ * @param rejecter rejecter for setPluginOrders
3529
+ */
3530
+ RCT_REMAP_METHOD(setPluginOrders,
3531
+ setPluginOrdersPlugins:(NSArray *) plugins
3532
+ withResolver:(RCTPromiseResolveBlock)resolve
3533
+ withRejecter:(RCTPromiseRejectBlock)reject)
3534
+ {
3535
+ if (!_theta) {
3536
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3537
+ return;
3538
+ }
3539
+ [_theta setPluginOrdersPlugins:plugins
3540
+ completionHandler:^(NSError *error) {
3541
+ if (error) {
3542
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
3543
+ } else {
3544
+ resolve(@(YES));
3545
+ }
3546
+ }];
3547
+ }
3548
+
3549
+ /**
3550
+ * setBluetoothDevice - register uuid of a BLE device
3551
+ * @param uuid uuid to set
3552
+ * @param resolve resolver for setAccessPointStaticcaly
3553
+ * @param rejecter rejecter for setAccessPointStaticcaly
3554
+ */
3555
+ RCT_REMAP_METHOD(setBluetoothDevice,
3556
+ setBluetoothDeviceWithUuid:(NSString *)uuid
3557
+ withResolver:(RCTPromiseResolveBlock)resolve
3558
+ withRejecter:(RCTPromiseRejectBlock)reject)
3559
+ {
3560
+ if (!_theta) {
3561
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3562
+ return;
3563
+ }
3564
+ [_theta setBluetoothDeviceUuid:uuid
3565
+ completionHandler:^(NSString *deviceName, NSError *error) {
2088
3566
  if (error) {
2089
- reject(@"error", [error localizedDescription], error);
3567
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2090
3568
  } else {
2091
- resolve(@(YES));
3569
+ resolve(deviceName);
2092
3570
  }
2093
3571
  }];
2094
3572
  }