diff --git a/build.gradle b/build.gradle index 43996148..2631af31 100644 --- a/build.gradle +++ b/build.gradle @@ -26,4 +26,5 @@ dependencies { compile "com.android.support:support-v4:19.0.+" compile "com.android.support:appcompat-v7:19.0.+" compile "org.apache.mina:mina-core:2.0.+" + compile fileTree(dir: 'libs', include: '*.jar') } diff --git a/kdeconnect-android.iml b/kdeconnect-android.iml index 5ba27bb2..2acb8db6 100644 --- a/kdeconnect-android.iml +++ b/kdeconnect-android.iml @@ -25,37 +25,37 @@ - - - - - + + + + + - + - - + + - - + + - - + + @@ -67,7 +67,6 @@ - @@ -77,6 +76,9 @@ + + + diff --git a/libs/bcprov-jdk16-145.jar b/libs/bcprov-jdk16-145.jar new file mode 100644 index 00000000..38685d51 Binary files /dev/null and b/libs/bcprov-jdk16-145.jar differ diff --git a/libs/sshd-core-0.7.0.jar b/libs/sshd-core-0.7.0.jar new file mode 100644 index 00000000..429065a7 Binary files /dev/null and b/libs/sshd-core-0.7.0.jar differ diff --git a/libs/tomcat-apr-5.5.23.jar b/libs/tomcat-apr-5.5.23.jar new file mode 100644 index 00000000..48aed1d5 Binary files /dev/null and b/libs/tomcat-apr-5.5.23.jar differ diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 10352654..1f2a96ba 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -26,6 +26,7 @@ + >asList(new SftpSubsystem.Factory())); + + sshd.setPasswordAuthenticator(passwordAuth); + return true; + } + + @Override + public void onDestroy() { + try { + started = false; + sshd.stop(); + } catch (InterruptedException e) { + + } + } + + public String getLocalIpAddress() { + try { + for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { + NetworkInterface intf = en.nextElement(); + for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { + InetAddress inetAddress = enumIpAddr.nextElement(); + if (!inetAddress.isLoopbackAddress()) { + return inetAddress.getHostAddress().toString(); + } + } + } + } catch (SocketException ex) { + } + return null; + } + + @Override + public boolean onPackageReceived(NetworkPackage np) { + if (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_SFTP)) return false; +// + if (np.getBoolean("startBrowsing")) { + try { + if (!started) { + sshd.start(); + started = true; + } + + NetworkPackage np2 = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_SFTP); + np2.set("ip", getLocalIpAddress()); + np2.set("port", PORT); + np2.set("user", USER); + np2.set("password", PASSWORD); + np2.set("home", Environment.getExternalStorageDirectory().getAbsolutePath()); + device.sendPackage(np2); + return true; + } catch (IOException e) { + e.printStackTrace(); + } + } + return false; + } + + @Override + public AlertDialog getErrorDialog(Context baseContext) { + return null; + } + + @Override + public Button getInterfaceButton(Activity activity) { + return null; + } + + // ======================================= + // Comented to be example of customization od SSHD + // ======================================= + +// static class SecureFileSystemFactory implements FileSystemFactory { +// // +// public SecureFileSystemFactory() { +// } +// // +// @Override +// public FileSystemView createFileSystemView(final Session username) { +// final String userName = username.getUsername(); +// final String home = "/mnt/sdcard/"; +// return new SecureFileSystemView(home, userName, false); +// } +// } + +// static class SecureFileSystemView extends NativeFileSystemView { +// // the first and the last character will always be '/' +// // It is always with respect to the root directory. +// private String currDir = "/"; +// private String rootDir = "/"; +// private String userName; +// private boolean isReadOnly = true; +// private boolean caseInsensitive = false; +// // +// public SecureFileSystemView(final String rootDir, final String userName, final boolean isReadOnly) { +// super(userName); +// this.rootDir = NativeSshFile.normalizeSeparateChar(rootDir); +// this.userName = userName; +// this.isReadOnly = isReadOnly; +// } +// // +// @Override +// public SshFile getFile(final String file) { +// return getFile(currDir, file); +// } +// +// @Override +// public SshFile getFile(final SshFile baseDir, final String file) { +// return getFile(baseDir.getAbsolutePath(), file); +// } +// +// // +// protected SshFile getFile(final String dir, final String file) { +// // get actual file object +// String physicalName = NativeSshFile.getPhysicalName("/", dir, file, caseInsensitive); +// File fileObj = new File(rootDir, physicalName); // chroot +// +// // strip the root directory and return +// String userFileName = physicalName.substring("/".length() - 1); +// return new SecureSshFile(userFileName, fileObj, userName, isReadOnly); +// } +// } +// +// static class SecureSshFile extends NativeSshFile { +// final boolean isReadOnly; +// // +// public SecureSshFile(final String fileName, final File file, final String userName, final boolean isReadOnly) { +// super(fileName, file, userName); +// this.isReadOnly = isReadOnly; +// } +// // +// public boolean isWritable() { +// if (isReadOnly) +// return false; +// return super.isWritable(); +// } +// } +} diff --git a/src/main/res/values-ru/strings.xml b/src/main/res/values-ru/strings.xml index 4591889b..6ed0edcb 100644 --- a/src/main/res/values-ru/strings.xml +++ b/src/main/res/values-ru/strings.xml @@ -4,6 +4,8 @@ Отправлять уведомления о SMS и звонках Состояние батареи Периодически сообщать о состоянии батареи + Доступ по SFTP + Возможность доступа к файлам по SFTP Синхронизация буфера обмена Сделать содержимое буфера обмена общим ДУ для мультимедия diff --git a/src/main/res/values-uk/strings.xml b/src/main/res/values-uk/strings.xml index 05c0e49c..99710e51 100644 --- a/src/main/res/values-uk/strings.xml +++ b/src/main/res/values-uk/strings.xml @@ -4,6 +4,8 @@ Надсилання сповіщень щодо SMS та дзвінків Звіт щодо заряду Періодична інформація щодо стану акумулятора + Доступ по SFTP + Возможность доступа к файлам по SFTP Синхронізація буфера Спільне використання буфера обміну даними Дистанційне керування відтворенням diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 47362219..02a5410f 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -5,6 +5,8 @@ Send notifications for SMS and calls Battery report Periodically report battery status + SFTP access + Possibility to browse filesystem through SFTP Clipboard sync Share the clipboard content Multimedia remote controls