forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstackbehavior.livecodescript
More file actions
1037 lines (874 loc) · 31.7 KB
/
Copy pathstackbehavior.livecodescript
File metadata and controls
1037 lines (874 loc) · 31.7 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
script "EnvironmentStackBehavior"
################################################################################
local sTest
local sVersion
local sUnlocked
local sDevelopment
local sToken
local sGlobalLicensePath
local sLicensePath
local sToolsPath
local sEnginePath
local sHomePath
local sLogPath
local sRepositoryPath
local sActivateReason
local sActivateError
local sActivateEmail
local sActivatePassword
local sActivateHashedPassword
local sActivateSession
local sActivateChallenge
local sActivateToken
constant kActivationUrl="http://www.runrev.com/activation-community/livecode"
on startup pTest
put pTest into sTest
put the version & "-" & the buildNumber into sVersion
put false into sUnlocked
put false into sDevelopment
put empty into sActivateReason
put empty into sActivateEmail
put empty into sActivatePassword
put empty into sActivateHashedPassword
-- When testing in the IDE we don't do some things that would be annoying...
if not sTest then
-- Set up the stack and such for activation
set the navigationArrows to false
set the allowInterrupts to false
reset cursors
set the loc of me to the screenLoc
end if
configureFonts the short name of me
-- Configure the appropriate paths
switch the platform
case "win32"
set the itemDelimiter to "/"
put the effective filename of this stack into sEnginePath
put item 1 to -2 of sEnginePath into sToolsPath
put specialFolderPath(0x0023) & "/RunRev/Licenses" into sGlobalLicensePath
put specialFolderPath(0x001a) & "/RunRev/Licenses" into sLicensePath
break
case "macos"
set the itemDelimiter to "/"
put the effective filename of this stack into sEnginePath
put item 1 to -3 of sEnginePath & "/Tools" into sToolsPath
put "/Library/Application Support/RunRev/Licenses" into sGlobalLicensePath
put specialFolderPath("cusr") & "/Library/Application Support/RunRev/Licenses" into sLicensePath
break
default
set the itemDelimiter to "/"
put the effective filename of this stack into sEnginePath
put item 1 to -2 of sEnginePath into sToolsPath
put empty into sGlobalLicensePath
put specialFolderPath("home") & "/.runrev/licenses" into sLicensePath
break
end switch
guessRepositoryPath
-- Run things as if the 'REV_TOOLS_PATH' var was set.
if sRepositoryPath is not empty then
if there is a folder (sRepositoryPath & "/ide-svn/Toolset") then
put sRepositoryPath & "/ide-svn" into $REV_TOOLS_PATH
else
put sRepositoryPath & "/ide" into $REV_TOOLS_PATH
end if
end if
-- if $0 is "activate" then
-- performFacelessActivation
-- quit 0
-- else if $0 is "deactivate" then
-- performFacelessDeactivation
-- quit 0
-- end if
if $REV_TOOLS_PATH is not empty then
put $REV_TOOLS_PATH into sToolsPath
put sToolsPath & slash & "environment_log.txt" into sLogPath
put true into sDevelopment
end if
if there is a file (sToolsPath & "/Startup.rev") then
put sToolsPath & "/Startup.rev" into sHomePath
else if there is a file (sToolsPath & "/mchome.mc") then
put sToolsPath & "/mchome.mc" into sHomePath
else if there is a file (sToolsPath & "/Toolset/home.rev") then
put sToolsPath & "/Toolset/home.rev" into sHomePath
else if there is a file (sToolsPath & "/Toolset/home.livecodescript") then
put sToolsPath & "/Toolset/home.livecodescript" into sHomePath
else
put the folder & "/Toolset/home.rev" into sHomePath
end if
log "Engine Path = " & sEnginePath
log "Repository Path = " & sHomePath
log "Tools Path = " & sToolsPath
log "Global License Path = " & sGlobalLicensePath
log "License Path = " & sLicensePath
log "Home Path = " & sHomePath
-- Make sure the licenses folder exists
ensureFolder sLicensePath
-- Now start the licensing process
/*local tActivationDetails, tFirstRun
fetchActivationDetails tActivationDetails
if the result is "not found" then
put true into tFirstRun
else
put false into tFirstRun
if the result is not "found" then
put "automatic" into tActivationDetails["type"]
put empty into tActivationDetails["email"]
put empty into tActivationDetails["password"]
end if
end if
-- Compute the token
put activationLicenseFileForVersion(sVersion) into sToken*/
-- EJB Activation Removal
local tLicense
fetchLicenseForVersion sVersion, tLicense
licenseUnlock tLicense
if firstRun() then
go to card "AccountSignUp"
return empty
else
return sHomePath
end if
/*local tLicense
fetchLicenseForVersion sVersion, tLicense
switch the result
case "found"
-- Attempt to unlock
licenseUnlock tLicense
switch the result
case "licensed"
-- The license we have for this version is valid
if sTest then
answer "Success!"
end if
return sHomePath
default
-- Some other error occurred, so fall through to activation.
put "The license for this version has become corrupted, please activate to continue." into sActivateReason
break
end switch
break
case "not found"
if not tFirstRun then
put "No license found for this version, please activate to continue." into sActivateReason
end if
break
case "invalid"
put "The current license for this version has become corrupted, please activate to continue." into sActivateReason
break
default
break
end switch */
-- If we got to here, something went wrong, so make sure the token is the local
-- one.
/*put empty into sGlobalLicensePath
put activationLicenseFileForVersion(sVersion) into sToken
-- If we have previously saved activation details then what we do now depends on those.
if tActivationDetails is an array then
put tActivationDetails["email"] into sActivateEmail
put empty into sActivatePassword
put hexDecode(tActivationDetails["password"]) into sActivateHashedPassword
end if
go to card "Automatic Activation"
return empty */
end startup
on shutdown
send "revUnloadLibrary" to stack "revLibURL"
set the allowInterrupts to true
if sUnlocked then
return sHomePath
end if
return ""
end shutdown
on log pMessage
if sDevelopment is true and sLogPath is not empty then
open file sLogPath for text append
write pMessage & return to file sLogPath
close file sLogPath
end if
end log
command configureFonts pStack
switch the platform
case "win32"
if word 2 of the systemVersion >= 6 and "Segoe UI" is among the lines of the fontNames then
set the textFont of stack pStack to "Segoe UI"
set the textSize of stack pStack to 12
else if word 2 of the systemVersion >= 5 and "Tahoma" is among the lines of the fontNames then
set the textFont of stack pStack to "Tahoma"
set the textSize of stack pStack to 11
else
set the textFont of stack pStack to "MS Sans Serif"
set the textSize of stack pStack to 10
end if
break
case "linux"
set the textFont of stack pStack to "Helvetica"
set the textSize of stack pStack to 12
break
case "macos"
set the textFont of stack pStack to "Lucida Grande"
set the textSize of stack pStack to 11
break
end switch
end configureFonts
function resolveImageId pImage
return the id of image (pImage & ".png") of card "Resources" of stack "EnvironmentResources"
end resolveImageId
function resolveImageLongId pImage
return the long id of image (pImage & ".png") of card "Resources" of stack "EnvironmentResources"
end resolveImageLongId
######################################################################
/*local sMovingOffset
on mouseDown
put the clickLoc into sMovingOffset
end mouseDown
on mouseUp
put empty into sMovingOffset
end mouseUp
on mouseRelease
put empty into sMovingOffset
end mouseRelease
on mouseMove
if sMovingOffset is not empty then
get the globalLoc of the mouseLoc
set the topLeft of me to item 1 of it - item 1 of sMovingOffset, item 2 of it - item 2 of sMovingOffset
end if
end mouseMove*/
################################################################################
function titleColor
return "#ffffff"
end titleColor
function headingColor
return "#a7a7a7"
end headingColor
function subtitleColor
return "#aaaaaa"
end subtitleColor
function bodyTextDullColor
return "#878787"
end bodyTextDullColor
function livecodeColor
return "#ffffff"
--return "#569e54"
end livecodeColor
function livecodeLightColor
return "#87af65"
end livecodeLightColor
function primaryErrorColor
return "#FF9900"
--return "#f3be26"
end primaryErrorColor
function secondaryErrorColor
return "#f4dd9a"
end secondaryErrorColor
-- Larger font size for input fields and labels and such
function primaryFont
return "Arial"
end primaryFont
function primaryFontSize
return 16
end primaryFontSize
function entryFont
return "Arial"
end entryFont
function entryFontSize
return 18
end entryFontSize
-- Title of dialog
function titleFont
return "Arial"
end titleFont
function titleFontSize
return 38
end titleFontSize
-- Error and info message font
function messageFont
if the platform is "win32" then
return the textFont of this stack
end if
return "Arial"
end messageFont
function messageFontSize
if the platform is "win32" then
return the textSize of this stack
end if
return 12
end messageFontSize
################################################################################
function urlForCreateAccount
return "http://www.runrev.com/links/livecode/activate-signup"
end urlForCreateAccount
command doCreateAccount
launch url urlForCreateAccount()
end doCreateAccount
command doQuit
if there is no stack "Home" then
quit 0
end if
end doQuit
command doContinueToLiveCode
if there is no stack "Home" then
close this stack
exit to top
end if
end doContinueToLiveCode
################################################################################
command clearActivationError
put empty into sActivateError
end clearActivationError
function activationReason
return sActivateReason
end activationReason
function activationError
return sActivateError
end activationError
function activationLogin
local tResult
put sActivateEmail into tResult["email"]
put sActivatePassword into tResult["password"]
put sActivateHashedPassword into tResult["hash"]
return tResult
end activationLogin
command performFacelessActivation
-- Check we can faceless activate
if sGlobalLicensePath is empty then
write "All-user activation not supported on this platform." & return to stdout
quit 1
end if
-- Check we can create/write into the license folder
ensureFolder sGlobalLicensePath
put empty into url ("file:" & sGlobalLicensePath & slash & "access.txt")
if there is no file (sGlobalLicensePath & slash & "access.txt") then
write "Unable to write to all-user license file location - make sure you are running as administrator." & return to stdout
quit 2
end if
delete file (sGlobalLicensePath & slash & "access.txt")
-- Check the required parameters have been supplied
if $1 is not "-file" or $3 is not "-passphrase" or $4 is empty then
write "Usage: <exe> activate -file <licensefile> -passphrase <passphrase>" & return to stdout
quit 3
end if
-- Get the parameters
local tLicenseFile
put $2 into tLicenseFile
if there is no file tLicenseFile then
write "Specified license file could not be found." & return to stdout
quit 4
end if
local tPassphrase
put the sha1Digest of $4 into tPassphrase
local tLicense
put url ("file:" & tLicenseFile) into tLicense
if the result is not empty then
write "Could not load specified license file." & return to stdout
quit 5
end if
-- Actually do the activation
licenseUnlock tLicense, tPassphrase, true
switch the result
case "wrong challenge"
write "Incorrect passphrase for that license." & return to stdout
quit 6
case "wrong version"
write "The provided license was generated for a different version of LiveCode." & return to stdout
quit 7
case "invalid"
write "The provided file is not a valid LiveCode license." & return to stdout
quit 8
case "lapsed"
write "The provided license is no longer valid." & return to stdout
quit 9
case "trial licensed"
case "trial expired"
write "Trial licenses cannot be used with faceless activation." & return to stdout
quit 10
case "prerelease expired"
write "The pre-release you are trying to activate has expired. Please download a newer version." & return to stdout
quit 11
case "prerelease licensed"
case "licensed"
storeLicenseForVersion sVersion, tLicense, tPassphrase, true
break
default
write "An unknown error occurred." & return to stdout
quit 12
end switch
write "All-user activation succeeded for version" && sVersion & return to stdout
end performFacelessActivation
command performFacelessDeactivation
-- Check we can faceless activate
if sGlobalLicensePath is empty then
write "All-user activation not supported on this platform." & return to stdout
quit 1
end if
-- Check we can create/write into the license folder
ensureFolder sGlobalLicensePath
put empty into url ("file:" & sGlobalLicensePath & slash & "access.txt")
if there is no file (sGlobalLicensePath & slash & "access.txt") then
write "Unable to write to all-user license file location - try running as administrator." & return to stdout
quit 2
end if
delete file (sGlobalLicensePath & slash & "access.txt")
-- Actually do the deactivation
local tLicenseFile
put activationLicenseFileForVersion(sVersion, true) into tLicenseFile
if there is no file tLicenseFile then
write "No all-user activation found for this version." & return to stdout
quit 3
end if
delete file tLicenseFile
if the result is not empty then
write "Unable to remove all-user activation file for this version - try running as administrator." & return to stdout
quit 4
end if
write "All-user deactivation succeeded for version" && sVersion & return to stdout
end performFacelessDeactivation
command performAutomaticActivation pEmail, pPassword, pHashedPassword
-- Make sure we have libUrl
if the backScripts is empty then
send "revLoadLibrary" to stack "revLibURL"
end if
-- Clear out the automatic activation state
put empty into sActivateSession
put empty into sActivateChallenge
put empty into sActivateToken
-- Store the last attempted login
put pEmail into sActivateEmail
if pPassword is not empty then
put pPassword into sActivatePassword
put empty into sActivateHashedPassword
else
put empty into sActivatePassword
put pHashedPassword into sActivateHashedPassword
end if
-- Hide the input panel
if there is a group "Input" then
hide group "Input"
end if
-- First do a 'login' request to fetch session and challenge
local tSession, tChallenge
automaticActivationLogin pEmail
if the result is not "success" then
return "error"
end if
-- Build up the token for authentication purposes
local tToken
put hexEncode(the md5Digest of (pHashedPassword & the md5Digest of sActivateChallenge)) into sActivateToken
-- Now do a 'list' request to fetch the licenses the user can choose from
local tListResponse
automaticActivationList
if the result is not "success" then
return "error"
end if
end performAutomaticActivation
private command automaticActivationLogin pEmail
-- Get the version name for the activation request.
local tVersionName
set the itemDelimiter to "-"
put item 1 to -2 of sVersion into tVersionName
set the itemDelimiter to comma
-- Build the request
local tPostData
put "action=login" & return & \
"email=" & pEmail & return & \
"version=" & tVersionName into tPostData
-- Submit the request
local tPostResult, tPostError
enterRemoteOperation
post encodeForPost(tPostData) to kActivationUrl
put the result into tPostError
put it into tPostResult
leaveRemoteOperation
if the result is "cancelled" then
put empty into sActivateError
return "error"
end if
-- If a network error was returned, do the right thing
if tPostError is not empty then
automaticActivationSetPostError tPostError
return "error"
end if
-- Extract the reponse
split tPostResult by return and "="
-- If it was unsuccessful, then do the right thing
if tPostResult["result"] is not "success" then
automaticActivationSetProtocolError tPostResult["result"]
return "error"
end if
-- Act on the response
put tPostResult["session"] into sActivateSession
put hexDecode(tPostResult["challenge"]) into sActivateChallenge
return "success"
end automaticActivationLogin
private command automaticActivationList
-- Get the version name for the activation request.
local tVersionName
set the itemDelimiter to "-"
put item 1 to -2 of sVersion into tVersionName
set the itemDelimiter to comma
-- Build the request
local tPostData
put "action=list" & return & \
"session=" & sActivateSession & return & \
"token=" & sActivateToken & return & \
"version=" & tVersionName into tPostData
-- Submit the request
local tPostResult, tPostError
enterRemoteOperation
post encodeForPost(tPostData) to kActivationUrl
put the result into tPostError
put it into tPostResult
leaveRemoteOperation
if the result is "cancelled" then
put empty into sActivateError
return "error"
end if
-- If a network error was returned, do the right thing
if tPostError is not empty then
automaticActivationSetPostError tPostError
return "error"
end if
-- Extract the reponse
split tPostResult by return and "="
-- If it was unsuccessful, then do the right thing
if tPostResult["result"] is not "success" and tPostResult["result"] is not "nolicenses" then
automaticActivationSetProtocolError tPostResult["result"]
return "error"
end if
-- Act on the response for 'nolicenses'
if tPostResult["result"] is "nolicenses" then
put "An error occurred while processing the request. Please try again." into sActivateError
return "error"
end if
-- Act on the response for success
local tLicense
put tPostResult into tLicense
delete variable tLicense["result"]
combine tLicense with return and "="
licenseUnlock tLicense
switch the result
case "licensed"
-- The license we have for this version is valid
storeActivationDetails
storeLicenseForVersion sVersion, tLicense
if not sTest then
libUrlResetAll
repeat for each line tSocket in the openSockets
close socket tSocket
end repeat
close this stack
else
answer "Success!"
end if
exit to top
default
-- Some other error occurred, so fall through to activation.
automaticActivationSetProtocolError "invalid"
return "error"
break
end switch
end automaticActivationList
private command enterRemoteOperation
show group "Processing"
dispatch "startLoading" to group "Processing"
return empty
end enterRemoteOperation
private command leaveRemoteOperation
hide group "Processing"
dispatch "stopLoading" to group "Processing"
return empty
end leaveRemoteOperation
private command automaticActivationSetPostError pPostError
put "An error occurred while attempting to contact the server. Please try again later." into sActivateError
end automaticActivationSetPosterror
private command automaticActivationSetProtocolError pError
switch pError
case "unknown"
-- license not found
put "The server could not generate the requested license. Please try again." into sActivateError
break
case "unavailable"
-- service unavailable
put "The activation server is unavailable. Please try again later." into sActivateError
break
case "notsupported"
-- version too old
put "Automatic activation is not supported for this version. Please use the manual system." into sActivateError
break
case "timedout"
-- session timedout
put "The session timed-out. Please try again." into sActivateError
break
case "nosession"
-- session vanished
put "The session has lapsed. Please try again." into sActivateError
break
case "nouser"
-- user not found
put "The email you have entered is unrecognised." into sActivateError
break
case "nolicense"
-- some sort of backend mismatch problem
put "An error occurred generating the license key. Please try again." into sActivateError
break
case "disabled"
-- account disabled
put "That account has been disabled. Please contact support@runrev.com if you believe this to be in error." into sActivateError
break
case "wrongpassword"
-- password wrong
put "The password you have entered does not match that email address." into sActivateError
break
case "invalid"
default
-- bad request
put "An error has occurred while contacting the server. Please try again." into sActivateError
break
end switch
end automaticActivationSetProtocolError
private function encodeForPost pData
local tPostData
set the itemDelimiter to "="
repeat for each line tLine in pData
put item 1 of tLine & "=" & the urlEncode of item 2 to -1 of tLine & "&" after tPostData
end repeat
delete the last char of tPostData
return tPostData
end encodeForPost
################################################################################
function activationDetailsFile
return sLicensePath & slash & "livecode-community.lcld"
end activationDetailsFile
function activationLicenseFileForVersion pVersion, pForceGlobal
local tLeaf
replace "." with "_" in pVersion
put "livecode-community-" & pVersion & ".lclk" into tLeaf
local tPath
if sGlobalLicensePath is not empty then
put sGlobalLicensePath & slash & tLeaf into tPath
if there is a file tPath or pForceGlobal then
return tPath
end if
end if
return sLicensePath & slash & tLeaf
end activationLicenseFileForVersion
command fetchActivationDetails @rDetails
local tDetailsFile
put activationDetailsFile() into tDetailsFile
if there is no file tDetailsFile then
return "not found"
end if
local tDetails
put url ("file:" & tDetailsFile) into tDetails
if the first line of tDetails is not "---- LIVECODE ACTIVATION DETAILS (R1) ----" or \
the last line of tDetails is not "---- LIVECODE ACTIVATION DETAILS (R1) ----" then
return "invalid"
end if
delete the first line of tDetails
delete the last line of tDetails
split tDetails by return and "="
put tDetails into rDetails
return "found"
end fetchActivationDetails
command fetchLicenseForVersion pVersion, @rLicense
local tLicenseFile
put activationLicenseFileForVersion(pVersion) into tLicenseFile
if there is no file tLicenseFile then
return "not found"
end if
local tKey
put url ("file:" & tLicenseFile) into tKey
if the first line of tKey is not "---- LIVECODE ACTIVATION KEY (R1) ----" or \
the last line of tKey is not "---- LIVECODE ACTIVATION KEY (R1) ----" then
return "invalid"
end if
put line 2 to -2 of tKey into rLicense
return "found"
end fetchLicenseForVersion
command storeActivationDetails
local tDetails
put "---- LIVECODE ACTIVATION DETAILS (R1) ----" & return into tDetails
put "email=" & sActivateEmail & return after tDetails
if sActivateHashedPassword is not empty then
put "password=" & hexEncode(sActivateHashedPassword) & return after tDetails
else
put "password=" & hexEncode(the md5Digest of sActivatePassword) & return after tDetails
end if
put "---- LIVECODE ACTIVATION DETAILS (R1) ----" after tDetails
put tDetails into url ("file:" & activationDetailsFile())
end storeActivationDetails
command storeLicenseForVersion pVersion, pLicense, pForceGlobal
local tKey
put "---- LIVECODE ACTIVATION KEY (R1) ----" & return into tKey
put pLicense & return after tKey
put "---- LIVECODE ACTIVATION KEY (R1) ----" after tKey
put tKey into url ("file:" & activationLicenseFileForVersion(pVersion, pForceGlobal))
end storeLicenseForVersion
################################################################################
-- This command unlocks the product with the given license.
command licenseUnlock pLicense
local tSettings
split pLicense by return and "="
-- if "name" is not among the lines of the keys of pLicense or \
-- "organization" is not among the lines of the keys of pLicense or \
-- "time" is not among the lines of the keys of pLicense then
-- return "invalid"
-- end if
-- Only include the token if it is not global
if sGlobalLicensePath is not empty and sToken begins with sGlobalLicensePath then
put empty into tSettings["token"]
else
put sToken into tSettings["token"]
end if
put pLicense["name"] into tSettings["name"]
put pLicense["organization"] into tSettings["organization"]
put "community" into tSettings["class"]
put 1 into tSettings["multiplicity"]
put "macosx,windows,linux,ios,android,html5" into tSettings["deploy"]
put "0" into tSettings["scriptlimit"]
put "0" into tSettings["dolimit"]
put "0" into tSettings["usinglimit"]
put "0" into tSettings["insertlimit"]
put true into sUnlocked
do "set the revLicenseLimits to tSettings"
return "licensed"
end licenseUnlock
################################################################################
-- Encode a string of bytes as hexadecimal
function hexEncode pValue
if pValue is empty then
return empty
end if
local tHexValue
get binaryDecode("H" & the length of pValue * 2, pValue, tHexValue)
return tHexValue
end hexEncode
function hexDecode pHexValue
if pHexValue is empty then
return empty
end if
return binaryEncode("H" & the length of pHexValue, pHexValue)
end hexDecode
private command ensureFolder pFolder
set the itemDelimiter to slash
repeat with x = 2 to the number of items of pFolder
if there is no folder item 1 to x of pFolder then
create folder (item 1 to x of pFolder)
end if
end repeat
end ensureFolder
private function utf8ToNative pUtf8
return uniDecode(uniEncode(pUtf8, "UTF8"), "Roman")
end utf8ToNative
################################################################################
on accountCreate pFirstname, pEmail, pPassword
local tEncryptedPassword
if the backScripts is empty then
send "revLoadLibrary" to stack "revLibURL"
end if
show image "loader"
if pPassword is not empty then
put hexEncode(md5digest(pPassword)) into tEncryptedPassword
end if
local tPostData
put "firstname="& urlencode(pFirstname) & "&" & \
"email=" & urlencode(pEmail) & "&" & \
"password=" & urlencode(tEncryptedPassword) into tPostData
local tPostResult, tPostError
post tPostData to "http://livecode.com/livecode/register/"
put the result into tPostError
put it into tPostResult
hide image "loader"
if char 1 of tPostResult is 1 then
put pEmail into sActivateEmail
put tEncryptedPassword into sActivateHashedPassword
storeActivationDetails
accountSignupFinish
else if char 1 of tPostResult is 0 then
set the itemDel to "|"
accountSignupMessage item 2 of tPostResult
else
accountSignupMessage "There was a problem when attempting to create your account. Please try again."
end if
end accountCreate
command accountSignupSkip
local tLicense
fetchLicenseForVersion sVersion, tLicense
licenseUnlock tLicense
close this stack
end accountSignupSkip
command accountSignupFinish
local tLicense
fetchLicenseForVersion sVersion, tLicense
licenseUnlock tLicense
libUrlResetAll
repeat for each line tSocket in the openSockets
close socket tSocket
end repeat
close this stack
end accountSignupFinish
on accountSignupMessage pMessage
put pMessage into field "signup_message" of card "AccountSignup"
show field "signup_message" of card "AccountSignup"
end accountSignupMessage
on accountSignupMessageClose
hide field "signup_message" of card "AccountSignup"
end accountSignupMessageClose
function firstRun
-- Create a blank old style activation file. This tells the updater that
-- this version has been installed.
--
local tLicense
put "name=LiveCode Community User" & return & "organization=" & return & "time=" & the seconds into tLicense
storeLicenseForVersion sVersion, tLicense
local tFirstRunPath, tCommunityLCLD, tCommercialLCLD
put sLicensePath & slash & "livecode-firstrun.lcf" into tFirstRunPath
put sLicensePath & slash & "livecode-community.lcld" into tCommunityLCLD
put sLicensePath & slash & "livecode.lcld" into tCommercialLCLD
if there is a file tFirstRunPath or there is a file tCommunityLCLD or there is a file tCommercialLCLD then
return false
else
put empty into url ("file:" & tFirstRunPath)
return true
end if
end firstRun
command guessRepositoryPath
-- Build and package directories
local tPlatform
local tProcessor
local tBuildDir
local tPackageDir
local tAltPackageDir
switch the platform