ruby-macrodroid 0.2.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d741e63df502364d934438221160e20d967303ec5c79923924e7c978175f44d
4
- data.tar.gz: 9b0e372bb0cfc60ddcd553355bc30dbb90cdd303904c93556a8f16ef87fb2432
3
+ metadata.gz: c73d4f6bcddec53817e6ae7c59224759e58dd490ab53b2cab91728ceb98961f7
4
+ data.tar.gz: 37887f1b46a2158d5101b2c51ae444016dcf34606df34f8e6f58aed05482efb9
5
5
  SHA512:
6
- metadata.gz: 40c3507258eade1847ea92c63912f930db4c3843e36beec011e9b9fbaf5fbbc47ea9d8778aaaf7b43be9486ce63875116433065a007dd6956112128c1d96aa0f
7
- data.tar.gz: dff690f4ce9ebb274cc22f99c95f18981ab05136597a2b0c0eabdf9fa6848c004d2003b653b280da147302aec651731952b8d3c5077222bfc625d4e3819b0008
6
+ metadata.gz: 6bb6b3059e62aa4ce7924207a6fe545bc5b588d4ea4eab315361be595c47f343602a617dc7c2fdbc4701b44456dfcd18b255dc0fccfd904f7b56b5455f6f67a4
7
+ data.tar.gz: 2b7f77a7b582a0a8d7beda8ba09d10973e06a4844d114398a5bf534e755e66914cede0023693605abe0100f882befe7598271d70aaa5747bde9dac39c04d03d3
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,13 +2,91 @@
2
2
 
3
3
  # file: ruby-macrodroid.rb
4
4
 
5
- require 'pp'
6
- require 'json'
7
5
  require 'uuid'
8
- require 'date'
9
6
  require 'rxfhelper'
7
+ require 'chronic_cron'
10
8
 
11
9
 
10
+ MODEL =<<EOF
11
+ device
12
+ connectivity
13
+ airplane_mode is disabled
14
+ EOF
15
+
16
+ class TriggersNlp
17
+ include AppRoutes
18
+
19
+ def initialize()
20
+
21
+ super()
22
+ params = {}
23
+ triggers(params)
24
+
25
+ end
26
+
27
+ def triggers(params)
28
+
29
+ get /^(?:at )?(\d+:\d+(?:[ap]m)?) (?:on )?(.*)/i do |time, days|
30
+ [TimerTrigger, {time: time, days: days}]
31
+ end
32
+
33
+
34
+ end
35
+
36
+ alias find_trigger run_route
37
+
38
+ end
39
+
40
+ class ActionsNlp
41
+ include AppRoutes
42
+
43
+ def initialize()
44
+
45
+ super()
46
+ params = {}
47
+ actions(params)
48
+
49
+ end
50
+
51
+ def actions(params)
52
+
53
+ get /^message popup: (.*)/i do |msg|
54
+ [ToastAction, {msg: msg}]
55
+ end
56
+
57
+ get /^Popup Message ['"][^'"]+/i do |msg|
58
+ [ToastAction, {msg: msg}]
59
+ end
60
+
61
+ end
62
+
63
+ alias find_action run_route
64
+
65
+ end
66
+
67
+ class ConstraintsNlp
68
+ include AppRoutes
69
+
70
+ def initialize()
71
+
72
+ super()
73
+ params = {}
74
+ constraints(params)
75
+
76
+ end
77
+
78
+ def constraints(params)
79
+
80
+ get /^airplane mode (.*)/i do |state|
81
+ [AirplaneModeConstraint, {enabled: (state =~ /^enabled|on$/) == 0}]
82
+ end
83
+
84
+ end
85
+
86
+ alias find_constraint run_route
87
+
88
+ end
89
+
12
90
  module Params
13
91
 
14
92
  refine Hash do
@@ -20,7 +98,7 @@ module Params
20
98
  h.inject({}) do |r, x|
21
99
 
22
100
  key, value = x
23
- puts 'value: ' + value.inspect
101
+ #puts 'value: ' + value.inspect
24
102
 
25
103
  val = if value.is_a?(Hash) then
26
104
  to_snake_case(value)
@@ -66,16 +144,16 @@ class Macro
66
144
  using ColouredText
67
145
  using Params
68
146
 
69
- attr_reader :local_variables, :triggers, :actions, :guid
70
- attr_accessor :name
147
+ attr_reader :local_variables, :triggers, :actions, :constraints, :guid
148
+ attr_accessor :title
71
149
 
72
150
  def initialize(name=nil, debug: false)
73
151
 
74
- @name, @debug = name, debug
75
- lv=[], triggers=[], actions=[]
76
- @local_variables, @triggers, @actions = lv, triggers, actions
152
+ @title, @debug = name, debug
153
+
154
+ puts 'inside Macro#initialize' if @debug
77
155
 
78
- @triggers, @actions = [], []
156
+ @local_variables, @triggers, @actions, @constraints = [], [], [], []
79
157
  @h = {}
80
158
 
81
159
  end
@@ -107,9 +185,9 @@ class Macro
107
185
  local_variables: @local_variables,
108
186
  m_trigger_list: @triggers.map(&:to_h),
109
187
  m_action_list: @actions.map(&:to_h),
110
- m_constraint_list: [],
188
+ m_constraint_list: @constraints.map(&:to_h),
111
189
  m_description: '',
112
- m_name: @name,
190
+ m_name: title(),
113
191
  m_excludeLog: false,
114
192
  m_GUID: guid(),
115
193
  m_isOrCondition: false,
@@ -125,6 +203,13 @@ class Macro
125
203
 
126
204
  def import_h(h)
127
205
 
206
+ if @debug then
207
+ puts 'inside import_h'
208
+ puts 'h:' + h.inspect
209
+ end
210
+
211
+ @title = h[:name]
212
+
128
213
  # fetch the local variables
129
214
  @local_variables = h['local_variables']
130
215
 
@@ -139,13 +224,15 @@ class Macro
139
224
  object(action.to_snake_case)
140
225
  end
141
226
 
142
- # fetch the constraints (not yet implemented)
227
+ # fetch the constraints
228
+ @constraints = h[:constraint_list].map do |constraint|
229
+ object(constraint.to_snake_case)
230
+ end
143
231
 
144
232
  @h = h
145
233
 
146
- %i(local_variables m_trigger_list m_action_list).each do |x|
147
- @h[x] = []
148
- end
234
+ %i(local_variables m_trigger_list m_action_list m_constraint_list)\
235
+ .each {|x| @h[x] = [] }
149
236
 
150
237
  @h
151
238
 
@@ -153,34 +240,133 @@ class Macro
153
240
 
154
241
  def import_xml(node)
155
242
 
156
- @name = node.attributes[:name]
243
+ if @debug then
244
+ puts 'inside Macro#import_xml'
245
+ puts 'node: ' + node.xml.inspect
246
+ end
247
+
248
+ @title = node.attributes[:name]
157
249
 
158
- # get all the triggers
159
- @triggers = node.xpath('triggers/*').map do |e|
250
+ if node.element('triggers') then
160
251
 
161
- puts 'e.name: ' + e.name.inspect if @debug
162
- {timer: TimerTrigger}[e.name.to_sym].new(e.attributes.to_h)
252
+ # level 2
163
253
 
164
- end
254
+ # get all the triggers
255
+ @triggers = node.xpath('triggers/*').map do |e|
256
+
257
+ puts 'e.name: ' + e.name.inspect if @debug
258
+ {timer: TimerTrigger}[e.name.to_sym].new(e.attributes.to_h)
259
+
260
+ end
261
+
262
+ # get all the actions
263
+ @actions = node.xpath('actions/*').map do |e|
264
+
265
+ if e.name == 'notification' then
266
+
267
+ case e.attributes[:type].to_sym
268
+ when :popup
269
+ e.attributes.delete :type
270
+ ToastAction.new e.attributes.to_h
271
+ end
272
+
273
+ end
274
+
275
+ end
276
+
277
+ # get all the constraints
278
+ @constraints = node.xpath('constraints/*').map do |e|
279
+
280
+ puts 'e.name: ' + e.name.inspect if @debug
281
+ {airplanemode: AirplaneModeConstraint}[e.name.to_sym].new(e.attributes.to_h)
165
282
 
166
- # get all the actions
167
- @actions = node.xpath('actions/*').map do |e|
283
+ end
284
+
285
+ else
286
+
287
+ # Level 1
168
288
 
169
- if e.name == 'notification' then
289
+ tp = TriggersNlp.new
290
+
291
+ @triggers = node.xpath('trigger').map do |e|
292
+
293
+ r = tp.find_trigger e.text
170
294
 
171
- case e.attributes[:type].to_sym
172
- when :popup
173
- e.attributes.delete :type
174
- ToastAction.new e.attributes.to_h
295
+ puts 'found trigger ' + r.inspect if @debug
296
+
297
+ if r then
298
+ r[0].new(r[1])
175
299
  end
176
300
 
177
301
  end
178
-
179
- end
302
+
303
+ ap = ActionsNlp.new
304
+
305
+ @actions = node.xpath('action').map do |e|
306
+
307
+ r = ap.find_action e.text
308
+ puts 'found action ' + r.inspect if @debug
309
+
310
+ if r then
311
+ r[0].new(r[1])
312
+ end
313
+
314
+ end
315
+
316
+ cp = ConstraintsNlp.new
317
+
318
+ @constraints = node.xpath('constraint').map do |e|
319
+
320
+ r = cp.find_constraint e.text
321
+ puts 'found constraint ' + r.inspect if @debug
322
+
323
+ if r then
324
+ r[0].new(r[1])
325
+ end
326
+
327
+ end
328
+
329
+ end
180
330
 
181
331
  self
182
332
 
183
333
  end
334
+
335
+ def match?(triggerx, detail={time: $env[:time]}, model=nil )
336
+
337
+ if @triggers.any? {|x| x.type == triggerx and x.match?(detail, model) } then
338
+
339
+ if @debug then
340
+ puts 'checking constraints ...'
341
+ puts '@constraints: ' + @constraints.inspect
342
+ end
343
+
344
+ if @constraints.all? {|x| x.match?($env.merge(detail), model) } then
345
+
346
+ true
347
+
348
+ else
349
+
350
+ return false
351
+
352
+ end
353
+
354
+ end
355
+
356
+ end
357
+
358
+ def run()
359
+ @actions.map(&:invoke)
360
+ end
361
+
362
+ def to_s()
363
+ [
364
+ 'm: ' + @title,
365
+ @triggers.map {|x| "t: %s" % x}.join("\n"),
366
+ @actions.map {|x| "a: %s" % x}.join("\n"),
367
+ @constraints.map {|x| "a: %s" % x}.join("\n")
368
+ ].join("\n")
369
+ end
184
370
 
185
371
  private
186
372
 
@@ -214,10 +400,12 @@ class MacroDroid
214
400
 
215
401
  if s[0] == '{' then
216
402
  import_json(s)
217
- else
218
- s[0] == '<'
403
+ elsif s[0] == '<'
219
404
  import_xml(s)
220
405
  @h = build_h
406
+ else
407
+ import_xml(text_to_xml(s))
408
+ @h = build_h
221
409
  end
222
410
 
223
411
  else
@@ -235,6 +423,7 @@ class MacroDroid
235
423
 
236
424
  def build_h()
237
425
 
426
+ puts 'inside Macro#build_h' if @debug
238
427
  {
239
428
  cell_tower_groups: [],
240
429
  cell_towers_ignore: [],
@@ -271,11 +460,11 @@ class MacroDroid
271
460
  def import_json(s)
272
461
 
273
462
  @h = JSON.parse(s, symbolize_names: true).to_snake_case
274
- puts ('@h: ' + @h.pretty_inspect).debug if @debug
463
+ puts ('@h: ' + @h.inspect).debug if @debug
275
464
 
276
465
  @macros = @h[:macro_list].map do |macro|
277
466
 
278
- puts ('macro: ' + macro.pretty_inspect).debug if @debug
467
+ puts ('macro: ' + macro.inspect).debug if @debug
279
468
  m = Macro.new(debug: @debug)
280
469
  m.import_h(macro)
281
470
  m
@@ -295,12 +484,39 @@ class MacroDroid
295
484
 
296
485
  @macros = doc.root.xpath('macro').map do |node|
297
486
 
298
- macro = Macro.new @name
487
+ macro = Macro.new @title, debug: @debug
299
488
  macro.import_xml(node)
300
489
  macro
301
490
 
302
491
  end
303
492
  end
493
+
494
+ def text_to_xml(s)
495
+
496
+ a = s.split(/.*(?=^m:)/); a.shift
497
+ a.map!(&:chomp)
498
+
499
+ macros = a.map do |x|
500
+
501
+ lines = x.lines
502
+ puts 'lines: ' + lines.inspect if @debug
503
+
504
+ name = lines.shift[/^m: +(.*)/,1]
505
+ h = {t: [], a: [], c: []}
506
+
507
+ lines.each {|line| h[line[0].to_sym] << line[/^\w: +(.*)/,1] }
508
+ triggers = h[:t].map {|text| [:trigger, {}, text]}
509
+ actions = h[:a].map {|text| [:action, {}, text]}
510
+ constraints = h[:c].map {|text| [:constraint, {}, text]}
511
+
512
+ [:macro, {name: name},'', *triggers, *actions, *constraints]
513
+
514
+ end
515
+
516
+ doc = Rexle.new([:macros, {}, '', *macros])
517
+ doc.root.xml pretty: true
518
+
519
+ end
304
520
 
305
521
  def to_h()
306
522
 
@@ -308,17 +524,29 @@ class MacroDroid
308
524
 
309
525
  end
310
526
 
311
-
527
+ def to_s()
528
+ @macros.map(&:to_s).join("\n\n")
529
+ end
312
530
 
313
531
  end
314
532
 
315
533
  class MacroObject
534
+ using ColouredText
535
+
536
+ attr_reader :type
537
+ attr_accessor :options
316
538
 
317
539
  def initialize(h={})
318
540
 
319
541
  @h = {constraint_list: [], is_or_condition: false,
320
542
  is_disabled: false}.merge(h)
321
543
  @list = []
544
+
545
+ # fetch the class name and convert from camelCase to snake_eyes
546
+ @type = self.class.to_s.sub(/Trigger|Action$/,'')\
547
+ .gsub(/\B[A-Z][a-z]/){|x| '_' + x.downcase}\
548
+ .gsub(/[a-z][A-Z]/){|x| x[0] + '_' + x[1].downcase}\
549
+ .downcase.to_sym
322
550
  end
323
551
 
324
552
  def to_h()
@@ -341,6 +569,13 @@ class MacroObject
341
569
 
342
570
  protected
343
571
 
572
+ def filter(options, h)
573
+
574
+ (h.keys - options.keys).each {|key| h.delete key }
575
+ return h
576
+
577
+ end
578
+
344
579
  def uuid()
345
580
  UUID.new.generate
346
581
  end
@@ -353,11 +588,19 @@ class Trigger < MacroObject
353
588
  super({fakeIcon: 0}.merge(h))
354
589
  @list << 'fakeIcon'
355
590
  end
591
+
592
+ def match?(detail={}, model=nil)
356
593
 
357
- end
594
+ # only match where the key exists in the trigger object
595
+ detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
596
+
597
+ end
358
598
 
599
+ end
359
600
 
360
601
 
602
+ # Category: Applications
603
+ #
361
604
  class WebHookTrigger < Trigger
362
605
 
363
606
  def initialize(h={})
@@ -372,6 +615,22 @@ class WebHookTrigger < Trigger
372
615
 
373
616
  end
374
617
 
618
+ # Category: Applications
619
+ #
620
+ # Also known as Wifi State Change
621
+ #
622
+ # wifi_state options:
623
+ # 0 - Wifi Enabled
624
+ # 1 - Wifi Disabled
625
+ # 2 - Connected to network
626
+ # ssid_list options:
627
+ # ["Any Network"]
628
+ # ["some Wifi SSID"] - 1 or more SSID can be supplied
629
+ # 3 - Disconnected from network
630
+ # ssid_list options:
631
+ # ["Any Network"]
632
+ # ["some Wifi SSID"] - 1 or more SSID can be supplied
633
+
375
634
  class WifiConnectionTrigger < Trigger
376
635
 
377
636
  def initialize(h={})
@@ -387,6 +646,8 @@ class WifiConnectionTrigger < Trigger
387
646
 
388
647
  end
389
648
 
649
+ # Category: Applications
650
+ #
390
651
  class ApplicationInstalledRemovedTrigger < Trigger
391
652
 
392
653
  def initialize(h={})
@@ -405,6 +666,8 @@ class ApplicationInstalledRemovedTrigger < Trigger
405
666
 
406
667
  end
407
668
 
669
+ # Category: Applications
670
+ #
408
671
  class ApplicationLaunchedTrigger < Trigger
409
672
 
410
673
  def initialize(h={})
@@ -421,6 +684,8 @@ class ApplicationLaunchedTrigger < Trigger
421
684
 
422
685
  end
423
686
 
687
+ # Category: Battery/Power
688
+ #
424
689
  class BatteryLevelTrigger < Trigger
425
690
 
426
691
  def initialize(h={})
@@ -437,6 +702,8 @@ class BatteryLevelTrigger < Trigger
437
702
 
438
703
  end
439
704
 
705
+ # Category: Battery/Power
706
+ #
440
707
  class BatteryTemperatureTrigger < Trigger
441
708
 
442
709
  def initialize(h={})
@@ -453,6 +720,8 @@ class BatteryTemperatureTrigger < Trigger
453
720
 
454
721
  end
455
722
 
723
+ # Category: Battery/Power
724
+ #
456
725
  class PowerButtonToggleTrigger < Trigger
457
726
 
458
727
  def initialize(h={})
@@ -467,6 +736,9 @@ class PowerButtonToggleTrigger < Trigger
467
736
 
468
737
  end
469
738
 
739
+
740
+ # Category: Battery/Power
741
+ #
470
742
  class ExternalPowerTrigger < Trigger
471
743
 
472
744
  def initialize(h={})
@@ -484,6 +756,8 @@ class ExternalPowerTrigger < Trigger
484
756
 
485
757
  end
486
758
 
759
+ # Category: Call/SMS
760
+ #
487
761
  class CallActiveTrigger < Trigger
488
762
 
489
763
  def initialize(h={})
@@ -500,6 +774,8 @@ class CallActiveTrigger < Trigger
500
774
 
501
775
  end
502
776
 
777
+ # Category: Call/SMS
778
+ #
503
779
  class IncomingCallTrigger < Trigger
504
780
 
505
781
  def initialize(h={})
@@ -518,6 +794,8 @@ class IncomingCallTrigger < Trigger
518
794
 
519
795
  end
520
796
 
797
+ # Category: Call/SMS
798
+ #
521
799
  class OutgoingCallTrigger < Trigger
522
800
 
523
801
  def initialize(h={})
@@ -536,6 +814,8 @@ class OutgoingCallTrigger < Trigger
536
814
 
537
815
  end
538
816
 
817
+ # Category: Call/SMS
818
+ #
539
819
  class CallEndedTrigger < Trigger
540
820
 
541
821
  def initialize(h={})
@@ -554,6 +834,8 @@ class CallEndedTrigger < Trigger
554
834
 
555
835
  end
556
836
 
837
+ # Category: Call/SMS
838
+ #
557
839
  class CallMissedTrigger < Trigger
558
840
 
559
841
  def initialize(h={})
@@ -568,6 +850,8 @@ class CallMissedTrigger < Trigger
568
850
 
569
851
  end
570
852
 
853
+ # Category: Call/SMS
854
+ #
571
855
  class IncomingSMSTrigger < Trigger
572
856
 
573
857
  def initialize(h={})
@@ -590,6 +874,8 @@ class IncomingSMSTrigger < Trigger
590
874
 
591
875
  end
592
876
 
877
+ # Category: Connectivity
878
+ #
593
879
  class WebHookTrigger < Trigger
594
880
 
595
881
  def initialize(h={})
@@ -604,6 +890,8 @@ class WebHookTrigger < Trigger
604
890
 
605
891
  end
606
892
 
893
+ # Category: Connectivity
894
+ #
607
895
  class WifiConnectionTrigger < Trigger
608
896
 
609
897
  def initialize(h={})
@@ -619,6 +907,8 @@ class WifiConnectionTrigger < Trigger
619
907
 
620
908
  end
621
909
 
910
+ # Category: Connectivity
911
+ #
622
912
  class BluetoothTrigger < Trigger
623
913
 
624
914
  def initialize(h={})
@@ -635,6 +925,8 @@ class BluetoothTrigger < Trigger
635
925
 
636
926
  end
637
927
 
928
+ # Category: Connectivity
929
+ #
638
930
  class HeadphonesTrigger < Trigger
639
931
 
640
932
  def initialize(h={})
@@ -650,6 +942,8 @@ class HeadphonesTrigger < Trigger
650
942
 
651
943
  end
652
944
 
945
+ # Category: Connectivity
946
+ #
653
947
  class SignalOnOffTrigger < Trigger
654
948
 
655
949
  def initialize(h={})
@@ -664,6 +958,8 @@ class SignalOnOffTrigger < Trigger
664
958
 
665
959
  end
666
960
 
961
+ # Category: Connectivity
962
+ #
667
963
  class UsbDeviceConnectionTrigger < Trigger
668
964
 
669
965
  def initialize(h={})
@@ -678,22 +974,45 @@ class UsbDeviceConnectionTrigger < Trigger
678
974
 
679
975
  end
680
976
 
977
+ # Category: Connectivity
978
+ #
979
+ # Also known as Wifi SSID Transition
980
+ #
981
+ # options:
982
+ # in_range: true | false
983
+ # wifi_cell_info: {display_name: "some Wifi SSID",
984
+ # ssid: "some Wifi SSID"} - 1 or more allowed
985
+ #
681
986
  class WifiSSIDTrigger < Trigger
682
987
 
683
988
  def initialize(h={})
684
989
 
685
990
  options = {
686
- wifi_cell_info_list: [{:displayName=>"", :ssid=>""}],
991
+ wifi_cell_info_list: [{:display_name=>"", :ssid=>""}],
687
992
  ssid_list: [],
688
- _in_range: true
993
+ in_range: true
689
994
  }
690
995
 
691
996
  super(options.merge h)
692
997
 
693
998
  end
999
+
1000
+ def to_h()
1001
+
1002
+ h = super()
1003
+ val = h[:m_inRange]
1004
+
1005
+ h[:m_InRange] = val
1006
+ h.delete :m_inRange
1007
+
1008
+ return h
1009
+
1010
+ end
694
1011
 
695
1012
  end
696
1013
 
1014
+ # Category: Date/Time
1015
+ #
697
1016
  class CalendarTrigger < Trigger
698
1017
 
699
1018
  def initialize(h={})
@@ -718,15 +1037,21 @@ class CalendarTrigger < Trigger
718
1037
 
719
1038
  end
720
1039
 
1040
+ # Category: Date/Time
1041
+ #
721
1042
  class TimerTrigger < Trigger
1043
+ using ColouredText
1044
+
722
1045
 
723
1046
  def initialize(h={})
1047
+
1048
+ puts 'TimerTrigger h: ' + h.inspect if $debug
724
1049
 
725
1050
  if h[:days] then
726
1051
 
727
1052
  days = [false] * 7
728
-
729
- h[:days].split(/, +/).each do |x|
1053
+
1054
+ h[:days].split(/, */).each do |x|
730
1055
 
731
1056
  r = Date::DAYNAMES.grep /#{x}/i
732
1057
  i = Date::DAYNAMES.index(r.first)
@@ -735,7 +1060,6 @@ class TimerTrigger < Trigger
735
1060
  end
736
1061
 
737
1062
  h[:days_of_week] = days
738
- h.delete :days
739
1063
 
740
1064
  end
741
1065
 
@@ -743,24 +1067,58 @@ class TimerTrigger < Trigger
743
1067
 
744
1068
  t = Time.parse(h[:time])
745
1069
  h[:hour], h[:minute] = t.hour, t.min
746
- h.delete :time
747
1070
 
748
1071
  end
1072
+
1073
+ #puts ('h: ' + h.inspect).debug
749
1074
 
750
1075
  options = {
751
1076
  alarm_id: uuid(),
752
- days_of_week: [false, true, false, false, false, false, false],
1077
+ days_of_week: [false, false, false, false, false, false, false],
753
1078
  minute: 10,
754
1079
  hour: 7,
755
1080
  use_alarm: false
756
1081
  }
1082
+
1083
+ super(options.merge filter(options,h))
757
1084
 
758
- super(options.merge h)
1085
+ end
1086
+
1087
+ def match?(detail={time: $env[:time]}, model=nil)
1088
+
1089
+ a = @h[:days_of_week]
1090
+ a.unshift a.pop
1091
+
1092
+ dow = a.map.with_index {|x, i| x ? i : nil }.compact.join(',')
1093
+
1094
+ s = "%s %s * * %s" % [@h[:minute], @h[:hour], dow]
1095
+
1096
+ if $debug then
1097
+ puts 's: ' + s.inspect
1098
+ puts 'detail: ' + detail.inspect
1099
+ puts '@h: ' + @h.inspect
1100
+ end
1101
+
1102
+ ChronicCron.new(s, detail[:time]).to_time == detail[:time]
1103
+
1104
+ end
1105
+
1106
+ def to_s()
1107
+
1108
+ dow = @h[:days_of_week]
759
1109
 
1110
+ a = Date::ABBR_DAYNAMES
1111
+
1112
+ time = Time.parse("%s:%s" % [@h[:hour], @h[:minute]]).strftime("%-H:%M%P")
1113
+ days = (a[1..-1] << a.first).zip(dow).select {|_,b| b}.map(&:first)
1114
+
1115
+ "at %s on %s" % [time, days.join(', ')]
760
1116
  end
761
1117
 
762
1118
  end
763
1119
 
1120
+ # Category: Date/Time
1121
+ #
764
1122
  class StopwatchTrigger < Trigger
765
1123
 
766
1124
  def initialize(h={})
@@ -776,6 +1134,13 @@ class StopwatchTrigger < Trigger
776
1134
 
777
1135
  end
778
1136
 
1137
+ # Category: Date/Time
1138
+ #
1139
+ # Also known as Day of Week/Month
1140
+ #
1141
+ # month_of_year equal to 0 means it occurs every month
1142
+ # day_of_week starts with a Monday (value is 0)
1143
+ #
779
1144
  class DayTrigger < Trigger
780
1145
 
781
1146
  def initialize(h={})
@@ -797,6 +1162,10 @@ class DayTrigger < Trigger
797
1162
 
798
1163
  end
799
1164
 
1165
+ # Category: Date/Time
1166
+ #
1167
+ # Regular Interval
1168
+ #
800
1169
  class RegularIntervalTrigger < Trigger
801
1170
 
802
1171
  def initialize(h={})
@@ -816,6 +1185,17 @@ class RegularIntervalTrigger < Trigger
816
1185
 
817
1186
  end
818
1187
 
1188
+ # Category: Device Events
1189
+ #
1190
+ # Airplane Mode Changed
1191
+ #
1192
+ # options:
1193
+ # Airplane Mode Enabled
1194
+ # Airplane Mode Disabled
1195
+ #
1196
+ # shorthand example:
1197
+ # airplanemode: enabled
1198
+ #
819
1199
  class AirplaneModeTrigger < Trigger
820
1200
 
821
1201
  def initialize(h={})
@@ -830,6 +1210,8 @@ class AirplaneModeTrigger < Trigger
830
1210
 
831
1211
  end
832
1212
 
1213
+ # Category: Device Events
1214
+ #
833
1215
  class AutoSyncChangeTrigger < Trigger
834
1216
 
835
1217
  def initialize(h={})
@@ -844,6 +1226,8 @@ class AutoSyncChangeTrigger < Trigger
844
1226
 
845
1227
  end
846
1228
 
1229
+ # Category: Device Events
1230
+ #
847
1231
  class DayDreamTrigger < Trigger
848
1232
 
849
1233
  def initialize(h={})
@@ -858,6 +1242,8 @@ class DayDreamTrigger < Trigger
858
1242
 
859
1243
  end
860
1244
 
1245
+ # Category: Device Events
1246
+ #
861
1247
  class DockTrigger < Trigger
862
1248
 
863
1249
  def initialize(h={})
@@ -872,6 +1258,8 @@ class DockTrigger < Trigger
872
1258
 
873
1259
  end
874
1260
 
1261
+ # Category: Device Events
1262
+ #
875
1263
  class GPSEnabledTrigger < Trigger
876
1264
 
877
1265
  def initialize(h={})
@@ -886,6 +1274,8 @@ class GPSEnabledTrigger < Trigger
886
1274
 
887
1275
  end
888
1276
 
1277
+ # Category: Device Events
1278
+ #
889
1279
  class MusicPlayingTrigger < Trigger
890
1280
 
891
1281
  def initialize(h={})
@@ -900,19 +1290,9 @@ class MusicPlayingTrigger < Trigger
900
1290
 
901
1291
  end
902
1292
 
903
- class DeviceUnlockedTrigger < Trigger
904
-
905
- def initialize(h={})
906
-
907
- options = {
908
- }
909
-
910
- super(options.merge h)
911
-
912
- end
913
-
914
- end
915
1293
 
1294
+ # Category: Device Events
1295
+ #
916
1296
  class DeviceUnlockedTrigger < Trigger
917
1297
 
918
1298
  def initialize(h={})
@@ -926,6 +1306,8 @@ class DeviceUnlockedTrigger < Trigger
926
1306
 
927
1307
  end
928
1308
 
1309
+ # Category: Device Events
1310
+ #
929
1311
  class AutoRotateChangeTrigger < Trigger
930
1312
 
931
1313
  def initialize(h={})
@@ -940,6 +1322,8 @@ class AutoRotateChangeTrigger < Trigger
940
1322
 
941
1323
  end
942
1324
 
1325
+ # Category: Device Events
1326
+ #
943
1327
  class ClipboardChangeTrigger < Trigger
944
1328
 
945
1329
  def initialize(h={})
@@ -955,6 +1339,8 @@ class ClipboardChangeTrigger < Trigger
955
1339
 
956
1340
  end
957
1341
 
1342
+ # Category: Device Events
1343
+ #
958
1344
  class BootTrigger < Trigger
959
1345
 
960
1346
  def initialize(h={})
@@ -968,19 +1354,8 @@ class BootTrigger < Trigger
968
1354
 
969
1355
  end
970
1356
 
971
- class BootTrigger < Trigger
972
-
973
- def initialize(h={})
974
-
975
- options = {
976
- }
977
-
978
- super(options.merge h)
979
-
980
- end
981
-
982
- end
983
-
1357
+ # Category: Device Events
1358
+ #
984
1359
  class IntentReceivedTrigger < Trigger
985
1360
 
986
1361
  def initialize(h={})
@@ -999,6 +1374,8 @@ class IntentReceivedTrigger < Trigger
999
1374
 
1000
1375
  end
1001
1376
 
1377
+ # Category: Device Events
1378
+ #
1002
1379
  class NotificationTrigger < Trigger
1003
1380
 
1004
1381
  def initialize(h={})
@@ -1023,6 +1400,8 @@ class NotificationTrigger < Trigger
1023
1400
 
1024
1401
  end
1025
1402
 
1403
+ # Category: Device Events
1404
+ #
1026
1405
  class ScreenOnOffTrigger < Trigger
1027
1406
 
1028
1407
  def initialize(h={})
@@ -1037,6 +1416,8 @@ class ScreenOnOffTrigger < Trigger
1037
1416
 
1038
1417
  end
1039
1418
 
1419
+ # Category: Device Events
1420
+ #
1040
1421
  class SilentModeTrigger < Trigger
1041
1422
 
1042
1423
  def initialize(h={})
@@ -1051,6 +1432,8 @@ class SilentModeTrigger < Trigger
1051
1432
 
1052
1433
  end
1053
1434
 
1435
+ # Category: Location
1436
+ #
1054
1437
  class WeatherTrigger < Trigger
1055
1438
 
1056
1439
  def initialize(h={})
@@ -1074,6 +1457,8 @@ class WeatherTrigger < Trigger
1074
1457
 
1075
1458
  end
1076
1459
 
1460
+ # Category: Location
1461
+ #
1077
1462
  class GeofenceTrigger < Trigger
1078
1463
 
1079
1464
  def initialize(h={})
@@ -1092,6 +1477,8 @@ class GeofenceTrigger < Trigger
1092
1477
 
1093
1478
  end
1094
1479
 
1480
+ # Category: Location
1481
+ #
1095
1482
  class SunriseSunsetTrigger < Trigger
1096
1483
 
1097
1484
  def initialize(h={})
@@ -1107,7 +1494,8 @@ class SunriseSunsetTrigger < Trigger
1107
1494
 
1108
1495
  end
1109
1496
 
1110
-
1497
+ # Category: Sensors
1498
+ #
1111
1499
  class ActivityRecognitionTrigger < Trigger
1112
1500
 
1113
1501
  def initialize(h={})
@@ -1123,7 +1511,8 @@ class ActivityRecognitionTrigger < Trigger
1123
1511
 
1124
1512
  end
1125
1513
 
1126
-
1514
+ # Category: Sensors
1515
+ #
1127
1516
  class ProximityTrigger < Trigger
1128
1517
 
1129
1518
  def initialize(h={})
@@ -1139,6 +1528,8 @@ class ProximityTrigger < Trigger
1139
1528
 
1140
1529
  end
1141
1530
 
1531
+ # Category: Sensors
1532
+ #
1142
1533
  class ShakeDeviceTrigger < Trigger
1143
1534
 
1144
1535
  def initialize(h={})
@@ -1152,6 +1543,8 @@ class ShakeDeviceTrigger < Trigger
1152
1543
 
1153
1544
  end
1154
1545
 
1546
+ # Category: Sensors
1547
+ #
1155
1548
  class FlipDeviceTrigger < Trigger
1156
1549
 
1157
1550
  def initialize(h={})
@@ -1168,6 +1561,8 @@ class FlipDeviceTrigger < Trigger
1168
1561
 
1169
1562
  end
1170
1563
 
1564
+ # Category: Sensors
1565
+ #
1171
1566
  class OrientationTrigger < Trigger
1172
1567
 
1173
1568
  def initialize(h={})
@@ -1183,6 +1578,8 @@ class OrientationTrigger < Trigger
1183
1578
 
1184
1579
  end
1185
1580
 
1581
+ # Category: User Input
1582
+ #
1186
1583
  class FloatingButtonTrigger < Trigger
1187
1584
 
1188
1585
  def initialize(h={})
@@ -1206,6 +1603,8 @@ class FloatingButtonTrigger < Trigger
1206
1603
 
1207
1604
  end
1208
1605
 
1606
+ # Category: User Input
1607
+ #
1209
1608
  class ShortcutTrigger < Trigger
1210
1609
 
1211
1610
  def initialize(h={})
@@ -1219,6 +1618,8 @@ class ShortcutTrigger < Trigger
1219
1618
 
1220
1619
  end
1221
1620
 
1621
+ # Category: User Input
1622
+ #
1222
1623
  class VolumeButtonTrigger < Trigger
1223
1624
 
1224
1625
  def initialize(h={})
@@ -1236,6 +1637,8 @@ class VolumeButtonTrigger < Trigger
1236
1637
 
1237
1638
  end
1238
1639
 
1640
+ # Category: User Input
1641
+ #
1239
1642
  class MediaButtonPressedTrigger < Trigger
1240
1643
 
1241
1644
  def initialize(h={})
@@ -1251,6 +1654,8 @@ class MediaButtonPressedTrigger < Trigger
1251
1654
 
1252
1655
  end
1253
1656
 
1657
+ # Category: User Input
1658
+ #
1254
1659
  class SwipeTrigger < Trigger
1255
1660
 
1256
1661
  def initialize(h={})
@@ -1273,14 +1678,30 @@ class Action < MacroObject
1273
1678
  def initialize(h={})
1274
1679
  super(h)
1275
1680
  end
1681
+
1682
+ def invoke(s='')
1683
+ "%s/%s: %s" % [@group, @type, s]
1684
+ end
1276
1685
 
1277
1686
  end
1278
1687
 
1279
1688
 
1689
+ class LocationAction < Action
1690
+
1691
+ def initialize(h={})
1692
+ super(h)
1693
+ @group = 'location'
1694
+ end
1695
+
1696
+ end
1280
1697
 
1281
- class ShareLocationAction < Action
1698
+ # Category: Location
1699
+ #
1700
+ class ShareLocationAction < LocationAction
1282
1701
 
1283
1702
  def initialize(h={})
1703
+
1704
+ super()
1284
1705
 
1285
1706
  options = {
1286
1707
  email: '',
@@ -1298,39 +1719,19 @@ class ShareLocationAction < Action
1298
1719
 
1299
1720
  end
1300
1721
 
1301
- class UDPCommandAction < Action
1302
-
1303
- def initialize(h={})
1304
-
1305
- options = {
1306
- destination: '',
1307
- message: '',
1308
- port: 1024
1309
- }
1310
-
1311
- super(options.merge h)
1312
-
1313
- end
1314
-
1315
- end
1316
-
1317
- class UDPCommandAction < Action
1318
1722
 
1723
+ class ApplicationAction < Action
1724
+
1319
1725
  def initialize(h={})
1320
-
1321
- options = {
1322
- destination: '',
1323
- message: '',
1324
- port: 1024
1325
- }
1326
-
1327
- super(options.merge h)
1328
-
1726
+ super(h)
1727
+ @group = 'application'
1329
1728
  end
1330
-
1729
+
1331
1730
  end
1332
1731
 
1333
- class LaunchActivityAction < Action
1732
+ # Category: Applications
1733
+ #
1734
+ class LaunchActivityAction < ApplicationAction
1334
1735
 
1335
1736
  def initialize(h={})
1336
1737
 
@@ -1347,7 +1748,9 @@ class LaunchActivityAction < Action
1347
1748
 
1348
1749
  end
1349
1750
 
1350
- class KillBackgroundAppAction < Action
1751
+ # Category: Applications
1752
+ #
1753
+ class KillBackgroundAppAction < ApplicationAction
1351
1754
 
1352
1755
  def initialize(h={})
1353
1756
 
@@ -1362,7 +1765,9 @@ class KillBackgroundAppAction < Action
1362
1765
 
1363
1766
  end
1364
1767
 
1365
- class OpenWebPageAction < Action
1768
+ # Category: Applications
1769
+ #
1770
+ class OpenWebPageAction < ApplicationAction
1366
1771
 
1367
1772
  def initialize(h={})
1368
1773
 
@@ -1380,7 +1785,19 @@ class OpenWebPageAction < Action
1380
1785
 
1381
1786
  end
1382
1787
 
1383
- class UploadPhotoAction < Action
1788
+
1789
+ class CameraAction < Action
1790
+
1791
+ def initialize(h={})
1792
+ super(h)
1793
+ @group = 'camera'
1794
+ end
1795
+
1796
+ end
1797
+
1798
+ # Category: Camera/Photo
1799
+ #
1800
+ class UploadPhotoAction < CameraAction
1384
1801
 
1385
1802
  def initialize(h={})
1386
1803
 
@@ -1395,7 +1812,9 @@ class UploadPhotoAction < Action
1395
1812
 
1396
1813
  end
1397
1814
 
1398
- class TakePictureAction < Action
1815
+ # Category: Camera/Photo
1816
+ #
1817
+ class TakePictureAction < CameraAction
1399
1818
 
1400
1819
  def initialize(h={})
1401
1820
 
@@ -1413,7 +1832,19 @@ class TakePictureAction < Action
1413
1832
 
1414
1833
  end
1415
1834
 
1416
- class SetWifiAction < Action
1835
+
1836
+ class ConnectivityAction < Action
1837
+
1838
+ def initialize(h={})
1839
+ super(h)
1840
+ @group = 'connectivity'
1841
+ end
1842
+
1843
+ end
1844
+
1845
+ # Category: Connectivity
1846
+ #
1847
+ class SetWifiAction < ConnectivityAction
1417
1848
 
1418
1849
  def initialize(h={})
1419
1850
 
@@ -1429,7 +1860,9 @@ class SetWifiAction < Action
1429
1860
 
1430
1861
  end
1431
1862
 
1432
- class SetBluetoothAction < Action
1863
+ # Category: Connectivity
1864
+ #
1865
+ class SetBluetoothAction < ConnectivityAction
1433
1866
 
1434
1867
  def initialize(h={})
1435
1868
 
@@ -1444,7 +1877,9 @@ class SetBluetoothAction < Action
1444
1877
 
1445
1878
  end
1446
1879
 
1447
- class SetBluetoothAction < Action
1880
+ # Category: Connectivity
1881
+ #
1882
+ class SetBluetoothAction < ConnectivityAction
1448
1883
 
1449
1884
  def initialize(h={})
1450
1885
 
@@ -1459,7 +1894,9 @@ class SetBluetoothAction < Action
1459
1894
 
1460
1895
  end
1461
1896
 
1462
- class SendIntentAction < Action
1897
+ # Category: Connectivity
1898
+ #
1899
+ class SendIntentAction < ConnectivityAction
1463
1900
 
1464
1901
  def initialize(h={})
1465
1902
 
@@ -1485,7 +1922,19 @@ class SendIntentAction < Action
1485
1922
 
1486
1923
  end
1487
1924
 
1488
- class SetAlarmClockAction < Action
1925
+
1926
+ class DateTimeAction < Action
1927
+
1928
+ def initialize(h={})
1929
+ super(h)
1930
+ @group = 'datetime'
1931
+ end
1932
+
1933
+ end
1934
+
1935
+ # Category: Date/Time
1936
+ #
1937
+ class SetAlarmClockAction < DateTimeAction
1489
1938
 
1490
1939
  def initialize(h={})
1491
1940
 
@@ -1508,7 +1957,9 @@ class SetAlarmClockAction < Action
1508
1957
 
1509
1958
  end
1510
1959
 
1511
- class StopWatchAction < Action
1960
+ # Category: Date/Time
1961
+ #
1962
+ class StopWatchAction < DateTimeAction
1512
1963
 
1513
1964
  def initialize(h={})
1514
1965
 
@@ -1523,7 +1974,9 @@ class StopWatchAction < Action
1523
1974
 
1524
1975
  end
1525
1976
 
1526
- class SayTimeAction < Action
1977
+ # Category: Date/Time
1978
+ #
1979
+ class SayTimeAction < DateTimeAction
1527
1980
 
1528
1981
  def initialize(h={})
1529
1982
 
@@ -1537,7 +1990,19 @@ class SayTimeAction < Action
1537
1990
 
1538
1991
  end
1539
1992
 
1540
- class AndroidShortcutsAction < Action
1993
+
1994
+ class DeviceAction < Action
1995
+
1996
+ def initialize(h={})
1997
+ super(h)
1998
+ @group = 'device'
1999
+ end
2000
+
2001
+ end
2002
+
2003
+ # Category: Device Actions
2004
+ #
2005
+ class AndroidShortcutsAction < DeviceAction
1541
2006
 
1542
2007
  def initialize(h={})
1543
2008
 
@@ -1551,7 +2016,9 @@ class AndroidShortcutsAction < Action
1551
2016
 
1552
2017
  end
1553
2018
 
1554
- class ClipboardAction < Action
2019
+ # Category: Device Actions
2020
+ #
2021
+ class ClipboardAction < DeviceAction
1555
2022
 
1556
2023
  def initialize(h={})
1557
2024
 
@@ -1565,7 +2032,9 @@ class ClipboardAction < Action
1565
2032
 
1566
2033
  end
1567
2034
 
1568
- class PressBackAction < Action
2035
+ # Category: Device Actions
2036
+ #
2037
+ class PressBackAction < DeviceAction
1569
2038
 
1570
2039
  def initialize(h={})
1571
2040
 
@@ -1578,7 +2047,9 @@ class PressBackAction < Action
1578
2047
 
1579
2048
  end
1580
2049
 
1581
- class SpeakTextAction < Action
2050
+ # Category: Device Actions
2051
+ #
2052
+ class SpeakTextAction < DeviceAction
1582
2053
 
1583
2054
  def initialize(h={})
1584
2055
 
@@ -1599,7 +2070,9 @@ class SpeakTextAction < Action
1599
2070
 
1600
2071
  end
1601
2072
 
1602
- class UIInteractionAction < Action
2073
+ # Category: Device Actions
2074
+ #
2075
+ class UIInteractionAction < DeviceAction
1603
2076
 
1604
2077
  def initialize(h={})
1605
2078
 
@@ -1614,7 +2087,9 @@ class UIInteractionAction < Action
1614
2087
 
1615
2088
  end
1616
2089
 
1617
- class VoiceSearchAction < Action
2090
+ # Category: Device Actions
2091
+ #
2092
+ class VoiceSearchAction < DeviceAction
1618
2093
 
1619
2094
  def initialize(h={})
1620
2095
 
@@ -1627,7 +2102,19 @@ class VoiceSearchAction < Action
1627
2102
 
1628
2103
  end
1629
2104
 
1630
- class ExpandCollapseStatusBarAction < Action
2105
+
2106
+ class DeviceSettingsAction < Action
2107
+
2108
+ def initialize(h={})
2109
+ super(h)
2110
+ @group = 'devicesettings'
2111
+ end
2112
+
2113
+ end
2114
+
2115
+ # Category: Device Settings
2116
+ #
2117
+ class ExpandCollapseStatusBarAction < DeviceSettingsAction
1631
2118
 
1632
2119
  def initialize(h={})
1633
2120
 
@@ -1641,7 +2128,9 @@ class ExpandCollapseStatusBarAction < Action
1641
2128
 
1642
2129
  end
1643
2130
 
1644
- class LaunchHomeScreenAction < Action
2131
+ # Category: Device Settings
2132
+ #
2133
+ class LaunchHomeScreenAction < DeviceSettingsAction
1645
2134
 
1646
2135
  def initialize(h={})
1647
2136
 
@@ -1654,7 +2143,9 @@ class LaunchHomeScreenAction < Action
1654
2143
 
1655
2144
  end
1656
2145
 
1657
- class CameraFlashLightAction < Action
2146
+ # Category: Device Settings
2147
+ #
2148
+ class CameraFlashLightAction < DeviceSettingsAction
1658
2149
 
1659
2150
  def initialize(h={})
1660
2151
 
@@ -1669,7 +2160,9 @@ class CameraFlashLightAction < Action
1669
2160
 
1670
2161
  end
1671
2162
 
1672
- class VibrateAction < Action
2163
+ # Category: Device Settings
2164
+ #
2165
+ class VibrateAction < DeviceSettingsAction
1673
2166
 
1674
2167
  def initialize(h={})
1675
2168
 
@@ -1683,7 +2176,9 @@ class VibrateAction < Action
1683
2176
 
1684
2177
  end
1685
2178
 
1686
- class SetAutoRotateAction < Action
2179
+ # Category: Device Settings
2180
+ #
2181
+ class SetAutoRotateAction < DeviceSettingsAction
1687
2182
 
1688
2183
  def initialize(h={})
1689
2184
 
@@ -1697,7 +2192,9 @@ class SetAutoRotateAction < Action
1697
2192
 
1698
2193
  end
1699
2194
 
1700
- class DayDreamAction < Action
2195
+ # Category: Device Settings
2196
+ #
2197
+ class DayDreamAction < DeviceSettingsAction
1701
2198
 
1702
2199
  def initialize(h={})
1703
2200
 
@@ -1710,7 +2207,9 @@ class DayDreamAction < Action
1710
2207
 
1711
2208
  end
1712
2209
 
1713
- class SetKeyboardAction < Action
2210
+ # Category: Device Settings
2211
+ #
2212
+ class SetKeyboardAction < DeviceSettingsAction
1714
2213
 
1715
2214
  def initialize(h={})
1716
2215
 
@@ -1723,7 +2222,9 @@ class SetKeyboardAction < Action
1723
2222
 
1724
2223
  end
1725
2224
 
1726
- class SetKeyguardAction < Action
2225
+ # Category: Device Settings
2226
+ #
2227
+ class SetKeyguardAction < DeviceSettingsAction
1727
2228
 
1728
2229
  def initialize(h={})
1729
2230
 
@@ -1737,7 +2238,9 @@ class SetKeyguardAction < Action
1737
2238
 
1738
2239
  end
1739
2240
 
1740
- class CarModeAction < Action
2241
+ # Category: Device Settings
2242
+ #
2243
+ class CarModeAction < DeviceSettingsAction
1741
2244
 
1742
2245
  def initialize(h={})
1743
2246
 
@@ -1751,7 +2254,9 @@ class CarModeAction < Action
1751
2254
 
1752
2255
  end
1753
2256
 
1754
- class ChangeKeyboardAction < Action
2257
+ # Category: Device Settings
2258
+ #
2259
+ class ChangeKeyboardAction < DeviceSettingsAction
1755
2260
 
1756
2261
  def initialize(h={})
1757
2262
 
@@ -1766,7 +2271,9 @@ class ChangeKeyboardAction < Action
1766
2271
 
1767
2272
  end
1768
2273
 
1769
- class SetWallpaperAction < Action
2274
+ # Category: Device Settings
2275
+ #
2276
+ class SetWallpaperAction < DeviceSettingsAction
1770
2277
 
1771
2278
  def initialize(h={})
1772
2279
 
@@ -1785,7 +2292,18 @@ class SetWallpaperAction < Action
1785
2292
 
1786
2293
  end
1787
2294
 
1788
- class OpenFileAction < Action
2295
+ class FileAction < Action
2296
+
2297
+ def initialize(h={})
2298
+ super(h)
2299
+ @group = 'file'
2300
+ end
2301
+
2302
+ end
2303
+
2304
+ # Category: Files
2305
+ #
2306
+ class OpenFileAction < FileAction
1789
2307
 
1790
2308
  def initialize(h={})
1791
2309
 
@@ -1802,7 +2320,19 @@ class OpenFileAction < Action
1802
2320
 
1803
2321
  end
1804
2322
 
1805
- class ForceLocationUpdateAction < Action
2323
+
2324
+ class LocationAction < Action
2325
+
2326
+ def initialize(h={})
2327
+ super(h)
2328
+ @group = 'location'
2329
+ end
2330
+
2331
+ end
2332
+
2333
+ # Category: Location
2334
+ #
2335
+ class ForceLocationUpdateAction < LocationAction
1806
2336
 
1807
2337
  def initialize(h={})
1808
2338
 
@@ -1815,7 +2345,9 @@ class ForceLocationUpdateAction < Action
1815
2345
 
1816
2346
  end
1817
2347
 
1818
- class ShareLocationAction < Action
2348
+ # Category: Location
2349
+ #
2350
+ class ShareLocationAction < LocationAction
1819
2351
 
1820
2352
  def initialize(h={})
1821
2353
 
@@ -1833,7 +2365,9 @@ class ShareLocationAction < Action
1833
2365
 
1834
2366
  end
1835
2367
 
1836
- class SetLocationUpdateRateAction < Action
2368
+ # Category: Location
2369
+ #
2370
+ class SetLocationUpdateRateAction < LocationAction
1837
2371
 
1838
2372
  def initialize(h={})
1839
2373
 
@@ -1848,7 +2382,18 @@ class SetLocationUpdateRateAction < Action
1848
2382
 
1849
2383
  end
1850
2384
 
1851
- class AddCalendarEntryAction < Action
2385
+ class LoggingAction < Action
2386
+
2387
+ def initialize(h={})
2388
+ super(h)
2389
+ @group = 'logging'
2390
+ end
2391
+
2392
+ end
2393
+
2394
+ # Category: Logging
2395
+ #
2396
+ class AddCalendarEntryAction < LoggingAction
1852
2397
 
1853
2398
  def initialize(h={})
1854
2399
 
@@ -1875,7 +2420,9 @@ class AddCalendarEntryAction < Action
1875
2420
 
1876
2421
  end
1877
2422
 
1878
- class LogAction < Action
2423
+ # Category: Logging
2424
+ #
2425
+ class LogAction < LoggingAction
1879
2426
 
1880
2427
  def initialize(h={})
1881
2428
 
@@ -1890,7 +2437,9 @@ class LogAction < Action
1890
2437
 
1891
2438
  end
1892
2439
 
1893
- class ClearLogAction < Action
2440
+ # Category: Logging
2441
+ #
2442
+ class ClearLogAction < LoggingAction
1894
2443
 
1895
2444
  def initialize(h={})
1896
2445
 
@@ -1904,24 +2453,18 @@ class ClearLogAction < Action
1904
2453
 
1905
2454
  end
1906
2455
 
1907
- class RecordMicrophoneAction < Action
1908
-
2456
+ class MediaAction < Action
2457
+
1909
2458
  def initialize(h={})
1910
-
1911
- options = {
1912
- path: '',
1913
- record_time_string: 'Until Cancelled',
1914
- recording_format: 0,
1915
- seconds_to_record_for: -1
1916
- }
1917
-
1918
- super(options.merge h)
1919
-
2459
+ super(h)
2460
+ @group = 'media'
1920
2461
  end
1921
-
2462
+
1922
2463
  end
1923
2464
 
1924
- class RecordMicrophoneAction < Action
2465
+ # Category: Media
2466
+ #
2467
+ class RecordMicrophoneAction < MediaAction
1925
2468
 
1926
2469
  def initialize(h={})
1927
2470
 
@@ -1938,7 +2481,9 @@ class RecordMicrophoneAction < Action
1938
2481
 
1939
2482
  end
1940
2483
 
1941
- class PlaySoundAction < Action
2484
+ # Category: Media
2485
+ #
2486
+ class PlaySoundAction < MediaAction
1942
2487
 
1943
2488
  def initialize(h={})
1944
2489
 
@@ -1954,7 +2499,18 @@ class PlaySoundAction < Action
1954
2499
  end
1955
2500
 
1956
2501
 
1957
- class SendEmailAction < Action
2502
+ class MessagingAction < Action
2503
+
2504
+ def initialize(h={})
2505
+ super(h)
2506
+ @group = 'messaging'
2507
+ end
2508
+
2509
+ end
2510
+
2511
+ # Category: Messaging
2512
+ #
2513
+ class SendEmailAction < MessagingAction
1958
2514
 
1959
2515
  def initialize(h={})
1960
2516
 
@@ -1974,7 +2530,9 @@ class SendEmailAction < Action
1974
2530
 
1975
2531
  end
1976
2532
 
1977
- class SendSMSAction < Action
2533
+ # Category: Messaging
2534
+ #
2535
+ class SendSMSAction < MessagingAction
1978
2536
 
1979
2537
  def initialize(h={})
1980
2538
 
@@ -1993,7 +2551,9 @@ class SendSMSAction < Action
1993
2551
 
1994
2552
  end
1995
2553
 
1996
- class UDPCommandAction < Action
2554
+ # Category: Messaging
2555
+ #
2556
+ class UDPCommandAction < MessagingAction
1997
2557
 
1998
2558
  def initialize(h={})
1999
2559
 
@@ -2009,7 +2569,19 @@ class UDPCommandAction < Action
2009
2569
 
2010
2570
  end
2011
2571
 
2012
- class ClearNotificationsAction < Action
2572
+
2573
+ class NotificationsAction < Action
2574
+
2575
+ def initialize(h={})
2576
+ super(h)
2577
+ @group = 'notifications'
2578
+ end
2579
+
2580
+ end
2581
+
2582
+ # Category: Notifications
2583
+ #
2584
+ class ClearNotificationsAction < NotificationsAction
2013
2585
 
2014
2586
  def initialize(h={})
2015
2587
 
@@ -2031,7 +2603,9 @@ class ClearNotificationsAction < Action
2031
2603
 
2032
2604
  end
2033
2605
 
2034
- class MessageDialogAction < Action
2606
+ # Category: Notifications
2607
+ #
2608
+ class MessageDialogAction < NotificationsAction
2035
2609
 
2036
2610
  def initialize(h={})
2037
2611
 
@@ -2056,7 +2630,9 @@ class MessageDialogAction < Action
2056
2630
 
2057
2631
  end
2058
2632
 
2059
- class AllowLEDNotificationLightAction < Action
2633
+ # Category: Notifications
2634
+ #
2635
+ class AllowLEDNotificationLightAction < NotificationsAction
2060
2636
 
2061
2637
  def initialize(h={})
2062
2638
 
@@ -2070,7 +2646,9 @@ class AllowLEDNotificationLightAction < Action
2070
2646
 
2071
2647
  end
2072
2648
 
2073
- class SetNotificationSoundAction < Action
2649
+ # Category: Notifications
2650
+ #
2651
+ class SetNotificationSoundAction < NotificationsAction
2074
2652
 
2075
2653
  def initialize(h={})
2076
2654
 
@@ -2084,7 +2662,9 @@ class SetNotificationSoundAction < Action
2084
2662
 
2085
2663
  end
2086
2664
 
2087
- class SetNotificationSoundAction < Action
2665
+ # Category: Notifications
2666
+ #
2667
+ class SetNotificationSoundAction < NotificationsAction
2088
2668
 
2089
2669
  def initialize(h={})
2090
2670
 
@@ -2098,7 +2678,9 @@ class SetNotificationSoundAction < Action
2098
2678
 
2099
2679
  end
2100
2680
 
2101
- class SetNotificationSoundAction < Action
2681
+ # Category: Notifications
2682
+ #
2683
+ class SetNotificationSoundAction < NotificationsAction
2102
2684
 
2103
2685
  def initialize(h={})
2104
2686
 
@@ -2112,7 +2694,9 @@ class SetNotificationSoundAction < Action
2112
2694
 
2113
2695
  end
2114
2696
 
2115
- class NotificationAction < Action
2697
+ # Category: Notifications
2698
+ #
2699
+ class NotificationAction < NotificationsAction
2116
2700
 
2117
2701
  def initialize(h={})
2118
2702
 
@@ -2136,7 +2720,9 @@ class NotificationAction < Action
2136
2720
 
2137
2721
  end
2138
2722
 
2139
- class ToastAction < Action
2723
+ # Category: Notifications
2724
+ #
2725
+ class ToastAction < NotificationsAction
2140
2726
 
2141
2727
  def initialize(h={})
2142
2728
 
@@ -2159,10 +2745,30 @@ class ToastAction < Action
2159
2745
  super(options.merge h)
2160
2746
 
2161
2747
  end
2748
+
2749
+ def invoke()
2750
+ super(@h[:message_text])
2751
+ end
2752
+
2753
+ def to_s()
2754
+ "Popup Message '%s'" % @h[:message_text]
2755
+ end
2162
2756
 
2163
2757
  end
2164
2758
 
2165
- class AnswerCallAction < Action
2759
+
2760
+ class PhoneAction < Action
2761
+
2762
+ def initialize(h={})
2763
+ super(h)
2764
+ @group = 'phone'
2765
+ end
2766
+
2767
+ end
2768
+
2769
+ # Category: Phone
2770
+ #
2771
+ class AnswerCallAction < PhoneAction
2166
2772
 
2167
2773
  def initialize(h={})
2168
2774
 
@@ -2176,7 +2782,9 @@ class AnswerCallAction < Action
2176
2782
 
2177
2783
  end
2178
2784
 
2179
- class ClearCallLogAction < Action
2785
+ # Category: Phone
2786
+ #
2787
+ class ClearCallLogAction < PhoneAction
2180
2788
 
2181
2789
  def initialize(h={})
2182
2790
 
@@ -2192,7 +2800,9 @@ class ClearCallLogAction < Action
2192
2800
 
2193
2801
  end
2194
2802
 
2195
- class OpenCallLogAction < Action
2803
+ # Category: Phone
2804
+ #
2805
+ class OpenCallLogAction < PhoneAction
2196
2806
 
2197
2807
  def initialize(h={})
2198
2808
 
@@ -2205,7 +2815,9 @@ class OpenCallLogAction < Action
2205
2815
 
2206
2816
  end
2207
2817
 
2208
- class RejectCallAction < Action
2818
+ # Category: Phone
2819
+ #
2820
+ class RejectCallAction < PhoneAction
2209
2821
 
2210
2822
  def initialize(h={})
2211
2823
 
@@ -2218,7 +2830,9 @@ class RejectCallAction < Action
2218
2830
 
2219
2831
  end
2220
2832
 
2221
- class MakeCallAction < Action
2833
+ # Category: Phone
2834
+ #
2835
+ class MakeCallAction < PhoneAction
2222
2836
 
2223
2837
  def initialize(h={})
2224
2838
 
@@ -2233,7 +2847,10 @@ class MakeCallAction < Action
2233
2847
 
2234
2848
  end
2235
2849
 
2236
- class SetRingtoneAction < Action
2850
+
2851
+ # Category: Phone
2852
+ #
2853
+ class SetRingtoneAction < PhoneAction
2237
2854
 
2238
2855
  def initialize(h={})
2239
2856
 
@@ -2247,7 +2864,18 @@ class SetRingtoneAction < Action
2247
2864
 
2248
2865
  end
2249
2866
 
2250
- class SetBrightnessAction < Action
2867
+ class ScreenAction < Action
2868
+
2869
+ def initialize(h={})
2870
+ super(h)
2871
+ @group = 'screen'
2872
+ end
2873
+
2874
+ end
2875
+
2876
+ # Category: Screen
2877
+ #
2878
+ class SetBrightnessAction < ScreenAction
2251
2879
 
2252
2880
  def initialize(h={})
2253
2881
 
@@ -2263,7 +2891,9 @@ class SetBrightnessAction < Action
2263
2891
 
2264
2892
  end
2265
2893
 
2266
- class ForceScreenRotationAction < Action
2894
+ # Category: Screen
2895
+ #
2896
+ class ForceScreenRotationAction < ScreenAction
2267
2897
 
2268
2898
  def initialize(h={})
2269
2899
 
@@ -2277,7 +2907,9 @@ class ForceScreenRotationAction < Action
2277
2907
 
2278
2908
  end
2279
2909
 
2280
- class ScreenOnAction < Action
2910
+ # Category: Screen
2911
+ #
2912
+ class ScreenOnAction < ScreenAction
2281
2913
 
2282
2914
  def initialize(h={})
2283
2915
 
@@ -2294,7 +2926,9 @@ class ScreenOnAction < Action
2294
2926
 
2295
2927
  end
2296
2928
 
2297
- class DimScreenAction < Action
2929
+ # Category: Screen
2930
+ #
2931
+ class DimScreenAction < ScreenAction
2298
2932
 
2299
2933
  def initialize(h={})
2300
2934
 
@@ -2309,7 +2943,9 @@ class DimScreenAction < Action
2309
2943
 
2310
2944
  end
2311
2945
 
2312
- class KeepAwakeAction < Action
2946
+ # Category: Screen
2947
+ #
2948
+ class KeepAwakeAction < ScreenAction
2313
2949
 
2314
2950
  def initialize(h={})
2315
2951
 
@@ -2326,7 +2962,9 @@ class KeepAwakeAction < Action
2326
2962
 
2327
2963
  end
2328
2964
 
2329
- class SetScreenTimeoutAction < Action
2965
+ # Category: Screen
2966
+ #
2967
+ class SetScreenTimeoutAction < ScreenAction
2330
2968
 
2331
2969
  def initialize(h={})
2332
2970
 
@@ -2343,8 +2981,18 @@ class SetScreenTimeoutAction < Action
2343
2981
  end
2344
2982
 
2345
2983
 
2984
+ class VolumeAction < Action
2985
+
2986
+ def initialize(h={})
2987
+ super(h)
2988
+ @group = 'volume'
2989
+ end
2990
+
2991
+ end
2346
2992
 
2347
- class SilentModeVibrateOffAction < Action
2993
+ # Category: Volume
2994
+ #
2995
+ class SilentModeVibrateOffAction < VolumeAction
2348
2996
 
2349
2997
  def initialize(h={})
2350
2998
 
@@ -2358,7 +3006,9 @@ class SilentModeVibrateOffAction < Action
2358
3006
 
2359
3007
  end
2360
3008
 
2361
- class SetVibrateAction < Action
3009
+ # Category: Volume
3010
+ #
3011
+ class SetVibrateAction < VolumeAction
2362
3012
 
2363
3013
  def initialize(h={})
2364
3014
 
@@ -2373,7 +3023,9 @@ class SetVibrateAction < Action
2373
3023
 
2374
3024
  end
2375
3025
 
2376
- class VolumeIncrementDecrementAction < Action
3026
+ # Category: Volume
3027
+ #
3028
+ class VolumeIncrementDecrementAction < VolumeAction
2377
3029
 
2378
3030
  def initialize(h={})
2379
3031
 
@@ -2387,7 +3039,9 @@ class VolumeIncrementDecrementAction < Action
2387
3039
 
2388
3040
  end
2389
3041
 
2390
- class SpeakerPhoneAction < Action
3042
+ # Category: Volume
3043
+ #
3044
+ class SpeakerPhoneAction < VolumeAction
2391
3045
 
2392
3046
  def initialize(h={})
2393
3047
 
@@ -2402,8 +3056,9 @@ class SpeakerPhoneAction < Action
2402
3056
 
2403
3057
  end
2404
3058
 
2405
-
2406
- class SetVolumeAction < Action
3059
+ # Category: Volume
3060
+ #
3061
+ class SetVolumeAction < VolumeAction
2407
3062
 
2408
3063
  def initialize(h={})
2409
3064
 
@@ -2426,5 +3081,905 @@ class Constraint < MacroObject
2426
3081
  def initialize(h={})
2427
3082
  super(h)
2428
3083
  end
3084
+
3085
+ def match?(detail={}, model=nil)
3086
+
3087
+ detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value}
3088
+
3089
+ end
3090
+
3091
+ #def to_s()
3092
+ # ''
3093
+ #end
3094
+
3095
+ protected
3096
+
3097
+ def toggle_match?(key, val)
3098
+
3099
+ if @h[key] == true and val == key.to_s then
3100
+ true
3101
+ elsif @h[key] == false and val != key.to_s
3102
+ true
3103
+ else
3104
+ false
3105
+ end
3106
+
3107
+ end
3108
+
3109
+ end
3110
+
3111
+ class TimeOfDayConstraint < Constraint
3112
+
3113
+ def initialize(h={})
3114
+
3115
+ options = {
3116
+ end_hour: 8,
3117
+ end_minute: 0,
3118
+ start_hour: 22,
3119
+ start_minute: 0
3120
+ }
3121
+
3122
+ super(options.merge h)
3123
+
3124
+ end
3125
+
3126
+ end
3127
+
3128
+ # Category: Battery/Power
3129
+ #
3130
+ class BatteryLevelConstraint < Constraint
3131
+
3132
+ def initialize(h={})
3133
+
3134
+ options = {
3135
+ battery_level: 23,
3136
+ equals: false,
3137
+ greater_than: false
3138
+ }
3139
+
3140
+ super(options.merge h)
3141
+
3142
+ end
3143
+
3144
+ end
3145
+
3146
+ # Category: Battery/Power
3147
+ #
3148
+ class BatterySaverStateConstraint < Constraint
3149
+
3150
+ def initialize(h={})
3151
+
3152
+ options = {
3153
+ option: 0
3154
+ }
3155
+
3156
+ super(options.merge h)
3157
+
3158
+ end
3159
+
3160
+ end
3161
+
3162
+ # Category: Battery/Power
3163
+ #
3164
+ class BatteryTemperatureConstraint < Constraint
3165
+
3166
+ def initialize(h={})
3167
+
3168
+ options = {
3169
+ equals: false,
3170
+ greater_than: false,
3171
+ temperature: 30
3172
+ }
3173
+
3174
+ super(options.merge h)
3175
+
3176
+ end
3177
+
3178
+ end
3179
+
3180
+ # Category: Battery/Power
3181
+ #
3182
+ class ExternalPowerConstraint < Constraint
3183
+
3184
+ def initialize(h={})
3185
+
3186
+ options = {
3187
+ external_power: true,
3188
+ power_connected_options: [false, true, false]
3189
+ }
3190
+
3191
+ super(options.merge h)
3192
+
3193
+ end
3194
+
3195
+ end
3196
+
3197
+ # Category: Connectivity
3198
+ #
3199
+ class BluetoothConstraint < Constraint
3200
+
3201
+ def initialize(h={})
3202
+
3203
+ options = {
3204
+ any_device: false,
3205
+ bt_state: 0,
3206
+ device_name: 'Any Device'
3207
+ }
3208
+
3209
+ super(options.merge h)
3210
+
3211
+ end
3212
+
3213
+ end
3214
+
3215
+ # Category: Connectivity
3216
+ #
3217
+ class GPSEnabledConstraint < Constraint
3218
+
3219
+ def initialize(h={})
3220
+
3221
+ options = {
3222
+ enabled: true
3223
+ }
3224
+
3225
+ super(options.merge h)
3226
+
3227
+ end
3228
+
3229
+ end
3230
+
3231
+ # Category: Connectivity
3232
+ #
3233
+ class LocationModeConstraint < Constraint
3234
+
3235
+ def initialize(h={})
3236
+
3237
+ options = {
3238
+ options: [false, false, false, true]
3239
+ }
3240
+
3241
+ super(options.merge h)
3242
+
3243
+ end
3244
+
3245
+ end
3246
+
3247
+ # Category: Connectivity
3248
+ #
3249
+ class SignalOnOffConstraint < Constraint
3250
+
3251
+ def initialize(h={})
3252
+
3253
+ options = {
3254
+ option: 0
3255
+ }
3256
+
3257
+ super(options.merge h)
3258
+
3259
+ end
3260
+
3261
+ end
3262
+
3263
+ # Category: Connectivity
3264
+ #
3265
+ class WifiConstraint < Constraint
3266
+
3267
+ def initialize(h={})
3268
+
3269
+ options = {
3270
+ ssid_list: [],
3271
+ wifi_state: 0
3272
+ }
3273
+
3274
+ super(options.merge h)
3275
+
3276
+ end
3277
+
3278
+ end
3279
+
3280
+ # Category: Connectivity
3281
+ #
3282
+ class CellTowerConstraint < Constraint
3283
+
3284
+ def initialize(h={})
3285
+
3286
+ options = {
3287
+ cell_group_name: 'test group',
3288
+ cell_ids: ["524,14,41070731"],
3289
+ in_range: true
3290
+ }
3291
+
3292
+ super(options.merge h)
3293
+
3294
+ end
3295
+
3296
+ end
3297
+
3298
+ # Category: Connectivity
3299
+ #
3300
+ class IsRoamingConstraint < Constraint
3301
+
3302
+ def initialize(h={})
3303
+
3304
+ options = {
3305
+ is_roaming: true
3306
+ }
3307
+
3308
+ super(options.merge h)
3309
+
3310
+ end
3311
+
3312
+ end
3313
+
3314
+ # Category: Connectivity
3315
+ #
3316
+ class DataOnOffConstraint < Constraint
3317
+
3318
+ def initialize(h={})
3319
+
3320
+ options = {
3321
+ data_on: true
3322
+ }
3323
+
3324
+ super(options.merge h)
3325
+
3326
+ end
3327
+
3328
+ end
3329
+
3330
+ # Category: Connectivity
3331
+ #
3332
+ class WifiHotSpotConstraint < Constraint
3333
+
3334
+ def initialize(h={})
3335
+
3336
+ options = {
3337
+ check_connections: false,
3338
+ comparison_value: 0,
3339
+ connected_count: 0,
3340
+ enabled: true
3341
+ }
3342
+
3343
+ super(options.merge h)
3344
+
3345
+ end
3346
+
3347
+ end
3348
+
3349
+ # Category: Date/Time
3350
+ #
3351
+ class CalendarConstraint < Constraint
3352
+
3353
+ def initialize(h={})
3354
+
3355
+ options = {
3356
+ enable_regex: false,
3357
+ availability: 0,
3358
+ calendar_id: '1',
3359
+ calendar_name: 'PC Sync',
3360
+ detail_text: '',
3361
+ entry_set: true,
3362
+ ignore_all_day: false,
3363
+ title_text: ''
3364
+ }
3365
+
3366
+ super(options.merge h)
3367
+
3368
+ end
3369
+
3370
+ end
3371
+
3372
+ # Category: Date/Time
3373
+ #
3374
+ class DayOfWeekConstraint < Constraint
3375
+
3376
+ def initialize(h={})
3377
+
3378
+ options = {
3379
+ days_of_week: [false, false, true, false, false, false, false]
3380
+ }
3381
+
3382
+ super(options.merge h)
3383
+
3384
+ end
3385
+
3386
+ end
3387
+
3388
+ # Category: Date/Time
3389
+ #
3390
+ class TimeOfDayConstraint < Constraint
3391
+
3392
+ def initialize(h={})
3393
+
3394
+ options = {
3395
+ end_hour: 1,
3396
+ end_minute: 1,
3397
+ start_hour: 21,
3398
+ start_minute: 58
3399
+ }
3400
+
3401
+ super(options.merge h)
3402
+
3403
+ end
3404
+
3405
+ end
3406
+
3407
+ # Category: Date/Time
3408
+ #
3409
+ class DayOfMonthConstraint < Constraint
3410
+
3411
+ def initialize(h={})
3412
+
3413
+ options = {
3414
+ day_names: ["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"],
3415
+ days_of_month: [false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]
3416
+ }
3417
+
3418
+ super(options.merge h)
3419
+
3420
+ end
3421
+
3422
+ end
3423
+
3424
+ # Category: Date/Time
3425
+ #
3426
+ class MonthOfYearConstraint < Constraint
3427
+
3428
+ def initialize(h={})
3429
+
3430
+ options = {
3431
+ months: [false, false, false, false, false, false, false, true, false, false, false, false]
3432
+ }
3433
+
3434
+ super(options.merge h)
3435
+
3436
+ end
3437
+
3438
+ end
3439
+
3440
+ # Category: Date/Time
3441
+ #
3442
+ class SunsetSunriseConstraint < Constraint
3443
+
3444
+ def initialize(h={})
3445
+
3446
+ options = {
3447
+ option: 0
3448
+ }
3449
+
3450
+ super(options.merge h)
3451
+
3452
+ end
3453
+
3454
+ end
3455
+
3456
+ # Category: Device State
3457
+ #
3458
+ class AirplaneModeConstraint < Constraint
3459
+
3460
+ def initialize(h={})
3461
+
3462
+ options = {
3463
+ enabled: true
3464
+ }
3465
+
3466
+ super(options.merge h)
3467
+
3468
+ end
3469
+
3470
+ def match?(detail={}, model=nil)
3471
+
3472
+ puts 'inside airplaneModeConstraint#match?' if $debug
3473
+
3474
+ if detail.has_key? :enabled then
3475
+
3476
+ puts 'detail has the key' if $debug
3477
+ super(detail)
3478
+
3479
+ elsif model
3480
+
3481
+ if $debug then
3482
+ puts 'checking the model'
3483
+ switch = model.connectivity.airplane_mode.switch
3484
+ puts 'switch: ' + switch.inspect
3485
+ end
3486
+
3487
+ toggle_match?(:enabled, switch)
3488
+
3489
+ end
3490
+
3491
+ end
3492
+
3493
+ end
3494
+
3495
+ # Category: Device State
3496
+ #
3497
+ class AutoRotateConstraint < Constraint
3498
+
3499
+ def initialize(h={})
3500
+
3501
+ options = {
3502
+ enabled: true
3503
+ }
3504
+
3505
+ super(options.merge h)
3506
+
3507
+ end
3508
+
3509
+ end
3510
+
3511
+ # Category: Device State
3512
+ #
3513
+ class DeviceLockedConstraint < Constraint
3514
+
3515
+ def initialize(h={})
3516
+
3517
+ options = {
3518
+ locked: true
3519
+ }
3520
+
3521
+ super(options.merge h)
3522
+
3523
+ end
3524
+
3525
+ end
3526
+
3527
+ # Category: Device State
3528
+ #
3529
+ class RoamingOnOffConstraint < Constraint
3530
+
3531
+ def initialize(h={})
3532
+
3533
+ options = {
3534
+ roaming_on: true
3535
+ }
3536
+
3537
+ super(options.merge h)
3538
+
3539
+ end
3540
+
3541
+ end
3542
+
3543
+ # Category: Device State
3544
+ #
3545
+ class TimeSinceBootConstraint < Constraint
3546
+
3547
+ def initialize(h={})
3548
+
3549
+ options = {
3550
+ less_than: true,
3551
+ time_period_seconds: 10921
3552
+ }
3553
+
3554
+ super(options.merge h)
3555
+
3556
+ end
3557
+
3558
+ end
3559
+
3560
+ # Category: Device State
3561
+ #
3562
+ class AutoSyncConstraint < Constraint
3563
+
3564
+ def initialize(h={})
3565
+
3566
+ options = {
3567
+ enabled: false
3568
+ }
3569
+
3570
+ super(options.merge h)
3571
+
3572
+ end
3573
+
3574
+ end
3575
+
3576
+ # Category: Device State
3577
+ #
3578
+ class NFCStateConstraint < Constraint
3579
+
3580
+ def initialize(h={})
3581
+
3582
+ options = {
3583
+ enabled: true
3584
+ }
3585
+
3586
+ super(options.merge h)
3587
+
3588
+ end
3589
+
3590
+ end
3591
+
3592
+ # Category: Device State
3593
+ #
3594
+ class IsRootedConstraint < Constraint
3595
+
3596
+ def initialize(h={})
3597
+
3598
+ options = {
3599
+ rooted: true
3600
+ }
3601
+
3602
+ super(options.merge h)
3603
+
3604
+ end
3605
+
3606
+ end
3607
+
3608
+ # Category: Device State
3609
+ #
3610
+ class VpnConstraint < Constraint
3611
+
3612
+ def initialize(h={})
3613
+
3614
+ options = {
3615
+ option: 0
3616
+ }
3617
+
3618
+ super(options.merge h)
3619
+
3620
+ end
3621
+
3622
+ end
3623
+
3624
+ # Category: MacroDroid Specific
3625
+ #
3626
+ class MacroEnabledConstraint < Constraint
3627
+
3628
+ def initialize(h={})
3629
+
3630
+ options = {
3631
+ enabled: true,
3632
+ macro_ids: [-8016812002629322290],
3633
+ macro_names: ["Intruder photo "]
3634
+ }
3635
+
3636
+ super(options.merge h)
3637
+
3638
+ end
3639
+
3640
+ end
3641
+
3642
+ # Category: MacroDroid Specific
3643
+ #
3644
+ class ModeConstraint < Constraint
3645
+
3646
+ def initialize(h={})
3647
+
3648
+ options = {
3649
+ mode: 'Away',
3650
+ mode_selected: true
3651
+ }
3652
+
3653
+ super(options.merge h)
3654
+
3655
+ end
3656
+
3657
+ end
3658
+
3659
+ # Category: MacroDroid Specific
3660
+ #
3661
+ class TriggerThatInvokedConstraint < Constraint
3662
+
3663
+ def initialize(h={})
3664
+
3665
+ options = {
3666
+ not: false,
3667
+ si_guid_that_invoked: -4951291100076165433,
3668
+ trigger_name: 'Shake Device'
3669
+ }
3670
+
3671
+ super(options.merge h)
3672
+
3673
+ end
3674
+
3675
+ end
3676
+
3677
+ # Category: MacroDroid Specific
3678
+ #
3679
+ class LastRunTimeConstraint < Constraint
3680
+
3681
+ def initialize(h={})
3682
+
3683
+ options = {
3684
+ check_this_macro: false,
3685
+ invoked: true,
3686
+ macro_ids: [-6922688338672048267],
3687
+ macro_names: ["Opendoor"],
3688
+ time_period_seconds: 7260
3689
+ }
3690
+
3691
+ super(options.merge h)
3692
+
3693
+ end
3694
+
3695
+ end
3696
+
3697
+ # Category: Media
3698
+ #
3699
+ class HeadphonesConnectionConstraint < Constraint
3700
+
3701
+ def initialize(h={})
3702
+
3703
+ options = {
3704
+ connected: true
3705
+ }
3706
+
3707
+ super(options.merge h)
3708
+
3709
+ end
3710
+
3711
+ end
3712
+
3713
+ # Category: Media
3714
+ #
3715
+ class MusicActiveConstraint < Constraint
3716
+
3717
+ def initialize(h={})
3718
+
3719
+ options = {
3720
+ music_active: true
3721
+ }
3722
+
3723
+ super(options.merge h)
3724
+
3725
+ end
3726
+
3727
+ end
3728
+
3729
+ # Category: Notification
3730
+ #
3731
+ class NotificationPresentConstraint < Constraint
3732
+
3733
+ def initialize(h={})
3734
+
3735
+ options = {
3736
+ enable_regex: false,
3737
+ application_name_list: ["All applications"],
3738
+ exact_match: false,
3739
+ excludes: false,
3740
+ excludes_apps: -1,
3741
+ option: 0,
3742
+ package_name_list: ["allApplications"],
3743
+ text_content: ''
3744
+ }
3745
+
3746
+ super(options.merge h)
3747
+
3748
+ end
3749
+
3750
+ end
3751
+
3752
+ # Category: Notification
3753
+ #
3754
+ class PriorityModeConstraint < Constraint
3755
+
3756
+ def initialize(h={})
3757
+
3758
+ options = {
3759
+ in_mode: true,
3760
+ selected_index: 0
3761
+ }
3762
+
3763
+ super(options.merge h)
3764
+
3765
+ end
3766
+
3767
+ end
3768
+
3769
+ # Category: Notification
3770
+ #
3771
+ class NotificationVolumeConstraint < Constraint
3772
+
3773
+ def initialize(h={})
3774
+
3775
+ options = {
3776
+ option: 1
3777
+ }
3778
+
3779
+ super(options.merge h)
3780
+
3781
+ end
3782
+
3783
+ end
3784
+
3785
+ # Category: Phone
3786
+ #
3787
+ class InCallConstraint < Constraint
3788
+
3789
+ def initialize(h={})
3790
+
3791
+ options = {
3792
+ in_call: true
3793
+ }
3794
+
3795
+ super(options.merge h)
3796
+
3797
+ end
3798
+
3799
+ end
3800
+
3801
+ # Category: Phone
3802
+ #
3803
+ class PhoneRingingConstraint < Constraint
3804
+
3805
+ def initialize(h={})
3806
+
3807
+ options = {
3808
+ ringing: true
3809
+ }
3810
+
3811
+ super(options.merge h)
3812
+
3813
+ end
3814
+
3815
+ end
3816
+
3817
+ # Category: Screen and Speaker
3818
+ #
3819
+ class BrightnessConstraint < Constraint
3820
+
3821
+ def initialize(h={})
3822
+
3823
+ options = {
3824
+ brightness: 35,
3825
+ equals: false,
3826
+ force_pie_mode: false,
3827
+ greater_than: false,
3828
+ is_auto_brightness: false
3829
+ }
3830
+
3831
+ super(options.merge h)
3832
+
3833
+ end
3834
+
3835
+ end
3836
+
3837
+ # Category: Screen and Speaker
3838
+ #
3839
+ class VolumeConstraint < Constraint
3840
+
3841
+ def initialize(h={})
3842
+
3843
+ options = {
3844
+ option: 0
3845
+ }
3846
+
3847
+ super(options.merge h)
3848
+
3849
+ end
3850
+
3851
+ end
3852
+
3853
+ # Category: Screen and Speaker
3854
+ #
3855
+ class SpeakerPhoneConstraint < Constraint
3856
+
3857
+ def initialize(h={})
3858
+
3859
+ options = {
3860
+ enabled: true
3861
+ }
3862
+
3863
+ super(options.merge h)
3864
+
3865
+ end
3866
+
3867
+ end
3868
+
3869
+ # Category: Screen and Speaker
3870
+ #
3871
+ class DarkThemeConstraint < Constraint
3872
+
3873
+ def initialize(h={})
3874
+
3875
+ options = {
3876
+ option: 0
3877
+ }
3878
+
3879
+ super(options.merge h)
3880
+
3881
+ end
3882
+
3883
+ end
3884
+
3885
+ # Category: Screen and Speaker
3886
+ #
3887
+ class ScreenOnOffConstraint < Constraint
3888
+
3889
+ def initialize(h={})
3890
+
3891
+ options = {
3892
+ a: true,
3893
+ screen_on: true
3894
+ }
3895
+
3896
+ super(options.merge h)
3897
+
3898
+ end
3899
+
3900
+ end
3901
+
3902
+ # Category: Screen and Speaker
3903
+ #
3904
+ class VolumeLevelConstraint < Constraint
3905
+
3906
+ def initialize(h={})
3907
+
3908
+ options = {
3909
+ comparison: 0,
3910
+ stream_index_array: [false, true, false, false, false, false, false],
3911
+ volume: 42
3912
+ }
3913
+
3914
+ super(options.merge h)
3915
+
3916
+ end
3917
+
3918
+ end
3919
+
3920
+ # Category: Sensors
3921
+ #
3922
+ class FaceUpDownConstraint < Constraint
3923
+
3924
+ def initialize(h={})
3925
+
3926
+ options = {
3927
+ option: -1,
3928
+ selected_options: [true, false, true, false, false, false]
3929
+ }
3930
+
3931
+ super(options.merge h)
3932
+
3933
+ end
3934
+
3935
+ end
3936
+
3937
+ # Category: Sensors
3938
+ #
3939
+ class LightLevelConstraint < Constraint
3940
+
3941
+ def initialize(h={})
3942
+
3943
+ options = {
3944
+ light_level: -1,
3945
+ light_level_float: 5000.0,
3946
+ option: 1
3947
+ }
3948
+
3949
+ super(options.merge h)
3950
+
3951
+ end
3952
+
3953
+ end
3954
+
3955
+ # Category: Sensors
3956
+ #
3957
+ class DeviceOrientationConstraint < Constraint
3958
+
3959
+ def initialize(h={})
3960
+
3961
+ options = {
3962
+ portrait: true
3963
+ }
3964
+
3965
+ super(options.merge h)
3966
+
3967
+ end
3968
+
3969
+ end
3970
+
3971
+ # Category: Sensors
3972
+ #
3973
+ class ProximitySensorConstraint < Constraint
3974
+
3975
+ def initialize(h={})
3976
+
3977
+ options = {
3978
+ near: true
3979
+ }
3980
+
3981
+ super(options.merge h)
3982
+
3983
+ end
2429
3984
 
2430
3985
  end