forked from alvonellos/AutoIt_Code-Snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__DROPBOX.au3
executable file
·1485 lines (1379 loc) · 61.5 KB
/
__DROPBOX.au3
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
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.1
Author: Alexander Alvonellos
Script Function:
This is a library containing four namespaces, all with different functions
related to working with, around, on, or about Dropbox in some way:
1). The __DROPBOX__ namespace contains functions that are used to interact
with dropbox and the dropbox itself.
2). The __DROPBOX__COMM namespace is a sister project that allows scripts
to communicate with one another through dropbox.
3). The __DROPBOX__TEST namespace is a namespace filled with functions that
were used to test functionality of that particular namespace, and so I left
them there as an example.
4). The __DROPBOX__COMM__TEST namespace is another namespace whose function is
the same as the __DROPBOX__TEST namespace.
Since this project is so big, I had no other option than to separate the
functions into their own namespaces. I haven't finished writing the general
help file yet, so any reference needs to be made in accordance with the
description that is above the function.
Coding conventions:
1). I like long identifier names when I have to work on a script over a large
period of time, so it's easier to read, understand, and pick right off
where I started after I've stopped coding for awhile. Don't get put off
by them. Sometimes I'll create a really long identifier, and then create
a alias of it right below it.
2). Functions are separated into namespaces, there are actually five
namespaces: __DROPBOX, __DROPBOX__COMM, __DROPBOX__COMM__TEST,
__DROPBOX__TEST, and PRIVATE__. They're pretty self explanatory.
3). When I say "BAD MAGIC" in a comment, error log, and such, that means
a logical contradiction has occurred and it's probably a bug. Let me
know what it is.
Known issues:
None that I've found after debugging today.
For best results:
1). Optimize the size & number of your datagrams accordingly. The
more sparse files you have, the slower the script will run.
Tasklist:
`08/07/12 Alex -> Alex :: Debug more. => Incompl.
08/07/12 Alex -> Any :: Tag all magic numbers => Incompl.
08/07/12 Alex -> Any :: Remote execution => Incomplete
08/07/12 Alex -> Any :: Binary data transmission => Incompl.
#ce
#cs -- Reasoning, justification, and design decisions behind __DROPBOX__COMM__
Reasoning behind __DROPBOX__COMM & design decisions.:
1). Reasoning:
I got very sick and tired of dealing with sockets and networking for
communication between my scripts. It can be unreliable, uncomfortable
and unnatural to code in, and took a long time to write, and I didn't
want to use SOAP or any kind of RESTful oriented architecture, http
nonsense, or anything of that sort -- I just wanted it to work. I
thought that I'd have to write my own TCP/IP library that made working
with networking more comfortable and natural.
So, while I was writing __DROPBOX, I started to wonder if I could use
dropbox to communicate with scripts over, but in a very natural way,
like I would using a pipe, a file, or a "channel" like I would talk
with people in IRC, then later that day, while I was working on an
old SCO/UNIX system, I remembered... "everything is a file" and it
all made a lot of sense:
"Communicate over networks using files, just like Plan 9, UNIX
and so on, communicates with."
... It hit me like a ton of bricks.
The next step was to think out how it would all work...
2). Design Decisions
The model behind __DROPBOX__COMM() is a subscriber->reciever model
like you would use a ham radio, but a few more perks that allow
scripts to communicate with them through. There are several modes of
communication that follow this model of a ham radio:
1). Many to Many
All members can contribute and hear all other members.
2). Many to One
All members can contribute, but only one can be listening.
3). One to One
One to one connection between one computer and another by
switching channels.
4). One to none.
It started to make more and more sense as I went along. but how was
I going to enable the natural model of reading, writing, and subscribing
to a channel and working with this data using just a file system, and no
packets? I didn't know right away, so I mapped out the functions that I'd
need to implement conforming to the interface of channel based communication.
Bingo.
One of the first things that I do when I go to write a script, is to figure
out what functions I need and start ordering them. knew that I'd need several
main functions:
__CREATE_CHANNEL()
__REMOVE_CHANNEL()
__WRITE()
__READ()
... And then the problems began:
a). File based communication
One of the trade offs with using files to send messages through
is that I have to sacrifice speed for the sake of ease, I wanted
to be able to gloat about reliability, so I set out with the purpose
of making this as reliable as possible.
There are a couple of problems with that, especially when dealing
with dropbox. Speed, synchronization, file locking, and such all
come into the equation, and have greatly influenced my design
decisions.
This library has some serious limitations in terms of speed. Only
one datagram can be sent a second, and the reasoning behind that
is two fold:
i). I didn't want to have to store a list of which datagrams
had been read or missed, nor did I want to have to open
each and every file and perform checksums or do any of
that. So I decided to use a time variable as a name.
And so I decided on using epoch time for the file name. It makes
it very easy to deal with conflicts when communicating over
dropbox, because when a conflict occurs, dropbox will
automatically rename it and append the (*conflicted*).ext
to the file name. Which is great, because it won't interfere
with the program, and if the extension is the same, that means
that both files were submitted at the same time and it doesn't
really matter if you recieve them in order or not. However, if
multiple sequential writes are performed in the same second
, then the files will get clobbered. So we delay a write by
1 second.
I also found out that if I use unix epoch time, I can process
the datagrams in order, sort them, manipulate them, and even
store the name of the file in a configuration file, so if I
decide to leave a few datagrams in a channel, when the subscriber
comes back online, they can recieve the messages.
...You can't do that with TCP/IP.
ii). I don't trust that the system timer can readily
measure time into the millisecond.
I didn't want the computer to have to read over many files
it had already read before getting to the ones it had not
read, and so, what I've done is to store the filename
of the last read file (which is in unix epoch time of course)
in a .ini file with the computers name and listener function
and read that and only read files that are newer than that
date. If I use a millisecond timer, there's a greater chance
that datagrams can get lost.
b). Threading
1). AutoIt doesn't have threads, and if I wanted to use a true
channel->subscriber model, then I'd need to use them.
I settled for using AdLibRegister, but the problem with
AdLibRegister and AdLibUnregister is that the function,
its parameters, and such will need to change, dynamically.
And so so I heavily abused Assign, Eval, and Call.
c). External libraries
They're a pain, and so I used my own.
d). Others
This project has taken a lot of code and a lot of time to
write, and so there's some difficulty in maintaining it
because it's so large. I want to be able to reuse this
over and over again, and so I've taken time and a great
deal of deliberation in writing this, so I'm considering
situations where I want to be notified.
how am I going to identify which files
to read, or how I'm going to format the datagrams.
How am I going to deal with threads, when autoit has none
how am I going to allow the user direct interaction with the
files while not wanting them to have to look into this script
before they start writing it?
3). Further justification
a). If I need to justify anything else or I have missed anything
please let me know.
#ce ----------------------------------------------------------------------------
#include-once
#include <Process.au3>
#include <Misc.au3>
#include <Date.au3>
#include <Array.au3>
#include <File.au3>
;; Configuration Options
; If the logging is too verbose
; and you just want it to shutup,
; set this to true.
Global $__DROPBOX__bHUSH_CERR = False
Func __DROPBOX__HUSH_CERR()
$__DROPBOX__bHUSH_CERR = True
EndFunc
Func __DROPBOX__UNHUSH_CERR()
$__DROPBOX__bHUSH_CERR = False
EndFunc
; This is the interval to wait for dropbox to
; appear before timing out.
Global $__DROPBOX__iPROCESSWAIT_INTERVAL = 1
;; __COMM__ namespace configuration options
; This is the interval to wait to poll the channels
Global $__DROPBOX__iDEFAULT_CHANNEL_POLLING_PERIOD = 250
; This is the interval to wait between subscriber notifications
Global $__DROPBOX__iINTERVAL_BETWEEN_SUBSCRIBER_NOTIFY = 0
; This variable is pretty self explanatory.
Global $__DROPBOX__iDEFAULT_MAX_REGISTERED_SUBSCRIBERS = 1024
;; End configutation options.
;; Globals - Don't touch
Global $PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS = 0
Global $PRIVATE__DROPBOX__COMM__NUMBER_DIGITS_IN_EPOCH _
= StringLen(__DROPBOX__COMM__EPOCH())
; Contains a pipe delimited string containing
; function names to call. (Used in __PARSE_SUBSCRIBERS
; and __SUBSCRIBE and UNSUBSCRIBE)
Global $__DROPBOX__szREGISTERED_FUNCTIONS = ""
;; End globals
; __DROPBOX__COMM__TEST_CREATE_REMOVE_CHANNEL()
;Sleep(10000)
;ConsoleWrite(@LF)
;__DROPBOX__COMM__TEST_WRITE_READ()
;Sleep(10000)
;ConsoleWrite(@LF)
;__DROPBOX__COMM__TEST_SUBSCRIBE_UNSUBSCRIBE()
;Sleep(10000)
;ConsoleWrite(@LF & @LF & @LF & @LF)
; __DROPBOX__COMM__TEST_MULTICHANNEL_MULTISUBSCRIBER()
; Sleep(10000)
; This function demonstrates is used to test
; the UDF while in development and serves as
; a reference on how to use it.
Func __DROPBOX__TEST()
ConsoleWrite("__DROPBOX__CHECK_EXIST:> " & __DROPBOX__CHECK_EXIST() & @LF)
ConsoleWrite("__DROPBOX__INITIALIZE():> " & __DROPBOX__INITIALIZE() & @LF)
ConsoleWrite("__DROPBOX__TERMINATE():> " & __DROPBOX__TERMINATE() & @LF)
ConsoleWrite("__DROPBOX__INITIALIZE():> " & __DROPBOX__INITIALIZE() & @LF)
EndFunc
Func __DROPBOX__COMM__TEST_DUMPVARS()
ConsoleWrite("--> __DROPBOX__COMM__TEST_SUBSCRIBE_UNSUBSCRIBE(), $PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS = " & _
$PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS & @LF)
COnsoleWrite("--> __DROPBOX__COMM__TEST_DUMPVARS(), $__DROPBOX__szREGISTERED_FUNCTIONS = " & $__DROPBOX__szREGISTERED_FUNCTIONS & @LF)
EndFunc
Func __DROPBOX__COMM__TEST_CREATE_REMOVE_CHANNEL()
ConsoleWrite("Testing __CREATE_CHANNEL() and __REMOVE_CHANNEL" & @LF)
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__CREATE_CHANNEL("comm", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__TEST_DUMPVARS()
Sleep(10000)
__DROPBOX__COMM__REMOVE_CHANNEL("comm", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__TEST_DUMPVARS()
EndFunc
Func __DROPBOX__COMM__TEST_WRITE_READ()
Local $strBuf = ""
$strBuf = "They Call Me Data"
__DROPBOX__COMM__CREATE_CHANNEL("comm", @ScriptDir)
__DROPBOX__COMM__TEST_DUMPVARS()
;__DROPBOX__COMM__SUBSCRIBE("comm", @ScriptDir, "__DROPBOX__COMM__READ__DEMO_READER_2")
__DROPBOX__COMM__WRITE("comm", @ScriptDir, $strBuf)
Sleep(10000)
__DROPBOX__COMM__READ("comm", @ScriptDir, "__DROPBOX__COMM__READ__DEMO_READER")
__DROPBOX__COMM__REMOVE_CHANNEL("comm", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__TEST_DUMPVARS()
EndFunc
Func __DROPBOX__COMM__TEST_SUBSCRIBE_UNSUBSCRIBE()
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__CREATE_CHANNEL("comm", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__SUBSCRIBE("comm", @ScriptDir, "__DROPBOX__COMM__READ__DEMO_READER")
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__WRITE("comm", @ScriptDir, "They Call Me Data")
Sleep(10000)
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__UNSUBSCRIBE("__DROPBOX__CERR")
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__WRITE("comm", @ScriptDir, "This is not supposed to show up")
Sleep(10000)
__DROPBOX__COMM__REMOVE_CHANNEL("comm", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__TEST_DUMPVARS()
EndFunc
; By no means are the following two functions the best way to perform
; a "relay" using my library. The ideal solution would be to use
; a verified copy function, like the one in my __FILE() library,
; and then to copy the datagram from one channel to another.
; anyway, there's more than one way to do it.
Func __DROPBOX__COMM__TEST__MULTICHANNEL_RELAY1($hFile)
Local $szDatum = FileRead($hFile, -1) ; Read to end
FileClose($hFile)
ConsoleWrite("-----------------__DROPBOX__COMM__TEST__MULTICHANNEL_RELAY1---------------------" & @LF)
ConsoleWrite($szDatum & @LF)
ConsoleWrite("--------------------------------------------------------------------------------" & @LF)
__DROPBOX__COMM__WRITE("comm2", @ScriptDir, @LF & $szDatum)
EndFunc
Func __DROPBOX__COMM__TEST__MULTICHANNEL_RELAY2($hFile)
Local $szDatum = FileRead($hFile, -1) ; Read to end
FileClose($hFile)
ConsoleWrite("-----------------__DROPBOX__COMM__TEST__MULTICHANNEL_RELAY2---------------------" & @LF)
ConsoleWrite($szDatum & @LF)
ConsoleWrite("--------------------------------------------------------------------------------" & @LF)
__DROPBOX__COMM__WRITE("comm3", @ScriptDir, @LF & $szDatum)
EndFunc
Func __DROPBOX__COMM__TEST_MULTICHANNEL_MULTISUBSCRIBER()
ConsoleWrite("--> Testing multichannel mode." & @LF)
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__CREATE_CHANNEL("comm", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__CREATE_CHANNEL("comm2", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__CREATE_CHANNEL("comm3", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__SUBSCRIBE("comm", @ScriptDir, "__DROPBOX__COMM__TEST__MULTICHANNEL_RELAY1")
__DROPBOX__COMM__SUBSCRIBE("comm2", @ScriptDir, "__DROPBOX__COMM__TEST__MULTICHANNEL_RELAY2")
__DROPBOX__COMM__TEST_DUMPVARS()
ConsoleWrite("--> Writing channel data " & @LF)
Local $i = 0
Local $max = 100
For $i = 0 To $max Step 1
__DROPBOX__COMM__WRITE("comm", @ScriptDir, "Datagram: " & $i & " of " & $max)
Next
Sleep(60000)
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__UNSUBSCRIBE()
Sleep(60000)
__DROPBOX__COMM__REMOVE_CHANNEL("comm", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__REMOVE_CHANNEL("comm2", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__REMOVE_CHANNEL("comm3", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__TEST_MULTICHANNEL_MULTISUBSCRIBER2()
EndFunc
Func __DROPBOX__COMM__TEST_MULTICHANNEL_MULTISUBSCRIBER2()
ConsoleWrite("--> Testing multichannel mode (2)" & @LF)
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__CREATE_CHANNEL("comm", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__CREATE_CHANNEL("comm2", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__CREATE_CHANNEL("comm3", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__TEST_DUMPVARS()
ConsoleWrite("--> Writing channel data " & @LF)
Local $i = 0
Local $max = 100
For $i = 0 To $max Step 1
__DROPBOX__COMM__WRITE("comm", @ScriptDir, "Datagram: " & $i & " of " & $max)
Next
Sleep(60000)
__DROPBOX__COMM__SUBSCRIBE("comm", @ScriptDir, "__DROPBOX__COMM__TEST__MULTICHANNEL_RELAY1")
Sleep(100000)
; If you're going to subscribe more than one function to a channel that already has a lot of
; datagrams in it, then you want to wait a little while for it to process it before subscribing
; the second channel.
;
; I've played with this in the function above and had problems with it, so I suppose the solution,
; for now, is to wait a little while before subscribing another function to a channel that, could,
; potentially have quite a few datagrams left in it. There are many ways to fix this problem, I just
; haven't found out which one I want to do yet.
; I could rebuild the model by which the delegates are called (the subscribers)
; or... I could have __SUBSCRIBE() call the function passed in with a "READ" call and see how
; if that works. Sounds to me like that'd be the best solution anyways.
; I'll decide later.
;
; That's what this test demonstrates.
; The ideal way to do this would be to do it in subscribe itself, so that after the function
; has subscribed to a channel, it reads some configuration information from the INI file,
; checks for datagrams in the existing directory, and then
__DROPBOX__COMM__SUBSCRIBE("comm2", @ScriptDir, "__DROPBOX__COMM__TEST__MULTICHANNEL_RELAY2")
__DROPBOX__COMM__TEST_DUMPVARS()
__DROPBOX__COMM__UNSUBSCRIBE()
Sleep(60000)
__DROPBOX__COMM__REMOVE_CHANNEL("comm", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__REMOVE_CHANNEL("comm2", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__REMOVE_CHANNEL("comm3", @ScriptDir, "__DROPBOX__CERR")
__DROPBOX__COMM__TEST_DUMPVARS()
EndFunc
Func __DROPBOX__COMM__READ__DEMO_READER_2($hFile)
Local $szDatum = FileRead($hFile, -1) ; Read to end
ConsoleWrite("-----------------__DROPBOX__COMM__READ__DEMO_READER_2---------------------------" & @LF)
ConsoleWrite($szDatum & @LF)
ConsoleWrite("--------------------------------------------------------------------------------" & @LF)
EndFunc
; Checks if Dropbox is an active
; process on the system.
;
; Parameters:
; [$szLogFuncHandler]
; A string function that takes
; a single parameter and is
; used to write log info.
; Returns:
; True if active
; False if not.
Func __DROPBOX__CHECK_EXIST($szLogFuncHandler = "__DROPBOX__CERR")
Local $iProcessResult = ProcessWait("Dropbox.exe", $__DROPBOX__iPROCESSWAIT_INTERVAL)
If( $iProcessResult <> 0 ) Then
; Dropbox exists
Call($szLogFuncHandler, "In __DROPBOX_CHECK_EXIST(), dropbox appears to be running.")
Return True
Else
; Dropbox doesn't exist
Call($szLogFuncHandler, "In __DROPBOX_CHECK_EXIST(), dropbox does not appear to be running.")
Return False
EndIf
EndFunc
; Terminates the dropbox
; process on the system
;
; Parameters:
; [$szLogFuncHandler]
; A string function that takes
; a single parameter and is
; used to write log info.
; Returns:
; True: successful
; False: otherwise
; @error:
; -2: Last ditch effort to terminate dropbox failed
; -1: Unknown error terminating dropbox
; 0: Successfully terminated dropbox
; 1: OpenProcess failed
; 2: AdjustTokenPrivileges failed
; 3: TerminateProcess failed
; 4: Cannot verify if process exists
; 5: Unknown error. Bad magic
; Remarks:
; If dropbox isn't running on
; the system, then this func
; will return true anyways.
Func __DROPBOX__TERMINATE($szLogFuncHandler = "__DROPBOX__CERR")
Local $bReturnValue = False
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE()")
If(ProcessExists("Dropbox.exe")) Then
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), dropbox exists, killing")
Local $result = ProcessClose("Dropbox.exe")
If( $result = 1 ) Then ; Terminated Dropbox, exiting
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), successfully terminated dropbox")
SetError(0)
$bReturnValue = True
Else
Select
Case @error = 1
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), OpenProcess failed")
SetError(1)
Case @error = 2
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), AdjustTokenPrivileges failed")
SetError(2)
Case @error = 3
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), TerminateProcess failed")
SetError(3)
Case @error = 4
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), Cannot verify if process exists")
SetError(4)
Case Else
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), there was an error and I don't know what caused it.")
SetError(-1)
EndSelect
; Fall back and do everything to kill DropBox
If(ProcessExists("Dropbox.exe")) Then
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), we've done almost everything to terminate dropBox(), making a last ditch effort.")
$result = _RunDos("taskkill /f /im Dropbox.exe")
If( @error <> 0 ) Then
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), last ditch effort to kill Dropbox failed. We're going to bomb now.")
SetError(-2)
$bReturnValue = False
Else
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), last ditch effort succeeded!")
$bReturnValue = True
EndIf
EndIf
EndIf
Else
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), dropbox isn't running")
$bReturnValue = True
EndIf
Call($szLogFuncHandler, "In __DROPBOX__TERMINATE(), exiting")
Return $bReturnValue
EndFunc
; Initializes (starts)
; dropbox on the host
; system.
;
; Parameters:
; [$szLogFuncHandler]
; A string function that takes
; a single parameter and is
; used to write log info.
; Returns:
; If successful:
; Returns True
; Otherwise:
; Returns False and sets @error
; @error:
; -1: If dropbox dir not found
; -2: Other problem.
Func __DROPBOX__INITIALIZE($szLogFuncHandler = "__DROPBOX__CERR")
Local $szDropBoxDir = @AppDataDir & "\Dropbox\bin"
If( FileExists($szDropBoxDir) = 0 ) Then
Call($szLogFuncHandler, "In __DROPBOX__INITIALIZE(), cannot find dropbox directory")
; Dropbox directory doesn't exist
SetError(-1)
Return False
Else
; Dropbox directory exists
Local $iResult = Run($szDropBoxDir & "\Dropbox.exe", "", @SW_HIDE)
Call($szLogFuncHandler, "In __DROPBOX__INITIALIZE(), " & _
_Iif($iResult <> 0, "successfully started dropbox.", _
"unsuccessfully started dropbox.") & _
" PID: " & $iResult)
If($iResult <> 0 ) Then
Return True
Else
Call($szLogFuncHandler, "In __DROPBOX__INITIALIZE(), failed to start dropbox.")
SetError(-2)
Return False
EndIf
EndIf
EndFunc
; This function creates a channel in the specified directory
; for communications to go through.
;
; Parameters:
; $szChannelName: A string describing the channel
; $szChannelPath: The path to create the channel in.
; $szLogFuncHandler: A string containing a function name
; to call with log information.
; Returns:
; True: If the channel was created successfully.
; False: If the channel was not created successfully
; (see @error)
; @error:
; -1: General error creating channel directory.
; -2: Error creating configuration file in channel.
; -3: Channel already exists.
; Remarks:
; TODO.
Func __DROPBOX__COMM__CREATE_CHANNEL($szChannelName, $szChannelPath, $szLogFuncHandler = "__DROPBOX__CERR")
If( FileExists($szChannelPath & "\" & $szChannelName) = 0 ) Then
; The channel doesn't exist, create it.
Call($szLogFuncHandler, "In __DROPBOX__COMM__CREATE_CHANNEL(), Creating channel: " & $szChannelPath & "\" & $szChannelName)
Local $oChannelCreationResult = DirCreate($szChannelPath & "\" & $szChannelName)
If( $oChannelCreationResult = 0 ) Then ; There was a problem
Call($szLogFuncHandler, "In __DROPBOX__COMM__CREATE_CHANNEL(), there was an error creating the channel.")
SetError(-1)
Return False
Else
Call($szLogFuncHandler, "In __DROPBOX__COMM__CREATE_CHANNEL(), Channel created, result: " & $oChannelCreationResult)
Local $oChannelIniCreationResult = IniWrite($szChannelPath & "\" & $szChannelName & "\" & $szChannelName & _
".ini" , $szChannelName & "-Creator", @ComputerName, __DROPBOX__COMM__EPOCH())
Local $oChannelIniCreationResult2 = IniWrite($szChannelPath & "\" & $szChannelName & "\" & @ComputerName & _
".ini" , $szChannelName & "-Creator", @ComputerName, __DROPBOX__COMM__EPOCH())
If( $oChannelCreationResult = 0) Then ; There was a problem
Call($szLogFuncHandler, "In __DROPBOX__COMM__CREATE_CHANNEL(), there was an error creating INI file for the channel")
Call($szLogFuncHandler, "In __DROPBOX__COMM__CREATE_CHANNEL(), cleaning up...")
Local $bCleanupResult = __DROPBOX__COMM__REMOVE_CHANNEL($szChannelName, $szChannelPath, $szLogFuncHandler)
; TODO: Add error handling code here (for __DROPBOX__COMM__REMOVE_CHANNEL())
SetError(-2)
Return False
Else
SetError(0)
Call($szLogFuncHandler, "In __DROPBOX__COMM__CREATE_CHANNEL(), creating channel configuration file. Result: " & $oChannelIniCreationResult)
Call($szLogFuncHandler, "In __DROPBOX__COMM__CREATE_CHANNEL(), channel " & $szChannelName & " created successfully.")
Return True
EndIf
EndIf
Else
; Channel exists
Call($szLogFuncHandler, "In __DROPBOX__COMM_CREATE_CHANNEL(), channel already exists.")
SetError(-3)
Return False
EndIf
EndFunc
; This function removes a channel in the specified directory
; for communications to go through.
;
; Parameters:
; $szChannelName: A string describing the channel
; $szChannelPath: The path to create the channel in.
; $szLogFuncHandler: A string containing a function name
; to call with log information.
; Returns:
; True: If the channel was removed successfully
; (see @error)
; False: If the channel was not removed successfully
; (see @error)
; @error:
; -1: General error unsubscribing from channel. (See @extended)
; -2: Error unsubscribing from channel,
; --> See @extended
; -3: Channel doesn't exist.
; @extended:
; Set to the return value of unsubscribe on error..
;
; Remarks:
; TODO: Finish fixing this (so that it can remove a channel without removing all
; subscribers from all channels.
; When you remove a channel, this function goes through the global list of subscribed functions,
; and iteratively removes them. This process runs at or above linear time, so, this operation is
; expensive. However, If your subscriber list is so large that you're running into some kind of a
; performance issue with the script itself and not whatever platform is facilitating the file-syncing
; then you have other problems...
Func __DROPBOX__COMM__REMOVE_CHANNEL($szChannelName, $szChannelPath, $szLogFuncHandler = "__DROPBOX__CERR")
Local $szChannelComb = $szChannelPath & "\" & $szChannelName
If( FileExists($szChannelComb) <> 1 ) Then
; Channel doesn't exist, so there's nothing to remove.
SetError(-3)
Return True ; Should I return here?
EndIf
If( $PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS > 0 ) Then
Local $aszFuncListing = __DROPBOX__COMM__GET_SUBSCRIBED_FUNCTION_LIST($szLogFuncHandler)
Local $i = 0
For $i = 1 To $aszFuncListing[0] - 1 Step 1
Local $chan = ""
Local $path = ""
Local $buf1 = "" ; This is the data handler
Local $buf2 = "" ; This is the log func handler
Local $aszFuncData = __DROPBOX__COMM__GET_FUNCTION_DATA($aszFuncListing[$i], _
$chan, $path, $buf1, _
$buf2, $szLogFuncHandler)
Local $_szChannelComb = $path & "\" & $path
If( StringCompare($_szChannelComb, $szChannelComb, 2) = 0 ) Then
; The channel name and paths match, so, remove that function.
Local $retVal = __DROPBOX__COMM__UNSUBSCRIBE_FUNCTION($aszFuncListing[$i], $szLogFuncHandler)
If( $retVal = False ) Then
; There was an error
Local $tmpExtended = @error
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), there was an error," & _
"unsubscribing a function, " & $aszFuncListing[$i] & ". " & _
"@error is " & @error & ".")
; At this point, there's nothing that I know to do.
SetError(-2, $tmpExtended)
; Don't return here, because we want to finish removing the channel.
EndIf
EndIf
Next
EndIf
Local $oChannelDeletionResult = DirRemove($szChannelPath & "\" & $szChannelName, 1)
If( $oChannelDeletionResult = 0 ) Then ; There was a problem.
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), error removing channel dir.")
If( FileExists($szChannelPath & "\" & $szChannelName) = 0 ) Then
; Dir doesn't exist, but, prior to entering this section of the massive IF statment
; (the one in the beginning), the directory must have existed for us to get to this
; point, and for the control flow to get here at this point means that we're at a
; logical contradiction... and therefore there's a bug in the logic.
;
; Code can't just magically change it's mind, that's why I call it bad magic.
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), channel dir doesn't exist. BAD MAGIC")
SetError(-3)
Return True
Else
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), channel exists, but cannot be deleted.")
SetError(-4)
Return False
EndIf
Else
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), successfully removed channel.")
Return True
EndIf
#cs -- TODO: Remove this code.
If( FileExists($szChannelPath & "\" & $szChannelName) = 1 ) Then ; Channel exists
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), file exists")
; Remove all the datagrams & channel directory.
$bReturnValue = __DROPBOX__COMM__UNSUBSCRIBE("-1", $szLogFuncHandler)
#cs
; -- This is a bugfix that fixes an issue where calling this function
; -- While there is more than one channel subscribed will unsubscribe all
; -- functions from all channels.
Local $bReturnValue = False
Local $i = 0
Local $aszFuncListing = StringSplit($__DROPBOX__szREGISTERED_FUNCTIONS, "|")
For $i = 1 To $aszFuncListing[0]-1 Step 1
Local $chan = ""
Local $path = ""
Local $name = ""
Local $logf = ""
Local $bGetDataResult = __DROPBOX__COMM__GET_FUNCTION_DATA($aszFuncListing[$i], $chan, $path, $name, $logf, $szLogFuncHandler)
If( $bGetDataResult = False ) Then
; There was a problem
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), there was an error retrieving data for function " & $aszFuncListing[$i] & ".")
$bReturnValue = False
Else
Local $szChannelCombParam = $szChannelPath & "\" & $szChannelName
Local $szChannelCombDatum = $chan & "\" & $path
If( StringCompare($szChannelCombParam, $szChannelCombDatum, 2) = 0 ) Then
; Both are equal, so remove it.
ConsoleWrite("In __DROPBOX__COMM__REMOVE_CHANNEL(), removing " & $aszFuncListing[$i] & " from " & $szChannelName & "." & @lF)
__DROPBOX__COMM__UNSUBSCRIBE($aszFuncListing[$i], $szLogFuncHandler)
Else
; Not a match, for now
ConsoleWrite("In __DROPBOX__COMM__REMOVE_CHANNEL(), did not remove " & $aszFuncListing[$i] & " from " & $szChannelName & "." & @lF)
ConsoleWrite("---> Mismatch: " & $chan & " " & $path & " " & $name & " " & $logf & @LF)
EndIf
#ce
If($bReturnValue = False) Then
; __DROPBOX__COMM__UNSUBSCRIBE() throws errors if there was an error deallocating memory, or if
; there was no subscriber attached to the thread. Both of these threads are non-fatal -- so
; what we can do here is just continue... but first, let's retrieve the value stored in @error and
; in @extended before we call the log-handler (because call can reset both of those to be 0xDEADBEEF
; and I don't want that.
Local $tmpaterror = @error
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), error unsubscribing from channel. @error: " & @error)
SetError(-2)
SetExtended($tmpaterror)
EndIf
Local $oChannelDeletionResult = DirRemove($szChannelPath & "\" & $szChannelName, 1)
If( $oChannelDeletionResult = 0 ) Then ; There was a problem.
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), error removing channel dir.")
If( FileExists($szChannelPath & "\" & $szChannelName) = 0 ) Then
; Dir doesn't exist, but, prior to entering this section of the massive IF statment
; (the one in the beginning), the directory must have existed for us to get to this
; point, and for the control flow to get here at this point means that we're at a
; logical contradiction... and therefore there's a bug in the logic.
;
; Code can't just magically change it's mind, that's why I call it bad magic.
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), channel dir doesn't exist. BAD MAGIC")
SetError(-3)
Return True
Else
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), channel exists, but cannot be deleted.")
SetError(-4)
Return False
EndIf
Else
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), successfully removed channel.")
Return True
EndIf
Else
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), channel dir doesn't exist.")
SetError(-3)
Return True
EndIf
Call($szLogFuncHandler, "In __DROPBOX__COMM__REMOVE_CHANNEL(), BAD MAGIC ON: " & @ScriptLineNumber)
; I just had a feeling.
#ce
EndFunc
; This function takes a single parameter, $szFunctionName,
; that denotes the name of the subscribed function, as would
; be used as a parameter to Call() and gets the data associated
; , internally, with that function, such as the channel name,
; channel path, and log functions and such associated with
; that function.
;
; Parameters:
; $szFunctionName: The name of the function, as would be used
; as a parameter to Call()
; $_szChannelName: A variable to store the channel name in
; $_szChannelPath: A variable to store the channel path in
; $_szFuncDataHandler: A variable to store the name of the
; function used to parse input data.
; In this case, this parameter is
; redundant and will be assigned
; the same data as what was supplied
; in $szFunctionName.
; $_szLogFuncHandler: A variable to store the name of the
; function called for logging purposes.
; $szLogFuncHandler: The name of the function to call with
; logging information.
; Returns:
; If successful:
; 1. Returns True
; 2. Sets @error to 0
; 3. Assigns the appropriate
; data to the supplied ByRef
; variables
; If not successful:
; 1. Returns False
; 2. Sets @error as appropriate
; 3. Assigns "" to all the provided
; variables.
; @error:
; 0: No problems.
; -1: Problem reading data from global variables.
;
; Remarks:
; None.
Func __DROPBOX__COMM__GET_FUNCTION_DATA($szFunctionName, _
ByRef $_szChannelName, ByRef $_szChannelPath, _
ByRef $_szFuncDataHandler, ByRef $_szLogFuncHandler, _
$szLogFuncHandler = "__DROPBOX__CERR")
Local $j1 = Eval("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$szFunctionName & "_szChannelName")
;ConsoleWrite("DEBUG: " & $chan & @LF)
Local $j2 = Eval("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$szFunctionName & "_szChannelPath")
;ConsoleWrite("DEBUG: " & $path & @LF)
Local $j3 = Eval("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$szFunctionName & "_szFuncDataHandler")
; ConsoleWrite("DEBUG: " & Eval($hand) & @LF)
Local $j4 = Eval("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$szFunctionName & "_szLogFuncHandler")
If( ($j1 & $j2 & $j3 & $j4) <> "") Then
; No problems.
SetError(0)
Call($szLogFuncHandler, "In __DROPBOX__COMM__GET_FUNCTION_DATA(), successfully retrieved function data")
Return True
Else
Local $szLogErrMessageForAssign = "Failed to retrieve the following data for the function " & $szFunctionName & ": "
If( $j1 = 0 ) Then
$szLogErrMessageForAssign &= "[Channel Name] "
EndIf
If( $j2 = 0 ) Then
$szLogErrMessageForAssign &= "[Channel Path] "
EndIf
If( $j3 = 0 ) Then
$szLogErrMessageForAssign &= "[Data Handler] "
EndIf
If( $j4 = 0 ) Then
$szLogErrMessageForAssign &= "[Channel Error Log Handler]."
EndIf
Call($szLogFuncHandler, "In __DROPBOX__COMM__GET_FUNCTION_DATA(), " & $szLogErrMessageForAssign)
SetError(-1)
Return False
EndIf
EndFunc
; This function subscribes a function specified by
; a parameter to changes made in the specified channel
; name. The function specified is called using AdLibRegister.
;
; Parameters:
; $szChannelName: The channel name to use
; $szChannelPath: The path the channel resides in
; $szFuncDataHandler: A string describing a function
; to be called when changes are
; made in the channel
; [$szLogFuncHandler]: A function to handle log information
; supplied by the parameter.
; Returns:
; True: If successful
; False: If not successful, and sets @error
; @error:
; 0: Channel doesn't exist.
; -1: Max number of subscribers reached
; -2: Problem assigning data to vars.
;
; Remarks:
; At this point, I've only coded this library to handle
; only one subscriber at a time. It wouldn't be too hard
; to add it, but I'm working on it...
Func __DROPBOX__COMM__SUBSCRIBE($szChannelName, $szChannelPath, $szFuncDataHandler, $szLogFuncHandler = "__DROPBOX__CERR", $szListenMode = False)
If( $szListenMode = False ) Then
If( FileExists($szChannelPath & "\" & $szChannelName) = 0 ) Then
SetError(0)
Return False
EndIf
EndIf
If( _
$PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS = 0 _
OR _
$PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS < $__DROPBOX__iDEFAULT_MAX_REGISTERED_SUBSCRIBERS _
) Then
Local $oChannelIniCreationResult = IniWrite($szChannelPath & "\" & $szChannelName & "\" & _
@ComputerName & ".ini" , $szChannelName & "-Listening", $szFuncDataHandler, _
__DROPBOX__COMM__EPOCH())
$PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS = $PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS + 1
$__DROPBOX__szREGISTERED_FUNCTIONS &= $szFuncDataHandler & "|"
Call($szLogFuncHandler, "In __DROPBOX__COMM__SUBSCRIBE(), adding subscriber " & "#" & _
$PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS &" : " & $szFuncDataHandler & "().")
Local $j1 = Assign("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$szFuncDataHandler & "_szChannelName", $szChannelName, 2)
Local $j2 = Assign("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$szFuncDataHandler & "_szChannelPath", $szChannelPath, 2)
Local $j3 = Assign("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$szFuncDataHandler & "_szFuncDataHandler", $szFuncDataHandler, 2)
Local $j4 = Assign("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$szLogFuncHandler & "_szLogFuncHandler", $szLogFuncHandler, 2)
;ConsoleWrite($j1 & " :: " & $j2 & " :: " & $j3 & " :: " & $j4 & @LF)
If( ($j1 + $j2 + $j3 + $j4) = 4) Then
If( $PRIVATE__DROPBOX__REGISTERED_SUBSCRIBERS <= 1 ) Then
AdlibRegister("PRIVATE__DROPBOX__COMM__PARSE_SUBSCRIBERS", _
$__DROPBOX__iDEFAULT_CHANNEL_POLLING_PERIOD)
EndIf
Call($szLogFuncHandler, "In __DROPBOX__COMM__SUBSCRIBE(), successfully added subscriber.")
Return True
Else
Local $szLogErrMessageForAssign = "The following assignments have failed: "
If( $j1 = 0 ) Then
$szLogErrMessageForAssign &= "$j1, "
EndIf
If( $j2 = 0 ) Then
$szLogErrMessageForAssign &= "$j2, "
EndIf
If( $j3 = 0 ) Then
$szLogErrMessageForAssign &= "$j3, "
EndIf
If( $j4 = 0 ) Then
$szLogErrMessageForAssign &= "$j4."
EndIf
Call($szLogFuncHandler, "In __DROPBOX__COMM__SUBSCRIBE(), there was a problem calling Assign()." & _
$szLogErrMessageForAssign)
SetError(-2)
Return False
EndIf
Else
Call($szLogFuncHandler, "In __DROPBOX__COMM__SUBSCRIBE(), attempted to subscribe handler when limit reached")
SetError(-1)
Return False
EndIf
EndFunc
; Not intended to be called from the outside,
; but this function execs the stuff that was
; assigned in __SUBSCRIBE().
Func PRIVATE__DROPBOX__COMM__PARSE_SUBSCRIBERS()
AdlibUnRegister("PRIVATE__DROPBOX__COMM__PARSE_SUBSCRIBERS")
Local $i = 0
Local $aszListing = StringSplit($__DROPBOX__szREGISTERED_FUNCTIONS, "|")
; _ArrayDisplay($aszListing, "Stuff")
For $i = 1 To $aszListing[0]-1 Step 1
; ConsoleWrite("DEBUG: " & $aszListing[$i] & @LF)
;__PRIVATE__DROPBOX__COMM__SUBSCRIBE_
Local $chan = Eval("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$aszListing[$i] & "_szChannelName")
;ConsoleWrite("DEBUG: " & $chan & @LF)
Local $path = Eval("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$aszListing[$i] & "_szChannelPath")
;ConsoleWrite("DEBUG: " & $path & @LF)
Local $hand = Eval("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$aszListing[$i] & "_szFuncDataHandler")
; ConsoleWrite("DEBUG: " & Eval($hand) & @LF)
Local $logf = Eval("__PRIVATE__DROPBOX__COMM__SUBSCRIBE_" & _
$aszListing[$i] & "_szLogFuncHandler")
;ConsoleWrite("DEBUG: " & $logf & @LF)
__DROPBOX__COMM__READ($chan, $path, $hand, $logf)
Sleep($__DROPBOX__iINTERVAL_BETWEEN_SUBSCRIBER_NOTIFY)
Next
AdlibRegister("PRIVATE__DROPBOX__COMM__PARSE_SUBSCRIBERS", $__DROPBOX__iDEFAULT_CHANNEL_POLLING_PERIOD)
EndFunc
; The following function is used by __UNSUBSCRIBE()
; to alert the user if a deadlock error happens where,
; __UNSUBSCRIBE() doesn't correctly unsubscribe a function
; from being called.
Func PRIVATE__DROPBOX__COMM__UNSUBSCRIBED_FUNC_TRIGGER($msg)
Call("__DROPBOX__CERR", "In PRIVATE__DROPBOX__COMM__UNSUBSCRIBED_FUNC_TRIGGER(), " & _
"A FUNCTION THAT HAS BEEN REMOVED FROM THE NOTIFY LIST " & _
"HAS CALLED THIS FUNCTION, HERE IS THE DATA IT GAVE ME: " & _
$msg)
EndFunc
; This function unsubscribes a previously assigned
; function from the specified channel residing in
; the specified path. The function specified is
; removed from being called using AdLibUnRegister.
;
; Parameters:
; $szChannelName: The channel name to use
; $szChannelPath: The path the channel resides in
; [$szFuncName = "-1"]: The function to unregister from
; the call. The default for this is
; "-1", which basically means unsub
; -scribe everything.
; [$szLogFuncHandler]: A function to handle log information