OSDN Git Service

97ad2df0cea37dc9560c253dc24b1498402ec03e
[gokigen/PKRemote.git] / app / src / main / java / net / osdn / gokigen / pkremote / camera / CameraInterfaceProvider.java
1 package net.osdn.gokigen.pkremote.camera;
2
3 import android.content.SharedPreferences;
4
5 import net.osdn.gokigen.pkremote.IInformationReceiver;
6 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraButtonControl;
7 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
8 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewListener;
9 import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentsRecognizer;
10 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus;
11 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraInformation;
12 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode;
13 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatus;
14 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver;
15 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusWatcher;
16 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICaptureControl;
17 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IDisplayInjector;
18 import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingControl;
19 import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider;
20 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl;
21 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
22 import net.osdn.gokigen.pkremote.camera.interfaces.control.IZoomLensControl;
23 import net.osdn.gokigen.pkremote.camera.playback.CameraContentsRecognizer;
24 import net.osdn.gokigen.pkremote.camera.utils.CameraStatusListener;
25 import net.osdn.gokigen.pkremote.camera.vendor.fujix.wrapper.FujiXInterfaceProvider;
26 import net.osdn.gokigen.pkremote.camera.vendor.olympus.IOlympusInterfaceProvider;
27 import net.osdn.gokigen.pkremote.camera.vendor.olympus.wrapper.OlympusInterfaceProvider;
28 import net.osdn.gokigen.pkremote.camera.vendor.panasonic.wrapper.PanasonicCameraWrapper;
29 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.IPtpIpInterfaceProvider;
30 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.PtpIpInterfaceProvider;
31 import net.osdn.gokigen.pkremote.camera.vendor.ricoh.wrapper.RicohGr2InterfaceProvider;
32 import net.osdn.gokigen.pkremote.camera.vendor.sony.ISonyInterfaceProvider;
33 import net.osdn.gokigen.pkremote.camera.vendor.sony.wrapper.SonyCameraWrapper;
34 import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
35
36 import androidx.annotation.NonNull;
37 import androidx.appcompat.app.AppCompatActivity;
38 import androidx.preference.PreferenceManager;
39
40 /**
41  *
42  *
43  */
44 public class CameraInterfaceProvider implements IInterfaceProvider
45 {
46     private final SonyCameraWrapper sony;
47     private final OlympusInterfaceProvider olympus;
48     private final RicohGr2InterfaceProvider ricohGr2;
49     private final FujiXInterfaceProvider fujiX;
50     private final PanasonicCameraWrapper panasonic;
51     private final PtpIpInterfaceProvider ptpip;
52     private final IInformationReceiver informationReceiver;
53     private final CameraContentsRecognizer cameraContentsRecognizer;
54     private final AppCompatActivity context;
55     //private final CameraStatusListener statusListener;
56     private ICameraConnection.CameraConnectionMethod connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
57
58     public static IInterfaceProvider newInstance(@NonNull AppCompatActivity context, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver)
59     {
60         return (new CameraInterfaceProvider(context, provider, informationReceiver));
61     }
62
63     /**
64      *
65      *
66      */
67     private CameraInterfaceProvider(@NonNull AppCompatActivity context, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver)
68     {
69         this.context = context;
70         CameraStatusListener statusListener = new CameraStatusListener();
71         olympus = new OlympusInterfaceProvider(context, provider);
72         ricohGr2 = new RicohGr2InterfaceProvider(context, provider);
73         fujiX = new FujiXInterfaceProvider(context, provider, statusListener, informationReceiver);
74         sony = new SonyCameraWrapper(context, provider, statusListener, informationReceiver);
75         ptpip = new PtpIpInterfaceProvider(context, provider, statusListener, informationReceiver);
76         panasonic = new PanasonicCameraWrapper(context, provider, statusListener, informationReceiver);
77         this.informationReceiver = informationReceiver;
78         this.cameraContentsRecognizer = new CameraContentsRecognizer(context, this);
79     }
80
81     @Override
82     public IOlympusInterfaceProvider getOlympusInterfaceProvider()
83     {
84         return (olympus);
85     }
86
87     @Override
88     public ISonyInterfaceProvider getSonyInterface()
89     {
90         return (sony);
91     }
92
93     @Override
94     public IPtpIpInterfaceProvider getPtpIpInterface()
95     {
96         return (ptpip);
97     }
98
99     /**
100      *
101      *
102      */
103     @Override
104     public ICameraConnection getCameraConnection()
105     {
106         try
107         {
108             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
109             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
110             {
111                 return (olympus.getOlyCameraConnection());
112             }
113             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
114             {
115                 return (fujiX.getFujiXCameraConnection());
116             }
117             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
118             {
119                 return (panasonic.getPanasonicCameraConnection());
120             }
121             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
122             {
123                 return (sony.getSonyCameraConnection());
124             }
125             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
126             {
127                 return (ptpip.getPtpIpCameraConnection());
128             }
129             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
130             {
131                 return (ptpip.getPtpIpCameraConnection());
132             }
133             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
134             {
135                 return (ricohGr2.getRicohGr2CameraConnection());
136             }
137         }
138         catch (Exception e)
139         {
140             e.printStackTrace();
141         }
142         return (null);
143     }
144
145     @Override
146     public ICameraButtonControl getButtonControl()
147     {
148         try
149         {
150             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
151             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
152             {
153                 return (olympus.getButtonControl());
154             }
155             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
156             {
157                 return (fujiX.getButtonControl());
158             }
159             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
160             {
161                 return (panasonic.getButtonControl());
162             }
163             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
164             {
165                 return (sony.getButtonControl());
166             }
167             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
168             {
169                 return (ptpip.getButtonControl());
170             }
171             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
172             {
173                 return (ptpip.getButtonControl());
174             }
175             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
176             {
177                 return (ricohGr2.getButtonControl());
178             }
179         }
180         catch (Exception e)
181         {
182             e.printStackTrace();
183         }
184         return (null);
185     }
186
187     @Override
188     public IDisplayInjector getDisplayInjector()
189     {
190         try
191         {
192             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
193             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
194             {
195                 return (olympus.getDisplayInjector());
196             }
197             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
198             {
199                 return (fujiX.getDisplayInjector());
200             }
201             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
202             {
203                 return (panasonic.getDisplayInjector());
204             }
205             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
206             {
207                 return (sony.getDisplayInjector());
208             }
209             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
210             {
211                 return (ptpip.getDisplayInjector());
212             }
213             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
214             {
215                 return (ptpip.getDisplayInjector());
216             }
217             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
218             {
219                 return (ricohGr2.getDisplayInjector());
220             }
221         }
222         catch (Exception e)
223         {
224             e.printStackTrace();
225         }
226         return (null);
227     }
228
229     @Override
230     public ILiveViewControl getLiveViewControl()
231     {
232         try
233         {
234             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
235             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
236             {
237                 return (olympus.getLiveViewControl());
238             }
239             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
240             {
241                 return (fujiX.getLiveViewControl());
242             }
243             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
244             {
245                 return (panasonic.getPanasonicLiveViewControl());
246             }
247             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
248             {
249                 return (sony.getLiveViewControl());
250             }
251             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
252             {
253                 return (ptpip.getLiveViewControl());
254             }
255             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
256             {
257                 return (ptpip.getLiveViewControl());
258             }
259             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
260             {
261                 return (ricohGr2.getLiveViewControl());
262             }
263         }
264         catch (Exception e)
265         {
266             e.printStackTrace();
267         }
268         return (null);
269     }
270
271     @Override
272     public ILiveViewListener getLiveViewListener()
273     {
274         try
275         {
276             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
277             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
278             {
279                 return (olympus.getLiveViewListener());
280             }
281             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
282             {
283                 return (fujiX.getLiveViewListener());
284             }
285             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
286             {
287                 return (panasonic.getLiveViewListener());
288             }
289             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
290             {
291                 return (sony.getLiveViewListener());
292             }
293             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
294             {
295                 return (ptpip.getLiveViewListener());
296             }
297             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
298             {
299                 return (ptpip.getLiveViewListener());
300             }
301             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
302             {
303                 return (ricohGr2.getLiveViewListener());
304             }
305         }
306         catch (Exception e)
307         {
308             e.printStackTrace();
309         }
310         return (null);
311     }
312
313     @Override
314     public IFocusingControl getFocusingControl()
315     {
316         try
317         {
318             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
319             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
320             {
321                 return (olympus.getFocusingControl());
322             }
323             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
324             {
325                 return (fujiX.getFocusingControl());
326             }
327             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
328             {
329                 return (panasonic.getFocusingControl());
330             }
331             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
332             {
333                 return (sony.getFocusingControl());
334             }
335             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
336             {
337                 return (ptpip.getFocusingControl());
338             }
339             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
340             {
341                 return (ptpip.getFocusingControl());
342             }
343             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
344             {
345                 return (ricohGr2.getFocusingControl());
346             }
347         }
348         catch (Exception e)
349         {
350             e.printStackTrace();
351         }
352         return (null);
353     }
354
355     @Override
356     public ICameraInformation getCameraInformation()
357     {
358         try
359         {
360             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
361             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
362             {
363                 return (olympus.getCameraInformation());
364             }
365             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
366             {
367                 return (fujiX.getCameraInformation());
368             }
369             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
370             {
371                 return (panasonic.getCameraInformation());
372             }
373             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
374             {
375                 return (sony.getCameraInformation());
376             }
377             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
378             {
379                 return (ptpip.getCameraInformation());
380             }
381             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
382             {
383                 return (ptpip.getCameraInformation());
384             }
385             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
386             {
387                 return (ricohGr2.getCameraInformation());
388             }
389         }
390         catch (Exception e)
391         {
392             e.printStackTrace();
393         }
394         return (null);
395     }
396
397     @Override
398     public IZoomLensControl getZoomLensControl()
399     {
400         try
401         {
402             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
403             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
404             {
405                 return (olympus.getZoomLensControl());
406             }
407             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
408             {
409                 return (fujiX.getZoomLensControl());
410             }
411             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
412             {
413                 return (panasonic.getZoomLensControl());
414             }
415             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
416             {
417                 return (sony.getZoomLensControl());
418             }
419             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
420             {
421                 return (ptpip.getZoomLensControl());
422             }
423             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
424             {
425                 return (ptpip.getZoomLensControl());
426             }
427             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
428             {
429                 return (ricohGr2.getZoomLensControl());
430             }
431         }
432         catch (Exception e)
433         {
434             e.printStackTrace();
435         }
436         return (null);
437     }
438
439     @Override
440     public ICaptureControl getCaptureControl()
441     {
442         try
443         {
444             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
445             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
446             {
447                 return (olympus.getCaptureControl());
448             }
449             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
450             {
451                 return (fujiX.getCaptureControl());
452             }
453             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
454             {
455                 return (panasonic.getCaptureControl());
456             }
457             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
458             {
459                 return (sony.getCaptureControl());
460             }
461             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
462             {
463                 return (ptpip.getCaptureControl());
464             }
465             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
466             {
467                 return (ptpip.getCaptureControl());
468             }
469             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
470             {
471                 return (ricohGr2.getCaptureControl());
472             }
473         }
474         catch (Exception e)
475         {
476             e.printStackTrace();
477         }
478         return (null);
479     }
480
481     @Override
482     public ICameraStatus getCameraStatusListHolder()
483     {
484         try
485         {
486             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
487             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
488             {
489                 return (olympus.getCameraStatusListHolder());
490             }
491             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
492             {
493                 return (fujiX.getCameraStatusListHolder());
494             }
495             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
496             {
497                 return (panasonic.getCameraStatusListHolder());
498             }
499             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
500             {
501                 return (sony.getCameraStatusListHolder());
502             }
503             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
504             {
505                 return (ptpip.getCameraStatusListHolder());
506             }
507             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
508             {
509                 return (ptpip.getCameraStatusListHolder());
510             }
511             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
512             {
513                 return (ricohGr2.getCameraStatusListHolder());
514             }
515         }
516         catch (Exception e)
517         {
518             e.printStackTrace();
519         }
520         return (null);
521     }
522
523     @Override
524     public ICameraStatusWatcher getCameraStatusWatcher()
525     {
526         try
527         {
528             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
529             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
530             {
531                 return (olympus.getCameraStatusWatcher());
532             }
533             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
534             {
535                 return (fujiX.getCameraStatusWatcher());
536             }
537             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
538             {
539                 return (panasonic.getCameraStatusWatcher());
540             }
541             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
542             {
543                 return (sony.getCameraStatusWatcher());
544             }
545             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
546             {
547                 return (ptpip.getCameraStatusWatcher());
548             }
549             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
550             {
551                 return (ptpip.getCameraStatusWatcher());
552             }
553             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
554             {
555                 return (ricohGr2.getCameraStatusWatcher());
556             }
557         }
558         catch (Exception e)
559         {
560             e.printStackTrace();
561         }
562         return (null);
563     }
564
565     @Override
566     public IPlaybackControl getPlaybackControl()
567     {
568         try
569         {
570             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
571             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
572             {
573                 return (olympus.getPlaybackControl());
574             }
575             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
576             {
577                 return (fujiX.getPlaybackControl());
578             }
579             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
580             {
581                 return (panasonic.getPlaybackControl());
582             }
583             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
584             {
585                 return (sony.getPlaybackControl());
586             }
587             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
588             {
589                 return (ptpip.getPlaybackControl());
590             }
591             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
592             {
593                 return (ptpip.getPlaybackControl());
594             }
595             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
596             {
597                 return (ricohGr2.getPlaybackControl());
598             }
599         }
600         catch (Exception e)
601         {
602             e.printStackTrace();
603         }
604         return (null);
605     }
606
607     @Override
608     public ICameraHardwareStatus getHardwareStatus()
609     {
610         try
611         {
612             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
613             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
614             {
615                 return (olympus.getHardwareStatus());
616             }
617             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
618             {
619                 return (fujiX.getHardwareStatus());
620             }
621             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
622             {
623                 return (panasonic.getHardwareStatus());
624             }
625             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
626             {
627                 return (sony.getHardwareStatus());
628             }
629             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
630             {
631                 return (ptpip.getHardwareStatus());
632             }
633             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
634             {
635                 return (ptpip.getHardwareStatus());
636             }
637             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
638             {
639                 return (ricohGr2.getHardwareStatus());
640             }
641         }
642         catch (Exception e)
643         {
644             e.printStackTrace();
645         }
646         return (null);
647     }
648
649     @Override
650     public ICameraRunMode getCameraRunMode()
651     {
652         try
653         {
654             ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
655             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
656             {
657                 return (olympus.getCameraRunMode());
658             }
659             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
660             {
661                 return (fujiX.getCameraRunMode());
662             }
663             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
664             {
665                 return (panasonic.getCameraRunMode());
666             }
667             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
668             {
669                 return (sony.getCameraRunMode());
670             }
671             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
672             {
673                 return (ptpip.getCameraRunMode());
674             }
675             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
676             {
677                 return (ptpip.getCameraRunMode());
678             }
679             else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH)
680             {
681                 return (ricohGr2.getCameraRunMode());
682             }
683         }
684         catch (Exception e)
685         {
686             e.printStackTrace();
687         }
688         return (null);
689     }
690
691     /**
692      *   OPC/GR2/SONY カメラを使用するかどうか
693      *
694      * @return OPC / SONY / RICOH  (ICameraConnection.CameraConnectionMethod)
695      */
696     public ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod()
697     {
698         return (getCammeraConnectionMethodImpl());
699     }
700
701     /**
702      *
703      *
704      */
705     @Override
706     public void resetCameraConnectionMethod()
707     {
708         connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
709     }
710
711     /**
712      *
713      *
714      */
715     @Override
716     public IInformationReceiver getInformationReceiver()
717     {
718         return (informationReceiver);
719     }
720
721     @Override
722     public ICameraContentsRecognizer getCameraContentsRecognizer()
723     {
724         return (cameraContentsRecognizer);
725     }
726
727     /**
728      *
729      *
730      */
731     private ICameraConnection.CameraConnectionMethod getCammeraConnectionMethodImpl()
732     {
733         if (connectionMethod != ICameraConnection.CameraConnectionMethod.UNKNOWN)
734         {
735             return (connectionMethod);
736         }
737         ICameraConnection.CameraConnectionMethod ret;
738         try
739         {
740             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
741             String connectionMethod = preferences.getString(IPreferencePropertyAccessor.CONNECTION_METHOD, "RICOH");
742             if (connectionMethod.contains("RICOH"))
743             {
744                 ret = ICameraConnection.CameraConnectionMethod.RICOH;
745             }
746             else if (connectionMethod.contains("FUJI_X"))
747             {
748                 ret = ICameraConnection.CameraConnectionMethod.FUJI_X;
749             }
750             else if (connectionMethod.contains("PANASONIC"))
751             {
752                 ret = ICameraConnection.CameraConnectionMethod.PANASONIC;
753             }
754             else if (connectionMethod.contains("SONY"))
755             {
756                 ret = ICameraConnection.CameraConnectionMethod.SONY;
757             }
758             else if (connectionMethod.contains("CANON"))
759             {
760                 ret = ICameraConnection.CameraConnectionMethod.CANON;
761             }
762             else if (connectionMethod.contains("NIKON"))
763             {
764                 ret = ICameraConnection.CameraConnectionMethod.NIKON;
765             }
766             else // if (connectionMethod.contains("OPC"))
767             {
768                 ret = ICameraConnection.CameraConnectionMethod.OPC;
769             }
770 /*
771             else if (connectionMethod.contains("SONY"))
772             {
773                 ret = ICameraConnection.CameraConnectionMethod.SONY;
774             }
775 */
776         }
777         catch (Exception e)
778         {
779             e.printStackTrace();
780             ret = ICameraConnection.CameraConnectionMethod.UNKNOWN;
781         }
782         connectionMethod = ret;
783         return (connectionMethod);
784     }
785 }