adhearsion 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/CHANGELOG +9 -42
  2. data/EVENTS +11 -0
  3. data/README.txt +5 -0
  4. data/Rakefile +94 -84
  5. data/adhearsion.gemspec +148 -0
  6. data/app_generators/ahn/USAGE +5 -0
  7. data/app_generators/ahn/ahn_generator.rb +87 -0
  8. data/app_generators/ahn/templates/.ahnrc +34 -0
  9. data/app_generators/ahn/templates/README +8 -0
  10. data/app_generators/ahn/templates/Rakefile +23 -0
  11. data/app_generators/ahn/templates/components/ami_remote/ami_remote.rb +15 -0
  12. data/app_generators/ahn/templates/components/disabled/HOW_TO_ENABLE +7 -0
  13. data/app_generators/ahn/templates/components/disabled/stomp_gateway/README.markdown +47 -0
  14. data/app_generators/ahn/templates/components/disabled/stomp_gateway/config.yml +12 -0
  15. data/app_generators/ahn/templates/components/disabled/stomp_gateway/stomp_gateway.rb +34 -0
  16. data/app_generators/ahn/templates/components/restful_rpc/README.markdown +11 -0
  17. data/app_generators/ahn/templates/components/restful_rpc/config.yml +34 -0
  18. data/app_generators/ahn/templates/components/restful_rpc/example-client.rb +48 -0
  19. data/app_generators/ahn/templates/components/restful_rpc/restful_rpc.rb +87 -0
  20. data/app_generators/ahn/templates/components/restful_rpc/spec/restful_rpc_spec.rb +263 -0
  21. data/app_generators/ahn/templates/components/simon_game/simon_game.rb +56 -0
  22. data/app_generators/ahn/templates/config/startup.rb +50 -0
  23. data/app_generators/ahn/templates/dialplan.rb +3 -0
  24. data/app_generators/ahn/templates/events.rb +32 -0
  25. data/bin/ahn +28 -0
  26. data/bin/ahnctl +68 -0
  27. data/bin/jahn +42 -0
  28. data/examples/asterisk_manager_interface/standalone.rb +51 -0
  29. data/lib/adhearsion.rb +35 -953
  30. data/lib/adhearsion/cli.rb +223 -0
  31. data/lib/adhearsion/component_manager.rb +208 -0
  32. data/lib/adhearsion/component_manager/component_tester.rb +55 -0
  33. data/lib/adhearsion/component_manager/spec_framework.rb +24 -0
  34. data/lib/adhearsion/events_support.rb +84 -0
  35. data/lib/adhearsion/foundation/all.rb +9 -0
  36. data/lib/adhearsion/foundation/blank_slate.rb +5 -0
  37. data/lib/adhearsion/foundation/custom_daemonizer.rb +45 -0
  38. data/lib/adhearsion/foundation/event_socket.rb +203 -0
  39. data/lib/adhearsion/foundation/future_resource.rb +36 -0
  40. data/lib/adhearsion/foundation/global.rb +1 -0
  41. data/lib/adhearsion/foundation/metaprogramming.rb +17 -0
  42. data/lib/adhearsion/foundation/numeric.rb +13 -0
  43. data/lib/adhearsion/foundation/pseudo_guid.rb +10 -0
  44. data/lib/adhearsion/foundation/relationship_properties.rb +42 -0
  45. data/lib/adhearsion/foundation/string.rb +26 -0
  46. data/lib/adhearsion/foundation/synchronized_hash.rb +96 -0
  47. data/lib/adhearsion/foundation/thread_safety.rb +7 -0
  48. data/lib/adhearsion/host_definitions.rb +67 -0
  49. data/lib/adhearsion/initializer.rb +373 -0
  50. data/lib/adhearsion/initializer/asterisk.rb +81 -0
  51. data/lib/adhearsion/initializer/configuration.rb +254 -0
  52. data/lib/adhearsion/initializer/database.rb +49 -0
  53. data/lib/adhearsion/initializer/drb.rb +31 -0
  54. data/lib/adhearsion/initializer/freeswitch.rb +22 -0
  55. data/lib/adhearsion/initializer/rails.rb +40 -0
  56. data/lib/adhearsion/logging.rb +92 -0
  57. data/lib/adhearsion/tasks.rb +16 -0
  58. data/lib/adhearsion/tasks/database.rb +5 -0
  59. data/lib/adhearsion/tasks/deprecations.rb +59 -0
  60. data/lib/adhearsion/tasks/generating.rb +20 -0
  61. data/lib/adhearsion/tasks/lint.rb +4 -0
  62. data/lib/adhearsion/tasks/testing.rb +37 -0
  63. data/lib/adhearsion/version.rb +9 -0
  64. data/lib/adhearsion/voip/asterisk.rb +4 -0
  65. data/lib/adhearsion/voip/asterisk/agi_server.rb +81 -0
  66. data/lib/adhearsion/voip/asterisk/commands.rb +1284 -0
  67. data/lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb +140 -0
  68. data/lib/adhearsion/voip/asterisk/config_generators/config_generator.rb +101 -0
  69. data/lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb +250 -0
  70. data/lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb +240 -0
  71. data/lib/adhearsion/voip/asterisk/config_manager.rb +71 -0
  72. data/lib/adhearsion/voip/asterisk/manager_interface.rb +562 -0
  73. data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rb +1754 -0
  74. data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rl.rb +286 -0
  75. data/lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb +78 -0
  76. data/lib/adhearsion/voip/asterisk/manager_interface/ami_protocol_lexer_machine.rl +87 -0
  77. data/lib/adhearsion/voip/asterisk/special_dial_plan_managers.rb +80 -0
  78. data/lib/adhearsion/voip/asterisk/super_manager.rb +19 -0
  79. data/lib/adhearsion/voip/call.rb +440 -0
  80. data/lib/adhearsion/voip/call_routing.rb +64 -0
  81. data/lib/adhearsion/voip/commands.rb +9 -0
  82. data/lib/adhearsion/voip/constants.rb +39 -0
  83. data/lib/adhearsion/voip/conveniences.rb +18 -0
  84. data/lib/adhearsion/voip/dial_plan.rb +218 -0
  85. data/lib/adhearsion/voip/dsl/dialing_dsl.rb +151 -0
  86. data/lib/adhearsion/voip/dsl/dialing_dsl/dialing_dsl_monkey_patches.rb +37 -0
  87. data/lib/adhearsion/voip/dsl/dialplan/control_passing_exception.rb +27 -0
  88. data/lib/adhearsion/voip/dsl/dialplan/dispatcher.rb +124 -0
  89. data/lib/adhearsion/voip/dsl/dialplan/parser.rb +71 -0
  90. data/lib/adhearsion/voip/dsl/dialplan/thread_mixin.rb +16 -0
  91. data/lib/adhearsion/voip/dsl/numerical_string.rb +117 -0
  92. data/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb +48 -0
  93. data/lib/adhearsion/voip/freeswitch/event_handler.rb +58 -0
  94. data/lib/adhearsion/voip/freeswitch/freeswitch_dialplan_command_factory.rb +129 -0
  95. data/lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb +38 -0
  96. data/lib/adhearsion/voip/freeswitch/oes_server.rb +195 -0
  97. data/lib/adhearsion/voip/menu_state_machine/calculated_match.rb +80 -0
  98. data/lib/adhearsion/voip/menu_state_machine/matchers.rb +123 -0
  99. data/lib/adhearsion/voip/menu_state_machine/menu_builder.rb +58 -0
  100. data/lib/adhearsion/voip/menu_state_machine/menu_class.rb +149 -0
  101. data/lib/theatre.rb +151 -0
  102. data/lib/theatre/README.markdown +64 -0
  103. data/lib/theatre/callback_definition_loader.rb +84 -0
  104. data/lib/theatre/guid.rb +23 -0
  105. data/lib/theatre/invocation.rb +121 -0
  106. data/lib/theatre/namespace_manager.rb +153 -0
  107. data/lib/theatre/version.rb +2 -0
  108. metadata +160 -140
  109. data/.version +0 -1
  110. data/TODO +0 -71
  111. data/ahn +0 -223
  112. data/apps/default/Rakefile +0 -65
  113. data/apps/default/config/adhearsion.sqlite3 +0 -0
  114. data/apps/default/config/adhearsion.yml +0 -95
  115. data/apps/default/config/database.rb +0 -50
  116. data/apps/default/config/database.yml +0 -12
  117. data/apps/default/config/helpers/drb_server.yml +0 -43
  118. data/apps/default/config/helpers/factorial.alien.c.yml +0 -1
  119. data/apps/default/config/helpers/growler.yml +0 -21
  120. data/apps/default/config/helpers/lookup.yml +0 -1
  121. data/apps/default/config/helpers/manager_proxy.yml +0 -8
  122. data/apps/default/config/helpers/micromenus.yml +0 -1
  123. data/apps/default/config/helpers/micromenus/collab.rb +0 -60
  124. data/apps/default/config/helpers/micromenus/images/arrow-off.gif +0 -0
  125. data/apps/default/config/helpers/micromenus/images/arrow-on.gif +0 -0
  126. data/apps/default/config/helpers/micromenus/images/error.gif +0 -0
  127. data/apps/default/config/helpers/micromenus/images/folder-off.gif +0 -0
  128. data/apps/default/config/helpers/micromenus/images/folder-on.gif +0 -0
  129. data/apps/default/config/helpers/micromenus/images/folder.png +0 -0
  130. data/apps/default/config/helpers/micromenus/images/ggbridge.jpg +0 -0
  131. data/apps/default/config/helpers/micromenus/images/green.png +0 -0
  132. data/apps/default/config/helpers/micromenus/images/microbrowser.bg.gif +0 -0
  133. data/apps/default/config/helpers/micromenus/images/red.png +0 -0
  134. data/apps/default/config/helpers/micromenus/images/tux.bmp +0 -0
  135. data/apps/default/config/helpers/micromenus/images/url-off.gif +0 -0
  136. data/apps/default/config/helpers/micromenus/images/url-on.gif +0 -0
  137. data/apps/default/config/helpers/micromenus/images/yellow.png +0 -0
  138. data/apps/default/config/helpers/micromenus/javascripts/animation.js +0 -1341
  139. data/apps/default/config/helpers/micromenus/javascripts/carousel.js +0 -1238
  140. data/apps/default/config/helpers/micromenus/javascripts/columnav.js +0 -306
  141. data/apps/default/config/helpers/micromenus/javascripts/connection.js +0 -965
  142. data/apps/default/config/helpers/micromenus/javascripts/container.js +0 -4727
  143. data/apps/default/config/helpers/micromenus/javascripts/container_core.js +0 -2915
  144. data/apps/default/config/helpers/micromenus/javascripts/dom.js +0 -892
  145. data/apps/default/config/helpers/micromenus/javascripts/dragdrop.js +0 -2958
  146. data/apps/default/config/helpers/micromenus/javascripts/event.js +0 -1771
  147. data/apps/default/config/helpers/micromenus/javascripts/yahoo.js +0 -433
  148. data/apps/default/config/helpers/micromenus/stylesheets/carousel.css +0 -78
  149. data/apps/default/config/helpers/micromenus/stylesheets/columnav.css +0 -135
  150. data/apps/default/config/helpers/micromenus/stylesheets/microbrowsers.css +0 -42
  151. data/apps/default/config/helpers/multi_messenger.yml +0 -9
  152. data/apps/default/config/helpers/weather.yml +0 -1
  153. data/apps/default/config/helpers/xbmc.yml +0 -2
  154. data/apps/default/config/migration.rb +0 -59
  155. data/apps/default/extensions.rb +0 -41
  156. data/apps/default/helpers/factorial.alien.c +0 -32
  157. data/apps/default/helpers/growler.rb +0 -53
  158. data/apps/default/helpers/lookup.rb +0 -44
  159. data/apps/default/helpers/manager_proxy.rb +0 -112
  160. data/apps/default/helpers/micromenus.rb +0 -514
  161. data/apps/default/helpers/multi_messenger.rb +0 -53
  162. data/apps/default/helpers/oscar_wilde_quotes.rb +0 -197
  163. data/apps/default/helpers/weather.rb +0 -85
  164. data/apps/default/helpers/xbmc.rb +0 -39
  165. data/apps/default/logs/adhearsion.log +0 -0
  166. data/apps/default/logs/database.log +0 -0
  167. data/lib/constants.rb +0 -24
  168. data/lib/core_extensions.rb +0 -180
  169. data/lib/drb_server.rb +0 -101
  170. data/lib/logging.rb +0 -85
  171. data/lib/phone_number.rb +0 -85
  172. data/lib/rami.rb +0 -823
  173. data/lib/servlet_container.rb +0 -174
  174. data/lib/sexy_migrations.rb +0 -70
  175. data/test/asterisk_module_test.rb +0 -14
  176. data/test/core_extensions_test.rb +0 -26
  177. data/test/dial_test.rb +0 -43
  178. data/test/specs/numerical_string_spec.rb +0 -53
  179. data/test/test_micromenus.rb +0 -0
@@ -1,135 +0,0 @@
1
- /*
2
- * Copyright (c) 2007, David A. Lindquist (stringify.com)
3
- * Some Rights Reserved
4
- *
5
- * This code is licensed under the Creative Commons Attribution 2.5 License
6
- * (http://creativecommons.org/licenses/by/2.5/). Please maintain the above
7
- * license and copyright statements when using this code.
8
- *
9
- * $Id: columnav.css 476 2007-02-20 23:43:22Z david $
10
- */
11
-
12
- /* DO NOT CHANGE ANYTHING IN THIS SECTION
13
-
14
- Styles below override defaults in carousel.css and govern fundamental layout
15
- and behavior.
16
-
17
- ------------------------------------------------------------------------------*/
18
-
19
- .carousel-component {
20
- background: transparent;
21
- color: black;
22
- overflow: auto !important;
23
- padding: 0;
24
- }
25
-
26
- .carousel-component ul.carousel-list li {
27
- color: black;
28
- font-family: inherit;
29
- font-size: 1em;
30
- text-align: left;
31
- }
32
-
33
- .carousel-component ul.carousel-list li div {
34
- overflow: auto;
35
- overflow-y: scroll;
36
- position: relative;
37
- }
38
-
39
- .carousel-component ul.carousel-list li a {
40
- display: block;
41
- overflow-x: hidden;
42
- position: relative;
43
- }
44
-
45
- .carousel-component ul.carousel-list li a span {
46
- display: block;
47
- position: relative;
48
- }
49
-
50
-
51
- /* CUSTOMIZE ANYTHING IN THIS SECTION
52
-
53
- Styles below can be changed to customize colors, margins, padding, fonts,
54
- etc., as well as the icons that appear before each item. At minimum, set the
55
- width of .carousel-component and its list items, and the height of the div
56
- it contains.
57
-
58
- ------------------------------------------------------------------------------*/
59
-
60
- .carousel-component {
61
- }
62
-
63
- .carousel-component ul.carousel-list li {
64
- width: 348px;
65
- }
66
-
67
- .carousel-component ul.carousel-list li div {
68
- height: 348px;
69
- }
70
-
71
- .carousel-component ul.carousel-list li a {
72
- color: black;
73
- cursor: default;
74
- font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
75
- font-size: 12px;
76
- margin: 0 1px;
77
- padding: 2px;
78
- text-decoration: none;
79
- }
80
-
81
- .carousel-component ul.carousel-list li a.columnav-has-menu {
82
- background-image: url(../images/arrow-off.gif);
83
- background-position: right center;
84
- background-repeat: no-repeat;
85
- }
86
-
87
- .carousel-component ul.carousel-list li a.columnav-active {
88
- background-color: #3875d7;
89
- }
90
-
91
- /* IE6 cannot grok element selectors with chained class names */
92
- html>body .carousel-component ul.carousel-list li a.columnav-has-menu.columnav-active {
93
- background-image: url(../images/arrow-on.gif);
94
- }
95
-
96
- .carousel-component ul.carousel-list li a.columnav-error span {
97
- background-image: url(../images/error.gif);
98
- color: red;
99
- }
100
-
101
- .carousel-component ul.carousel-list li a span {
102
- background-repeat: no-repeat;
103
- background-position: 0px center;
104
- margin-right: 14px;
105
- padding-left: 20px;
106
- }
107
-
108
- .carousel-component ul.carousel-list li a.columnav-active span {
109
- color: white;
110
- }
111
-
112
- .carousel-component ul.carousel-list li a.columnav-has-menu span {
113
- background-image: url(../images/folder-off.gif);
114
- }
115
-
116
- /* IE6 cannot grok element selectors with chained class names */
117
- html>body .carousel-component ul.carousel-list li a.columnav-has-menu.columnav-active span {
118
- background-image: url(../images/folder-on.gif);
119
- }
120
-
121
- .prevButton { }
122
- .prevButton a {
123
- color: black;
124
- font-family: 'Lucida Grande', Helvetica, Arial;
125
- font-size: 10px;
126
- line-height: 22px;
127
- position: relative;
128
- text-align: center;
129
- text-decoration: none;
130
- }
131
-
132
- .prevButton a:hover {
133
- background-color: #3875d7;
134
- color: white;
135
- }
@@ -1,42 +0,0 @@
1
- body {
2
- background: url(/images/ggbridge.jpg) top left no-repeat; }
3
-
4
- div.microbrowser {
5
- background: url(/images/microbrowser.bg.gif) top left no-repeat;}
6
- div.microbrowser .hd {}
7
- div.microbrowser .ft {
8
- display: none; }
9
- div.microbrowser h1 {
10
- color: white;
11
- text-shadow: black 0px 0px 5px;
12
- margin: 0; padding: 6px 0;
13
- text-align: center;
14
- font-size: 20px; }
15
-
16
- .yui-panel {
17
- width: 400px;}
18
-
19
- .yui-panel .hd {
20
- padding:0;
21
- border:none;
22
- color:#000;
23
- height:44px;
24
- margin-left:33px;
25
- margin-right:33px;
26
- text-align:center;
27
- overflow:visible; }
28
-
29
- .yui-panel .hd .tl {
30
- width:30px;
31
- height:22px;
32
- top: 4px;
33
- left:10px;
34
- position:absolute; }
35
-
36
- .yui-panel .hd .tr {
37
- width:30px;
38
- height:22px;
39
- line-height: 22px;
40
- top:6px;
41
- left:315px;
42
- position:absolute; }
@@ -1,9 +0,0 @@
1
- # Feel free to use your Gmail account here! Can also
2
- # be any Jabber/XMPP account.
3
- username: test@adhearsion.com
4
- password: password
5
- enabled: false
6
-
7
- # Specify whether incoming subscription requests should
8
- # be automatically accepted.
9
- accept_subscriptions: false
@@ -1 +0,0 @@
1
- units: fahrenheit # can be 'fahrenheit' or 'celsuis' (case sensitive)
@@ -1,2 +0,0 @@
1
- enabled: false
2
- ip: 192.168.1.136:80
@@ -1,59 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'yaml'
3
- require 'rubygems'
4
- require 'active_record'
5
-
6
- # A migration script uses a database configuration and creates tables
7
- # very conveniently in a database-agnostic way. Below, add any customizations
8
- # to the sample schema or leave it as-is. When done, type "rake migrate" to
9
- # have this schema generated.
10
-
11
- ActiveRecord::Base.establish_connection YAML.load_file('config/database.yml')
12
-
13
- class CreateUsers < ActiveRecord::Migration
14
- # Available column types are :primary_key, :string, :text, :integer,
15
- # :float, :datetime, :timestamp, :time, :date, :binary, and :boolean
16
- def self.up
17
- create_table :users do |t|
18
- t.column :name, :string
19
- t.column :group_id, :integer # Foreign key
20
- t.column :extension, :string
21
- # t.column :billed_time, :integer, :null => false
22
-
23
- # Feel free to remove or change this to "email". Gmail offers email,
24
- # instant messaging, calendars, and so forth -- all of which you
25
- # can integrate with using one simple username.
26
- t.column :gmail, :string
27
- end
28
- end
29
-
30
- def self.down
31
- drop_table :users
32
- end
33
- end
34
-
35
- class CreateGroups < ActiveRecord::Migration
36
- def self.up
37
- create_table :groups do |t|
38
- t.column :name, :string
39
- t.column :administrator_email, :string
40
- t.column :callerid_name, :string
41
- t.column :callerid_num, :string
42
- #t.column :usage_limit, :integer
43
- end
44
- end
45
-
46
- def self.down
47
- drop_table :groups
48
- end
49
- end
50
-
51
-
52
- CreateUsers.up
53
- CreateGroups.up
54
-
55
- ### If you'd like to create any initial users, do it here by
56
- ### requiring your database.rb file and performing your logic.
57
- #
58
- # require 'config/database.rb'
59
- # User.create :name => "Jay Phillips", :extension => 123
@@ -1,41 +0,0 @@
1
- # This is an example dialplan. Feel free to remove this file and
2
- # start your dialplan from scratch.
3
-
4
-
5
- # This "internal" context would map over if Adhearsion were invoked
6
- # in Asterisk's own "internal" context. For example, if you set up
7
- # your extensions.conf file for Adhearsion as so:
8
- #
9
- # [internal]
10
- # exten => _.,1,AGI(agi://192.168.1.3)
11
- #
12
- # then, when Adhearsion receives that call, it sees it came from
13
- # the "internal" context and invokes this.
14
- internal {
15
- # In this example context you'll see use of a User object. This
16
- # is intended to be an ActiveRecord object created from your
17
- # config/database.rb file.
18
- case extension
19
- when 101...200
20
- employee = Employee.find_by_extension extension
21
- unless employee.busy? then dial employee
22
- else
23
- voicemail extension
24
- end
25
-
26
- when 888 then play weather_report("Dallas, Texas")
27
- when 999 then check_voicemail extension
28
-
29
- # This is simply an example of including another context in
30
- # the block of another context. Simply place a plus sign before
31
- # its name. No need to even declare it above the context you
32
- # enter it into.
33
- when 999 then +joker_voicemail
34
- end
35
- }
36
- joker_voicemail {
37
- play %w(a-connect-charge-of 22 cents-per-minute will-apply)
38
- sleep 2.seconds
39
- play 'just-kidding-not-upset'
40
- check_voicemail extension
41
- }
@@ -1,32 +0,0 @@
1
-
2
- /*
3
- =begin Adhearsion metadata
4
-
5
- name: Native Factorial
6
- author:
7
- name: Jay Phillips
8
- blog: http://jicksta.com
9
- email: Jicksta -at- Gmail.com
10
- gems:
11
- - soap4r
12
- - rubyinline: >= 0.8.2
13
- instructions: >
14
- Yes, this is a pure C file!!!
15
- This is an example of writing Adhearsion extensions in
16
- other languages. The first time this file is executed
17
- it will be compiled and the binary form will be cached.
18
-
19
- If your Adhearsion system is heavily dependent on
20
- an intensive helper, it may be advantageous to rewrite
21
- it in a language such as C or C++ and use it like this.
22
-
23
- =end
24
- */
25
-
26
- int fast_factorial(int input) {
27
- int prod = 1, count = 1;
28
- while(count <= input) {
29
- prod *= count++;
30
- }
31
- return prod;
32
- }
@@ -1,53 +0,0 @@
1
- =begin Adhearsion metadata
2
- name: Adhearsion Growler
3
- author:
4
- name: Phil Kates
5
- email: hawk684 -at- gmail.com
6
- modified-by: Jay Phillips
7
- gems:
8
- - ruby-growl
9
- =end
10
-
11
- require 'ruby-growl'
12
-
13
- GROWL_SERVER = unless $HELPERS['growler']['ip'] then nil else
14
- Growl.new $HELPERS['growler']['ip'] || 'localhost',
15
- $HELPERS['growler']['app_name'] || "Adhearsion",
16
- $HELPERS['growler']['notifications'],
17
- nil, $HELPERS['growler']['password']
18
- end
19
-
20
- # Sends a message to an OSX desktop's Growl notification server. If you
21
- # intend to only notify a single machine, you can specify the parameters
22
- # in growler.yml.
23
- #
24
- # == Usage:
25
- #
26
- # - message: The notification or message you wish to send!
27
- # - type (optional): The type of notification as specified in the growler.yml
28
- # config file. This defaults to the first "notifications" entry. If you want
29
- # growl() to automatically set this for you, simply send it nil.
30
- # - ip (optional): The desktop's IP address you wish to notify. This
31
- # by default uses what's in growler.yml or, if unavailable, "localhost".
32
- # - password (optional): a password if one is needed. Defaults to nothing.
33
- #
34
- # == Examples:
35
- # - growl "Isn't it about time you debugged me?"
36
- # - growl "Call from #{callerid}!", "Incoming Call"
37
- # - growl "The caller queue size is #{queue.size}", nil, "192.168.1.133"
38
- # - growl "Join conference 1234!", nil, "192.168.50.151", "Secretz!"
39
- def growl message, type=nil, ip=nil, password=nil
40
- type = $HELPERS['growler']['notifications'].first unless type
41
-
42
- # Create a new Growl client if an IP was specified, otherwise use
43
- # our server created when Adhearsion booted.
44
- svr = unless ip then GROWL_SERVER else
45
- Growl.new ip, $HELPERS['growler']['app_name'] || "Adhearsion",
46
- $HELPERS['growler']['notifications'], nil,
47
- $HELPERS['growler']['password']
48
- end
49
-
50
- # TODO support priorities and stickies. May need to use hash-key argments?
51
- # TODO handle unreachable desktops
52
- svr.notify type, type, message
53
- end
@@ -1,44 +0,0 @@
1
- =begin Adhearsion metadata
2
- name: Number Metadata Lookup
3
- author: Jay Phillips
4
- =end
5
-
6
- require "hpricot"
7
- require "open-uri"
8
-
9
- def lookup number
10
- hash = {}
11
- url = "http://www.whitepages.com/9901/search/ReversePhone?phone=#{number}"
12
- doc = Hpricot open(url)
13
-
14
- # This div contains all the information we need, unless it's an unlisted number
15
- if (results = doc.at "#results_single_listing") then
16
- # This div's h3 contains the name of the caller
17
- hash[:first_name], hash[:last_name] = results.at('h3').inner_html.split(/,\s*/).reverse
18
- hash[:name] = hash[:first_name] + " " + hash[:last_name]
19
-
20
- # Now we just need the rest of the information contained in p's.
21
- meta = results/'p'
22
- meta.pop # Discard the useless p element
23
-
24
- hash[:number] = meta.pop.inner_html
25
- city_info = meta.pop.inner_html
26
- city_info = city_info.match /(.+), ([A-Za-z]{2}) (\d{5})/
27
- hash[:city] = city_info[1]
28
- hash[:state] = city_info[2]
29
- hash[:zip] = city_info[3]
30
-
31
- hash[:address] = meta.map(&:inner_html) * " "
32
- elsif (results = doc.at "#results_single_phone_info") then
33
- meta = results/'span'
34
- hash[:location] = (meta.pop.inner_html.match /Location: (.*)/)[1]
35
- end
36
-
37
- if hash[:first_name] or hash[:last_name] then
38
- hash[:composite] = "#{hash[:first_name]} #{hash[:last_name]}"
39
- else
40
- hash[:composite] = hash[:location]
41
- end
42
-
43
- hash
44
- end
@@ -1,112 +0,0 @@
1
- require 'rami'
2
- class PBX
3
- include Rami
4
-
5
- @@sip_users = {}
6
-
7
- @@rami_server_thread = Thread.current
8
-
9
- @@rami_server = Rami::Server.new $HELPERS.manager_proxy
10
- @@rami_server.console = 1
11
- @@rami_server.run
12
-
13
- @@rami_client = Client.new @@rami_server
14
- @@rami_client.timeout = 10
15
-
16
- def self.rami_client() @@rami_client end
17
-
18
- $HUTDOWN.hook do
19
- @@rami_client.stop
20
- end
21
-
22
- def self.sip_users
23
- if !@@sip_users[:expiration] || @@sip_users[:expiration] <= Time.now
24
- sip_db = PBX.rami_client.command("database show SIP/Registry").first
25
- sip_db = sip_db[ sip_db.keys.select { |x| x.is_a? Fixnum }.first ]
26
- sip_db = sip_db.gsub( /--[A-Z ]+?--/ , '').strip
27
- users = sip_db.split "\n"
28
- users.collect! do |user|
29
- fields = user.split ':'
30
- { :username => fields[4],
31
- :ip => fields[1].strip,
32
- :port => fields[2],
33
- :address => fields[6] }
34
- end
35
- @@sip_users[:users] = users
36
- @@sip_users[:expiration] = 90.seconds.from_now
37
- end
38
- @@sip_users[:users]
39
- end
40
-
41
- class << self
42
-
43
- # An introduction connects two endpoints together. The first argument is
44
- # the first person the PBX will call. When she's picked up, Asterisk will
45
- # play ringing while the second person is being dialed.
46
- #
47
- # The first argument is the person called first. Pass this as a canonical
48
- # IAX2/server/user type argument. Destination takes the same format, but
49
- # comma-separated Dial() arguments can be optionally passed after the
50
- # technology.
51
- #
52
- # TODO: Provide an example when this works.
53
- def introduce src, dst, hash={}
54
- cid = hash.delete(:callerid) || hash.delete(:cid)
55
- options = hash.delete(:options) || hash.delete(:opts)
56
- dst << "|" << options if options
57
- call_and_exec src, "Dial", dst, cid
58
- end
59
-
60
- def call_and_exec channel, app, args=nil, callerid=nil
61
- args = { :channel => channel
62
- :application => app }
63
- args[:data] = args if args
64
- args[:callerid] = callerid if callerid
65
- originate args
66
- end
67
-
68
- def overhear their_channel, your_channel
69
-
70
- end
71
-
72
-
73
- def call chan, code=nil, &block
74
- raise "Cannot provide both a String and a block!" if code && block_given?
75
- ip = 'localhost' # TODO: How to get this?!
76
- originate :application => "AGI",
77
- :data => "agi://#{ip}/?call_id=",
78
- :channel => chan
79
-
80
- # TODO: Initiate an origination that comes back
81
- # into Adhearsion and runs either a certain block
82
- # of code or eval()s a String of dialplan code.
83
- end
84
-
85
- def originate hash
86
- # This is an ugly hack to use until RAI's AMI work is ported in.
87
- h = {}
88
- h['Application'] = hash.delete :app
89
- hash.each { |k,v| h[k.to_s.titleize] = v }
90
- @@rami_client.originate h
91
- end
92
-
93
- def record hash={}, &block
94
- # TODO: Implement me!
95
- raise NotImplementedError
96
-
97
- # defaults = {:file => "#{String.random(5)}", :folder => nil,
98
- # :channel => Thread.current[:VARS]['channel'], :format => 'wav', :mix => '1'}
99
- # defaults = defaults.merge hash
100
- # PBX.rami_client.... # TODO
101
- end
102
-
103
- # private
104
- # CALL_BLOCK_CACHE = {}
105
- # def handle_call_specifically expiration=3.minutes.from_now, &block
106
- # # Find a random, unused id
107
- # while CALL_BLOCK_CACHE[id = rand(1_073_741_823)]; end # 1073741823 is the Fixnum max
108
- # CALL_BLOCK_CACHE[id] = [expiration, block]
109
- # end
110
- end
111
-
112
- end