diff options
Diffstat (limited to 'app/src/main')
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 | |||
19 | package org.pacien.tincapp.activities.configure | ||
20 | |||
21 | import android.content.Intent | ||
22 | import android.os.Bundle | ||
23 | import android.view.LayoutInflater | ||
24 | import android.view.View | ||
25 | import android.view.ViewGroup | ||
26 | import androidx.databinding.Observable | ||
27 | import androidx.databinding.ObservableBoolean | ||
28 | import org.pacien.tincapp.activities.BaseFragment | ||
29 | import org.pacien.tincapp.databinding.ConfigureToolsConfigurationAccessFragmentBinding | ||
30 | import org.pacien.tincapp.service.ConfigurationAccessService | ||
31 | |||
32 | /** | ||
33 | * @author pacien | ||
34 | */ | ||
35 | class 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 | |||
36 | class AppNotificationManager(private val context: Context) { | 36 | class 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 | |||
19 | package org.pacien.tincapp.service | ||
20 | |||
21 | import android.app.Service | ||
22 | import android.content.Context | ||
23 | import android.content.Intent | ||
24 | import android.os.IBinder | ||
25 | import androidx.databinding.ObservableBoolean | ||
26 | import ch.qos.logback.classic.Level | ||
27 | import ch.qos.logback.classic.Logger | ||
28 | import org.apache.ftpserver.ConnectionConfigFactory | ||
29 | import org.apache.ftpserver.DataConnectionConfigurationFactory | ||
30 | import org.apache.ftpserver.FtpServer | ||
31 | import org.apache.ftpserver.FtpServerFactory | ||
32 | import org.apache.ftpserver.ftplet.* | ||
33 | import org.apache.ftpserver.listener.ListenerFactory | ||
34 | import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication | ||
35 | import org.apache.ftpserver.usermanager.impl.WritePermission |