OSDN Git Service

VisionKids 画像ファイル一覧を取得するところまで。
authorMRSa <mrsa@myad.jp>
Mon, 24 Jul 2023 14:53:49 +0000 (23:53 +0900)
committerMRSa <mrsa@myad.jp>
Mon, 24 Jul 2023 14:53:49 +0000 (23:53 +0900)
12 files changed:
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/VisionKidsHardwareStatus.kt [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/VisionKidsInterfaceProvider.kt
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/connection/VisionKidsCameraConnectSequence.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/connection/VisionKidsConnection.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/FtpCommand.kt [moved from app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/FtpCommand.kt with 91% similarity]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/IFtpServiceCallback.kt [moved from app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/IFtpServiceCallback.kt with 93% similarity]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/MyFtpClient.kt [moved from app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/MyFtpClient.kt with 99% similarity]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/VisionKidsCameraContent.kt [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/VisionKidsCameraContentProvider.kt [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/VisionKidsPlaybackControl.kt
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/strings.xml

diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/VisionKidsHardwareStatus.kt b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/VisionKidsHardwareStatus.kt
new file mode 100644 (file)
index 0000000..e0884c9
--- /dev/null
@@ -0,0 +1,14 @@
+package net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper
+
+import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus
+
+class VisionKidsHardwareStatus : ICameraHardwareStatus
+{
+    override fun isAvailableHardwareStatus(): Boolean { return (false) }
+    override fun getLensMountStatus(): String? { return (null) }
+    override fun getMediaMountStatus(): String? { return (null) }
+    override fun getMinimumFocalLength(): Float { return (0.0f) }
+    override fun getMaximumFocalLength(): Float { return (0.0f) }
+    override fun getActualFocalLength(): Float { return (0.0f) }
+    override fun inquireHardwareInformation(): Map<String?, Any?>? { return (null) }
+}
index 960fc95..601198d 100644 (file)
@@ -7,11 +7,8 @@ import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICaptureControl
 import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingControl
-import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingModeNotify
 import net.osdn.gokigen.pkremote.camera.interfaces.control.IZoomLensControl
-import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IAutoFocusFrameDisplay
 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IDisplayInjector
-import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IIndicatorControl
 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl
 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewListener
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl
@@ -21,22 +18,19 @@ import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatus
 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver
 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusWatcher
 import net.osdn.gokigen.pkremote.camera.vendor.visionkids.IVisionKidsInterfaceProvider
+import net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper.connection.VisionKidsConnection
 import net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper.playback.VisionKidsPlaybackControl
 
-class VisionKidsInterfaceProvider(private val activity: AppCompatActivity, private val provider: ICameraStatusReceiver, private val informationReceiver: IInformationReceiver) : IVisionKidsInterfaceProvider, IDisplayInjector
+class VisionKidsInterfaceProvider(activity: AppCompatActivity, provider: ICameraStatusReceiver, informationReceiver: IInformationReceiver) : IVisionKidsInterfaceProvider, ICameraRunMode
 {
-    private val playbackControl = VisionKidsPlaybackControl()
-
-    // IDisplayInjector
-    override fun injectDisplay(frameDisplayer: IAutoFocusFrameDisplay?, indicator: IIndicatorControl?, focusingModeNotify: IFocusingModeNotify?)
-    {
-        // TODO("Not yet implemented")
-    }
+    private val playbackControl = VisionKidsPlaybackControl(activity, provider, informationReceiver)
+    private val cameraConnection = VisionKidsConnection(activity, provider)
+    private val hardwareStatus = VisionKidsHardwareStatus()
 
     // IVisionKidsInterfaceProvider
-    override fun getVisionKidsCameraConnection(): ICameraConnection?
+    override fun getVisionKidsCameraConnection(): ICameraConnection
     {
-        return (null)
+        return (cameraConnection)
     }
 
     // IVisionKidsInterfaceProvider
@@ -106,15 +100,21 @@ class VisionKidsInterfaceProvider(private val activity: AppCompatActivity, priva
     }
 
     // IVisionKidsInterfaceProvider
-    override fun getHardwareStatus(): ICameraHardwareStatus?
+    override fun getHardwareStatus(): ICameraHardwareStatus
     {
-        return (null)
+        return (hardwareStatus)
     }
 
     // IVisionKidsInterfaceProvider
-    override fun getCameraRunMode(): ICameraRunMode?
+    override fun getCameraRunMode(): ICameraRunMode
     {
-        return (null)
+        return (this)
     }
 
+    // ICameraRunMode
+    override fun changeRunMode(isRecording: Boolean) { }
+
+    // ICameraRunMode
+    override fun isRecordingMode(): Boolean { return (false) }
+
 }
index 20e60fb..69c8160 100644 (file)
@@ -1,20 +1,11 @@
 package net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper.connection;
 
-import android.app.Activity;
-import android.content.SharedPreferences;
 import android.util.Log;
-
 import androidx.annotation.NonNull;
-import androidx.preference.PreferenceManager;
-
+import androidx.appcompat.app.AppCompatActivity;
 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 org.json.JSONArray;
-import org.json.JSONObject;
 
 /**
  *   VisionKidsとの接続シーケンス
@@ -23,11 +14,11 @@ import org.json.JSONObject;
 public class VisionKidsCameraConnectSequence implements Runnable
 {
     private final String TAG = this.toString();
-    private final Activity context;
+    private final AppCompatActivity context;
     private final ICameraConnection cameraConnection;
     private final ICameraStatusReceiver cameraStatusReceiver;
 
-    VisionKidsCameraConnectSequence(@NonNull Activity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection)
+    VisionKidsCameraConnectSequence(@NonNull AppCompatActivity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection)
     {
         Log.v(TAG, "VisionKidsCameraConnectSequence");
         this.context = context;
@@ -40,143 +31,30 @@ public class VisionKidsCameraConnectSequence implements Runnable
     {
         try
         {
-            final String oscInfoUrl = "http://192.168.1.1/osc/info";
-            final int TIMEOUT_MS = 5000;
-
-            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
-            boolean useThetaV21 = preferences.getBoolean(IPreferencePropertyAccessor.USE_OSC_THETA_V21, false);
-
-            String response = SimpleHttpClient.httpGet(oscInfoUrl, TIMEOUT_MS);
-            Log.v(TAG, " " + oscInfoUrl + " " + response);
-            if (response.length() > 0)
-            {
-                try
-                {
-                    JSONArray apiLevelArray = new JSONObject(response).getJSONArray("apiLevel");
-                    int size = apiLevelArray.length();
-                    for (int index = 0; index < size; index++)
-                    {
-                        int api = apiLevelArray.getInt(index);
-                        if ((api == 2)&&(useThetaV21))
-                        {
-                            // API Level V2.1を使用して通信する
-                            connectApiV21();
-                            return;
-                        }
-                    }
-                }
-                catch (Exception e)
-                {
-                    e.printStackTrace();
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-            // onConnectError(e.getLocalizedMessage());
-        }
-
-        // API Level V2 を使用して通信する
-        connectApiV2();
-    }
-
-    /**
-     *
-     */
-    private void connectApiV2()
-    {
-        final String commandsExecuteUrl = "http://192.168.1.1/osc/commands/execute";
-        final String startSessionData = "{\"name\":\"camera.startSession\",\"parameters\":{\"timeout\":0}}";
-        final String getStateUrl = "http://192.168.1.1/osc/state";
-        final int TIMEOUT_MS = 2000;
-
-        try
-        {
-            String response = SimpleHttpClient.httpPostWithHeader(commandsExecuteUrl, startSessionData, null, "application/json;charset=utf-8", TIMEOUT_MS);
-            Log.v(TAG, " " + commandsExecuteUrl + " " + startSessionData + " " + response);
-
-            String response2 = SimpleHttpClient.httpPostWithHeader(getStateUrl, "", null, "application/json;charset=utf-8", TIMEOUT_MS);
-            Log.v(TAG, " " + getStateUrl + " " + response2);
-
             onConnectNotify();
         }
         catch (Exception e)
         {
             e.printStackTrace();
-            onConnectError(e.getLocalizedMessage());
-        }
-    }
-
-    private void connectApiV21()
-    {
-        final String commandsExecuteUrl = "http://192.168.1.1/osc/commands/execute";
-        final String startSessionData = "{\"name\":\"camera.startSession\",\"parameters\":{\"timeout\":0}}";
-        final String getStateUrl = "http://192.168.1.1/osc/state";
-        final int TIMEOUT_MS = 5000;
-
-        try
-        {
-            String responseS = SimpleHttpClient.httpPostWithHeader(commandsExecuteUrl, startSessionData, null, "application/json;charset=utf-8", TIMEOUT_MS);
-            Log.v(TAG, " " + commandsExecuteUrl + " " + startSessionData + " " + responseS);
-
-            String response = SimpleHttpClient.httpPostWithHeader(getStateUrl, "", null, "application/json;charset=utf-8", TIMEOUT_MS);
-            Log.v(TAG, " " + getStateUrl + " " + response);
-            if (response.length() > 0)
-            {
-                int apiLevel = 1;
-               JSONObject object = new JSONObject(response);
-               try
-               {
-                   apiLevel = object.getJSONObject("state").getInt("_apiVersion");
-               }
-               catch (Exception e)
-               {
-                   e.printStackTrace();
-               }
-               if (apiLevel != 2)
-               {
-                   JSONObject jsonObject = object.getJSONObject("state");
-                   String sessionId = jsonObject.getString("sessionId");
-                   String setApiLevelData = "{\"name\":\"camera.setOptions\",\"parameters\":{" + "\"sessionId\" : \"" + sessionId + "\", \"options\":{ \"clientVersion\":2}}}";
-
-                   String response3 = SimpleHttpClient.httpPostWithHeader(commandsExecuteUrl, setApiLevelData, null, "application/json;charset=utf-8", TIMEOUT_MS);
-                   Log.v(TAG, " " + commandsExecuteUrl + " " + setApiLevelData + " " + response3);
-               }
-                onConnectNotify();
-            }
-            else
-            {
-                onConnectError(context.getString(R.string.camera_not_found));
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-            onConnectError(e.getLocalizedMessage());
-        }
+         }
     }
 
     private void onConnectNotify()
     {
         try
         {
-            final Thread thread = new Thread(new Runnable()
-            {
-                @Override
-                public void run()
-                {
-                    // カメラとの接続確立を通知する
-                    cameraStatusReceiver.onStatusNotify(context.getString(R.string.connect_connected));
-                    cameraStatusReceiver.onCameraConnected();
-                    Log.v(TAG, "onConnectNotify()");
-                }
+            final Thread thread = new Thread(() -> {
+                // カメラとの接続確立を通知する
+                cameraStatusReceiver.onStatusNotify(context.getString(R.string.connect_connected));
+                cameraStatusReceiver.onCameraConnected();
+                Log.v(TAG, "onConnectNotify()");
             });
             thread.start();
         }
         catch (Exception e)
         {
             e.printStackTrace();
+            onConnectError(e.getLocalizedMessage());
         }
     }
 
@@ -184,5 +62,4 @@ public class VisionKidsCameraConnectSequence implements Runnable
     {
         cameraConnection.alertConnectingFailed(reason);
     }
-
 }
index d4e9064..d27a09a 100644 (file)
@@ -1,6 +1,5 @@
 package net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper.connection;
 
-import android.app.Activity;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -13,6 +12,7 @@ import android.util.Log;
 
 import androidx.annotation.NonNull;
 import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
 
 import net.osdn.gokigen.pkremote.R;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
@@ -24,21 +24,19 @@ import java.util.concurrent.Executors;
 public class VisionKidsConnection implements ICameraConnection
 {
     private final String TAG = toString();
-    private final Activity context;
+    private final AppCompatActivity context;
     private final ICameraStatusReceiver statusReceiver;
     private final BroadcastReceiver connectionReceiver;
     private final Executor cameraExecutor = Executors.newFixedThreadPool(1);
-
     private CameraConnectionStatus connectionStatus = CameraConnectionStatus.UNKNOWN;
 
-
     /**
      *
      *
      */
-    public VisionKidsConnection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver)
+    public VisionKidsConnection(@NonNull final AppCompatActivity context, @NonNull final ICameraStatusReceiver statusReceiver)
     {
-        Log.v(TAG, "ThetaConnection()");
+        Log.v(TAG, "VisionKidsConnection()");
         this.context = context;
         this.statusReceiver = statusReceiver;
         connectionReceiver = new BroadcastReceiver()
@@ -63,7 +61,6 @@ public class VisionKidsConnection implements ICameraConnection
         String action = intent.getAction();
         if (action == null)
         {
-            //
             Log.v(TAG, "intent.getAction() : null");
             return;
         }
@@ -164,7 +161,7 @@ public class VisionKidsConnection implements ICameraConnection
     {
         Log.v(TAG, "alertConnectingFailed() : " + message);
         final AlertDialog.Builder builder = new AlertDialog.Builder(context)
-                .setTitle(context.getString(R.string.dialog_title_connect_failed_theta))
+                .setTitle(context.getString(R.string.dialog_title_connect_failed_visionkids))
                 .setMessage(message)
                 .setPositiveButton(context.getString(R.string.dialog_title_button_retry), (dialog, which) -> connect())
                 .setNeutralButton(R.string.dialog_title_button_network_settings, (dialog, which) -> {
@@ -1,4 +1,4 @@
-package net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper
+package net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper.playback
 
 import android.util.Log
 import net.osdn.gokigen.pkremote.camera.utils.SimpleLogDumper
@@ -17,7 +17,6 @@ class MyFtpClient(private val callbackReceiver: IFtpServiceCallback, private val
     private var isConnected = false
     private var socket: Socket? = null
     private var dataOutputStream: DataOutputStream? = null
-    //private var bufferedReader: BufferedReader? = null
     private var connectedAddress : String? = null
     private val commandQueue : Queue<FtpCommand> = ArrayDeque()
 
@@ -410,6 +409,5 @@ class MyFtpClient(private val callbackReceiver: IFtpServiceCallback, private val
         private const val PACKET_BUFFER_SIZE = 8192
 
         private const val FTP_CONTROL_PORT = 21
-        // private const val FTP_DATA_PORT = 20
     }
 }
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/VisionKidsCameraContent.kt b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/VisionKidsCameraContent.kt
new file mode 100644 (file)
index 0000000..8ffc253
--- /dev/null
@@ -0,0 +1,48 @@
+package net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper.playback
+
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent
+import java.text.SimpleDateFormat
+import java.util.Date
+import java.util.Locale
+
+class VisionKidsCameraContent(private val name: String, private val path: String, private val dateString: String) : ICameraContent
+{
+    override fun getCameraId(): String { return ("") }
+
+    override fun getCardId(): String { return ("") }
+
+    override fun getContentPath(): String { return (path) }
+
+    override fun getContentName(): String { return (name) }
+
+    override fun getOriginalName(): String { return (name) }
+
+    override fun isRaw(): Boolean { return (false) }
+
+    override fun isMovie(): Boolean { return (name.contains(".AVI")) }
+
+    override fun isDateValid(): Boolean { return (true) }
+
+    override fun isContentNameValid(): Boolean { return (true) }
+
+    override fun getCapturedDate(): Date
+    {
+        try
+        {
+            val dateFormat = SimpleDateFormat("MMM d yyyy", Locale.ENGLISH)
+            return (dateFormat.parse(dateString)?: Date())
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+        return (Date())
+    }
+
+    override fun setCapturedDate(date: Date?) { }
+
+    companion object
+    {
+        private val TAG = VisionKidsCameraContent::class.java.simpleName
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/VisionKidsCameraContentProvider.kt b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/visionkids/wrapper/playback/VisionKidsCameraContentProvider.kt
new file mode 100644 (file)
index 0000000..03e8f31
--- /dev/null
@@ -0,0 +1,234 @@
+package net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper.playback
+
+import android.util.Log
+import androidx.appcompat.app.AppCompatActivity
+import androidx.preference.PreferenceManager
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback
+import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor
+
+class VisionKidsCameraContentProvider(context: AppCompatActivity) : IFtpServiceCallback
+{
+    private val ftpClient = MyFtpClient(this)
+    private val preferences = PreferenceManager.getDefaultSharedPreferences(context)
+    private val cameraContentList = ArrayList<ICameraContent>()
+    private lateinit var callback : ICameraContentListCallback
+
+
+    fun getContentList(callback: ICameraContentListCallback)
+    {
+        try
+        {
+            val address = preferences.getString(IPreferencePropertyAccessor.VISIONKIDS_HOST_IP, IPreferencePropertyAccessor.VISIONKIDS_HOST_IP_DEFAULT_VALUE)?: IPreferencePropertyAccessor.VISIONKIDS_HOST_IP_DEFAULT_VALUE
+            this.callback = callback
+            ftpClient.connect(address)
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    // IFtpServiceCallback
+    override fun onReceivedFtpResponse(command: String, code: Int, response: String)
+    {
+        try
+        {
+            if (code == 0)
+            {
+                // 成功の応答の場合... FTPのシーケンスを進める
+                when (command)
+                {
+                    "connect" -> inputUser(response)
+                    "user" -> inputPass(response)
+                    "pass" -> changeCurrentWorkingDirectory(response)
+                    "cwd" -> setAsciiTransferMode(response)
+                    "ascii" -> setPassiveMode(response)
+                    "passive" -> checkPassivePort(response)
+                    "data_port" -> getFileList(response)
+                    "list" -> checkListCommand(response)
+                    "data" -> parseFileList(response)
+                    "quit" -> checkQuitResponse(response)
+                }
+            }
+            else
+            {
+                Log.v(TAG, " onReceivedFtpResponse($command/$code) [${response.length}] $response")
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun inputUser(response: String)
+    {
+        try
+        {
+            if (response.startsWith("220"))
+            {
+                val user = preferences.getString(IPreferencePropertyAccessor.VISIONKIDS_FTP_USER, IPreferencePropertyAccessor.VISIONKIDS_FTP_USER_DEFAULT_VALUE)?: IPreferencePropertyAccessor.VISIONKIDS_FTP_USER_DEFAULT_VALUE
+
+                ftpClient.enqueueCommand(FtpCommand("user", "USER $user\r\n"))
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun inputPass(response: String)
+    {
+        try
+        {
+            if (response.startsWith("331"))
+            {
+                val pass = preferences.getString(IPreferencePropertyAccessor.VISIONKIDS_FTP_PASS, IPreferencePropertyAccessor.VISIONKIDS_FTP_PASS_DEFAULT_VALUE)?: IPreferencePropertyAccessor.VISIONKIDS_FTP_PASS_DEFAULT_VALUE
+                ftpClient.enqueueCommand(FtpCommand("pass", "PASS $pass\r\n"))
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun changeCurrentWorkingDirectory(response: String)
+    {
+        try
+        {
+            if (response.startsWith("230"))
+            {
+                ftpClient.enqueueCommand(FtpCommand("cwd", "CWD /1/DCIM\r\n"))
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun setAsciiTransferMode(response: String)
+    {
+        try
+        {
+            if (response.startsWith("250"))
+            {
+                ftpClient.enqueueCommand(FtpCommand("ascii", "TYPE A\r\n"))
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun setPassiveMode(response: String)
+    {
+        try
+        {
+            if (response.startsWith("200"))
+            {
+                ftpClient.enqueueCommand(FtpCommand("passive", "PASV\r\n"))
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun checkPassivePort(response: String)
+    {
+        try
+        {
+            if (response.startsWith("227"))
+            {
+                ftpClient.decidePassivePort(response)
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+    private fun getFileList(response: String)
+    {
+        try
+        {
+            ftpClient.openPassivePort(response)
+            ftpClient.enqueueCommand(FtpCommand("list", "LIST\r\n"))
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+    private fun checkListCommand(response: String)
+    {
+        try
+        {
+            Log.v(TAG, "RESPONSE: $response")
+            if ((response.startsWith("226"))||((response.startsWith("150"))&&(response.contains("226"))))
+            {
+                ftpClient.enqueueCommand(FtpCommand("quit", "QUIT\r\n"))
+            }
+            else if (response.startsWith("150"))
+            {
+                Log.v(TAG, "RESP. 150")
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun parseFileList(response: String)
+    {
+        try
+        {
+            cameraContentList.clear()
+            val fileList = response.split("\r\n")
+            for (files in fileList)
+            {
+                val fileData = files.split(Regex("\\s+"))
+                if (fileData.size > 8)
+                {
+                    val imageFile = fileData[8]
+                    val imagePath = ""
+                    val imageDate = "${fileData[5]} ${fileData[6]} ${fileData[7]}" // MM DD YYYY
+                    cameraContentList.add(VisionKidsCameraContent(imageFile, imagePath, imageDate))
+                }
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun checkQuitResponse(response: String)
+    {
+        try
+        {
+            Log.v(TAG, "RESPONSE: $response")
+            ftpClient.disconnect()
+
+            // 取得した画像の一覧を応答する
+            callback.onCompleted(cameraContentList)
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    companion object
+    {
+        private val TAG = VisionKidsCameraContentProvider::class.java.simpleName
+    }
+
+}
\ No newline at end of file
index f3be20d..c5635eb 100644 (file)
@@ -1,5 +1,8 @@
 package net.osdn.gokigen.pkremote.camera.vendor.visionkids.wrapper.playback
 
+import android.util.Log
+import androidx.appcompat.app.AppCompatActivity
+import net.osdn.gokigen.pkremote.IInformationReceiver
 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
@@ -7,38 +10,44 @@ import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentCall
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentListCallback
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl
+import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver
 
-class VisionKidsPlaybackControl: IPlaybackControl
+class VisionKidsPlaybackControl(activity: AppCompatActivity, private val provider: ICameraStatusReceiver, private val informationReceiver: IInformationReceiver): IPlaybackControl
 {
+    private val contentProvider = VisionKidsCameraContentProvider(activity)
+
     override fun getRawFileSuffix(): String
     {
         return (".DNG")
     }
 
-    override fun downloadContentList(callback: IDownloadContentListCallback?) {
-        //TODO("Not yet implemented")
+    override fun downloadContentList(callback: IDownloadContentListCallback?)
+    {
+        // 利用箇所なし
     }
 
-    override fun getContentInfo(path: String?, name: String?, callback: IContentInfoCallback?) {
-        //TODO("Not yet implemented")
+    override fun getContentInfo(path: String?, name: String?, callback: IContentInfoCallback?)
+    {
+        Log.v(TAG, "getContentInfo($path, $name)")
     }
 
-    override fun updateCameraFileInfo(info: ICameraFileInfo?) {
-        //TODO("Not yet implemented")
+    override fun updateCameraFileInfo(info: ICameraFileInfo?)
+    {
+        // 利用箇所なし
     }
 
     override fun downloadContentScreennail(
         path: String?,
         callback: IDownloadThumbnailImageCallback?
     ) {
-        //TODO("Not yet implemented")
+        Log.v(TAG, "downloadContentScreennail($path)")
     }
 
     override fun downloadContentThumbnail(
         path: String?,
         callback: IDownloadThumbnailImageCallback?
     ) {
-        //TODO("Not yet implemented")
+        Log.v(TAG, "downloadContentThumbnail($path)")
     }
 
     override fun downloadContent(
@@ -46,19 +55,33 @@ class VisionKidsPlaybackControl: IPlaybackControl
         isSmallSize: Boolean,
         callback: IDownloadContentCallback?
     ) {
-        //TODO("Not yet implemented")
+        Log.v(TAG, "downloadContent($path, $isSmallSize)")
     }
 
-    override fun getCameraContentList(callback: ICameraContentListCallback?) {
-        //TODO("Not yet implemented")
+    override fun getCameraContentList(callback: ICameraContentListCallback)
+    {
+        Log.v(TAG, "getCameraContentList()")
+        try
+        {
+            contentProvider.getContentList(callback)
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
     }
 
-    override fun showPictureStarted() {
-        //TODO("Not yet implemented")
+    override fun showPictureStarted()
+    {
+        Log.v(TAG, "showPictureStarted()")
     }
 
-    override fun showPictureFinished() {
-        //TODO("Not yet implemented")
+    override fun showPictureFinished()
+    {
+        Log.v(TAG, "showPictureFinished()")
     }
-
-}
\ No newline at end of file
+    companion object
+    {
+        private val TAG = VisionKidsPlaybackControl::class.java.simpleName
+    }
+}
index 2c09c3d..a1d4ecf 100644 (file)
@@ -78,6 +78,7 @@
     <string name="dialog_title_connect_failed_nikon">接続失敗(Nikon)</string>
     <string name="dialog_title_connect_failed_olympus">接続失敗(Olympus)</string>
     <string name="dialog_title_connect_failed_theta">接続失敗(Theta)</string>
+    <string name="dialog_title_connect_failed_visionkids">接続失敗(VisionKids)</string>
 
     <string name="dialog_title_button_retry">再接続</string>
     <string name="dialog_title_button_network_settings">WiFi設定</string>
index 0d751a8..1b308e7 100644 (file)
@@ -78,6 +78,7 @@
     <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_connect_failed_theta">Connect failed (Theta)</string>
+    <string name="dialog_title_connect_failed_visionkids">Connect failed (VisionKids)</string>
 
     <string name="dialog_title_button_retry">Retry</string>
     <string name="dialog_title_button_network_settings">WiFi Settings</string>