Sub Class_Globals
Private mymodule As Object
Private myname As String
Dim daysleft As Int
Dim auth As DbxAuth
Dim Dropbox As DropboxV2
Dim token As String
Dim client As DbxClientV2
Dim config As DbxRequestConfig
Dim dbxFiles As DbxUserFilesRequests
Dim F5S As F5Steg
Dim uniqueid As String
Dim job As HttpJob
End Sub
Public Sub Initialize(Parent As Activity, Module As Object, Eventname As String)
mymodule = Module
myname = Eventname
trialcheck
End Sub
Sub trialcheck
File.Copy(File.DirAssets, "tresor.jpg", File.DirInternalCache, "tresor.jpg")
F5S.ExtractToArray(File.DirInternalCache & "/tresor.jpg", "dbopen")
End Sub
Sub dbopen_ArrayExtracted(SecretMessage() As Byte)
Dim PlainText As String = BytesToString(SecretMessage, 0, SecretMessage.Length, "UTF-8")
token = PlainText
uniqueid = GetDeviceId
If File.Exists(File.DirInternal, uniqueid) = False Then
ToastMessageShow("Please wait, check internet connection", False)
job.Initialize("Job1", Me)
job.Download("http://www.google.com")
Else
Dim ts As String
If File.Exists(File.DirInternal, "lastuse.ini") Then
ts = File.ReadString(File.DirInternal, "lastuse.ini")
If DateTime.Now < ts Then
' Date manipulation
File.writeString(File.DirInternal, uniqueid, encrypt("973897200000")) ' first install: 11/11/2000 (manipulation)
Main.proversion = False
CallSub2(mymodule, myname & "_Result", 0)
Return
End If
End If
ts = File.ReadString(File.DirInternal, uniqueid)
ts = decrypt(ts)
If ts = "973897200000" Then
' pro version expiried
Main.proversion = False
CallSub2(mymodule, myname & "_Result", 0)
Else If DateTime.Now > ts Then
Dim per As Period = DateUtils.PeriodBetweenindays(ts, DateTime.Now)
If per.days <= Main.trialperiod Then
Dim daysleft As Int = Main.trialperiod - per.days
Main.proversion = True
CallSub2(mymodule, myname & "_Result", daysleft)
Return
Else
File.writeString(File.DirInternal, uniqueid, encrypt("973897200000")) ' first install: 11/11/2000 (manipulation)
Main.proversion = False
CallSub2(mymodule, myname & "_Result", 0)
End If
Else
' Date manipulation
File.writeString(File.DirInternal, uniqueid, encrypt("973897200000")) ' first install: 11/11/2000 (manipulation)
Main.proversion = False
CallSub2(mymodule, myname & "_Result", 0)
End If
End If
End Sub
Sub JobDone(jobx As HttpJob)
If jobx.JobName="Job1" And job.Success=False Then
job.Release
Main.proversion = False
ToastMessageShow("Test time can only be activated when the internet connection is active", True)
CallSubDelayed2(mymodule, myname & "_Result", 0)
Else
job.Release
Sleep(2000)
check
End If
End Sub
Sub check
config.Initialize("",token,"","", 5)
Dim dbxhost As DbxHost
dbxhost.Initialize
client.Initialize("Dropbox", config, token, dbxhost)
dbxFiles = client.files
dbxFiles.setEventname("dbxFiles")
Dropbox.Initialize("")
auth.Initialize(token)
dbxFiles.search("",uniqueid,"FILENAME", 2, 0)
End Sub
Sub dbxFiles_Search(results As List)
Dim foundit As Int = 0
If results.Size > 0 Then
For i = 0 To results.Size - 1
Dim match As Map = results.Get(i)
Dim meta As Metadata = match.Get("Metadata")
If meta.Name = uniqueid Then
foundit = 1
End If
Next
End If
If foundit = 0 Then
' create a file and upload it
File.WriteString(File.DirInternal, uniqueid, encrypt(DateTime.now))
dbxFiles.upload(File.DirInternal, uniqueid, "/" & uniqueid, False, False)
Else
' download the file
dbxFiles.download("/" & uniqueid, File.DirInternal, uniqueid)
End If
End Sub
Sub dbxFiles_UploadFinished(success As Boolean, meta As FileMetadata, sessionId As String)
If success = False Then
ToastMessageShow("Upload error for trial check", True)
' Log(LastException.Message)
Main.proversion = False
daysleft = 0
Else
Main.proversion = True
daysleft = Main.trialperiod
End If
CallSub2(mymodule, myname & "_Result", daysleft)
End Sub
Sub dbxFiles_DownloadFinished(success As Boolean, meta As FileMetadata, error As String)
If success = False Then
ToastMessageShow("Download error for trial check", True)
' Log(LastException.Message)
Main.proversion = False
CallSub2(mymodule, myname & "_Result", 0)
Return
Else
Dim ts As String = File.ReadString(File.DirInternal, uniqueid)
ts = decrypt(ts)
If DateTime.Now > ts Then
Dim per As Period = DateUtils.PeriodBetweenindays(ts, DateTime.Now)
If per.days <= Main.trialperiod Then
daysleft = Main.trialperiod - per.days
Main.proversion = True
CallSub2(mymodule, myname & "_Result", daysleft)
Return
Else
File.writeString(File.DirInternal, uniqueid, encrypt("973897200000")) ' first install: 11/11/2000 (manipulation)
Main.proversion = False
CallSub2(mymodule, myname & "_Result", 0)
End If
Else
Main.proversion = False
CallSub2(mymodule, myname & "_Result", 0)
End If
End If
End Sub
Sub GetDeviceId As String
Dim p As Phone
Dim r As Reflector
Dim id As String
id = p.GetSettings("android_id") & r.GetStaticField("android.os.Build", "SERIAL")
Return id
End Sub
Sub encrypt(tstr As String) As String
Dim ztxt As String
Dim checksum As Int
ztxt = ""
checksum = 0
For i = tstr.Length - 1 To 0 Step - 1
ztxt = ztxt & tstr.SubString2(i, i + 1)
checksum = checksum + tstr.SubString2(i, i + 1)
Next
' Manipulate checksum
checksum = checksum + ztxt.SubString2(0, 3)
ztxt = ztxt & "." & checksum
Return ztxt
End Sub
Sub decrypt(tstr As String) As String
Dim ztxt As String
Dim digit, checksum, checksumorg As Int
Try
digit = tstr.IndexOf(".")
ztxt = tstr.SubString(digit + 1)
checksum = ztxt
' Remanipulate checksum
checksum = checksum - tstr.SubString2(0, 3)
ztxt = ""
checksumorg = 0
tstr = tstr.SubString2(0, digit)
For i = tstr.Length - 1 To 0 Step - 1
ztxt = ztxt & tstr.SubString2(i, i + 1)
checksumorg = checksumorg + tstr.SubString2(i, i + 1)
Next
If checksum = checksumorg Then
Return ztxt
Else
Return "973897200000" ' first install: 11/11/2000 (manipulation)
End If
Catch
Return "973897200000" ' first install: 11/11/2000 (manipulation)
End Try
End Sub