-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI.bas
More file actions
3061 lines (2743 loc) · 106 KB
/
API.bas
File metadata and controls
3061 lines (2743 loc) · 106 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
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=StaticCode
Version=6.77
@EndOfDesignText@
'Google weather API: http://www.google.com/ig/api?weather=L8L%206V6
'IP http://api.hostip.info/get_html.php
'http://ipinfodb.com/ip_locator.php?ip=70.52.165.17
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim dURL As String ,Title As String ,FileLoaded As String ,BaseHref As String , aHREF As String ,phone1 As Phone
Type HTMLvalue(Key As String, Value As String)
Type HTMLtag(Level As Int, TagName As String, Node As String, Values As List)
Type APIKeyboard(Text As String, SelStart As Int, SelLength As Int, Shift As Boolean,CapsLock As Boolean )
Type IPaddress( Octets(4) As Int , Port As Int, SelectedOctet As Int )
Dim debugMode As Boolean, HasChecked As Boolean , ascA As Int, ascZ As Int: ascA = Asc("A"): ascZ= Asc("Z")
Dim BUTTON_A As Int, BUTTON_B As Int, BUTTON_C As Int, BUTTON_X As Int, BUTTON_Y As Int, BUTTON_Z As Int, BUTTON_L1 As Int, BUTTON_R1 As Int, BUTTON_L2 As Int, BUTTON_R2 As Int
Dim BUTTON_SELECT As Int, BUTTON_START As Int, BUTTON_MODE As Int, BUTTON_L3 As Int, BUTTON_R3 As Int ':BUTTON_MODE=316:BUTTON_L3=317:BUTTON_R3=318
'BUTTON_A= 304 :BUTTON_B=305:BUTTON_C=306:BUTTON_X = 307:BUTTON_Y=308:BUTTON_Z=309:BUTTON_L1 =310:BUTTON_R1=311:BUTTON_L2=312:BUTTON_R2=313:BUTTON_SELECT=314:BUTTON_START=315
BUTTON_A=96: BUTTON_B=97:BUTTON_C=98:BUTTON_X=99:BUTTON_Y=100:BUTTON_Z=101:BUTTON_L1=102:BUTTON_R1=103:BUTTON_L2=104:BUTTON_R2=105:BUTTON_L3=106:BUTTON_R3=107
BUTTON_START=108:BUTTON_SELECT=109:BUTTON_MODE=110
Dim DIRECTORY_MUSIC As Int, DIRECTORY_PICTURES As Int, DIRECTORY_RINGTONES As Int, DIRECTORY_ALARMS As Int,DIRECTORY_DCIM As Int,DIRECTORY_DOWNLOADS As Int,DIRECTORY_MOVIES As Int, DIRECTORY_NOTIFICATIONS As Int, DIRECTORY_PODCASTS As Int
DIRECTORY_MUSIC=7:DIRECTORY_RINGTONES=1:DIRECTORY_ALARMS=2:DIRECTORY_DCIM=4:DIRECTORY_DOWNLOADS=5:DIRECTORY_MOVIES=6:DIRECTORY_NOTIFICATIONS=3:DIRECTORY_PODCASTS=8
Dim YourName As String ,UnreadThreads As Int , vbQuote As String = Chr(34)'PhoneNumbers As Map ,
Dim DebugStr As StringBuilder,UsePebble As Boolean
Private cr As ContentResolver, dataUri As Uri
Public phoneTypes As List, mailTypes As List 'for phone number label lookup
Type Country(Name As String, Code As Int)
Dim Countries As List ,AltMethod As Boolean ',ProxyInit As Boolean
Dim CU As ContactsUtils ,IgnoreNew As Boolean , BlockLollipop As Int = 21
End Sub
Sub SetMargin(Target As Object, Value As Int)
Dim refl As Reflector, args(4) As Object, types(4) As String
refl.Target = Target
args(0) = Value ' left
args(1) = Value ' top
args(2) = Value ' right
args(3) = Value ' bottom
types(0) = "java.lang.int"
types(1) = "java.lang.int"
types(2) = "java.lang.int"
types(3) = "java.lang.int"
refl.RunMethod4("setPadding", args, types)
End Sub
Sub ProximityState(Enabled As Boolean, FromWhat As String)
'CallSub3(Main, "ProximityState", Enabled, FromWhat)
End Sub
Sub DeleteSMScache(Delete As Boolean) As Boolean
Dim Dir As String = File.Combine(LCAR.DirDefaultExternal, "HTML"), Filename As String = "sms.html"
If File.Exists(Dir,Filename) Then
If Delete Then' File.Delete(Dir,Filename)
MakeHTML2("SMS LOG DELETED FOR YOUR PROTECTION. PLEASE RELOAD IT IF YOU WANT TO VIEW IT AGAIN", Dir,Filename)
End If
Return True
End If
End Sub
Sub SendPebbleConnected(State As Boolean)
Dim P As Phone, I As Intent
If Not(State) And Not(STimer.FwdPebble) Then Return
I.Initialize("com.getpebble.action.PEBBLE_" & IIF(State, "", "DIS") & "CONNECTED", "")
I.PutExtra("address", "00-B0-D0-86-BB-F7")
P.SendBroadcastIntent(I)
End Sub
Sub Broadcast(Action As String, Value As Object)
Dim P As Phone, I As Intent
I.Initialize("com.omnicorp.lcarui", "")
I.PutExtra("Action", Action)
I.PutExtra("Value", Value)
P.SendBroadcastIntent(I)
End Sub
Sub SetScreenBrightness(Value As Float)
'debug("SetScreenBrightness: " & Value)
CallSub2(Main, "ScreenBrightness", Value)
'debug(GetScreenBrightness)
'phone1.SetScreenBrightness(Value)
End Sub
Sub GetScreenBrightness As Float
Return phone1.GetSettings("screen_brightness")/255
End Sub
Sub Deltree(Directory As String, Recursive As Boolean)
Dim temp As Int, Files As List ,Size As Int
Try
Files = File.ListFiles(Directory)
Size=Files.Size
For temp = 0 To Files.Size-1 'To 0 Step -1
If File.IsDirectory(Directory, Files.Get(temp)) Then
If Recursive Then
Deltree(File.Combine(Directory, Files.Get(temp)), True)
Size=Size-1
End If
Else
File.Delete(Directory, Files.Get(temp))
Size=Size-1
End If
Next
If Size=0 Then File.Delete(GetDir(Directory), GetFile(Directory))
Catch
End Try
End Sub
Sub SetupCountries
If Not(Countries.IsInitialized) Then
Countries.Initialize
MakeCountry("American Samoa", 1684)
MakeCountry("Anguilla", 1264)
MakeCountry("Antigua and Barbuda", 1268)
MakeCountry("Bahamas", 1242)
MakeCountry("Barbados", 1246)
MakeCountry("Bermuda", 1441)
MakeCountry("British Virgin Islands", 1284)
MakeCountry("Cayman Islands", 1345)
MakeCountry("Dominica", 1767)
MakeCountry("Dominican Republic", 1809)
MakeCountry("Grenada", 1473)
MakeCountry("Guam", 1671)
MakeCountry("Jamaica", 1876)
MakeCountry("Montserrat", 1664)
MakeCountry("Northern Mariana Islands", 1670)
MakeCountry("Saint Kitts and Nevis", 1869)
MakeCountry("Saint Lucia", 1758)
MakeCountry("Saint Martin", 1599)
MakeCountry("Saint Vincent and the Grenadines", 1784)
MakeCountry("Trinidad and Tobago", 1868)
MakeCountry("Turks and Caicos Islands", 1649)
MakeCountry("US Virgin Islands", 1340)
'MakeCountry("North America", 1)
End If
End Sub
Sub MakeCountry(Name As String, Code As Int)
Dim temp As Country
temp.Initialize
temp.Name=Name
temp.Code=Code
Countries.Add(temp)
End Sub
Sub GetCountry(PhoneNumber As String) As Int
Dim temp As Int ,tempcountry As Country,tempstr As String
If Left(PhoneNumber,1)="+" Then
SetupCountries
PhoneNumber = Right(PhoneNumber, PhoneNumber.Length-1)
For temp = 0 To Countries.Size-1
tempcountry= Countries.Get(temp)
tempstr=tempcountry.Code
If PhoneNumber.Length>=tempstr.Length Then
If Left(PhoneNumber, tempstr.Length) = tempstr Then Return temp
End If
Next
End If
Return -1
End Sub
Sub IsCountryBlocked(PhoneNumber As String, AllowedCountry As String) As Boolean
Dim temp As Int, tempcountry As Country
If Left(PhoneNumber,1)="+" AND AllowedCountry <> "0" AND AllowedCountry.Length>0 AND AllowedCountry <> "-1" Then
If AllowedCountry = "1" Then
If GetCountry(PhoneNumber)>-1 Then Return True
If Mid(PhoneNumber,1,1) <> "1" Then Return True
Else
PhoneNumber = Left( Right(PhoneNumber, PhoneNumber.Length-1), AllowedCountry.Length)
If PhoneNumber <> AllowedCountry Then Return True
End If
End If
Return False
End Sub
Sub DebugLog(Text As String)As Boolean
If debugMode Then
Dim Output As OutputStream = File.OpenOutput(LCAR.DirDefaultExternal, "log.txt", True), ST As ByteConverter
Log("DEBUG: " & Text)
Text= DateTime.Time(DateTime.Now) & ": " & Text & CRLF
Output.WriteBytes( ST.StringToBytes(Text, "UTF8"), 0, Text.Length)
Output.Close
End If
End Sub
Sub IsScreenLocked As Boolean
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "keyguard", "java.lang.String")
Return r.RunMethod("inKeyguardRestrictedInputMode")
End Sub
Sub IsScreenOn As Boolean
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "power", "java.lang.String")
Return r.RunMethod("isScreenOn")
End Sub
Sub WakeUp
Dim temp As Boolean = IsScreenOn
Log("Is screen on? " & temp)
If Not(temp) Then
Dim P As PhoneWakeState
P.ReleaseKeepAlive
P.KeepAlive(True)
End If
'p.PartialLock
'StartActivity(Main) ' start the activity
'SetShowWhenLocked(True)
'debug("Screen should be on")
End Sub
Sub GotoSleep
Dim P As PhoneWakeState
'SetShowWhenLocked(False)
If Not(IsInIDE) Then
P.ReleaseKeepAlive
P.ReleasePartialLock
ProximityState(False,"Gotosleep")
End If
'STimer.ProximityEnabled=False
'debug("Screen should be off")
End Sub
Sub SetShowWhenLocked(State As Boolean)
'CallSubDelayed2(Main, "setshowwhenlocked", State)
End Sub
Sub Now As String
Return DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now)
End Sub
Sub ContactName(tempcontact As Contact)As String
If tempcontact.DisplayName = Null Then
Return "Unknown Caller"
Else
Return tempcontact.DisplayName
End If
End Sub
Sub LoadSettings(BG As Canvas, Save As Boolean) As Boolean
Dim tempdate As Long ,temp As Boolean
If Not(Save) Then
'API.Debug("Loading settings")
LCAR.SetupLCARcolors(Null)
' Settings.Initialize
' If File.ExternalReadable = True Then
' If File.Exists(File.DirInternal, "settings.ini") Then Settings = File.ReadMap (File.DirInternal , "settings.ini")
' End If
'Msgbox(File.DirRootExternal, "This is where error.txt will be")
'Debug("SD card directory=" & LCAR.DirDefaultExternal)
If LCAR.DirDefaultExternal.Length=0 Then
Log("DIR WAS EMPTY")
Return False
End If
'API.Debug("DirDefaultExternal succeeded")
Main.Settings = LoadMap(LCAR.DirDefaultExternal, "settings.ini")'LastLoaded=DateTime.Now
'API.Debug("Settings load succeeded")
'Debug("Settings loaded=" & Settings.IsInitialized)
If Not(Main.Settings.IsInitialized ) Then
Log("SETTINGS MISSING")
Return False
End If
If File.Exists(File.DirInternal, "settings.ini") Then
Main.Settings2 = LoadMap(File.DirInternal, "settings.ini")
Else
Main.Settings2.Initialize
End If
'API.Debug("settings 2 loaded")
' tempdate= Settings.Getdefault("FirstRun", 0)
' tempdate = (DateTime.Now - tempdate) / DateTime.TicksPerMinute
' If Not (tempdate>15) Then Return False
End If
'lcarseffects.ClearGPScoordinates(Settings)
'DOS=1
'API.Debug("first group of settings")
LCAR.AntiAliasing = HandleSetting("AntiAliasing",LCAR.AntiAliasing,True, Save)
LCAR.Volume(HandleSetting("Volume", LCAR.cVol, 100, Save), False)
LCAR.SmoothScrolling= HandleSetting("SmoothScrolling", LCAR.SmoothScrolling, False, Save)
'LCAR.Mute = HandleSetting("Mute",LCAR.Mute,False, Save)
Main.BackToQuit= True'HandleSetting("BackToQuit",BackToQuit,False, Save)
LCAR.Zoom = HandleSetting("Zoom", LCAR.Zoom,1,Save)
LCAR.LOD = HandleSetting("LOD",LCAR.LOD, True, Save)
Main.Keytones=HandleSetting("Keytones", Main.Keytones, True,Save)
Main.KeyToneIndex=HandleSetting("KeyToneIndex",Main.KeyToneIndex, 1,Save)
'lcarseffects.NAVSTARS = HandleSetting("NAVSTARS",lcarseffects.NAVSTARS, False, Save)
LCAR.SmallScreen = HandleSetting("SmallScreen", LCAR.SmallScreen, False, Save)
Main.SpeakName = Main.Settings.GetDefault("SpeakName", False)
LCAR.CrazyRez = HandleSetting("HIRES", LCAR.CrazyRez, 0,Save)
Main.CallsAnswered = HandleSetting("AnswerMade", Main.CallsAnswered, 0, Save)
Main.AutoTurnOff = HandleSetting("AutoTurnOff", Main.AutoTurnOff, 60, Save)
If Not(IsPackageInstalled("com.getpebble.android")) Then
SendPebbleConnected(True)
STimer.FwdPebble = Main.Settings.GetDefault("FwdPebble", False)
End If
'API.Debug("second group of settings")
BaseHref = HandleSetting("BaseHREF", BaseHref, "http://en.memory-alpha.org/", Save)
Main.Screenshots=False'HandleSetting("Screenshots", Screenshots, True, Save)
'LCAR.SmoothScrolling= False' HandleSetting("SmoothScrolling", LCAR.SmoothScrolling, False, Save)
'api.Title = HandleSetting("Title", api.Title, "", Save)
'API.Debug("third group")
LCAR.HasHardwareKeyboard= HandleSetting("HasHardwareKeyboard",LCAR.HasHardwareKeyboard,False, Save)
LCAR.Fontfactor=HandleSetting("Fontfactor",LCAR.Fontfactor, 50, Save)
'LCAR.RumbleEnabled=HandleSetting("Rumble",LCAR.RumbleEnabled, True, Save)
LCAR.RumbleUnit = HandleSetting("RumbleUnit", LCAR.RumbleUnit, IIF(HandleSetting("Rumble",True, True, False), 75,0) , Save)
LCAR.LessRandom= HandleSetting("LessRandom", LCAR.LessRandom, False, Save)
UsePebble= HandleSetting("UsePebble", UsePebble, False, Save)
Main.LastVersion= HandleSetting("LastVersion", Main.LastVersion, "", Save)
IgnoreNew = HandleSetting("IgnoreNew", IgnoreNew, False, Save)
'if not save then HasShown=HandleSetting("HasShown", HasShown, False, false)
'API.Debug("fourth group")
'debugMode= HandleSetting("debugMode", debugMode, False, Save)
Main.Password= HandleSetting("Password", Main.Password, "", Save)
Main.Starshipname= HandleSetting("Starshipname", Main.Starshipname, "UNNAMED", Save)
Main.StarshipID = HandleSetting("StarshipID", Main.StarshipID, "", Save)
Main.UID=HandleSetting("UID",Main.UID, "",Save)
If Main.UID.Length=0 Then
Main.UID=GetUniqueKey(True)
Main.Settings.Put("UID", Main.UID)
End If
YourName=HandleSetting("YourName", YourName, "UNNAMED", Save)
STimer.AnswerCalls = Main.Settings.GetDefault("AnswerCalls", False)
If APIlevel >= BlockLollipop And BlockLollipop>0 Then STimer.AnswerCalls = False
STimer.AllowedCountry = Main.Settings.GetDefault("BlockCountry", "0")
AltMethod = Main.Settings.GetDefault("AltMethod", False)
If Save Then
If Main.Settings2.IsInitialized Then File.WriteMap(File.DirInternal, "settings.ini", Main.Settings2)
Else
'API.Debug("fifth group")
STimer.MaxPeriod = Main.Settings.GetDefault("EMAILperiod", 15)
'If Not(STimer.IncomingIsInitialized) OR Not(STimer.OutGoingIsInitialized ) Then
temp=LoadEmailSettings(Main.settings)
If BG <> Null And LCAR.ScreenIsOn Then
If Not(temp) Then LCAR.ToastMessage(BG, "YOUR EMAIL IS NOT SET UP", 2)
'API.Title = "PRESS SEARCH BUTTON OR TOP LEFT LCARS TO BEGIN"
End If
LCAR.LoadLCARSize(BG)
Main.LastLoaded=DateTime.Now
End If
'API.Debug("done")
Return True
End Sub
Sub PasswordText(Text As String, Character As String, MaxLen As Int) As String
Dim temp As Int , tempstr As StringBuilder ,Length As Int
tempstr.Initialize
If MaxLen>0 And MaxLen< Text.Length Then Length = MaxLen Else Length = Text.Length
For temp = 1 To Length
tempstr.Append(Character)
Next
Return tempstr.ToString
End Sub
Sub InitOutGoing(TheServer As String, Port As Int, Username As String, YourPassword As String, SenderName As String, UseSSL As Boolean)As Boolean
Dim ret As Boolean
If TheServer.EqualsIgnoreCase("gmail") Then
TheServer = "smtp.gmail.com"
If Not(Username.Contains("@")) Then Username= Username & "@gmail.com"
Port=465
InitIncoming("pop.gmail.com", 995,Username,YourPassword,True)
ret = True
End If
STimer.OutGoing.Initialize(TheServer, Port, Username, YourPassword, "OutGoing")
STimer.OutGoing.UseSSL = TheServer.EqualsIgnoreCase("smtp.gmail.com") OR UseSSL
STimer.OutGoing.Sender = SenderName
STimer.OutGoingIsInitialized=True
'Msgbox( TheServer & CRLF & Port & CRLF & Username & CRLF & YourPassword & CRLF & SenderName, "server,port,user,pass,name")
LCAR.ToastMessage(LCARSeffects2.TempCanvas, "SMTP: " & TheServer & ":" & Port & IIF(UseSSL, "+SSL","") & CRLF & "USERNAME: " & Username & CRLF & "PASSWORD: " & PasswordText(YourPassword,"*",0),3)
Return ret
End Sub
Sub InitIncoming(TheServer As String, Port As Int, Username As String, YourPassword As String,UseSSL As Boolean )
If TheServer.EqualsIgnoreCase("gmail") Then
TheServer = "pop.gmail.com"
If Not(Username.Contains("@")) Then Username= Username & "@gmail.com"
Port=995
End If
STimer.Incoming.Initialize(TheServer, Port, Username, YourPassword, "Incoming")
STimer.Incoming.UseSSL =TheServer.EqualsIgnoreCase("pop.gmail.com") OR UseSSL
STimer.IncomingIsInitialized=True
'ZRLHPFVRMHPGHOIL
'Log(IIF(STimer.Incoming.UseSSL, "SSL ", "") & "POP: " & TheServer & CRLF & ":" & Port & CRLF & "USERNAME: " & Username & CRLF & "PASSWORD: " & YourPassword)
LCAR.ToastMessage(LCARSeffects2.TempCanvas, "POP: " & TheServer & ":" & Port & IIF(UseSSL, "+SSL","") & CRLF & "USERNAME: " & Username & CRLF & "PASSWORD: " & PasswordText(YourPassword,"*",0),3)
'Msgbox( TheServer & CRLF & Port & CRLF & Username & CRLF & YourPassword, "server,port,user,pass")
End Sub
Sub LoadEmailSettings(Settings As Map) As Boolean
Dim username As String ,Password As String
STimer.ForwardMissedCalls = Settings.GetDefault("EMAILmissed",False)
STimer.ForwardSMS = Settings.GetDefault("EMAILsms",False)
STimer.MaxMessages = Settings.GetDefault("EMAILmessages",15)
STimer.MaxPeriod =Settings.GetDefault("EMAILperiod",15)
STimer.MaxMessageSize = Settings.GetDefault("EMAILsize",100) * 1024
MailParser.TheKey = MailParser.GetEncryptionKey(False)
username = Settings.GetDefault("EMAILaddress", "")
If Not(username.Contains("@")) AND username.Length>0 Then username= username & "@gmail.com"
STimer.EmailAddress = username
STimer.NeedsChecking=True
If Settings.ContainsKey("EMAILuser") AND Settings.ContainsKey("EMAILencrypted") Then
username=Settings.GetDefault("EMAILuser","gmail")
Password= MailParser.CODEC(Settings.Get("EMAILencrypted"), False, MailParser.GetEncryptionKey(False))
If Not(username.Contains("@")) Then
username = username & "@gmail.com"
STimer.EmailAddress=username
End If
If Not(InitOutGoing( Settings.GetDefault("SMTPserver","gmail"), Settings.GetDefault("SMTPport", 465),username, Password, GetUserName(0), Settings.GetDefault("EMAILssl", False) )) Then
InitIncoming(Settings.GetDefault("POP3server","gmail"), Settings.GetDefault("POP3port", 995),username, Password, Settings.GetDefault("EMAILssl", False) )
End If
If STimer.EmailAddress.Length=0 Then STimer.EmailAddress=username
Return True
End If
End Sub
Sub HandleSetting(VariableName As String, CurrentValue As Object , DefaultValue As Object, Save As Boolean )As Object
Dim tempstr As String
If Save Then
Main.Settings.Put(VariableName, CurrentValue)
Return CurrentValue
Else
tempstr=Main.Settings.GetDefault(VariableName,DefaultValue)
Select Case tempstr.ToLowerCase
Case "":Return DefaultValue
Case "true": Return True
Case "false": Return False
Case Else: Return tempstr
End Select
End If
End Sub
Sub GetBmpFromDrawable(D As Object) As Bitmap
Dim bmp As Bitmap
bmp.InitializeMutable(48dip,48dip)
Dim cnv As Canvas
Dim dr As Rect
dr.Initialize(0,0,48dip,48dip)
cnv.Initialize2(bmp)
cnv.DrawDrawable(D,dr)
Return cnv.Bitmap
End Sub
Sub GetPhoneVolume As Int
Dim P As Phone
Select Case P.GetRingerMode
Case P.RINGER_NORMAL: Return P.GetVolume( P.VOLUME_RING )
Case P.RINGER_SILENT: Return 0
Case P.RINGER_VIBRATE: Return -1
End Select
End Sub
Sub GetMonth(Month As Int, LongForm As Boolean) As String
Dim text() As String = Array As String("JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER")
If LongForm Then
Return text(Month)
Else
Return Left(text(Month),3)
End If
End Sub
Sub GetDuration(Seconds As Int) As String
Dim tempstr As StringBuilder ,temp As Long
tempstr.Initialize
Seconds = DurTest(Seconds, tempstr, 3600, "HRS")
Seconds = DurTest(Seconds, tempstr, 60, "MIN")
Seconds = DurTest(Seconds, tempstr, 1, "SEC")
If tempstr.Length=0 Then Return "0 SEC"
Return tempstr.ToString
End Sub
Sub DurTest(TimeDate As Long, tempstr As StringBuilder, Ticks As Int, Text As String) As Int
Dim temp As Int
If TimeDate>= Ticks Then
temp = Floor(TimeDate/Ticks)
'Log(temp)
TimeDate = TimeDate Mod Ticks
If temp = 1 Then Text = Text.Replace("S","")
tempstr.Append(IIF(tempstr.Length=0, "", ", ") & temp & " " & Text)
End If
Return TimeDate
End Sub
Sub HowLongAgo(TimeDate As Long) As String
Dim Diff As Long,Text As String
Diff = DateTime.Now - TimeDate
If Diff < DateTime.TicksPerMinute Then
Return "<1 MIN AGO"
Else If Diff < DateTime.TicksPerHour Then
Diff = Floor(Diff / DateTime.TicksPerMinute)
Text = "MIN"
Else If Diff < DateTime.TicksPerDay Then
Diff = Floor(Diff / DateTime.TicksPerHour)
Text= "HRS"
Else If Diff< DateTime.TicksPerDay * 7 Then
Diff = Floor(Diff / DateTime.TicksPerDay)
Text = "DAYS"
Else If Diff< (DateTime.TicksPerDay * 30) Then
Diff = Floor(Diff / (DateTime.TicksPerDay*7))
Text = "WKS"
Else If Diff < (DateTime.TicksPerDay * 365) Then
Diff = Floor(Diff / (DateTime.TicksPerDay*30))
Text= "MTHS"
Else
Diff = Floor(Diff / (DateTime.TicksPerDay*365))
Text = "YRS"
End If
If Diff= 1 Then Text = Text.Replace("S", "")
Return Diff & " " & Text & " AGO"
End Sub
'Form: 0=Full name, 1=Initials + Last name, 2= Last name, -1=clearcache
Sub GetUserName(Form As Int) As String
Dim pid As PhoneId, tempContact As Contact , text() As String, tempstr As StringBuilder ,temp As Int
'If Form=-1 OR Not(PhoneNumbers.IsInitialized) Then PhoneNumbers.Initialize
'If YourName.Length=0 OR Form=-1 OR PhoneNumbers.Size=0 Then
Try
'debug("YOUR PHONE NUMBER: " & pid.GetLine1Number)
'tempContact=EnumContacts(pid.GetLine1Number,True).Get(0)
'tempContact=GetContactByPhoneNumber(pid.GetLine1Number)
'If tempContact <> Null Then
'debug("FULL: " & tempContact)
'YourName=tempContact.DisplayName
If YourName.Length=0 Then tempContact=GetContactByPhoneNumber(pid.GetLine1Number)
'debug("FAST: " & tempContact)
If Not(tempContact.DisplayName=Null) AND YourName.Length=0 Then
YourName=tempContact.DisplayName
End If
Catch
Return ""
End Try
'End If
If Form=0 OR Not(YourName.Contains(" ")) Then
Return YourName
Else
text = Regex.Split(" ", YourName)
If Form = 2 Then
Return text(text.Length-1)
Else
tempstr.Initialize
For temp = 0 To text.Length-2
tempstr.Append( Left(text(temp),1).ToUpperCase & ". ")
Next
tempstr.Append( Left(text(text.Length-1), 1).ToUpperCase & Right(text(text.Length-1), text(text.Length-1).Length -1).ToLowerCase )
Return tempstr.ToString
End If
End If
End Sub
Sub GetContactByPhoneNumber(PhoneNumber As String) As Contact
Dim ContactList As List , tempContact As Contact,tempContact2 As Contact, tempstr As String , NeedsInit As Boolean ,temp As String, temp2 As Int,tempMap As Map ,CON As Contacts2,ContactExtract As Technis
' If Not(PhoneNumbers.IsInitialized) Then
' NeedsInit =True
' PhoneNumbers.Initialize
' Else If PhoneNumbers.Size=0 Then
' NeedsInit =True
' End If
' If NeedsInit Then
' Log("GENERATING CACHE")
' ContactList= EnumContacts("",True)
' For temp = 0 To ContactList.Size-1
' tempContact = ContactList.Get(temp)
' If Not(tempContact.DisplayName.EqualsIgnoreCase("MiPhone")) Then
' tempMap=tempContact.GetPhones
' For temp2 = 0 To tempMap.Size-1
' tempstr=FilterPhoneNumber(tempMap.GetKeyAt(temp2))
' If PhoneNumbers.ContainsKey(tempstr) Then
' If Not( tempContact.PhoneNumber.EqualsIgnoreCase(tempContact.DisplayName)) Then
' PhoneNumbers.Put(tempstr, tempContact.Id)
' Log("DUPE " & tempContact)
' End If
' Else
' PhoneNumbers.Put(tempstr, tempContact.Id)
' End If
' Next
' End If
' Next
' End If
'tempstr=FilterPhoneNumber(PhoneNumber)
'temp=PhoneNumbers.GetDefault(tempstr,-1)
'Msgbox(PhoneNumber,"TEST1")
Try
temp= ContactExtract.GetContactIDbyPhone(PhoneNumber) 'MUST BE UNCOMMENTED
If temp.Length>0 Then
tempContact2 = CON.GetById(temp,True,True)
Else
PhoneNumber=CU.CleanPhone(PhoneNumber)
If Not(CU.IsInitialized) Then CU.Initialize
InitPhoneTypes
For Each c As Contact In CU.EnumContacts
If HasPhoneNumber(c, PhoneNumber) Then Return c
Next
End If
Catch
End Try
Return tempContact2
'ContactList = EnumContacts(tempstr,True)
'If ContactList.Size>0 Then tempContact = ContactList.Get(0)
'Return tempContact
End Sub
Sub HasPhoneNumber(C As Contact, PhoneNumber As String) As Boolean
Dim temp As Int , tempstr As String , IsMatch As Boolean
For temp = 0 To C.GetPhones.Size -1
tempstr = CU.CleanPhone(C.GetPhones.GetKeyAt(temp))
IsMatch=PhoneNumber.EndsWith(tempstr) OR tempstr.EndsWith(PhoneNumber)
'Log(C.DisplayName & " - " & PhoneNumber & " - " & tempstr & " - " & IsMatch)
If IsMatch Then Return True
Next
End Sub
'Action: 0=down, 1=up
Sub MakeKeyEvent(Action As Int, KeyCode As Int) As Object
Dim ke As JavaObject
ke.InitializeNewInstance("android.view.KeyEvent", Array As Object(Action, KeyCode))
Return ke
End Sub
'ie: keycodes.KEYCODE_MEDIA_FAST_FORWARD
Sub SendMediaButton(TheButton As Int)
'method 3
Dim Data As Intent, P As Phone,Command As String
Data.Initialize("android.intent.action.MEDIA_BUTTON", "")
Data.PutExtra("android.intent.extra.KEY_EVENT",MakeKeyEvent(0, TheButton))'needs to be passed as a keyevent, not an Int. 1 is up
' sendOrderedBroadcast(Data, "")
P.SendBroadcastIntent(Data)
Data.Initialize("android.intent.action.MEDIA_BUTTON", "")
Data.PutExtra("android.intent.extra.KEY_EVENT",MakeKeyEvent(1, TheButton))'needs to be passed as a keyevent, not an Int. 1 is up
' sendOrderedBroadcast(Data, "")
P.SendBroadcastIntent(Data)
End Sub
Sub ForceMain
StartActivity(Main)
End Sub
Sub FilterPhoneNumber(Number As String) As String
Dim Digits As Int '93,54,61,43,32,55,95,56,86,61,57,53,45,20,33,49,30,36,91,62,98,44,39,81,60,52,31,64,47,9251,63,48,40,65,27,82,34,94,46,41,66,90,44,39,58,84
If Left(Number,1)= "+" Then
Number=RemoveAllExceptNumbers(Number) 'Number= Right(Number, Number.Length-1)
Digits=3
Select Case Left(Number,4)
Case 1242,1246,1264,1268,1284,1340,1345,1441,1473,1671,1684,1767,1809 :Digits=4
Case Else
Select Case Left(Number,1)
Case 1, 7: Digits=1
Case Else
Select Case Left(Number,2)
Case 93,54,61,43,32,55,95,56,86,61,57,53,45,20,33,49,30,36,91,62,98,44,39,81,60,52,31,64,47,9251,63,48,40,65,27,82,34,94,46,41,66,90,44,39,58,84:Digits=2
End Select
' Select Case Left(Number,4)
' Case 213,220,224,226,229,233,235,236,237,238,240,241,242,243,244,245,251,253,256,257,260,263,267,269,291,297,298,299:Digits=3
' Case 350,351,353,354,355,357,358,359,372,374,375,376,380,385,387:Digits=3
' Case 420,421:Digits=3
' Case 500,501,502,503,504,506,509,591,592,593,598:Digits=3
' Case 670,672,673,678,679,681,682,689,690:Digits=3
' Case 852,855,880,886:Digits=3
' Case 964,966,967,970,971,972,973,975,994,995,998:Digits=3
' End Select
End Select
End Select
Number= Right(Number, Number.Length-Digits)
End If
Return RemoveAllExceptNumbers(Number)
End Sub
Sub KillCall'AddPermission("android.permission.CALL_PHONE")
Dim r As Reflector
r.Target = r.GetContext
Dim TelephonyManager, TelephonyInterface As Object
TelephonyManager = r.RunMethod2("getSystemService", "phone", "java.lang.String")
r.Target = TelephonyManager
TelephonyInterface = r.RunMethod("getITelephony")
r.Target = TelephonyInterface
r.RunMethod("endCall")
End Sub
Sub SendCall(PhoneNumber As String) As Boolean
Dim P As PhoneCalls, tempintent As Intent
If PhoneNumber.Length>0 Then
'STimer.IncomingCall=False
STimer.DidAnswer=False
STimer.ResponseWas=False
tempintent = P.Call(PhoneNumber.Replace("#","%23"))
If Not(tempintent=Null) Then
StartActivity(tempintent)
Return True
End If
End If
End Sub
Sub SendPhotoMessage(PhoneNumber As String, Message As String, Dir As String, Filename As String)
Dim iIntent As Intent
iIntent.Initialize("android.intent.action.SEND_MSG", "")
iIntent.setType("vnd.android-dir/mms-sms")
iIntent.PutExtra("android.intent.extra.STREAM", CreateUri("file://" & File.Combine(Dir, Filename)))
iIntent.PutExtra("sms_body", Message)
iIntent.PutExtra("address", PhoneNumber)
iIntent.SetType("image/png")
AddMessageToLogs(PhoneNumber, Message, File.Combine(Dir, Filename),-1,0 )
StartActivity(iIntent)
End Sub
Sub CreateUri(Uri As String) As Object
Dim r As Reflector
Return r.RunStaticMethod("android.net.Uri", "parse", Array As Object(Uri), Array As String("java.lang.String"))
End Sub
Sub SendTextMessage(PhoneNumber As String, Message As String,AddToLogs As Boolean )As Boolean
Dim SmsManager As PhoneSms ,r As Reflector, parts As Object, temp As Int
If PhoneNumber.Length>0 Then
If AddToLogs Then
MailParser.SaveOfflineEmail(PhoneNumber, "","", "", Message, False, Array As String(""), -1, "")
Else
Try
Debug("SendTextMessage: " & PhoneNumber & " Message: " & Message)
'If Not (smssent) Then
'smssent = True
If Message.Length <= 160 Then
SmsManager.Send(PhoneNumber, Message)
Else
r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
parts = r.RunMethod2("divideMessage", Message, "java.lang.String")
r.RunMethod4("sendMultipartTextMessage", Array As Object(PhoneNumber, Null, parts, Null, Null), Array As String("java.lang.String", "java.lang.String", "java.util.ArrayList", "java.util.ArrayList", "java.util.ArrayList"))
End If
'If AddToLogs Then AddMessageToLogs(PhoneNumber, Message, "",-1, 0)
Return True
'End If
Catch
End Try
End If
End If
End Sub
Sub AddMessageToLogs(PhoneNumber As String, Message As String, Filename As String, ThreadID As Int, Status As Int)
Dim r As Reflector
r.Target = r.CreateObject("android.content.ContentValues")
r.RunMethod3("put", "address", "java.lang.String", PhoneNumber, "java.lang.String")
r.RunMethod3("put", "body", "java.lang.String", Message, "java.lang.String")
'r.RunMethod3("put", "thread_id", "java.lang.String", thread_id, "java.lang.Integer")
'r.RunMethod3("put", "status", "java.lang.String", status, "java.lang.Integer")
Dim ContentValues As Object = r.Target
r.Target = r.GetContext
r.Target = r.RunMethod("getContentResolver")
r.RunMethod4("insert", Array As Object(r.RunStaticMethod("android.net.Uri", "parse", Array As Object("content://sms/sent"), Array As String("java.lang.String")), ContentValues), Array As String("android.net.Uri", "android.content.ContentValues"))
End Sub
Sub FindContactID(ID As Int, ContactList As List) As Int
Dim temp As Int, tempContact As Contact
For temp = 0 To ContactList.Size-1
tempContact= ContactList.Get(temp)
If tempContact.ID=ID Then Return temp
Next
Return -1
End Sub
Sub GetContactByID(ID As Int) As Contact
Dim CON As Contacts2
Return CON.GetById(ID,True,True)
End Sub
'Name: * = favorites, [text]* = name must start with [text], # = starts with a number, [number] = find by phone number, [number]+[any other symbol] = find by id number
Sub EnumContacts2(Name As String) As List 'returns a list of type Contact
Dim Names As List, temp As Int, c As cuContact , theContacts As List
If Not(CU.IsInitialized) Then CU.Initialize
InitPhoneTypes
If Name.Length= 0 Then'all
Names = CU.FindAllContacts(True)
Else If Name = "*" Then'* = favorites
Names = CU.FindContactsByStarred(True)
Else If Name = "#" Then'# = starts with a number
Names = CU.FindAllContacts(True)
For temp = Names.Size-1 To 0 Step -1
c = Names.Get(temp)
If Not(IsNumber(Left(c.DisplayName,1))) Then Names.RemoveAt(temp)
Next
Else If Name.EndsWith("*") Then '[text]* = name must start with [text]
Name = Left(Name , Name.Length-1).ToLowerCase
Names = CU.FindContactsByName(Name, False,True)
For temp = Names.Size-1 To 0 Step -1
c = Names.Get(temp)
If Not(c.DisplayName.ToLowerCase.StartsWith(Name)) Then Names.RemoveAt(temp)
Next
Else If IsNumber(Name) Then'[number] = find by phone number
Names = CU.FindContactsByPhone(Name, False, True)
Else If IsNumber(RemoveAllExceptNumbers(Name)) Then'[number]+[any other symbol] = find by id number
Name = RemoveAllExceptNumbers(Name)
Names = CU.FindAllContacts(True)
For temp = Names.Size-1 To 0 Step -1
c = Names.Get(temp)
If c.Id <> Name Then Names.RemoveAt(temp)
Next
End If
theContacts.Initialize
For Each c As cuContact In Names' IDtoContact
theContacts.Add( CU.IDtoContact(c.Id,c.DisplayName))
Next
Return theContacts
End Sub
'Name: * = favorites, [text]* = name must start with [text], # = starts with a number, [number] = find by phone number, [number]+[any other symbol] = find by id number
Sub EnumContacts(Name As String, HasNames As Boolean) As List 'returns a list of type Contact
Return EnumContacts2(Name)
Dim CON As Contacts2 ,tempContact As Contact, Names As List, Special As Int,DoRemove As Boolean
Dim temp As Int, temp2 As Int, tempContact As Contact , tempMap As Map,tempstr As String
If Name.Length =0 OR Name = "*" OR Name = "#" OR IsNumber(Name) Then
Names = CON.GetAll(True,False)
Select Case Name
Case "*": Special = 1'get favorites
Case "#": Special = 3'get names starting with number
Case Else:If IsNumber(Name) Then Special = 4'get by phone number
End Select
Else If IsNumber(RemoveAllExceptNumbers(Name)) Then'get by id number
Names.Initialize
tempContact = CON.GetById(Name,True,True)
If tempContact<> Null Then Names.Add(tempContact)
Return Names
Else If Name.Contains("@") AND Name.Contains(".") Then'get by email address
Names = CON.FindByMail(Name,False,True,True)
Else'get by name
If Right(Name,1)= "*" Then'get names starting with text
Special=2
Name = Left(Name, Name.Length-1).ToUpperCase
End If
Names = CON.FindByName(Name,False, True,True)
End If
If Names<>Null AND Names.IsInitialized Then
If Special>0 OR HasNames Then
For temp = Names.Size-1 To 0 Step -1
tempContact= Names.Get(temp)
DoRemove=False
If HasNames Then
If tempContact.DisplayName.Contains("@") Then
DoRemove =True
Else If tempContact.DisplayName.EqualsIgnoreCase("DISQUS") Then
DoRemove =True
Else If tempContact.DisplayName.Contains(", (Google+)") Then
DoRemove =True
Else If tempContact.DisplayName.Trim.Length=0 Then
DoRemove =True
End If
End If
If Not(DoRemove) Then
Select Case Special
Case 1'favorites only
If Not(tempContact.Starred) Then DoRemove=True
Case 2'starts with name text
If Not(tempContact.Name.ToUpperCase.StartsWith(Name)) Then DoRemove=True
Case 3'starts with a number
If Not(IsNumber( Left(tempContact.Name,1))) Then DoRemove=True
Case 4'search by phone number
DoRemove=True
tempMap=tempContact.GetPhones
For temp2 = 0 To tempMap.Size-1
tempstr=RemoveAllExceptNumbers(tempMap.GetKeyAt(temp2))
If tempstr = Right(Name, tempstr.Length) Then
DoRemove=False
temp2=tempMap.Size
End If
Next
End Select
End If
If DoRemove Then Names.RemoveAt(temp)
Next
End If
'debug
' For temp = 0 To Names.Size-1
' tempContact= Names.Get(temp)
' tempMap= tempContact.GetEmails
'
' 'If tempContact.PhoneNumber.Length>0 Then Log(tempContact.DisplayName & " " & tempContact.PhoneNumber )
' tempMap=tempContact.GetPhones
' If tempMap.Size>0 Then
' 'debug(tempContact)
' Log(tempContact.DisplayName & " " & tempMap)
'
' EnumCallLogs(20,tempMap)
' EnumSMSmessages(tempContact.Id)
' End If
' Next
End If
If Names=Null Then
Names.Initialize
'Else
'Names.SortType("DisplayName", True)
End If
Return Names
End Sub
Sub Backup(DoCalls As Boolean,Dir As String, Filename As String)As String
Dim Calls As List, CallLog As CallLog,temp As Int , c As CallItem, OUT As TextWriter ,TD As String ,SmsMessages1 As SmsMessages,theSms As Sms,tempContact As Contact
If Filename.Length =0 Then Filename = IIF(DoCalls, "Call logs ", "SMS logs ") & DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now) & ".html"
Filename=Filename.Replace("/", "-").Replace(":", "")
TD="</TD><TD>"
OUT.Initialize(File.OpenOutput(Dir,Filename,False))
OUT.WriteLine("<TABLE BORDER=2 CELLPADDING=2 CELLSPACING=2>")
If DoCalls Then
OUT.WriteLine(" <TR><TH>Name</TH><TH>Number</TH><TH>Date</TH><TH>Duration</TH><TH>Type</TH></TR>")
Calls = CallLog.GetAll(0)
For temp = 0 To Calls.Size - 1 'To 0 Step -1
c = Calls.Get(temp)
OUT.Write(" <TR><TD>" & c.CachedName & TD & c.Number & TD & DateTime.Date(c.Date) & " " & DateTime.Time(c.Date) & TD & GetTime(c.Duration) & TD)
Select Case c.CallType
Case c.TYPE_INCOMING: OUT.WriteLine("Incoming</TD></TR>")
Case c.TYPE_MISSED: OUT.WriteLine("Missed</TD></TR>")
Case c.TYPE_OUTGOING : OUT.WriteLine("Outgoing</TD></TR>")
End Select
Next
Else
Calls = SmsMessages1.GetAll
OUT.WriteLine(" <TR><TH>Name</TH><TH>Number</TH><TH>Date</TH><TH>Read</TH><TH>Type</TH></TR>")
For temp = 0 To Calls.Size-1
theSms = Calls.Get(temp)
tempContact = GetContactByPhoneNumber(theSms.Address)
If tempContact.DisplayName = Null Then
OUT.Write(" <TR><TD>Unknown")
Else
OUT.Write(" <TR><TD>" & tempContact.DisplayName)
End If
OUT.Write(TD & theSms.Address & TD & DateTime.Time(theSms.Date) & TD & GetTime(theSms.Date) & TD & IIF(theSms.Read, "Yes", "No") & TD)
Select Case (theSms.Type)
Case SmsMessages1.TYPE_DRAFT: OUT.WriteLine("Draft</TD></TR>")
Case SmsMessages1.TYPE_FAILED: OUT.WriteLine("Failed</TD></TR>")
Case SmsMessages1.TYPE_INBOX: OUT.WriteLine("Inbox</TD></TR>")
Case SmsMessages1.TYPE_OUTBOX: OUT.WriteLine("Outbox</TD></TR>")
Case SmsMessages1.TYPE_QUEUED: OUT.WriteLine("Queued</TD></TR>")
Case SmsMessages1.TYPE_SENT: OUT.WriteLine("Sent</TD></TR>")
Case SmsMessages1.TYPE_UNKNOWN: OUT.WriteLine("Unknown</TD></TR>")
End Select
OUT.WriteLine(" <TR><TD colspan=5>" & theSms.Body & "</TD></TR>")
Next
End If
OUT.WriteLine("</TABLE>")
OUT.Close
Return File.Combine(Dir,Filename)
End Sub
'Zero = all
'Sub DeleteCallLogs
' Dim Calls As List, CallLog As CallLog,temp As Int , c As CallItem, reg As MyFirstLib
' Calls = CallLog.GetAll(0)
' For temp = Calls.Size-1 To 0 Step -1
' c = Calls.Get(temp)
' reg.DeleteCallLogs(c.Number)
' Next
'End Sub
Sub EnumCallLogs(Quantity As Int, Phones As Map) As List
Dim Calls As List, CallLog As CallLog,temp As Int, temp2 As Int,Found As Boolean ,tempstr As String , c As CallItem
If Phones.IsInitialized Then'filter by contact info
Calls = CallLog.GetAll(Quantity)
For temp = 0 To Calls.Size - 1 'To 0 Step -1
Found=False