This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQuestDrive.b4a
156 lines (136 loc) · 4.54 KB
/
QuestDrive.b4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
Build1=Default,de.questdrive.blueforcer
File1=favicon.ico
File2=functions.js
File3=grade-hover.png
File4=icon.png
File5=list_template.html
File6=Main.bal
File7=main_template.html
File8=style.css
File9=top.png
FileGroup1=Default Group
FileGroup2=Default Group
FileGroup3=Default Group
FileGroup4=Default Group
FileGroup5=Default Group
FileGroup6=Default Group
FileGroup7=Default Group
FileGroup8=Default Group
FileGroup9=Default Group
Group=Default Group
IconFile=
Library1=core
Library2=runtimepermissions
Library3=phone
Library4=javaobject
Library5=httpserver
Library6=stringutils
Library7=network
Library8=randomaccessfile
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26"/>~\n~<supports-screens android:largeScreens="true"~\n~ android:normalScreens="true"~\n~ android:smallScreens="true"~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~SetApplicationAttribute(android:value, "vr_only")~\n~SetApplicationAttribute(android:launchMode,"singleTask")~\n~SetApplicationAttribute(android:excludeFromRecents,"true")~\n~'End of default text.~\n~AddActivityText(Main,~\n~<intent-filter>~\n~ <action android:name="android.intent.action.MAIN" />~\n~ <category android:name="android.intent.category.INFO" />~\n~</intent-filter>)~\n~
Module1=Starter
Module2=ServerService
Module3=boot
Module4=FTPServer
Module5=FTPClient
Module6=AsyncStreamsText
Module7=FTPDataConnection
NumberOfFiles=9
NumberOfLibraries=8
NumberOfModules=7
Version=9.3
@EndOfDesignText@
#Region Project Attributes
#ApplicationLabel: QuestDrive
#VersionCode: 3
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private rp As RuntimePermissions
Dim s As ServerSocket
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Label1 As Label
Private btnStop As Button
Private btnStart As Button
Private Label2 As Label
Private CheckBox1 As CheckBox
Private cbxftp As CheckBox
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Main")
rp.CheckAndRequest(rp.PERMISSION_READ_EXTERNAL_STORAGE)
wait for Activity_PermissionResult (permission As String, result As Boolean)
If result Then
End If
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
wait for Activity_PermissionResult (permission As String, result As Boolean)
If result Then
End If
If File.Exists(File.DirDefaultExternal,"autostart") Then
CheckBox1.Checked=True
End If
If File.Exists(File.DirDefaultExternal,"useftp") Then
cbxftp.Checked=True
End If
checkserver
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnStart_Click
ServerService.IsRunning=True
StartService(ServerService)
Label2.Color=Colors.Green
Dim ftpstring As String
If cbxftp.Checked Then
ftpstring=" and FTP on port 51041"
End If
Label2.Text="Server is running at http://" & s.GetMyWifiIP & ":7123" & ftpstring
End Sub
Sub btnStop_Click
ServerService.IsRunning=False
StopService(ServerService)
Label2.Color=Colors.red
Label2.Text="Server is not running"
End Sub
Sub CheckBox1_CheckedChange(Checked As Boolean)
If Checked Then
File.WriteString(File.DirDefaultExternal,"autostart","autostart")
Else
File.Delete(File.DirDefaultExternal,"autostart")
End If
End Sub
Sub cbxftp_CheckedChange(Checked As Boolean)
If Checked Then
File.WriteString(File.DirDefaultExternal,"useftp","useftp")
Else
File.Delete(File.DirDefaultExternal,"useftp")
End If
End Sub
Sub checkserver
If ServerService.isRunning Then
Label2.Color=Colors.Green
Dim ftpstring As String
If cbxftp.Checked Then
ftpstring=" and FTP on port 51041"
End If
Label2.Text="Server is running at http://" & s.GetMyWifiIP & ":7123" & ftpstring
Else
Label2.Color=Colors.red
Label2.Text="Server is not running"
End If
End Sub