Sub Process_Globals
Dim httpC As HttpClient
' 'BurgerLand' is a fantasy name of a client Company.Change the whole string to your address data
Dim indirizzo As String : indirizzo="http://www.xxxx.xxx/ctrllicence.php?company=BurgerLand&imei="
'[->Release(obfuscated)]
End Sub
Sub Globals
Dim p As PhoneId
Dim deviceID As String
'Dim Label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
'if this file doesn't exists, you need to connect
If File.Exists(File.DirInternal,"checkLic.txt")= False Then
deviceID = p.GetDeviceId
httpC.Initialize("httpC")
registerLicence
Else
'if the controller file exists
Msgbox("Not first app opening: no need to connect again","")
End If
End If
'Activity.LoadLayout("1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub registerLicence
ProgressDialogShow("New installation. Licence validation ...")
Dim req As HttpRequest
req.InitializeGet(indirizzo&deviceID)
httpC.Execute(req,1)
End Sub
Sub httpC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim result,rCompany As String
Dim ctrlTest As Int
Dim JSON As JSONParser
result = Response.GetString("UTF8")
'I remove '[' and ']' from the response received from my server -> array[{jsonObject}]
Dim tmp As String
Dim lungh As Int
tmp=result
lungh= tmp.Length
tmp= tmp.SubString2(1,lungh-1)
result=tmp
'-----------------------------
JSON.Initialize(result)
Dim m As Map
m=JSON.NextObject
ctrlTest=m.Get("installato")
rCompany=m.Get("cliente")
ProgressDialogHide
If ctrlTest>0 Then 'save controller file for not connecting in the future
File.WriteString(File.DirInternal, "checkLic.txt","ok")
'(MsgBox only for demo)
Msgbox("This Phone has "&ctrlTest&" new installation/s activated under "&rCompany&" Company.","")
End If
Response.Release
End Sub
Sub httpC_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
ProgressDialogHide
Log(Reason)
Msgbox("Web connection error. Try later again.","")'and no informations shown about hosting and php names
If Response <> Null Then 'Null=if no web connection, so there's nothing to release.
Response.Release
Activity.Finish
End If
Activity.Finish
End Sub