OSDN Git Service

一応、Olympus対応。(screennailがとれないけど...)
authorMRSa <mrsa@myad.jp>
Sat, 19 Oct 2019 12:33:06 +0000 (21:33 +0900)
committerMRSa <mrsa@myad.jp>
Sat, 19 Oct 2019 12:33:06 +0000 (21:33 +0900)
16 files changed:
app/src/main/java/net/osdn/gokigen/pkremote/camera/utils/SimpleHttpClient.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/OlympusPenInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/OlympusPenRunMode.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/connection/OlympusPenCameraConnectSequence.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/connection/OlympusPenCameraDisconnectSequence.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/connection/OlympusPenConnection.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/playback/OlympusPenCameraContent.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/playback/OlympusPenObjectDataHolder.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/playback/OlympusPenPlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/panasonic/wrapper/playback/PanasonicPlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ricoh/wrapper/RicohGr2PlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/sony/wrapper/playback/SonyPlaybackControl.java
app/src/main/res/values-ja/arrays.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/arrays.xml
app/src/main/res/values/strings.xml

index b28cd32..4752d6a 100644 (file)
@@ -130,7 +130,7 @@ public class SimpleHttpClient
      *
      *
      */
-    public static void httpGetBytes(String url, int timeoutMs, @NonNull IReceivedMessageCallback callback)
+    public static void httpGetBytes(String url, Map<String, String> setProperty, int timeoutMs, @NonNull IReceivedMessageCallback callback)
     {
         HttpURLConnection httpConn = null;
         InputStream inputStream = null;
@@ -146,6 +146,14 @@ public class SimpleHttpClient
             final URL urlObj = new URL(url);
             httpConn = (HttpURLConnection) urlObj.openConnection();
             httpConn.setRequestMethod("GET");
+            if (setProperty != null)
+            {
+                for (String key : setProperty.keySet())
+                {
+                    String value = setProperty.get(key);
+                    httpConn.setRequestProperty(key, value);
+                }
+            }
             httpConn.setConnectTimeout(timeout);
             httpConn.setReadTimeout(timeout);
             httpConn.connect();
@@ -200,7 +208,10 @@ public class SimpleHttpClient
                     List<String> valueList = headers.get("X-FILE_SIZE");
                     try
                     {
-                        contentLength = Integer.parseInt(getValue(valueList));
+                        if (valueList != null)
+                        {
+                            contentLength = Integer.parseInt(getValue(valueList));
+                        }
                     }
                     catch (Exception ee)
                     {
@@ -270,7 +281,7 @@ public class SimpleHttpClient
      *
      *
      */
-    public static Bitmap httpGetBitmap(String url, int timeoutMs)
+    public static Bitmap httpGetBitmap(String url, Map<String, String> setProperty, int timeoutMs)
     {
         HttpURLConnection httpConn = null;
         InputStream inputStream = null;
@@ -288,6 +299,14 @@ public class SimpleHttpClient
             final URL urlObj = new URL(url);
             httpConn = (HttpURLConnection) urlObj.openConnection();
             httpConn.setRequestMethod("GET");
+            if (setProperty != null)
+            {
+                for (String key : setProperty.keySet())
+                {
+                    String value = setProperty.get(key);
+                    httpConn.setRequestProperty(key, value);
+                }
+            }
             httpConn.setConnectTimeout(timeout);
             httpConn.setReadTimeout(timeout);
             httpConn.connect();
index 8c04a20..97d85d7 100644 (file)
@@ -40,8 +40,6 @@ import androidx.preference.PreferenceManager;
 public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider, IDisplayInjector
 {
     private final String TAG = toString();
-    //private final Activity activity;
-    //private final ICameraStatusReceiver provider;
     private final OlympusPenConnection olympusPenConnection;
     private final OlympusPenButtonControl buttonControl;
     private final OlympusPenPlaybackControl playbackControl;
@@ -55,8 +53,6 @@ public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider
     public OlympusPenInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
     {
         SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
-        //useGrCommand = preferences.getBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
-        //pentaxCaptureAfterAf = preferences.getBoolean(IPreferencePropertyAccessor.PENTAX_CAPTURE_AFTER_AF, false);
         int communicationTimeoutMs = 10000;  // デフォルトは 10000ms とする
         try
         {
@@ -70,27 +66,11 @@ public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider
         {
             e.printStackTrace();
         }
-        int maxCount = 3000;  // デフォルトは 3000枚 とする
-        try
-        {
-            maxCount = Integer.parseInt(preferences.getString(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_MAX_COUNT, IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_MAX_COUNT_DEFAULT_VALUE));
-            if (maxCount < 300)
-            {
-                maxCount = 300;  // 最小値は 300枚とする。
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
 
         //this.activity = context;
         //this.provider = provider;
         olympusPenConnection = new OlympusPenConnection(context, provider);
-        //liveViewControl = new RicohGr2LiveViewControl(useGrCommand);
-        //zoomControl = new RicohGr2CameraZoomLensControl();
         buttonControl = new OlympusPenButtonControl();
-        //statusChecker = new RicohGr2StatusChecker(500, useGrCommand);
         playbackControl = new OlympusPenPlaybackControl(communicationTimeoutMs);
         hardwareStatus = new OlympusPenHardwareStatus();
         runMode = new OlympusPenRunMode();
@@ -105,8 +85,6 @@ public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider
     public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
     {
         Log.v(TAG, "injectDisplay()");
-        //focusControl = new RicohGr2CameraFocusControl(useGrCommand, frameDisplayer, indicator);
-        //captureControl = new RicohGr2CameraCaptureControl(useGrCommand, pentaxCaptureAfterAf, frameDisplayer, statusChecker);
     }
 
     @Override
index 395385e..21fd88c 100644 (file)
@@ -1,15 +1,53 @@
 package net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper;
 
+import android.util.Log;
+
+import net.osdn.gokigen.pkremote.R;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode;
+import net.osdn.gokigen.pkremote.camera.utils.SimpleHttpClient;
+
+import java.util.HashMap;
+import java.util.Map;
 
 public class OlympusPenRunMode implements ICameraRunMode
 {
+    private final String TAG = this.toString();
+
     @Override
-    public void changeRunMode(boolean isRecording)
+    public void changeRunMode(final boolean isRecording)
     {
+        final int TIMEOUT_MS = 5000;
+        try
+        {
+            final Thread thread = new Thread(new Runnable()
+            {
+                @Override
+                public void run()
+                {
+                    // カメラとの接続確立を通知する
+                    Map<String, String> headerMap = new HashMap<>();
+                    headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
+                    headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
 
-
-
+                    String playModeUrl = "http://192.168.0.10/switch_cameramode.cgi";
+                    if (isRecording)
+                    {
+                        playModeUrl = playModeUrl + "?mode=rec";
+                    }
+                    else
+                    {
+                        playModeUrl = playModeUrl + "?mode=play";
+                    }
+                    String response = SimpleHttpClient.httpGetWithHeader(playModeUrl, headerMap, null, TIMEOUT_MS);
+                    Log.v(TAG, " " + playModeUrl + " " + response);
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
     }
 
     @Override
index 4a8182a..2d0b20d 100644 (file)
@@ -1,18 +1,18 @@
 package net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.connection;
 
 import android.app.Activity;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
 import android.util.Log;
 
 import net.osdn.gokigen.pkremote.R;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver;
 import net.osdn.gokigen.pkremote.camera.utils.SimpleHttpClient;
-import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
 
 import androidx.annotation.NonNull;
 
+import java.util.HashMap;
+import java.util.Map;
+
 class OlympusPenCameraConnectSequence implements Runnable
 {
     private final String TAG = this.toString();
@@ -31,31 +31,27 @@ class OlympusPenCameraConnectSequence implements Runnable
     @Override
     public void run()
     {
-        final String areYouThereUrl = "http://192.168.0.1/v1/ping";
-        final String grCommandUrl = "http://192.168.0.1/_gr";
+        final String camInfoUrl = "http://192.168.0.10/get_caminfo.cgi";
+        final String getCommandListUrl = "http://192.168.0.10/get_commandlist.cgi";
+        final String getConnectModeUrl = "http://192.168.0.10/get_connectmode.cgi";
+
         final int TIMEOUT_MS = 5000;
         try
         {
-            String response = SimpleHttpClient.httpGet(areYouThereUrl, TIMEOUT_MS);
-            Log.v(TAG, areYouThereUrl + " " + response);
+            Map<String, String> headerMap = new HashMap<>();
+            headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
+            headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
+
+            String response = SimpleHttpClient.httpGetWithHeader(getConnectModeUrl, headerMap, null, TIMEOUT_MS);
+            Log.v(TAG, " " + getConnectModeUrl + " " + response);
             if (response.length() > 0)
             {
-                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+                String response2 = SimpleHttpClient.httpGetWithHeader(getCommandListUrl, headerMap, null, TIMEOUT_MS);
+                Log.v(TAG, " " + getCommandListUrl + " " + response2);
 
-                // 接続時、レンズロックOFF
-                {
-                    final String postData = "cmd=acclock off";
-                    String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
-                    Log.v(TAG, grCommandUrl + " " + response0);
-                }
+                String response3 = SimpleHttpClient.httpGetWithHeader(camInfoUrl, headerMap, null, TIMEOUT_MS);
+                Log.v(TAG, " " + camInfoUrl + " " + response3);
 
-                // 接続時、カメラの画面を消す
-                if (preferences.getBoolean(IPreferencePropertyAccessor.GR2_LCD_SLEEP, false))
-                {
-                    final String postData = "cmd=lcd sleep on";
-                    String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
-                    Log.v(TAG, grCommandUrl + " " + response0);
-                }
                 onConnectNotify();
             }
             else
@@ -93,21 +89,6 @@ class OlympusPenCameraConnectSequence implements Runnable
         }
     }
 
-/*
-    private void waitForAMoment(long mills)
-    {
-        if (mills > 0)
-        {
-            try {
-                Log.v(TAG, " WAIT " + mills + "ms");
-                Thread.sleep(mills);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-    }
-*/
-
     private void onConnectError(String reason)
     {
         cameraConnection.alertConnectingFailed(reason);
index 3402c11..7e94044 100644 (file)
@@ -1,12 +1,12 @@
 package net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.connection;
 
 import android.app.Activity;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
 import android.util.Log;
 
 import net.osdn.gokigen.pkremote.camera.utils.SimpleHttpClient;
-import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
+
+import java.util.HashMap;
+import java.util.Map;
 
 public class OlympusPenCameraDisconnectSequence  implements Runnable
 {
@@ -26,23 +26,16 @@ public class OlympusPenCameraDisconnectSequence  implements Runnable
         // カメラをPowerOffして接続を切る
         try
         {
-            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
-            if (preferences.getBoolean(IPreferencePropertyAccessor.GR2_LCD_SLEEP, false))
-            {
-                final String screenOnUrl = "http://192.168.0.1/_gr";
-                final String postData = "lcd sleep off";
-                final int TIMEOUT_MS = 5000;
-                String response = SimpleHttpClient.httpPost(screenOnUrl, postData, TIMEOUT_MS);
-                Log.v(TAG, screenOnUrl + " " + response);
-            }
+            Map<String, String> headerMap = new HashMap<>();
+            headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
+            headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
 
             if (powerOff)
             {
-                final String cameraPowerOffUrl = "http://192.168.0.1/v1/device/finish";
-                final String postData = "";
+                final String cameraPowerOffUrl = "http://192.168.0.10/exec_pwoff.cgi";
                 final int TIMEOUT_MS = 5000;
-                String response = SimpleHttpClient.httpPost(cameraPowerOffUrl, postData, TIMEOUT_MS);
-                Log.v(TAG, cameraPowerOffUrl + " " + response);
+                String response = SimpleHttpClient.httpGetWithHeader(cameraPowerOffUrl, headerMap, null, TIMEOUT_MS);
+                Log.v(TAG, " " + cameraPowerOffUrl + " " + response);
             }
         }
         catch (Exception e)
index 03b25b3..c7e7b23 100644 (file)
@@ -175,7 +175,7 @@ public class OlympusPenConnection implements ICameraConnection
     {
         Log.v(TAG, "alertConnectingFailed() : " + message);
         final AlertDialog.Builder builder = new AlertDialog.Builder(context)
-                .setTitle(context.getString(R.string.dialog_title_connect_failed_ricoh))
+                .setTitle(context.getString(R.string.dialog_title_connect_failed_olympus))
                 .setMessage(message)
                 .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
                     @Override
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/playback/OlympusPenCameraContent.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/playback/OlympusPenCameraContent.java
new file mode 100644 (file)
index 0000000..814f94c
--- /dev/null
@@ -0,0 +1,98 @@
+package net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.playback;
+
+import android.util.Log;
+
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+public class OlympusPenCameraContent implements ICameraContent
+{
+    private final String TAG = toString();
+
+    private final String path;
+    private final String name;
+    private final String size;
+    private final String attribute;
+    private final String date;
+    private final String time;
+
+    OlympusPenCameraContent(String path, String name, String size, String attribute, String date, String time)
+    {
+        Log.v(TAG, "  " + path + " " + name + "  size: " + size + " ");
+
+        this.path = path;
+        this.name = name;
+        this.size = size;
+        this.attribute = attribute;
+        this.date = date;
+        this.time = time;
+    }
+
+    @Override
+    public String getCameraId()
+    {
+        return ("");
+    }
+
+    @Override
+    public String getCardId()
+    {
+        return ("");
+    }
+
+    @Override
+    public String getContentPath()
+    {
+        return (path);
+    }
+
+    @Override
+    public String getContentName()
+    {
+        return (name);
+    }
+
+    @Override
+    public boolean isDateValid()
+    {
+        return (true);
+    }
+
+    @Override
+    public Date getCapturedDate()
+    {
+        try
+        {
+            int timeInt = Integer.parseInt(time);
+            int dateInt = Integer.parseInt(date);
+
+            int year = ((dateInt & 0xfe00) >> 9) + 1980;
+            int month = ((dateInt & 0x01f0) >> 5);
+            int day =  (dateInt & 0x001f);
+
+            int sec = ((timeInt & 0x001f) << 1); // 2倍...
+            int min = ((timeInt & 0x07e0) >> 5);
+            int hour = ((timeInt & 0x07e0) >> 11);
+
+            //Log.v(TAG, " " + year + "/" + month + "/" + day + "  " + (hour + 1) + ":" + min + ":" + sec);
+
+            Calendar cal = new GregorianCalendar();
+            cal.set(year, (month - 1), day, hour, min, sec);
+            return (cal.getTime());
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (new Date());
+    }
+
+    @Override
+    public void setCapturedDate(Date date)
+    {
+
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/playback/OlympusPenObjectDataHolder.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/playback/OlympusPenObjectDataHolder.java
new file mode 100644 (file)
index 0000000..5b4023f
--- /dev/null
@@ -0,0 +1,83 @@
+package net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.playback;
+
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *   画像一覧について、受信データを解析して保持するクラス
+ *
+ */
+class OlympusPenObjectDataHolder
+{
+    private List<ICameraContent> contentList;
+
+    OlympusPenObjectDataHolder()
+    {
+        contentList = new ArrayList<>();
+    }
+
+    void clear()
+    {
+        contentList.clear();
+    }
+
+    List<OlympusPenCameraContent> parsePath(String response)
+    {
+        List<OlympusPenCameraContent> pathList = new ArrayList<>();
+        try
+        {
+            if ((response == null) || (response.length() <= 0))
+            {
+                // データがない、、
+                return (pathList);
+            }
+
+            for (String path : response.split("\r\n"))
+            {
+                String[] values = path.split(",");
+                if (values.length > 5)
+                {
+                    pathList.add(new OlympusPenCameraContent(values[0], values[1], values[2], values[3], values[4], values[5]));
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (pathList);
+    }
+
+    void parseImage(String response)
+    {
+        try
+        {
+            if ((response == null) || (response.length() <= 0))
+            {
+                // データがない、、何もしない
+                return;
+            }
+
+            for (String path : response.split("\r\n"))
+            {
+                String[] values = path.split(",");
+                if (values.length > 5)
+                {
+                    contentList.add(new OlympusPenCameraContent(values[0], values[1], values[2], values[3], values[4], values[5]));
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    List<ICameraContent> getImageList()
+    {
+        return (contentList);
+    }
+
+}
index e6e77b5..edc743d 100644 (file)
@@ -2,7 +2,6 @@ package net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.playback;
 import android.graphics.Bitmap;
 import android.util.Log;
 
-import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraFileInfo;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IContentInfoCallback;
@@ -10,21 +9,11 @@ import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentList
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
-import net.osdn.gokigen.pkremote.camera.playback.CameraContentInfo;
-import net.osdn.gokigen.pkremote.camera.playback.CameraFileInfo;
 import net.osdn.gokigen.pkremote.camera.playback.ProgressEvent;
 import net.osdn.gokigen.pkremote.camera.utils.SimpleHttpClient;
 
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.GregorianCalendar;
 import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
+import java.util.Map;
 
 import androidx.annotation.NonNull;
 
@@ -35,12 +24,13 @@ import androidx.annotation.NonNull;
 public class OlympusPenPlaybackControl implements IPlaybackControl
 {
     private final String TAG = toString();
-    private final String getPhotoUrl = "http://192.168.0.1/v1/photos/";
     private static final int DEFAULT_TIMEOUT = 3000;
     private final int timeoutValue;
+    private OlympusPenObjectDataHolder imageListHolder = new OlympusPenObjectDataHolder();
 
     public OlympusPenPlaybackControl(int timeoutMs)
     {
+        Log.v(TAG, "OlympusPenPlaybackControl()");
         this.timeoutValue  = (timeoutMs < DEFAULT_TIMEOUT) ? DEFAULT_TIMEOUT : timeoutMs;
     }
 
@@ -53,146 +43,35 @@ public class OlympusPenPlaybackControl implements IPlaybackControl
     @Override
     public void downloadContentList(@NonNull IDownloadContentListCallback callback)
     {
-        List<ICameraFileInfo> fileList = new ArrayList<>();
-        String imageListurl = "http://192.168.0.1/v1/photos?";// + maxCount;
-        String contentList;
-        try
-        {
-            contentList = SimpleHttpClient.httpGet(imageListurl, timeoutValue);
-            if (contentList == null)
-            {
-                // ぬるぽ発行
-                callback.onErrorOccurred(new NullPointerException());
-                return;
-            }
-        }
-        catch (Exception e)
-        {
-            // 例外をそのまま転送
-            callback.onErrorOccurred(e);
-            return;
-        }
-        try
-        {
-            JSONArray dirsArray = new JSONObject(contentList).getJSONArray("dirs");
-            if (dirsArray != null)
-            {
-                int size = dirsArray.length();
-                for (int index = 0; index < size; index++)
-                {
-                    JSONObject object = dirsArray.getJSONObject(index);
-                    String dirName = object.getString("name");
-                    JSONArray filesArray = object.getJSONArray("files");
-                    int nofFiles = filesArray.length();
-                    for (int fileIndex = 0; fileIndex < nofFiles; fileIndex++)
-                    {
-                        String fileName = filesArray.getString(fileIndex);
-                        fileList.add(new CameraFileInfo(dirName, fileName));
-                    }
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            callback.onErrorOccurred(e);
-            return;
-        }
-        callback.onCompleted(fileList);
+        Log.v(TAG, " downloadContentList()");
     }
 
     @Override
     public void updateCameraFileInfo(ICameraFileInfo info)
     {
-        String url = getPhotoUrl + info.getDirectoryPath() + "/" + info.getFilename() + "/info";
-        Log.v(TAG, "updateCameraFileInfo() GET URL : " + url);
-        try
-        {
-            String response = SimpleHttpClient.httpGet(url, timeoutValue);
-            if ((response == null)||(response.length() < 1))
-            {
-                return;
-            }
-            JSONObject object = new JSONObject(response);
-
-            // データを突っ込む
-            boolean captured = object.getBoolean("captured");
-            String av = getJSONString(object, "av");
-            String tv = getJSONString(object, "tv");
-            String sv = getJSONString(object,"sv");
-            String xv = getJSONString(object,"xv");
-            int orientation = object.getInt("orientation");
-            String aspectRatio = getJSONString(object,"aspectRatio");
-            String cameraModel = getJSONString(object,"cameraModel");
-            String latLng = getJSONString(object,"latlng");
-            String dateTime = object.getString("datetime");
-            info.updateValues(dateTime, av, tv, sv, xv, orientation, aspectRatio, cameraModel, latLng, captured);
-        }
-        catch (Throwable e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    private String getJSONString(JSONObject object, String key)
-    {
-        String value = "";
-        try
-        {
-            value = object.getString(key);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-        return (value);
+        Log.v(TAG, " updateCameraFileInfo() : " + info.getFilename());
     }
 
     @Override
     public void getContentInfo(@NonNull String path, @NonNull String name, @NonNull IContentInfoCallback callback)
     {
-        String url = getPhotoUrl + path + "/" + name + "/info";
-        Log.v(TAG, "getContentInfo() GET URL : " + url);
-        try
-        {
-            String response = SimpleHttpClient.httpGet(url, timeoutValue);
-            if ((response == null)||(response.length() < 1))
-            {
-                callback.onErrorOccurred(new NullPointerException());
-            }
-            CameraFileInfo fileInfo = new CameraFileInfo(path, name);
-
-            JSONObject object = new JSONObject(response);
-
-            boolean captured = object.getBoolean("captured");
-            String av = getJSONString(object, "av");
-            String tv = getJSONString(object, "tv");
-            String sv = getJSONString(object,"sv");
-            String xv = getJSONString(object,"xv");
-            int orientation = object.getInt("orientation");
-            String aspectRatio = getJSONString(object,"aspectRatio");
-            String cameraModel = getJSONString(object,"cameraModel");
-            String latLng = getJSONString(object,"latlng");
-            String dateTime = object.getString("datetime");
-            fileInfo.updateValues(dateTime, av, tv, sv, xv, orientation, aspectRatio, cameraModel, latLng, captured);
+        Log.v(TAG, " getContentInfo() : " + path + " / " + name);
 
-            callback.onCompleted(fileInfo);
-        }
-        catch (Throwable e)
-        {
-            e.printStackTrace();
-        }
+        // 画像の情報を取得する
     }
 
     @Override
     public void downloadContentScreennail(@NonNull String path, @NonNull IDownloadThumbnailImageCallback callback)
     {
-        //Log.v(TAG, "downloadContentScreennail() : " + path);
-        String suffix = "?size=view";
-        String url = getPhotoUrl + path + suffix;
-        Log.v(TAG, "downloadContentScreennail() GET URL : " + url);
+        Log.v(TAG, "downloadContentScreennail() : " + path);
         try
         {
-            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, timeoutValue);
+            String url = "http://192.168.0.10/get_screennail.cgi?DIR=" + path;
+
+            Map<String, String> headerMap = new HashMap<>();
+            headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
+            headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
+            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, headerMap, timeoutValue);
             HashMap<String, Object> map = new HashMap<>();
             map.put("Orientation", 0);
             callback.onCompleted(bmp, map);
@@ -200,23 +79,22 @@ public class OlympusPenPlaybackControl implements IPlaybackControl
         catch (Throwable e)
         {
             e.printStackTrace();
+            callback.onErrorOccurred(new NullPointerException());
         }
     }
 
     @Override
     public void downloadContentThumbnail(@NonNull String path, @NonNull IDownloadThumbnailImageCallback callback)
     {
-        //Log.v(TAG, "downloadContentThumbnail() : " + path);
-        String suffix = "?size=view";
-        if (path.contains(".JPG"))
-        {
-            suffix = "?size=thumb";
-        }
-        String url = getPhotoUrl + path + suffix;
-        Log.v(TAG, "downloadContentThumbnail() GET URL : " + url);
+        Log.v(TAG, "downloadContentThumbnail() : " + path);
         try
         {
-            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, timeoutValue);
+            String url = "http://192.168.0.10/get_thumbnail.cgi?DIR=" + path;
+
+            Map<String, String> headerMap = new HashMap<>();
+            headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
+            headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
+            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, headerMap, timeoutValue);
             HashMap<String, Object> map = new HashMap<>();
             map.put("Orientation", 0);
             callback.onCompleted(bmp, map);
@@ -231,17 +109,25 @@ public class OlympusPenPlaybackControl implements IPlaybackControl
     @Override
     public void downloadContent(@NonNull String  path, boolean isSmallSize, @NonNull final IDownloadContentCallback callback)
     {
-        Log.v(TAG, "downloadContent() : " + path);
-        String suffix = "?size=full";
-        if (isSmallSize)
-        {
-            suffix = "?size=view";
-        }
-        String url = getPhotoUrl + path + suffix;
-        Log.v(TAG, "downloadContent() GET URL : " + url);
+        Log.v(TAG, "downloadContent() : " + path + " (small :" + isSmallSize + ")");
         try
         {
-            SimpleHttpClient.httpGetBytes(url, timeoutValue, new SimpleHttpClient.IReceivedMessageCallback() {
+            String url;
+            if ((isSmallSize)&&(path.contains(".JPG")))
+            {
+                // 縮小サイズで画像をとる
+                url = "http://192.168.0.10/get_resizeimg.cgi?DIR=" + path + "&size=" + "1600";
+            }
+            else
+            {
+                url = "http://192.168.0.10/" + path;
+            }
+
+            Map<String, String> headerMap = new HashMap<>();
+            headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
+            headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
+
+            SimpleHttpClient.httpGetBytes(url, headerMap, timeoutValue, new SimpleHttpClient.IReceivedMessageCallback() {
                 @Override
                 public void onCompleted() {
                     callback.onCompleted();
@@ -255,6 +141,7 @@ public class OlympusPenPlaybackControl implements IPlaybackControl
                 @Override
                 public void onReceive(int readBytes, int length, int size, byte[] data) {
                     float percent = (length == 0) ? 0.0f : ((float) readBytes / (float) length);
+                    //Log.v(TAG, " onReceive : " + readBytes + " " + length + " " + size);
                     ProgressEvent event = new ProgressEvent(percent, null);
                     callback.onProgress(data, size, event);
                 }
@@ -267,59 +154,41 @@ public class OlympusPenPlaybackControl implements IPlaybackControl
     }
 
     /**
-     *   撮影時刻は(個別に)取れるが、非常に遅い...
-     *
-     */
-    private Date getCameraContentDate(@NonNull ICameraContent cameraContent)
-    {
-        // 各ファイルを個別に撮影時刻をとると、反応が悪すぎるので処理を抑止。
-/*
-        String fileInfo;
-        try
-        {
-            String imageInfoUrl = "http://192.168.0.1/v1/photos/" + cameraContent.getContentPath() + "/" + cameraContent.getContentName() + "/info?storage=" + cameraContent.getCardId();
-            //Log.v(TAG, "getCameraContentDate() : " + imageInfoUrl);
-            fileInfo = SimpleHttpClient.httpGet(imageInfoUrl, DEFAULT_TIMEOUT);
-            if (fileInfo != null)
-            {
-                String datetime = new JSONObject(fileInfo).getString("datetime");
-                SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); // "yyyy-MM-dd'T'HH:mm:ssZ"
-                dateFormatter.setCalendar(new GregorianCalendar());
-                return (dateFormatter.parse(datetime));
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-        return (cameraContent.getCapturedDate());
-*/
-        return (null);
-    }
-
-
-    /**
-     *   カメラ内画像ファイルの取得処理... GRコマンドが失敗したらPENTAXコマンドを使う。
-     *
+     *   カメラ内画像ファイルの取得処理
+     *      - フォルダ一覧を取得してから、それぞれのフォルダ内に入っている画像一覧を取得する
      */
     @Override
     public void getCameraContentList(ICameraContentListCallback callback)
     {
+        String imageListTopLevelUrl = "http://192.168.0.10/get_imglist.cgi?DIR=/DCIM";
+        String contentInformation;
         try
         {
-/*
-            if (useGrCommand)
+            Map<String, String> headerMap = new HashMap<>();
+            headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
+            headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
+
+            // フォルダー情報を取得する
+            contentInformation = SimpleHttpClient.httpGetWithHeader(imageListTopLevelUrl, headerMap, null, timeoutValue);
+            Log.v(TAG, " " + imageListTopLevelUrl + " " + contentInformation);
+            imageListHolder.clear();
+            for (OlympusPenCameraContent path : imageListHolder.parsePath(contentInformation))
             {
-                getGrCameraContentListImpl(callback);
-                return;
+                //  フォルダ内の画像を取得する
+                String imageListPathUrl = "http://192.168.0.10/get_imglist.cgi?DIR=/DCIM/" + path.getContentName();
+                String imgList = SimpleHttpClient.httpGetWithHeader(imageListPathUrl, headerMap, null, timeoutValue);
+                if ((imgList != null)&&(imgList.length() > 0))
+                {
+                    imageListHolder.parseImage(imgList);
+                }
             }
-*/
+            callback.onCompleted(imageListHolder.getImageList());
         }
         catch (Exception e)
         {
-            e.printStackTrace();
+            // 例外をそのまま転送
+            callback.onErrorOccurred(e);
         }
-        getCameraContentListImpl(callback);
     }
 
     @Override
@@ -333,132 +202,4 @@ public class OlympusPenPlaybackControl implements IPlaybackControl
     {
 
     }
-
-    /**
-     *   RICOH GR2用のカメラ内画像ファイル一覧取得処理
-     *   (エラー発生時には、通常のPENTAX用のカメラ内画像ファイル一覧取得処理を使う)
-     *
-     */
-    private void getGrCameraContentListImpl(ICameraContentListCallback callback)
-    {
-        List<ICameraContent> fileList = new ArrayList<>();
-        String imageListurl = "http://192.168.0.1/_gr/objs";
-        String contentList;
-
-        // try ~ catch でくくらない ... だめだったら PENTAXのシーケンスに入るようにしたいので
-        contentList = SimpleHttpClient.httpGet(imageListurl, timeoutValue);
-        if (contentList == null)
-        {
-            // ぬるぽ発行
-            throw (new NullPointerException());
-        }
-
-        try
-        {
-            String cameraId = ""; //statusChecker.getCameraId();
-            JSONArray dirsArray = new JSONObject(contentList).getJSONArray("dirs");
-            if (dirsArray != null)
-            {
-                int size = dirsArray.length();
-                for (int index = 0; index < size; index++)
-                {
-                    JSONObject object = dirsArray.getJSONObject(index);
-                    String dirName = object.getString("name");
-                    JSONArray filesArray = object.getJSONArray("files");
-                    int nofFiles = filesArray.length();
-                    for (int fileIndex = 0; fileIndex < nofFiles; fileIndex++)
-                    {
-                        JSONObject fileObject = filesArray.getJSONObject(fileIndex);
-                        String fileName = fileObject.getString("n");
-                        String dateString = fileObject.getString("d");
-                        Date capturedDate = new Date(2001, 1, 1);
-                        if (dateString != null)
-                        {
-                            SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); // "yyyy-MM-dd'T'HH:mm:ssZ"
-                            dateFormatter.setCalendar(new GregorianCalendar());
-                            capturedDate = dateFormatter.parse(dateString);
-                        }
-                        ICameraContent cameraContent = new CameraContentInfo(cameraId, "sd1", dirName, fileName, capturedDate);
-                        fileList.add(cameraContent);
-                    }
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            // ぬるぽ発行
-           throw  (new NullPointerException());
-        }
-        callback.onCompleted(fileList);
-    }
-
-    private void getCameraContentListImpl(ICameraContentListCallback callback)
-    {
-        List<ICameraContent> fileList = new ArrayList<>();
-        String imageListurl = "http://192.168.0.1/v1/photos?limit=";// + maxCount;
-        String contentList;
-        try
-        {
-            contentList = SimpleHttpClient.httpGet(imageListurl, timeoutValue);
-            if (contentList == null)
-            {
-                // ぬるぽ発行
-                callback.onErrorOccurred(new NullPointerException());
-                return;
-            }
-        }
-        catch (Exception e)
-        {
-            // 例外をそのまま転送
-            callback.onErrorOccurred(e);
-            return;
-        }
-        try
-        {
-            Log.v(TAG, "PHOTO LIST RECV: [" + contentList.length() + "]");
-            String cameraId = "";//statusChecker.getCameraId();
-            JSONArray dirsArray = new JSONObject(contentList).getJSONArray("dirs");
-            if (dirsArray != null)
-            {
-                int size = dirsArray.length();
-                Log.v(TAG, "DIRECTORIES : " + size);
-                for (int index = 0; index < size; index++)
-                {
-                    JSONObject object = dirsArray.getJSONObject(index);
-                    String dirName = object.getString("name");
-                    JSONArray filesArray = object.getJSONArray("files");
-                    int nofFiles = filesArray.length();
-                    Log.v(TAG, "FILES : [" + dirName + "] " + nofFiles);
-                    for (int fileIndex = 0; fileIndex < nofFiles; fileIndex++)
-                    {
-                        String fileName = filesArray.getString(fileIndex);
-                        //Log.v(TAG, "FILE : " + fileName);
-                        ICameraContent cameraContent = new CameraContentInfo(cameraId, "sd1", dirName, fileName, null);
-                        Date capturedDate = getCameraContentDate(cameraContent);
-                        if (capturedDate != null)
-                        {
-                            cameraContent.setCapturedDate(capturedDate);
-                        }
-                        fileList.add(cameraContent);
-                    }
-                }
-            }
-            else
-            {
-                Log.v(TAG, "NOT FOUND dirs array.");
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-            try {
-                fileList.clear();
-            }
-            catch (Exception ee)
-            {
-                ee.printStackTrace();
-            }
-        }
-        callback.onCompleted(fileList);
-    }
 }
index 99cd899..9194066 100644 (file)
@@ -224,7 +224,7 @@ public class PanasonicPlaybackControl implements IPlaybackControl
         Log.v(TAG, " downloadContentScreennail() : " + requestUrl + "  ");
         try
         {
-            Bitmap bmp = SimpleHttpClient.httpGetBitmap(requestUrl, timeoutMs);
+            Bitmap bmp = SimpleHttpClient.httpGetBitmap(requestUrl, null, timeoutMs);
             HashMap<String, Object> map = new HashMap<>();
             map.put("Orientation", 0);
             callback.onCompleted(bmp, map);
@@ -247,7 +247,7 @@ public class PanasonicPlaybackControl implements IPlaybackControl
         Log.v(TAG, " downloadContentThumbnail() : " + path + "  [" +  requestUrl + "]");
         try
         {
-            Bitmap bmp = SimpleHttpClient.httpGetBitmap(requestUrl, timeoutMs);
+            Bitmap bmp = SimpleHttpClient.httpGetBitmap(requestUrl, null, timeoutMs);
             HashMap<String, Object> map = new HashMap<>();
             map.put("Orientation", 0);
             callback.onCompleted(bmp, map);
@@ -275,7 +275,7 @@ public class PanasonicPlaybackControl implements IPlaybackControl
 
         try
         {
-            SimpleHttpClient.httpGetBytes(url, timeoutMs, new SimpleHttpClient.IReceivedMessageCallback() {
+            SimpleHttpClient.httpGetBytes(url, null, timeoutMs, new SimpleHttpClient.IReceivedMessageCallback() {
                 @Override
                 public void onCompleted() {
                     callback.onCompleted();
index 1a0c696..a3d87aa 100644 (file)
@@ -212,7 +212,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         Log.v(TAG, "downloadContentScreennail() GET URL : " + url);
         try
         {
-            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, timeoutValue);
+            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, null, timeoutValue);
             HashMap<String, Object> map = new HashMap<>();
             map.put("Orientation", 0);
             callback.onCompleted(bmp, map);
@@ -236,7 +236,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         Log.v(TAG, "downloadContentThumbnail() GET URL : " + url);
         try
         {
-            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, timeoutValue);
+            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, null, timeoutValue);
             HashMap<String, Object> map = new HashMap<>();
             map.put("Orientation", 0);
             callback.onCompleted(bmp, map);
@@ -261,7 +261,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         Log.v(TAG, "downloadContent() GET URL : " + url);
         try
         {
-            SimpleHttpClient.httpGetBytes(url, timeoutValue, new SimpleHttpClient.IReceivedMessageCallback() {
+            SimpleHttpClient.httpGetBytes(url, null, timeoutValue, new SimpleHttpClient.IReceivedMessageCallback() {
                 @Override
                 public void onCompleted() {
                     callback.onCompleted();
index bb7b6d6..74fc336 100644 (file)
@@ -98,7 +98,7 @@ public class SonyPlaybackControl implements IPlaybackControl
                 }
                 if (url.length() > 1)
                 {
-                    Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, timeoutMs);
+                    Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, null, timeoutMs);
                     HashMap<String, Object> map = new HashMap<>();
                     map.put("Orientation", 0);
                     callback.onCompleted(bmp, map);
@@ -133,7 +133,7 @@ public class SonyPlaybackControl implements IPlaybackControl
                 String url = content.getThumbnailUrl();
                 if (url.length() > 1)
                 {
-                    Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, timeoutMs);
+                    Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, null, timeoutMs);
                     HashMap<String, Object> map = new HashMap<>();
                     map.put("Orientation", 0);
                     callback.onCompleted(bmp, map);
@@ -179,7 +179,7 @@ public class SonyPlaybackControl implements IPlaybackControl
                 }
                 Log.v(TAG, "downloadContent()  PATH : " + path + "  [SMALL:" + isSmallSize + "][VGA:" + isVgaSize + "]" + " GET URL : " + url);
 
-                SimpleHttpClient.httpGetBytes(url, timeoutMs, new SimpleHttpClient.IReceivedMessageCallback()
+                SimpleHttpClient.httpGetBytes(url, null, timeoutMs, new SimpleHttpClient.IReceivedMessageCallback()
                 {
                     @Override
                     public void onCompleted() {
index 486eae7..46bdf95 100644 (file)
         <item >2048</item>
     </string-array>
 
+    <string-array name="pen_picture_quality">
+        <item >0640</item>
+        <item >1024</item>
+        <item >1280</item>
+        <item >1600</item>
+        <item >1920</item>
+        <item >2048</item>
+        <item >2560</item>
+    </string-array>
+
+    <string-array name="pen_picture_quality_value">
+        <item >0640</item>
+        <item >1024</item>
+        <item >1280</item>
+        <item >1600</item>
+        <item >1920</item>
+        <item >2048</item>
+        <item >2560</item>
+    </string-array>
+
 </resources>
index aa7e703..72e9e1c 100644 (file)
@@ -76,6 +76,7 @@
     <string name="dialog_title_connect_failed_fuji">接続失敗(FUJI)</string>
     <string name="dialog_title_connect_failed_canon">接続失敗(Canon)</string>
     <string name="dialog_title_connect_failed_nikon">接続失敗(Nikon)</string>
+    <string name="dialog_title_connect_failed_olympus">接続失敗(Olympus)</string>
 
 
     <string name="dialog_title_button_retry">再接続</string>
index 3a58604..87b24db 100644 (file)
         <item >2048</item>
     </string-array>
 
+    <string-array name="pen_picture_quality">
+        <item >0640</item>
+        <item >1024</item>
+        <item >1280</item>
+        <item >1600</item>
+        <item >1920</item>
+        <item >2048</item>
+        <item >2560</item>
+    </string-array>
+
+    <string-array name="pen_picture_quality_value">
+        <item >0640</item>
+        <item >1024</item>
+        <item >1280</item>
+        <item >1600</item>
+        <item >1920</item>
+        <item >2048</item>
+        <item >2560</item>
+    </string-array>
+
 </resources>
index 4e2a369..9406332 100644 (file)
@@ -76,7 +76,7 @@
     <string name="dialog_title_connect_failed_fuji">Connect failed (FUJI)</string>
     <string name="dialog_title_connect_failed_canon">Connect failed (Canon)</string>
     <string name="dialog_title_connect_failed_nikon">Connect failed (Nikon)</string>
-
+    <string name="dialog_title_connect_failed_olympus">Connect failed (Olympus)</string>
 
     <string name="dialog_title_button_retry">Retry</string>
     <string name="dialog_title_button_network_settings">WiFi Settings</string>