theta-client-react-native 1.1.0 → 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 (162) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/ricoh360/thetaclientreactnative/Converter.kt +375 -0
  3. package/android/src/main/java/com/ricoh360/thetaclientreactnative/ThetaClientSdkModule.kt +391 -17
  4. package/ios/ThetaClientReactNative.h +6 -0
  5. package/ios/ThetaClientReactNative.mm +1125 -132
  6. package/lib/commonjs/capture/index.js +11 -0
  7. package/lib/commonjs/capture/index.js.map +1 -1
  8. package/lib/commonjs/capture/notify.js +12 -0
  9. package/lib/commonjs/capture/notify.js.map +1 -0
  10. package/lib/commonjs/capture/time-shift-capture.js +91 -0
  11. package/lib/commonjs/capture/time-shift-capture.js.map +1 -0
  12. package/lib/commonjs/theta-repository/access-point.js.map +1 -1
  13. package/lib/commonjs/theta-repository/digest-auth.js +2 -0
  14. package/lib/commonjs/theta-repository/digest-auth.js.map +1 -0
  15. package/lib/commonjs/theta-repository/index.js +37 -4
  16. package/lib/commonjs/theta-repository/index.js.map +1 -1
  17. package/lib/commonjs/theta-repository/options/index.js +110 -0
  18. package/lib/commonjs/theta-repository/options/index.js.map +1 -1
  19. package/lib/commonjs/theta-repository/options/option-camera-control-source.js +29 -0
  20. package/lib/commonjs/theta-repository/options/option-camera-control-source.js.map +1 -0
  21. package/lib/commonjs/theta-repository/options/option-camera-mode.js +26 -0
  22. package/lib/commonjs/theta-repository/options/option-camera-mode.js.map +1 -0
  23. package/lib/commonjs/theta-repository/options/option-network-type.js +26 -0
  24. package/lib/commonjs/theta-repository/options/option-network-type.js.map +1 -0
  25. package/lib/commonjs/theta-repository/options/option-power-saving.js +24 -0
  26. package/lib/commonjs/theta-repository/options/option-power-saving.js.map +1 -0
  27. package/lib/commonjs/theta-repository/options/option-preview-format.js +32 -0
  28. package/lib/commonjs/theta-repository/options/option-preview-format.js.map +1 -0
  29. package/lib/commonjs/theta-repository/options/option-proxy.js +2 -0
  30. package/lib/commonjs/theta-repository/options/option-proxy.js.map +1 -0
  31. package/lib/commonjs/theta-repository/options/option-shooting-method.js +41 -0
  32. package/lib/commonjs/theta-repository/options/option-shooting-method.js.map +1 -0
  33. package/lib/commonjs/theta-repository/options/option-shutter-speed.js +302 -0
  34. package/lib/commonjs/theta-repository/options/option-shutter-speed.js.map +1 -0
  35. package/lib/commonjs/theta-repository/options/option-time-shift.js +43 -0
  36. package/lib/commonjs/theta-repository/options/option-time-shift.js.map +1 -0
  37. package/lib/commonjs/theta-repository/options/option-wlan-frequency.js +22 -0
  38. package/lib/commonjs/theta-repository/options/option-wlan-frequency.js.map +1 -0
  39. package/lib/commonjs/theta-repository/options/options.js +30 -2
  40. package/lib/commonjs/theta-repository/options/options.js.map +1 -1
  41. package/lib/commonjs/theta-repository/theta-config.js +6 -0
  42. package/lib/commonjs/theta-repository/theta-config.js.map +1 -0
  43. package/lib/commonjs/theta-repository/theta-files.js +13 -1
  44. package/lib/commonjs/theta-repository/theta-files.js.map +1 -1
  45. package/lib/commonjs/theta-repository/theta-repository.js +39 -8
  46. package/lib/commonjs/theta-repository/theta-repository.js.map +1 -1
  47. package/lib/commonjs/theta-repository/theta-timeout.js +2 -0
  48. package/lib/commonjs/theta-repository/theta-timeout.js.map +1 -0
  49. package/lib/module/capture/index.js +1 -0
  50. package/lib/module/capture/index.js.map +1 -1
  51. package/lib/module/capture/notify.js +6 -0
  52. package/lib/module/capture/notify.js.map +1 -0
  53. package/lib/module/capture/time-shift-capture.js +83 -0
  54. package/lib/module/capture/time-shift-capture.js.map +1 -0
  55. package/lib/module/theta-repository/access-point.js.map +1 -1
  56. package/lib/module/theta-repository/digest-auth.js +2 -0
  57. package/lib/module/theta-repository/digest-auth.js.map +1 -0
  58. package/lib/module/theta-repository/index.js +4 -1
  59. package/lib/module/theta-repository/index.js.map +1 -1
  60. package/lib/module/theta-repository/options/index.js +10 -0
  61. package/lib/module/theta-repository/options/index.js.map +1 -1
  62. package/lib/module/theta-repository/options/option-camera-control-source.js +22 -0
  63. package/lib/module/theta-repository/options/option-camera-control-source.js.map +1 -0
  64. package/lib/module/theta-repository/options/option-camera-mode.js +19 -0
  65. package/lib/module/theta-repository/options/option-camera-mode.js.map +1 -0
  66. package/lib/module/theta-repository/options/option-network-type.js +19 -0
  67. package/lib/module/theta-repository/options/option-network-type.js.map +1 -0
  68. package/lib/module/theta-repository/options/option-power-saving.js +17 -0
  69. package/lib/module/theta-repository/options/option-power-saving.js.map +1 -0
  70. package/lib/module/theta-repository/options/option-preview-format.js +25 -0
  71. package/lib/module/theta-repository/options/option-preview-format.js.map +1 -0
  72. package/lib/module/theta-repository/options/option-proxy.js +2 -0
  73. package/lib/module/theta-repository/options/option-proxy.js.map +1 -0
  74. package/lib/module/theta-repository/options/option-shooting-method.js +34 -0
  75. package/lib/module/theta-repository/options/option-shooting-method.js.map +1 -0
  76. package/lib/module/theta-repository/options/option-shutter-speed.js +295 -0
  77. package/lib/module/theta-repository/options/option-shutter-speed.js.map +1 -0
  78. package/lib/module/theta-repository/options/option-time-shift.js +36 -0
  79. package/lib/module/theta-repository/options/option-time-shift.js.map +1 -0
  80. package/lib/module/theta-repository/options/option-wlan-frequency.js +15 -0
  81. package/lib/module/theta-repository/options/option-wlan-frequency.js.map +1 -0
  82. package/lib/module/theta-repository/options/options.js +30 -2
  83. package/lib/module/theta-repository/options/options.js.map +1 -1
  84. package/lib/module/theta-repository/theta-config.js +2 -0
  85. package/lib/module/theta-repository/theta-config.js.map +1 -0
  86. package/lib/module/theta-repository/theta-files.js +12 -0
  87. package/lib/module/theta-repository/theta-files.js.map +1 -1
  88. package/lib/module/theta-repository/theta-repository.js +38 -9
  89. package/lib/module/theta-repository/theta-repository.js.map +1 -1
  90. package/lib/module/theta-repository/theta-timeout.js +2 -0
  91. package/lib/module/theta-repository/theta-timeout.js.map +1 -0
  92. package/lib/typescript/capture/index.d.ts +1 -0
  93. package/lib/typescript/capture/index.d.ts.map +1 -1
  94. package/lib/typescript/capture/notify.d.ts +13 -0
  95. package/lib/typescript/capture/notify.d.ts.map +1 -0
  96. package/lib/typescript/capture/time-shift-capture.d.ts +44 -0
  97. package/lib/typescript/capture/time-shift-capture.d.ts.map +1 -0
  98. package/lib/typescript/theta-repository/access-point.d.ts +4 -1
  99. package/lib/typescript/theta-repository/access-point.d.ts.map +1 -1
  100. package/lib/typescript/theta-repository/digest-auth.d.ts +17 -0
  101. package/lib/typescript/theta-repository/digest-auth.d.ts.map +1 -0
  102. package/lib/typescript/theta-repository/index.d.ts +4 -1
  103. package/lib/typescript/theta-repository/index.d.ts.map +1 -1
  104. package/lib/typescript/theta-repository/options/index.d.ts +10 -0
  105. package/lib/typescript/theta-repository/options/index.d.ts.map +1 -1
  106. package/lib/typescript/theta-repository/options/option-camera-control-source.d.ts +22 -0
  107. package/lib/typescript/theta-repository/options/option-camera-control-source.d.ts.map +1 -0
  108. package/lib/typescript/theta-repository/options/option-camera-mode.d.ts +19 -0
  109. package/lib/typescript/theta-repository/options/option-camera-mode.d.ts.map +1 -0
  110. package/lib/typescript/theta-repository/options/option-network-type.d.ts +19 -0
  111. package/lib/typescript/theta-repository/options/option-network-type.d.ts.map +1 -0
  112. package/lib/typescript/theta-repository/options/option-power-saving.d.ts +16 -0
  113. package/lib/typescript/theta-repository/options/option-power-saving.d.ts.map +1 -0
  114. package/lib/typescript/theta-repository/options/option-preview-format.d.ts +25 -0
  115. package/lib/typescript/theta-repository/options/option-preview-format.d.ts.map +1 -0
  116. package/lib/typescript/theta-repository/options/option-proxy.d.ts +23 -0
  117. package/lib/typescript/theta-repository/options/option-proxy.d.ts.map +1 -0
  118. package/lib/typescript/theta-repository/options/option-shooting-method.d.ts +33 -0
  119. package/lib/typescript/theta-repository/options/option-shooting-method.d.ts.map +1 -0
  120. package/lib/typescript/theta-repository/options/option-shutter-speed.d.ts +295 -0
  121. package/lib/typescript/theta-repository/options/option-shutter-speed.d.ts.map +1 -0
  122. package/lib/typescript/theta-repository/options/option-time-shift.d.ts +54 -0
  123. package/lib/typescript/theta-repository/options/option-time-shift.d.ts.map +1 -0
  124. package/lib/typescript/theta-repository/options/option-white-balance-auto-strength.d.ts +1 -1
  125. package/lib/typescript/theta-repository/options/option-white-balance-auto-strength.d.ts.map +1 -1
  126. package/lib/typescript/theta-repository/options/option-wlan-frequency.d.ts +15 -0
  127. package/lib/typescript/theta-repository/options/option-wlan-frequency.d.ts.map +1 -0
  128. package/lib/typescript/theta-repository/options/options.d.ts +73 -6
  129. package/lib/typescript/theta-repository/options/options.d.ts.map +1 -1
  130. package/lib/typescript/theta-repository/theta-config.d.ts +20 -0
  131. package/lib/typescript/theta-repository/theta-config.d.ts.map +1 -0
  132. package/lib/typescript/theta-repository/theta-files.d.ts +14 -1
  133. package/lib/typescript/theta-repository/theta-files.d.ts.map +1 -1
  134. package/lib/typescript/theta-repository/theta-repository.d.ts +28 -7
  135. package/lib/typescript/theta-repository/theta-repository.d.ts.map +1 -1
  136. package/lib/typescript/theta-repository/theta-timeout.d.ts +22 -0
  137. package/lib/typescript/theta-repository/theta-timeout.d.ts.map +1 -0
  138. package/package.json +1 -1
  139. package/src/capture/index.ts +1 -0
  140. package/src/capture/notify.ts +27 -0
  141. package/src/capture/time-shift-capture.ts +99 -0
  142. package/src/theta-repository/access-point.ts +5 -1
  143. package/src/theta-repository/digest-auth.ts +16 -0
  144. package/src/theta-repository/index.ts +4 -1
  145. package/src/theta-repository/options/index.ts +11 -0
  146. package/src/theta-repository/options/option-camera-control-source.ts +24 -0
  147. package/src/theta-repository/options/option-camera-mode.ts +20 -0
  148. package/src/theta-repository/options/option-network-type.ts +20 -0
  149. package/src/theta-repository/options/option-power-saving.ts +18 -0
  150. package/src/theta-repository/options/option-preview-format.ts +27 -0
  151. package/src/theta-repository/options/option-proxy.ts +22 -0
  152. package/src/theta-repository/options/option-shooting-method.ts +36 -0
  153. package/src/theta-repository/options/option-shutter-speed.ts +360 -0
  154. package/src/theta-repository/options/option-time-shift.ts +59 -0
  155. package/src/theta-repository/options/option-white-balance-auto-strength.ts +1 -1
  156. package/src/theta-repository/options/option-wlan-frequency.ts +16 -0
  157. package/src/theta-repository/options/options.ts +74 -6
  158. package/src/theta-repository/theta-config.ts +20 -0
  159. package/src/theta-repository/theta-files.ts +16 -1
  160. package/src/theta-repository/theta-repository.ts +68 -17
  161. package/src/theta-repository/theta-timeout.ts +21 -0
  162. 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
  /**
@@ -264,6 +360,17 @@ static convert_t FileTypeEnum = {
264
360
  }
265
361
  };
266
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
+
267
374
  /**
268
375
  * AuthModeEnum converter
269
376
  */
@@ -318,6 +425,12 @@ static convert_t ApertureEnum = {
318
425
  [builder setApertureAperture:val];
319
426
  }
320
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
+ },
321
434
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
322
435
  id val = [ApertureEnum.toTheta objectForKey:[rct objectForKey:@"aperture"]];
323
436
  if (val) {
@@ -352,6 +465,62 @@ static convert_t BluetoothPowerEnum = {
352
465
  }
353
466
  };
354
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
+
355
524
  /**
356
525
  * CaptureModeEnum converter
357
526
  */
@@ -432,6 +601,12 @@ static convert_t ExposureCompensationEnum = {
432
601
  [builder setExposureCompensationValue:val];
433
602
  }
434
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
+ },
435
610
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
436
611
  id val = [ExposureCompensationEnum.toTheta
437
612
  objectForKey:[rct objectForKey:@"exposureCompensation"]];
@@ -489,6 +664,12 @@ static convert_t ExposureDelayEnum = {
489
664
  [builder setExposureDelayDelay:val];
490
665
  }
491
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
+ },
492
673
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
493
674
  id val = [ExposureDelayEnum.toTheta objectForKey:[rct objectForKey:@"exposureDelay"]];
494
675
  if (val) {
@@ -535,6 +716,12 @@ static convert_t ExposureProgramEnum = {
535
716
  [builder setExposureProgramProgram:val];
536
717
  }
537
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
+ },
538
725
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
539
726
  id val = [ExposureProgramEnum.toTheta
540
727
  objectForKey:[rct objectForKey:@"exposureProgram"]];
@@ -711,6 +898,12 @@ static convert_t GpsTagRecordingEnum = {
711
898
  [builder setGpsTagRecordingValue:val];
712
899
  }
713
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
+ },
714
907
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
715
908
  id val = [GpsTagRecordingEnum.toTheta
716
909
  objectForKey:[rct objectForKey:@"_gpsTagRecording"]];
@@ -792,6 +985,12 @@ static convert_t IsoEnum = {
792
985
  [builder setIsoIso:val];
793
986
  }
794
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
+ },
795
994
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
796
995
  id val = [IsoEnum.toTheta objectForKey:[rct objectForKey:@"iso"]];
797
996
  if (val) {
@@ -866,6 +1065,12 @@ static convert_t IsoAutoHighLimitEnum = {
866
1065
  [builder setIsoAutoHighLimitIso:val];
867
1066
  }
868
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
+ },
869
1074
  .setVideoOption = ^(NSDictionary* rct, THETACVideoCaptureBuilder *builder) {
870
1075
  id val = [IsoAutoHighLimitEnum.toTheta
871
1076
  objectForKey:[rct objectForKey:@"isoAutoHighLimit"]];
@@ -922,12 +1127,16 @@ static convert_t MaxRecordableTimeEnum = {
922
1127
  .toTheta = @{
923
1128
  @"RECORDABLE_TIME_180": THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime180,
924
1129
  @"RECORDABLE_TIME_300": THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime300,
925
- @"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
926
1133
  },
927
1134
  .fromTheta = @{
928
1135
  THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime180: @"RECORDABLE_TIME_180",
929
1136
  THETACThetaRepositoryMaxRecordableTimeEnum.recordableTime300: @"RECORDABLE_TIME_300",
930
- 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"
931
1140
  },
932
1141
  .setToTheta = ^(NSDictionary* rct, THETACThetaRepositoryOptions *opt) {
933
1142
  id val = [MaxRecordableTimeEnum.toTheta
@@ -993,6 +1202,71 @@ static convert_t OffDelayEnum = {
993
1202
  }
994
1203
  };
995
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
+
996
1270
  /**
997
1271
  * WhiteBalanceEnum converter
998
1272
  */
@@ -1143,6 +1417,44 @@ static convert_t IsGpsOnCvt = {
1143
1417
  }
1144
1418
  };
1145
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
+
1146
1458
  /**
1147
1459
  * SleepDelay converter
1148
1460
  */
@@ -1299,12 +1611,253 @@ static convert_t GpsInfoCvt = {
1299
1611
  }
1300
1612
  };
1301
1613
 
1614
+ /**
1615
+ * NetworkType converter
1616
+ */
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
+ }
1642
+ };
1643
+
1644
+ /**
1645
+ * WlanFrequency converter
1646
+ */
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
+
1302
1853
  /**
1303
1854
  * OptionNames converter
1304
1855
  */
1305
1856
  static NSDictionary *NameToOptionEnum = @{
1306
1857
  @"Aperture": THETACThetaRepositoryOptionNameEnum.aperture,
1307
1858
  @"BluetoothPower": THETACThetaRepositoryOptionNameEnum.bluetoothpower,
1859
+ @"CameraControlSource": THETACThetaRepositoryOptionNameEnum.cameracontrolsource,
1860
+ @"CameraMode": THETACThetaRepositoryOptionNameEnum.cameramode,
1308
1861
  @"CaptureMode": THETACThetaRepositoryOptionNameEnum.capturemode,
1309
1862
  @"ColorTemperature": THETACThetaRepositoryOptionNameEnum.colortemperature,
1310
1863
  @"DateTimeZone": THETACThetaRepositoryOptionNameEnum.datetimezone,
@@ -1319,15 +1872,25 @@ static NSDictionary *NameToOptionEnum = @{
1319
1872
  @"IsoAutoHighLimit": THETACThetaRepositoryOptionNameEnum.isoautohighlimit,
1320
1873
  @"Language": THETACThetaRepositoryOptionNameEnum.language,
1321
1874
  @"MaxRecordableTime": THETACThetaRepositoryOptionNameEnum.maxrecordabletime,
1875
+ @"NetworkType": THETACThetaRepositoryOptionNameEnum.networktype,
1322
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,
1323
1883
  @"SleepDelay": THETACThetaRepositoryOptionNameEnum.sleepdelay,
1324
1884
  @"RemainingPictures": THETACThetaRepositoryOptionNameEnum.remainingpictures,
1325
1885
  @"RemainingVideoSeconds": THETACThetaRepositoryOptionNameEnum.remainingvideoseconds,
1326
1886
  @"RemainingSpace": THETACThetaRepositoryOptionNameEnum.remainingspace,
1887
+ @"TimeShift": THETACThetaRepositoryOptionNameEnum.timeshift,
1327
1888
  @"TotalSpace": THETACThetaRepositoryOptionNameEnum.totalspace,
1328
1889
  @"ShutterVolume": THETACThetaRepositoryOptionNameEnum.shuttervolume,
1890
+ @"Username": THETACThetaRepositoryOptionNameEnum.username,
1329
1891
  @"WhiteBalance": THETACThetaRepositoryOptionNameEnum.whitebalance,
1330
- @"WhiteBalanceAutoStrength": THETACThetaRepositoryOptionNameEnum.whitebalanceautostrength
1892
+ @"WhiteBalanceAutoStrength": THETACThetaRepositoryOptionNameEnum.whitebalanceautostrength,
1893
+ @"WlanFrequency": THETACThetaRepositoryOptionNameEnum.wlanfrequency
1331
1894
  };
1332
1895
 
1333
1896
  /**
@@ -1336,6 +1899,8 @@ static NSDictionary *NameToOptionEnum = @{
1336
1899
  static NSDictionary *OptionEnumToOption = @{
1337
1900
  @"Aperture": @"aperture",
1338
1901
  @"BluetoothPower": @"bluetoothPower",
1902
+ @"CameraControlSource": @"cameraControlSource",
1903
+ @"CameraMode": @"cameraMode",
1339
1904
  @"CaptureMode": @"captureMode",
1340
1905
  @"ColorTemperature": @"colorTemperature",
1341
1906
  @"DateTimeZone": @"dateTimeZone",
@@ -1350,15 +1915,25 @@ static NSDictionary *OptionEnumToOption = @{
1350
1915
  @"IsoAutoHighLimit": @"isoAutoHighLimit",
1351
1916
  @"Language": @"language",
1352
1917
  @"MaxRecordableTime": @"maxRecordableTime",
1918
+ @"NetworkType": @"networkType",
1353
1919
  @"OffDelay": @"offDelay",
1920
+ @"Password": @"password",
1921
+ @"PowerSaving": @"powerSaving",
1922
+ @"PreviewFormat": @"previewFormat",
1923
+ @"Proxy": @"proxy",
1924
+ @"ShootingMethod": @"shootingMethod",
1925
+ @"ShutterSpeed": @"shutterSpeed",
1354
1926
  @"SleepDelay": @"sleepDelay",
1355
1927
  @"RemainingPictures": @"remainingPictures",
1356
1928
  @"RemainingVideoSeconds": @"remainingVideoSeconds",
1357
1929
  @"RemainingSpace": @"remainingSpace",
1930
+ @"TimeShift": @"timeShift",
1358
1931
  @"TotalSpace": @"totalSpace",
1359
1932
  @"ShutterVolume": @"shutterVolume",
1933
+ @"Username": @"username",
1360
1934
  @"WhiteBalance": @"whiteBalance",
1361
- @"WhiteBalanceAutoStrength": @"whiteBalanceAutoStrength"
1935
+ @"WhiteBalanceAutoStrength": @"whiteBalanceAutoStrength",
1936
+ @"WlanFrequency": @"wlanFrequency"
1362
1937
  };
1363
1938
 
1364
1939
  /** Option converter builder */
@@ -1370,6 +1945,8 @@ typedef convert_t * (^OptionConverter)();
1370
1945
  static NSDictionary<NSString*, OptionConverter> *NameToConverter = @{
1371
1946
  @"aperture": ^{return &ApertureEnum;},
1372
1947
  @"bluetoothPower": ^{return &BluetoothPowerEnum;},
1948
+ @"cameraControlSource": ^{return &CameraControlSourceEnum;},
1949
+ @"cameraMode": ^{return &CameraModeEnum;},
1373
1950
  @"captureMode": ^{return &CaptureModeEnum;},
1374
1951
  @"colorTemperature": ^{return &ColorTemperatureCvt;},
1375
1952
  @"dateTimeZone": ^{return &DateTimeZoneCvt;},
@@ -1384,19 +1961,94 @@ static NSDictionary<NSString*, OptionConverter> *NameToConverter = @{
1384
1961
  @"isoAutoHighLimit": ^{return &IsoAutoHighLimitEnum;},
1385
1962
  @"language": ^{return &LanguageEnum;},
1386
1963
  @"maxRecordableTime": ^{return &MaxRecordableTimeEnum;},
1964
+ @"networkType": ^{return &NetworkTypeEnum;},
1387
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;},
1388
1972
  @"sleepDelay": ^{return &SleepDelayEnum;},
1389
1973
  @"remainingPictures": ^{return &RemainingPicturesCvt;},
1390
1974
  @"remainingVideoSeconds": ^{return &RemainingVideoSecondsCvt;},
1391
1975
  @"remainingSpace": ^{return &RemainingSpaceCvt;},
1976
+ @"timeShift": ^{return &TimeShiftCvt;},
1392
1977
  @"totalSpace": ^{return &TotalSpaceCvt;},
1393
1978
  @"shutterVolume": ^{return &ShutterVolumeCvt;},
1979
+ @"username": ^{return &UsernameCvt;},
1394
1980
  @"whiteBalance": ^{return &WhiteBalanceEnum;},
1395
1981
  @"_gpsTagRecording": ^{return &GpsTagRecordingEnum;},
1396
- @"whiteBalanceAutoStrength": ^{return &WhiteBalanceAutoStrengthEnum;}
1982
+ @"whiteBalanceAutoStrength": ^{return &WhiteBalanceAutoStrengthEnum;},
1983
+ @"wlanFrequency": ^{return &WlanFrequencyEnum;}
1397
1984
  };
1398
1985
 
1399
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
+ }
1400
2052
 
1401
2053
  /**
1402
2054
  * ThetaClientReactNative implementation
@@ -1435,7 +2087,7 @@ RCT_EXPORT_MODULE(ThetaClientReactNative)
1435
2087
  */
1436
2088
  -(NSArray *)supportedEvents
1437
2089
  {
1438
- return @[EVENT_NAME];
2090
+ return @[EVENT_NAME, EVENT_NOTIFY];
1439
2091
  }
1440
2092
 
1441
2093
  /**
@@ -1457,34 +2109,61 @@ RCT_EXPORT_MODULE(ThetaClientReactNative)
1457
2109
  /**
1458
2110
  * initialize ThetaRepository
1459
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
1460
2114
  * @param resolve resolver for initilization
1461
2115
  * @param rejecter rejecter for initialization
1462
2116
  */
1463
2117
  RCT_REMAP_METHOD(initialize,
1464
2118
  initializeWithEndpoint:(NSString *)endPoint
2119
+ withConfig:(NSDictionary*)config
2120
+ withTimeout:(NSDictionary*)timeout
1465
2121
  withResolver:(RCTPromiseResolveBlock)resolve
1466
2122
  withRejecter:(RCTPromiseRejectBlock)reject)
1467
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
+
1468
2135
  if (!endPoint) {
1469
2136
  endPoint = @"http://192.168.1.1";
1470
2137
  }
1471
2138
  NSError *error = nil;
1472
2139
  THETACThetaRepositoryCompanion *companion = THETACThetaRepository.companion;
1473
2140
  [companion doNewInstanceEndpoint:endPoint
1474
- config:nil
1475
- timeout:nil
2141
+ config:configToTheta(config)
2142
+ timeout:timeoutToTheta(timeout)
1476
2143
  completionHandler:^(THETACThetaRepository *repo, NSError *error) {
1477
2144
  if (error) {
1478
- reject(@"error", [error localizedDescription], error);
2145
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1479
2146
  } else if (repo) {
1480
2147
  self.theta = repo;
1481
2148
  resolve(@(YES));
1482
2149
  } else {
1483
- reject(@"error", @"can not create repository", nil);
2150
+ reject(ERROR_CODE_ERROR, @"can not create repository", nil);
1484
2151
  }
1485
2152
  }];
1486
2153
  }
1487
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
+
1488
2167
  /**
1489
2168
  * getThetaInfo - retrieve ThetaInfo from THETA via repository
1490
2169
  * @param resolve resolver for getThetaInfo
@@ -1494,10 +2173,14 @@ RCT_REMAP_METHOD(getThetaInfo,
1494
2173
  getThetaInfoWithResolver:(RCTPromiseResolveBlock)resolve
1495
2174
  withRejecter:(RCTPromiseRejectBlock)reject)
1496
2175
  {
2176
+ if (!_theta) {
2177
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2178
+ return;
2179
+ }
1497
2180
  [_theta getThetaInfoWithCompletionHandler:^(THETACThetaRepositoryThetaInfo *info,
1498
2181
  NSError *error) {
1499
2182
  if (error) {
1500
- reject(@"error", [error localizedDescription], error);
2183
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1501
2184
  } else if (info) {
1502
2185
  NSMutableArray *apiLevelList = [[NSMutableArray alloc] init];
1503
2186
  for (THETACInt *element in info.apiLevel) {
@@ -1520,7 +2203,7 @@ RCT_REMAP_METHOD(getThetaInfo,
1520
2203
  },
1521
2204
  @"apiLevel": apiLevelList});
1522
2205
  } else {
1523
- reject(@"error", @"no info", nil);
2206
+ reject(ERROR_CODE_ERROR, @"no info", nil);
1524
2207
  }
1525
2208
  }];
1526
2209
  }
@@ -1534,10 +2217,14 @@ RCT_REMAP_METHOD(getThetaState,
1534
2217
  getThetaStateWithResolver:(RCTPromiseResolveBlock)resolve
1535
2218
  withRejecter:(RCTPromiseRejectBlock)reject)
1536
2219
  {
2220
+ if (!_theta) {
2221
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2222
+ return;
2223
+ }
1537
2224
  [_theta getThetaStateWithCompletionHandler:^(THETACThetaRepositoryThetaState *state,
1538
2225
  NSError *error) {
1539
2226
  if (error) {
1540
- reject(@"error", [error localizedDescription], error);
2227
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1541
2228
  } else if (state) {
1542
2229
  NSMutableArray *cameraErrorList = [[NSMutableArray alloc] init];
1543
2230
  if (state.cameraError != nil) {
@@ -1566,7 +2253,7 @@ RCT_REMAP_METHOD(getThetaState,
1566
2253
  @"cameraError": state.cameraError != nil ? cameraErrorList : [NSNull null],
1567
2254
  @"isBatteryInsert": state.isBatteryInsert != nil ? @([state.isBatteryInsert boolValue]) : [NSNull null]});
1568
2255
  } else {
1569
- reject(@"error", @"no state", nil);
2256
+ reject(ERROR_CODE_ERROR, @"no state", nil);
1570
2257
  }
1571
2258
  }];
1572
2259
  }
@@ -1576,6 +2263,7 @@ RCT_REMAP_METHOD(getThetaState,
1576
2263
  * @param fileType file type to retrieve
1577
2264
  * @param startPosition start position to retrieve
1578
2265
  * @param entryCount count to retrieve
2266
+ * @param storage Desired storage
1579
2267
  * @param resolve resolver for listFiles
1580
2268
  * @param rejecter rejecter for listFiles
1581
2269
  */
@@ -1583,32 +2271,42 @@ RCT_REMAP_METHOD(listFiles,
1583
2271
  listFilesWithFileTypeEnum:(NSString*)fileType
1584
2272
  withStartPosition:(int32_t)startPosition
1585
2273
  withEntryCount:(int32_t)entryCount
2274
+ withStorage:(NSString*)storage
1586
2275
  withResolver:(RCTPromiseResolveBlock)resolve
1587
2276
  withRejecter:(RCTPromiseRejectBlock)reject)
1588
2277
  {
2278
+ if (!_theta) {
2279
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2280
+ return;
2281
+ }
1589
2282
  [_theta listFilesFileType:[FileTypeEnum.toTheta objectForKey:fileType]
1590
2283
  startPosition:startPosition
1591
2284
  entryCount:entryCount
2285
+ storage:[StorageEnum.toTheta objectForKey:storage]
1592
2286
  completionHandler:^(THETACThetaRepositoryThetaFiles *items,
1593
2287
  NSError *error) {
1594
2288
  if (error) {
1595
- reject(@"error", [error localizedDescription], error);
2289
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1596
2290
  } else if (items) {
1597
2291
  NSMutableArray *ary = [[NSMutableArray alloc] init];
1598
2292
  for (int i = 0; i < items.fileList.count; i++) {
1599
2293
  THETACThetaRepositoryFileInfo *finfo = items.fileList[i];
1600
- [ary addObject: @{
1601
- @"name":finfo.name,
1602
- @"size":@(finfo.size),
1603
- @"dateTime":finfo.dateTime,
1604
- @"thumbnailUrl":finfo.thumbnailUrl,
1605
- @"fileUrl":finfo.fileUrl
1606
- }];
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];
1607
2305
  }
1608
- resolve(@{@"fileList":ary,
1609
- @"totalEntries": @(items.totalEntries)});
2306
+ resolve(@{@"fileList":ary,
2307
+ @"totalEntries": @(items.totalEntries)});
1610
2308
  } else {
1611
- reject(@"error", @"no items", nil);
2309
+ reject(ERROR_CODE_ERROR, @"no items", nil);
1612
2310
  }
1613
2311
  }];
1614
2312
  }
@@ -1624,9 +2322,13 @@ RCT_REMAP_METHOD(deleteFiles,
1624
2322
  withResolver:(RCTPromiseResolveBlock)resolve
1625
2323
  withRejecter:(RCTPromiseRejectBlock)reject)
1626
2324
  {
2325
+ if (!_theta) {
2326
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2327
+ return;
2328
+ }
1627
2329
  [_theta deleteFilesFileUrls:fileUrls completionHandler:^(NSError *error) {
1628
2330
  if (error) {
1629
- reject(@"error", [error localizedDescription], error);
2331
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1630
2332
  } else {
1631
2333
  resolve(@(YES));
1632
2334
  }
@@ -1642,9 +2344,13 @@ RCT_REMAP_METHOD(deleteAllFiles,
1642
2344
  deleteAllFilesWithResolver:(RCTPromiseResolveBlock)resolve
1643
2345
  withRejecter:(RCTPromiseRejectBlock)reject)
1644
2346
  {
2347
+ if (!_theta) {
2348
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2349
+ return;
2350
+ }
1645
2351
  [_theta deleteAllFilesWithCompletionHandler:^(NSError *error) {
1646
2352
  if (error) {
1647
- reject(@"error", [error localizedDescription], error);
2353
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1648
2354
  } else {
1649
2355
  resolve(@(YES));
1650
2356
  }
@@ -1660,9 +2366,13 @@ RCT_REMAP_METHOD(deleteAllImageFiles,
1660
2366
  deleteAllImageFilesWithResolver:(RCTPromiseResolveBlock)resolve
1661
2367
  withRejecter:(RCTPromiseRejectBlock)reject)
1662
2368
  {
2369
+ if (!_theta) {
2370
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2371
+ return;
2372
+ }
1663
2373
  [_theta deleteAllImageFilesWithCompletionHandler:^(NSError *error) {
1664
2374
  if (error) {
1665
- reject(@"error", [error localizedDescription], error);
2375
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1666
2376
  return;
1667
2377
  }
1668
2378
  resolve(@(YES));
@@ -1678,9 +2388,13 @@ RCT_REMAP_METHOD(deleteAllVideoFiles,
1678
2388
  deleteAllVideoFilesWithResolver:(RCTPromiseResolveBlock)resolve
1679
2389
  withRejecter:(RCTPromiseRejectBlock)reject)
1680
2390
  {
2391
+ if (!_theta) {
2392
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2393
+ return;
2394
+ }
1681
2395
  [_theta deleteAllVideoFilesWithCompletionHandler:^(NSError *error) {
1682
2396
  if (error) {
1683
- reject(@"error", [error localizedDescription], error);
2397
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1684
2398
  } else {
1685
2399
  resolve(@(YES));
1686
2400
  }
@@ -1698,6 +2412,10 @@ RCT_REMAP_METHOD(getOptions,
1698
2412
  withResolver:(RCTPromiseResolveBlock)resolve
1699
2413
  withRejecter:(RCTPromiseRejectBlock)reject)
1700
2414
  {
2415
+ if (!_theta) {
2416
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2417
+ return;
2418
+ }
1701
2419
  NSMutableArray *optionNameList = [[NSMutableArray alloc] init];
1702
2420
  for (id name in optionNames) {
1703
2421
  [optionNameList addObject:[NameToOptionEnum objectForKey:name]];
@@ -1705,7 +2423,7 @@ RCT_REMAP_METHOD(getOptions,
1705
2423
  [_theta getOptionsOptionNames:optionNameList
1706
2424
  completionHandler:^(THETACThetaRepositoryOptions *options, NSError *error) {
1707
2425
  if (error) {
1708
- reject(@"error", [error localizedDescription], error);
2426
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1709
2427
  } else if (options) {
1710
2428
  NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
1711
2429
  for (id name in optionNames) {
@@ -1717,7 +2435,7 @@ RCT_REMAP_METHOD(getOptions,
1717
2435
  }
1718
2436
  resolve(results);
1719
2437
  } else {
1720
- reject(@"error", @"no options", nil);
2438
+ reject(ERROR_CODE_ERROR, @"no options", nil);
1721
2439
  }
1722
2440
  }];
1723
2441
  }
@@ -1733,6 +2451,10 @@ RCT_REMAP_METHOD(setOptions,
1733
2451
  withResolver:(RCTPromiseResolveBlock)resolve
1734
2452
  withRejecter:(RCTPromiseRejectBlock)reject)
1735
2453
  {
2454
+ if (!_theta) {
2455
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2456
+ return;
2457
+ }
1736
2458
  THETACThetaRepositoryOptions *newoptions = [[THETACThetaRepositoryOptions alloc] init];
1737
2459
  for (id option in [options allKeys]) {
1738
2460
  OptionConverter converter = [NameToConverter objectForKey:option];
@@ -1745,7 +2467,7 @@ RCT_REMAP_METHOD(setOptions,
1745
2467
  }
1746
2468
  [_theta setOptionsOptions:newoptions completionHandler:^(NSError *error) {
1747
2469
  if (error) {
1748
- reject(@"error", [error localizedDescription], error);
2470
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1749
2471
  } else {
1750
2472
  resolve(@(YES));
1751
2473
  }
@@ -1783,6 +2505,10 @@ RCT_REMAP_METHOD(getLivePreview,
1783
2505
  getLivePreviewWithResolver:(RCTPromiseResolveBlock)resolve
1784
2506
  withRejecter:(RCTPromiseRejectBlock)reject)
1785
2507
  {
2508
+ if (!_theta) {
2509
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2510
+ return;
2511
+ }
1786
2512
  FrameHandler *_frameHandler =
1787
2513
  [[FrameHandler alloc] initWith:self withEvent:^(NSData *data) {
1788
2514
  if (self->hasListeners) {
@@ -1795,7 +2521,7 @@ RCT_REMAP_METHOD(getLivePreview,
1795
2521
  self.previewing = YES;
1796
2522
  [_theta getLivePreviewFrameHandler:_frameHandler completionHandler:^(NSError *error) {
1797
2523
  if (error) {
1798
- reject(@"error", [error localizedDescription], error);
2524
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1799
2525
  } else {
1800
2526
  resolve(@(YES));
1801
2527
  }
@@ -1817,6 +2543,10 @@ RCT_REMAP_METHOD(stopLivePreview,
1817
2543
  RCT_REMAP_METHOD(getPhotoCaptureBuilder,
1818
2544
  getPhotoCaptureBuilder)
1819
2545
  {
2546
+ if (!_theta) {
2547
+ [NSException raise:ERROR_CODE_ERROR format:MESSAGE_NOT_INIT];
2548
+ return;
2549
+ }
1820
2550
  self.photoCaptureBuilder = [_theta getPhotoCaptureBuilder];
1821
2551
  }
1822
2552
 
@@ -1831,8 +2561,12 @@ RCT_REMAP_METHOD(buildPhotoCapture,
1831
2561
  withResolver:(RCTPromiseResolveBlock)resolve
1832
2562
  withRejecter:(RCTPromiseRejectBlock)reject)
1833
2563
  {
2564
+ if (!_theta) {
2565
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2566
+ return;
2567
+ }
1834
2568
  if (!self.photoCaptureBuilder) {
1835
- reject(@"error", @"no photo capture pbuilder", nil);
2569
+ reject(ERROR_CODE_ERROR, @"no photo capture pbuilder", nil);
1836
2570
  return;
1837
2571
  }
1838
2572
  for (id photoOption in [options allKeys]) {
@@ -1844,7 +2578,7 @@ RCT_REMAP_METHOD(buildPhotoCapture,
1844
2578
  [self.photoCaptureBuilder
1845
2579
  buildWithCompletionHandler:^(THETACPhotoCapture *photoCapture, NSError *error) {
1846
2580
  if (error) {
1847
- reject(@"error", [error localizedDescription], error);
2581
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1848
2582
  return;
1849
2583
  }
1850
2584
  if (photoCapture) {
@@ -1852,7 +2586,7 @@ RCT_REMAP_METHOD(buildPhotoCapture,
1852
2586
  self.photoCaptureBuilder = nil;
1853
2587
  resolve(@(YES));
1854
2588
  } else {
1855
- reject(@"error", @"no photoCapture", nil);
2589
+ reject(ERROR_CODE_ERROR, @"no photoCapture", nil);
1856
2590
  }
1857
2591
  }];
1858
2592
  }
@@ -1866,8 +2600,12 @@ RCT_REMAP_METHOD(takePicture,
1866
2600
  takePictureWithResolver:(RCTPromiseResolveBlock)resolve
1867
2601
  withRejecter:(RCTPromiseRejectBlock)reject)
1868
2602
  {
2603
+ if (!_theta) {
2604
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2605
+ return;
2606
+ }
1869
2607
  if (!self.photoCapture) {
1870
- reject(@"error", @"no photoCapture", nil);
2608
+ reject(ERROR_CODE_ERROR, @"no photoCapture", nil);
1871
2609
  return;
1872
2610
  }
1873
2611
  PhotoCallback *callback = [[PhotoCallback alloc] initWith:self
@@ -1876,12 +2614,126 @@ RCT_REMAP_METHOD(takePicture,
1876
2614
  [self.photoCapture takePictureCallback:callback];
1877
2615
  }
1878
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
+
1879
2727
  /**
1880
2728
  * getVideoCaptureBuilder - get video capture builder
1881
2729
  */
1882
2730
  RCT_REMAP_METHOD(getVideoCaptureBuilder,
1883
2731
  getVideoCaptureBuilder)
1884
2732
  {
2733
+ if (!_theta) {
2734
+ [NSException raise:ERROR_CODE_ERROR format:MESSAGE_NOT_INIT];
2735
+ return;
2736
+ }
1885
2737
  self.videoCaptureBuilder = [_theta getVideoCaptureBuilder];
1886
2738
  }
1887
2739
 
@@ -1896,8 +2748,12 @@ RCT_REMAP_METHOD(buildVideoCapture,
1896
2748
  withResolver:(RCTPromiseResolveBlock)resolve
1897
2749
  withRejecter:(RCTPromiseRejectBlock)reject)
1898
2750
  {
2751
+ if (!_theta) {
2752
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2753
+ return;
2754
+ }
1899
2755
  if (!self.videoCaptureBuilder) {
1900
- reject(@"error", @"no video capture builder", nil);
2756
+ reject(ERROR_CODE_ERROR, @"no video capture builder", nil);
1901
2757
  return;
1902
2758
  }
1903
2759
  for (id videoOption in [options allKeys]) {
@@ -1909,7 +2765,7 @@ RCT_REMAP_METHOD(buildVideoCapture,
1909
2765
  [self.videoCaptureBuilder
1910
2766
  buildWithCompletionHandler:^(THETACVideoCapture *videoCapture, NSError *error) {
1911
2767
  if (error) {
1912
- reject(@"error", @"videoCapture build failed", error);
2768
+ reject(ERROR_CODE_ERROR, @"videoCapture build failed", error);
1913
2769
  return;
1914
2770
  }
1915
2771
  if (videoCapture) {
@@ -1917,7 +2773,7 @@ RCT_REMAP_METHOD(buildVideoCapture,
1917
2773
  self.videoCaptureBuilder = nil;
1918
2774
  resolve(@(YES));
1919
2775
  } else {
1920
- reject(@"error", @"no videoCapture", nil);
2776
+ reject(ERROR_CODE_ERROR, @"no videoCapture", nil);
1921
2777
  }
1922
2778
  }];
1923
2779
  }
@@ -1931,8 +2787,12 @@ RCT_REMAP_METHOD(startCapture,
1931
2787
  startCaptureWithResolver:(RCTPromiseResolveBlock)resolve
1932
2788
  withRejecter:(RCTPromiseRejectBlock)reject)
1933
2789
  {
2790
+ if (!_theta) {
2791
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2792
+ return;
2793
+ }
1934
2794
  if (!self.videoCapture) {
1935
- reject(@"error", @"no videoCapture", nil);
2795
+ reject(ERROR_CODE_ERROR, @"no videoCapture", nil);
1936
2796
  return;
1937
2797
  }
1938
2798
  VideoCallback *callback = [[VideoCallback alloc] initWith:self
@@ -1947,6 +2807,10 @@ RCT_REMAP_METHOD(startCapture,
1947
2807
  RCT_REMAP_METHOD(stopCapture,
1948
2808
  stopCapture)
1949
2809
  {
2810
+ if (!_theta) {
2811
+ [NSException raise:ERROR_CODE_ERROR format:MESSAGE_NOT_INIT];
2812
+ return;
2813
+ }
1950
2814
  if (!self.videoCapturing) {
1951
2815
  // todo warning
1952
2816
  return;
@@ -1964,12 +2828,16 @@ RCT_REMAP_METHOD(getMetadata,
1964
2828
  withResolver:(RCTPromiseResolveBlock)resolve
1965
2829
  withRejecter:(RCTPromiseRejectBlock)reject)
1966
2830
  {
2831
+ if (!_theta) {
2832
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2833
+ return;
2834
+ }
1967
2835
  [_theta getMetadataFileUrl:fileUrl
1968
2836
  completionHandler:^(THETACKotlinPair<THETACThetaRepositoryExif *,
1969
2837
  THETACThetaRepositoryXmp *> *metaData,
1970
2838
  NSError *error) {
1971
2839
  if (error) {
1972
- reject(@"error", [error localizedDescription], error);
2840
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
1973
2841
  } else if (metaData) {
1974
2842
  NSDictionary* exif = nil;
1975
2843
  NSDictionary* xmp = nil;
@@ -1992,7 +2860,7 @@ RCT_REMAP_METHOD(getMetadata,
1992
2860
  }
1993
2861
  resolve(@{@"exif": exif, @"xmp": xmp});
1994
2862
  } else {
1995
- reject(@"error", @"no metaData", nil);
2863
+ reject(ERROR_CODE_ERROR, @"no metaData", nil);
1996
2864
  }
1997
2865
  }];
1998
2866
  }
@@ -2006,9 +2874,13 @@ RCT_REMAP_METHOD(reset,
2006
2874
  resetWithResolver:(RCTPromiseResolveBlock)resolve
2007
2875
  withRejecter:(RCTPromiseRejectBlock)reject)
2008
2876
  {
2877
+ if (!_theta) {
2878
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2879
+ return;
2880
+ }
2009
2881
  [_theta resetWithCompletionHandler:^(NSError *error) {
2010
2882
  if (error) {
2011
- reject(@"error", [error localizedDescription], error);
2883
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2012
2884
  } else {
2013
2885
  resolve(@(YES));
2014
2886
  }
@@ -2024,9 +2896,13 @@ RCT_REMAP_METHOD(restoreSettings,
2024
2896
  restoreSettingsWithResolver:(RCTPromiseResolveBlock)resolve
2025
2897
  withRejecter:(RCTPromiseRejectBlock)reject)
2026
2898
  {
2899
+ if (!_theta) {
2900
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2901
+ return;
2902
+ }
2027
2903
  [_theta restoreSettingsWithCompletionHandler:^(NSError *error) {
2028
2904
  if (error) {
2029
- reject(@"error", [error localizedDescription], error);
2905
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2030
2906
  } else {
2031
2907
  resolve(@(YES));
2032
2908
  }
@@ -2042,9 +2918,13 @@ RCT_REMAP_METHOD(stopSelfTimer,
2042
2918
  stopSelfTimerWithResolver:(RCTPromiseResolveBlock)resolve
2043
2919
  withRejecter:(RCTPromiseRejectBlock)reject)
2044
2920
  {
2921
+ if (!_theta) {
2922
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2923
+ return;
2924
+ }
2045
2925
  [_theta stopSelfTimerWithCompletionHandler:^(NSError *error) {
2046
2926
  if (error) {
2047
- reject(@"error", [error localizedDescription], error);
2927
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2048
2928
  } else {
2049
2929
  resolve(@(YES));
2050
2930
  }
@@ -2066,16 +2946,20 @@ RCT_REMAP_METHOD(convertVideoFormats,
2066
2946
  withResolver:(RCTPromiseResolveBlock)resolve
2067
2947
  withRejecter:(RCTPromiseRejectBlock)reject)
2068
2948
  {
2949
+ if (!_theta) {
2950
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2951
+ return;
2952
+ }
2069
2953
  [_theta convertVideoFormatsFileUrl:fileUrl
2070
2954
  toLowResolution:toLowResolution
2071
2955
  applyTopBottomCorrection:applyTopBottomCorrection
2072
2956
  completionHandler:^(NSString *convertedUrl, NSError *error) {
2073
2957
  if (error) {
2074
- reject(@"error", [error localizedDescription], error);
2958
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2075
2959
  } else if (convertedUrl) {
2076
2960
  resolve(convertedUrl);
2077
2961
  } else {
2078
- reject(@"error", @"no convertVideo", nil);
2962
+ reject(ERROR_CODE_ERROR, @"no convertVideo", nil);
2079
2963
  }
2080
2964
  }];
2081
2965
  }
@@ -2089,9 +2973,13 @@ RCT_REMAP_METHOD(cancelVideoConvert,
2089
2973
  cancelVideoConvertWithResolver:(RCTPromiseResolveBlock)resolve
2090
2974
  withRejecter:(RCTPromiseRejectBlock)reject)
2091
2975
  {
2976
+ if (!_theta) {
2977
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
2978
+ return;
2979
+ }
2092
2980
  [_theta cancelVideoConvertWithCompletionHandler:^(NSError *error) {
2093
2981
  if (error) {
2094
- reject(@"error", [error localizedDescription], error);
2982
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2095
2983
  } else {
2096
2984
  resolve(@(YES));
2097
2985
  }
@@ -2107,9 +2995,13 @@ RCT_REMAP_METHOD(finishWlan,
2107
2995
  finishWlanWithResolver:(RCTPromiseResolveBlock)resolve
2108
2996
  withRejecter:(RCTPromiseRejectBlock)reject)
2109
2997
  {
2998
+ if (!_theta) {
2999
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3000
+ return;
3001
+ }
2110
3002
  [_theta finishWlanWithCompletionHandler:^(NSError *error) {
2111
3003
  if (error) {
2112
- reject(@"error", [error localizedDescription], error);
3004
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2113
3005
  } else {
2114
3006
  resolve(@(YES));
2115
3007
  }
@@ -2125,28 +3017,50 @@ RCT_REMAP_METHOD(listAccessPoints,
2125
3017
  listAccessPointsWithResolver:(RCTPromiseResolveBlock)resolve
2126
3018
  withRejecter:(RCTPromiseRejectBlock)reject)
2127
3019
  {
2128
- [_theta listAccessPointsWithCompletionHandler:^(NSArray *accessPointList, NSError *error) {
2129
- if (error) {
2130
- reject(@"error", [error localizedDescription], error);
2131
- } else if (accessPointList) {
2132
- NSMutableArray *ary = [[NSMutableArray alloc] init];
2133
- for (int i = 0; i < accessPointList.count; i++) {
2134
- THETACThetaRepositoryAccessPoint *apinfo = accessPointList[i];
2135
- [ary addObject: @{
2136
- @"ssid": apinfo.ssid,
2137
- @"ssidStealth": @(apinfo.ssidStealth),
2138
- @"authMode": [AuthModeEnum.fromTheta objectForKey:apinfo.authMode],
2139
- @"connectionPriority": @(apinfo.connectionPriority),
2140
- @"usingDhcp": @(apinfo.usingDhcp),
2141
- @"ipAddress": apinfo.ipAddress,
2142
- @"subnetMask": apinfo.subnetMask,
2143
- @"defaultGateway": apinfo.defaultGateway
2144
- }];
2145
- }
2146
- resolve(ary);
2147
- } else {
2148
- reject(@"error", @"no access point", nil);
2149
- }
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
+ }
2150
3064
  }];
2151
3065
  }
2152
3066
 
@@ -2157,6 +3071,7 @@ RCT_REMAP_METHOD(listAccessPoints,
2157
3071
  * @param authMode auth mode to connect
2158
3072
  * @param password password to connect with auth
2159
3073
  * @param connectionPriority connection priority
3074
+ * @param proxy Proxy information to be used for the access point.
2160
3075
  * @param resolve resolver for setAccessPointDynamically
2161
3076
  * @param rejecter rejecter for setAccessPointDynamically
2162
3077
  */
@@ -2166,20 +3081,26 @@ RCT_REMAP_METHOD(setAccessPointDynamically,
2166
3081
  withAuthMode:(NSString *)authMode
2167
3082
  withPassword:(NSString *)password
2168
3083
  withConnectionPrioryty:(int32_t)connectionPriority
3084
+ withProxy:(NSDictionary *)proxy
2169
3085
  withResolver:(RCTPromiseResolveBlock)resolve
2170
3086
  withRejecter:(RCTPromiseRejectBlock)reject)
2171
3087
  {
2172
- [_theta setAccessPointDynamicallySsid:ssid
2173
- ssidStealth:ssidStealth
2174
- authMode:[AuthModeEnum.toTheta objectForKey:authMode]
2175
- password:password
2176
- connectionPriority:connectionPriority
2177
- completionHandler:^(NSError *error) {
2178
- if (error) {
2179
- reject(@"error", [error localizedDescription], error);
2180
- } else {
2181
- resolve(@(YES));
2182
- }
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
+ }
2183
3104
  }];
2184
3105
  }
2185
3106
 
@@ -2193,6 +3114,7 @@ RCT_REMAP_METHOD(setAccessPointDynamically,
2193
3114
  * @param ipAddress static ipaddress to connect
2194
3115
  * @param subnetMask subnet mask for ip address
2195
3116
  * @param defaultGateway default gateway address
3117
+ * @param proxy Proxy information to be used for the access point.
2196
3118
  * @param resolve resolver for setAccessPointStatically
2197
3119
  * @param rejecter rejecter for setAccessPointStatically
2198
3120
  */
@@ -2205,23 +3127,29 @@ RCT_REMAP_METHOD(setAccessPointStatically,
2205
3127
  withIpAddress:(NSString *)ipAddress
2206
3128
  withSubnetMask:(NSString *)subnetMask
2207
3129
  withDefaultGateway:(NSString *)defaultGateway
3130
+ withProxy:(NSDictionary *)proxy
2208
3131
  withResolver:(RCTPromiseResolveBlock)resolve
2209
3132
  withRejecter:(RCTPromiseRejectBlock)reject)
2210
3133
  {
2211
- [_theta setAccessPointStaticallySsid:ssid
2212
- ssidStealth:ssidStealth
2213
- authMode:[AuthModeEnum.toTheta objectForKey:authMode]
2214
- password:password
2215
- connectionPriority:connectionPriority
2216
- ipAddress:ipAddress
2217
- subnetMask:subnetMask
2218
- defaultGateway:defaultGateway
2219
- completionHandler:^(NSError *error) {
2220
- if (error) {
2221
- reject(@"error", [error localizedDescription], error);
2222
- } else {
2223
- resolve(@(YES));
2224
- }
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
+ }
2225
3153
  }];
2226
3154
  }
2227
3155
 
@@ -2236,16 +3164,33 @@ RCT_REMAP_METHOD(deleteAccessPoint,
2236
3164
  withResolver:(RCTPromiseResolveBlock)resolve
2237
3165
  withRejecter:(RCTPromiseRejectBlock)reject)
2238
3166
  {
2239
- [_theta deleteAccessPointSsid:ssid
2240
- completionHandler:^(NSError *error) {
2241
- if (error) {
2242
- reject(@"error", [error localizedDescription], error);
2243
- } else {
2244
- resolve(@(YES));
2245
- }
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
+ }
2246
3178
  }];
2247
3179
  }
2248
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
+
2249
3194
  /**
2250
3195
  * convertOptionsFromTheta - convert resposnse of getMySetting
2251
3196
  * @param results conversion results
@@ -2284,19 +3229,23 @@ RCT_REMAP_METHOD(getMySetting,
2284
3229
  withResolver:(RCTPromiseResolveBlock)resolve
2285
3230
  withRejecter:(RCTPromiseRejectBlock)reject)
2286
3231
  {
3232
+ if (!_theta) {
3233
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3234
+ return;
3235
+ }
2287
3236
  [_theta getMySettingCaptureMode:[CaptureModeEnum.toTheta objectForKey:captureMode]
2288
3237
  completionHandler:^(THETACThetaRepositoryOptions *options, NSError *error) {
2289
3238
  if (error) {
2290
- reject(@"error", [error localizedDescription], error);
3239
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2291
3240
  } else if (options) {
2292
3241
  NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
2293
3242
  NSError *convertError = convertOptionsFromTheta(results, options);
2294
3243
  if (convertError) {
2295
- reject(@"error", [error localizedDescription], convertError);
3244
+ reject(ERROR_CODE_ERROR, [error localizedDescription], convertError);
2296
3245
  }
2297
3246
  resolve(results);
2298
3247
  } else {
2299
- reject(@"error", @"no options", nil);
3248
+ reject(ERROR_CODE_ERROR, @"no options", nil);
2300
3249
  }
2301
3250
  }];
2302
3251
  }
@@ -2312,6 +3261,10 @@ RCT_REMAP_METHOD(getMySettingFromOldModel,
2312
3261
  withResolver:(RCTPromiseResolveBlock)resolve
2313
3262
  withRejecter:(RCTPromiseRejectBlock)reject)
2314
3263
  {
3264
+ if (!_theta) {
3265
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3266
+ return;
3267
+ }
2315
3268
  NSMutableArray *optionNameList = [[NSMutableArray alloc] init];
2316
3269
  for (id name in optionNames) {
2317
3270
  [optionNameList addObject:[NameToOptionEnum objectForKey:name]];
@@ -2319,7 +3272,7 @@ RCT_REMAP_METHOD(getMySettingFromOldModel,
2319
3272
  [_theta getMySettingOptionNames:optionNameList
2320
3273
  completionHandler:^(THETACThetaRepositoryOptions *options, NSError *error) {
2321
3274
  if (error) {
2322
- reject(@"error", [error localizedDescription], error);
3275
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2323
3276
  } else if (options) {
2324
3277
  NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
2325
3278
  for (id name in optionNames) {
@@ -2334,7 +3287,7 @@ RCT_REMAP_METHOD(getMySettingFromOldModel,
2334
3287
  }
2335
3288
  resolve(results);
2336
3289
  } else {
2337
- reject(@"error", @"no options", nil);
3290
+ reject(ERROR_CODE_ERROR, @"no options", nil);
2338
3291
  }
2339
3292
  }];
2340
3293
  }
@@ -2352,6 +3305,10 @@ RCT_REMAP_METHOD(setMySetting,
2352
3305
  withResolver:(RCTPromiseResolveBlock)resolve
2353
3306
  withRejecter:(RCTPromiseRejectBlock)reject)
2354
3307
  {
3308
+ if (!_theta) {
3309
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3310
+ return;
3311
+ }
2355
3312
  THETACThetaRepositoryOptions *newoptions = [[THETACThetaRepositoryOptions alloc] init];
2356
3313
  for (id option in [options allKeys]) {
2357
3314
  OptionConverter converter = [NameToConverter objectForKey:option];
@@ -2366,7 +3323,7 @@ RCT_REMAP_METHOD(setMySetting,
2366
3323
  options:newoptions
2367
3324
  completionHandler:^(NSError *error) {
2368
3325
  if (error) {
2369
- reject(@"error", [error localizedDescription], error);
3326
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2370
3327
  } else {
2371
3328
  resolve(@(YES));
2372
3329
  }
@@ -2384,10 +3341,14 @@ RCT_REMAP_METHOD(deleteMySetting,
2384
3341
  withResolver:(RCTPromiseResolveBlock)resolve
2385
3342
  withRejecter:(RCTPromiseRejectBlock)reject)
2386
3343
  {
3344
+ if (!_theta) {
3345
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3346
+ return;
3347
+ }
2387
3348
  [_theta deleteMySettingCaptureMode:[CaptureModeEnum.toTheta objectForKey:captureMode]
2388
3349
  completionHandler:^(NSError *error) {
2389
3350
  if (error) {
2390
- reject(@"error", [error localizedDescription], error);
3351
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2391
3352
  } else {
2392
3353
  resolve(@(YES));
2393
3354
  }
@@ -2403,9 +3364,13 @@ RCT_REMAP_METHOD(listPlugins,
2403
3364
  listPluginsWithResolver:(RCTPromiseResolveBlock)resolve
2404
3365
  withRejecter:(RCTPromiseRejectBlock)reject)
2405
3366
  {
3367
+ if (!_theta) {
3368
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3369
+ return;
3370
+ }
2406
3371
  [_theta listPluginsWithCompletionHandler:^(NSArray *pluginList, NSError *error) {
2407
3372
  if (error) {
2408
- reject(@"error", [error localizedDescription], error);
3373
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2409
3374
  } else if (pluginList) {
2410
3375
  NSMutableArray *ary = [[NSMutableArray alloc] init];
2411
3376
  for (int i = 0; i < pluginList.count; i++) {
@@ -2425,7 +3390,7 @@ RCT_REMAP_METHOD(listPlugins,
2425
3390
  }
2426
3391
  resolve(ary);
2427
3392
  } else {
2428
- reject(@"error", @"no plugin", nil);
3393
+ reject(ERROR_CODE_ERROR, @"no plugin", nil);
2429
3394
  }
2430
3395
  }];
2431
3396
  }
@@ -2441,10 +3406,14 @@ RCT_REMAP_METHOD(setPlugin,
2441
3406
  withResolver:(RCTPromiseResolveBlock)resolve
2442
3407
  withRejecter:(RCTPromiseRejectBlock)reject)
2443
3408
  {
3409
+ if (!_theta) {
3410
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3411
+ return;
3412
+ }
2444
3413
  [_theta setPluginPackageName:packageName
2445
3414
  completionHandler:^(NSError *error) {
2446
3415
  if (error) {
2447
- reject(@"error", [error localizedDescription], error);
3416
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2448
3417
  } else {
2449
3418
  resolve(@(YES));
2450
3419
  }
@@ -2462,10 +3431,14 @@ RCT_REMAP_METHOD(startPlugin,
2462
3431
  withResolver:(RCTPromiseResolveBlock)resolve
2463
3432
  withRejecter:(RCTPromiseRejectBlock)reject)
2464
3433
  {
3434
+ if (!_theta) {
3435
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3436
+ return;
3437
+ }
2465
3438
  [_theta startPluginPackageName:packageName
2466
3439
  completionHandler:^(NSError *error) {
2467
3440
  if (error) {
2468
- reject(@"error", [error localizedDescription], error);
3441
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2469
3442
 
2470
3443
  } else {
2471
3444
  resolve(@(YES));
@@ -2482,9 +3455,13 @@ RCT_REMAP_METHOD(stopPlugin,
2482
3455
  stopPluginWithResolver:(RCTPromiseResolveBlock)resolve
2483
3456
  withRejecter:(RCTPromiseRejectBlock)reject)
2484
3457
  {
3458
+ if (!_theta) {
3459
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3460
+ return;
3461
+ }
2485
3462
  [_theta stopPluginWithCompletionHandler:^(NSError *error) {
2486
3463
  if (error) {
2487
- reject(@"error", [error localizedDescription], error);
3464
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2488
3465
 
2489
3466
  } else {
2490
3467
  resolve(@(YES));
@@ -2503,15 +3480,19 @@ RCT_REMAP_METHOD(getPluginLicense,
2503
3480
  withResolver:(RCTPromiseResolveBlock)resolve
2504
3481
  withRejecter:(RCTPromiseRejectBlock)reject)
2505
3482
  {
3483
+ if (!_theta) {
3484
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3485
+ return;
3486
+ }
2506
3487
  [_theta getPluginLicensePackageName:packageName
2507
3488
  completionHandler:^(NSString *pluginLicense, NSError *error) {
2508
3489
  if (error) {
2509
- reject(@"error", [error localizedDescription], error);
3490
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2510
3491
 
2511
3492
  } else if (pluginLicense) {
2512
3493
  resolve(pluginLicense);
2513
3494
  } else {
2514
- reject(@"error", @"no plugin lincense", nil);
3495
+ reject(ERROR_CODE_ERROR, @"no plugin lincense", nil);
2515
3496
  }
2516
3497
  }];
2517
3498
  }
@@ -2525,13 +3506,17 @@ RCT_REMAP_METHOD(getPluginOrders,
2525
3506
  getPluginOrdersWithResolver:(RCTPromiseResolveBlock)resolve
2526
3507
  withRejecter:(RCTPromiseRejectBlock)reject)
2527
3508
  {
3509
+ if (!_theta) {
3510
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3511
+ return;
3512
+ }
2528
3513
  [_theta getPluginOrdersWithCompletionHandler:^(NSArray *pluginOrders, NSError *error) {
2529
3514
  if (error) {
2530
- reject(@"error", [error localizedDescription], error);
3515
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2531
3516
  } else if (pluginOrders) {
2532
3517
  resolve(pluginOrders);
2533
3518
  } else {
2534
- reject(@"error", @"no plugin orders", nil);
3519
+ reject(ERROR_CODE_ERROR, @"no plugin orders", nil);
2535
3520
  }
2536
3521
  }];
2537
3522
  }
@@ -2547,10 +3532,14 @@ RCT_REMAP_METHOD(setPluginOrders,
2547
3532
  withResolver:(RCTPromiseResolveBlock)resolve
2548
3533
  withRejecter:(RCTPromiseRejectBlock)reject)
2549
3534
  {
3535
+ if (!_theta) {
3536
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3537
+ return;
3538
+ }
2550
3539
  [_theta setPluginOrdersPlugins:plugins
2551
3540
  completionHandler:^(NSError *error) {
2552
3541
  if (error) {
2553
- reject(@"error", [error localizedDescription], error);
3542
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2554
3543
  } else {
2555
3544
  resolve(@(YES));
2556
3545
  }
@@ -2568,10 +3557,14 @@ RCT_REMAP_METHOD(setBluetoothDevice,
2568
3557
  withResolver:(RCTPromiseResolveBlock)resolve
2569
3558
  withRejecter:(RCTPromiseRejectBlock)reject)
2570
3559
  {
3560
+ if (!_theta) {
3561
+ reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil);
3562
+ return;
3563
+ }
2571
3564
  [_theta setBluetoothDeviceUuid:uuid
2572
3565
  completionHandler:^(NSString *deviceName, NSError *error) {
2573
3566
  if (error) {
2574
- reject(@"error", [error localizedDescription], error);
3567
+ reject(ERROR_CODE_ERROR, [error localizedDescription], error);
2575
3568
  } else {
2576
3569
  resolve(deviceName);
2577
3570
  }