aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml7
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/ConfigurationAccessServerFragment.kt77
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt13
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/ConfigurationAccessService.kt204
-rw-r--r--app/src/main/res/layout/configure_activity.xml14
-rw-r--r--app/src/main/res/layout/configure_tools_configuration_access_fragment.xml86
-rw-r--r--app/src/main/res/values-ru-rRU/strings.xml10
-rw-r--r--app/src/main/res/values/strings.xml10
8 files changed, 2 insertions, 419 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8d71109..827f421 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,9 +26,6 @@
26 <!-- required for VPN service error reporting, since API 33 --> 26 <!-- required for VPN service error reporting, since API 33 -->
27 <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> 27 <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
28 28
29 <!-- needed for the configuration FTP server -->
30 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
31
32 <!-- workaround for broken file permissions on some Android ROMs --> 29 <!-- workaround for broken file permissions on some Android ROMs -->
33 <uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 30 <uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
34 31
@@ -91,10 +88,6 @@
91 </intent-filter> 88 </intent-filter>
92 </service> 89 </service>
93 90
94 <service
95 android:name="org.pacien.tincapp.service.ConfigurationAccessService">
96 </service>
97
98 </application> 91 </application>
99 92
100</manifest> 93</manifest>
diff --git a/app/src/main/java/org/pacien/tincapp/activities/configure/ConfigurationAccessServerFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/configure/ConfigurationAccessServerFragment.kt
deleted file mode 100644
index c90299a..0000000
--- a/app/src/main/java/org/pacien/tincapp/activities/configure/ConfigurationAccessServerFragment.kt
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19package org.pacien.tincapp.activities.configure
20
21import android.content.Intent
22import android.os.Bundle
23import android.view.LayoutInflater
24import android.view.View
25import android.view.ViewGroup
26import androidx.databinding.Observable
27import androidx.databinding.ObservableBoolean
28import org.pacien.tincapp.activities.BaseFragment
29import org.pacien.tincapp.databinding.ConfigureToolsConfigurationAccessFragmentBinding
30import org.pacien.tincapp.service.ConfigurationAccessService
31
32/**
33 * @author pacien
34 */
35class ConfigurationAccessServerFragment : BaseFragment() {
36 private val ftpServerStartListener = object : Observable.OnPropertyChangedCallback() {
37 override fun onPropertyChanged(sender: Observable, propertyId: Int) {
38 binding.ftpEnabled = (sender as ObservableBoolean).get()
39 }
40 }
41
42 private lateinit var binding: ConfigureToolsConfigurationAccessFragmentBinding
43
44 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
45 binding = ConfigureToolsConfigurationAccessFragmentBinding.inflate(inflater, container, false)
46 binding.toggleFtpState = { toggleServer() }
47 setConnectionInfo()
48 return binding.root
49 }
50
51 override fun onResume() {
52 super.onResume()
53 setConnectionInfo()
54 ConfigurationAccessService.runningState.addOnPropertyChangedCallback(ftpServerStartListener)
55 binding.ftpEnabled = ConfigurationAccessService.runningState.get()
56 }
57
58 override fun onPause() {
59 ConfigurationAccessService.runningState.removeOnPropertyChangedCallback(ftpServerStartListener)
60 super.onPause()
61 }
62
63 private fun setConnectionInfo() {
64 binding.ftpUsername = ConfigurationAccessService.getFtpUsername()
65 binding.ftpPassword = ConfigurationAccessService.getFtpPassword()
66 binding.ftpPort = ConfigurationAccessService.getFtpPort()
67 }
68
69 private fun toggleServer() {
70 val targetServiceIntent = Intent(requireContext(), ConfigurationAccessService::class.java)
71
72 if (binding.ftpEnabled)
73 requireContext().stopService(targetServiceIntent)
74 else
75 requireContext().startService(targetServiceIntent)
76 }
77}
diff --git a/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt b/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt
index 5b01a54..d6e21f5 100644
--- a/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt
+++ b/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt
@@ -36,10 +36,7 @@ import org.pacien.tincapp.utils.PendingIntentUtils
36class AppNotificationManager(private val context: Context) { 36class AppNotificationManager(private val context: Context) {
37 companion object { 37 companion object {
38 private const val ERROR_CHANNEL_ID = "org.pacien.tincapp.notification.channels.error" 38 private const val ERROR_CHANNEL_ID = "org.pacien.tincapp.notification.channels.error"
39 private const val CONFIG_ACCESS_CHANNEL_ID = "org.pacien.tincapp.notification.channels.configuration"
40
41 const val ERROR_NOTIFICATION_ID = 0 39 const val ERROR_NOTIFICATION_ID = 0
42 const val CONFIG_ACCESS_NOTIFICATION_ID = 1
43 } 40 }
44 41
45 init { 42 init {
@@ -65,9 +62,6 @@ class AppNotificationManager(private val context: Context) {
65 NotificationManagerCompat.from(context).cancelAll() 62 NotificationManagerCompat.from(context).cancelAll()
66 } 63 }
67 64
68 fun newConfigurationAccessNotificationBuilder() =
69 NotificationCompat.Builder(context, CONFIG_ACCESS_CHANNEL_ID)
70
71 @RequiresApi(Build.VERSION_CODES.O) 65 @RequiresApi(Build.VERSION_CODES.O)
72 private fun registerChannels() { 66 private fun registerChannels() {
73 context.getSystemService(NotificationManager::class.java) 67 context.getSystemService(NotificationManager::class.java)
@@ -78,13 +72,6 @@ class AppNotificationManager(private val context: Context) {
78 NotificationManager.IMPORTANCE_HIGH 72 NotificationManager.IMPORTANCE_HIGH
79 )) 73 ))
80 } 74 }
81 .apply {
82 createNotificationChannel(NotificationChannel(
83 CONFIG_ACCESS_CHANNEL_ID,
84 context.getString(R.string.notification_config_access_channel_name),
85 NotificationManager.IMPORTANCE_MIN
86 ))
87 }
88 } 75 }
89 76
90 private fun NotificationCompat.Builder.setHighPriority() = apply { 77 private fun NotificationCompat.Builder.setHighPriority() = apply {
diff --git a/app/src/main/java/org/pacien/tincapp/service/ConfigurationAccessService.kt b/app/src/main/java/org/pacien/tincapp/service/ConfigurationAccessService.kt
deleted file mode 100644
index 916f19d..0000000
--- a/app/src/main/java/org/pacien/tincapp/service/ConfigurationAccessService.kt
+++ /dev/null
@@ -1,204 +0,0 @@
1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2023 Pacien TRAN-GIRARD
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19package org.pacien.tincapp.service
20
21import android.app.Service
22import android.content.Context
23import android.content.Intent
24import android.os.IBinder
25import androidx.databinding.ObservableBoolean
26import ch.qos.logback.classic.Level
27import ch.qos.logback.classic.Logger
28import org.apache.ftpserver.ConnectionConfigFactory
29import org.apache.ftpserver.DataConnectionConfigurationFactory
30import org.apache.ftpserver.FtpServer
31import org.apache.ftpserver.FtpServerFactory
32import org.apache.ftpserver.ftplet.*