adhearsion 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -42
- data/EVENTS +11 -0
- data/README.txt +5 -0
- data/Rakefile +94 -84
- data/adhearsion.gemspec +148 -0
- data/app_generators/ahn/USAGE +5 -0
- data/app_generators/ahn/ahn_generator.rb +87 -0
- data/app_generators/ahn/templates/.ahnrc +34 -0
- data/app_generators/ahn/templates/README +8 -0
- data/app_generators/ahn/templates/Rakefile +23 -0
- data/app_generators/ahn/templates/components/ami_remote/ami_remote.rb +15 -0
- data/app_generators/ahn/templates/components/disabled/HOW_TO_ENABLE +7 -0
- data/app_generators/ahn/templates/components/disabled/stomp_gateway/README.markdown +47 -0
- data/app_generators/ahn/templates/components/disabled/stomp_gateway/config.yml +12 -0
- data/app_generators/ahn/templates/components/disabled/stomp_gateway/stomp_gateway.rb +34 -0
- data/app_generators/ahn/templates/components/restful_rpc/README.markdown +11 -0
- data/app_generators/ahn/templates/components/restful_rpc/config.yml +34 -0
- data/app_generators/ahn/templates/components/restful_rpc/example-client.rb +48 -0
- data/app_generators/ahn/templates/components/restful_rpc/restful_rpc.rb +87 -0
- data/app_generators/ahn/templates/components/restful_rpc/spec/restful_rpc_spec.rb +263 -0
- data/app_generators/ahn/templates/components/simon_game/simon_game.rb +56 -0
- data/app_generators/ahn/templates/config/startup.rb +50 -0
- data/app_generators/ahn/templates/dialplan.rb +3 -0
- data/app_generators/ahn/templates/events.rb +32 -0
- data/bin/ahn +28 -0
- data/bin/ahnctl +68 -0
- data/bin/jahn +42 -0
- data/examples/asterisk_manager_interface/standalone.rb +51 -0
- data/lib/adhearsion.rb +35 -953
- data/lib/adhearsion/cli.rb +223 -0
- data/lib/adhearsion/component_manager.rb +208 -0
- data/lib/adhearsion/component_manager/component_tester.rb +55 -0
- data/lib/adhearsion/component_manager/spec_framework.rb +24 -0
- data/lib/adhearsion/events_support.rb +84 -0
- data/lib/adhearsion/foundation/all.rb +9 -0
- data/lib/adhearsion/foundation/blank_slate.rb +5 -0
- data/lib/adhearsion/foundation/custom_daemonizer.rb +45 -0
- data/lib/adhearsion/foundation/event_socket.rb +203 -0
- data/lib/adhearsion/foundation/future_resource.rb +36 -0
- data/lib/adhearsion/foundation/global.rb +1 -0
- data/lib/adhearsion/foundation/metaprogramming.rb +17 -0
- data/lib/adhearsion/foundation/numeric.rb +13 -0
- data/lib/adhearsion/foundation/pseudo_guid.rb +10 -0
- data/lib/adhearsion/foundation/relationship_properties.rb +42 -0
- data/lib/adhearsion/foundation/string.rb +26 -0
- data/lib/adhearsion/foundation/synchronized_hash.rb +96 -0
- data/lib/adhearsion/foundation/thread_safety.rb +7 -0
- data/lib/adhearsion/host_definitions.rb +67 -0
- data/lib/adhearsion/initializer.rb +373 -0
- data/lib/adhearsion/initializer/asterisk.rb +81 -0
- data/lib/adhearsion/initializer/configuration.rb +254 -0
- data/lib/adhearsion/initializer/database.rb +49 -0
- data/lib/adhearsion/initializer/drb.rb +31 -0
- data/lib/adhearsion/initializer/freeswitch.rb +22 -0
- data/lib/adhearsion/initializer/rails.rb +40 -0
- data/lib/adhearsion/logging.rb +92 -0
- data/lib/adhearsion/tasks.rb +16 -0
- data/lib/adhearsion/tasks/database.rb +5 -0
- data/lib/adhearsion/tasks/deprecations.rb +59 -0
- data/lib/adhearsion/tasks/generating.rb +20 -0
- data/lib/adhearsion/tasks/lint.rb +4 -0
- data/lib/adhearsion/tasks/testing.rb +37 -0
- data/lib/adhearsion/version.rb +9 -0
- data/lib/adhearsion/voip/asterisk.rb +4 -0
- data/lib/adhearsion/voip/asterisk/agi_server.rb +81 -0
- data/lib/adhearsion/voip/asterisk/commands.rb +1284 -0
- data/lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb +140 -0
- data/lib/adhearsion/voip/asterisk/config_generators/config_generator.rb +101 -0
- data/lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb +250 -0
- data/lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb +240 -0
- data/lib/adhearsion/voip/asterisk/config_manager.rb +71 -0
- data/lib/adhearsion/voip/asterisk/manager_interface.rb +562 -0
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rb +1754 -0
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rl.rb +286 -0
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb +78 -0
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_protocol_lexer_machine.rl +87 -0
- data/lib/adhearsion/voip/asterisk/special_dial_plan_managers.rb +80 -0
- data/lib/adhearsion/voip/asterisk/super_manager.rb +19 -0
- data/lib/adhearsion/voip/call.rb +440 -0
- data/lib/adhearsion/voip/call_routing.rb +64 -0
- data/lib/adhearsion/voip/commands.rb +9 -0
- data/lib/adhearsion/voip/constants.rb +39 -0
- data/lib/adhearsion/voip/conveniences.rb +18 -0
- data/lib/adhearsion/voip/dial_plan.rb +218 -0
- data/lib/adhearsion/voip/dsl/dialing_dsl.rb +151 -0
- data/lib/adhearsion/voip/dsl/dialing_dsl/dialing_dsl_monkey_patches.rb +37 -0
- data/lib/adhearsion/voip/dsl/dialplan/control_passing_exception.rb +27 -0
- data/lib/adhearsion/voip/dsl/dialplan/dispatcher.rb +124 -0
- data/lib/adhearsion/voip/dsl/dialplan/parser.rb +71 -0
- data/lib/adhearsion/voip/dsl/dialplan/thread_mixin.rb +16 -0
- data/lib/adhearsion/voip/dsl/numerical_string.rb +117 -0
- data/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb +48 -0
- data/lib/adhearsion/voip/freeswitch/event_handler.rb +58 -0
- data/lib/adhearsion/voip/freeswitch/freeswitch_dialplan_command_factory.rb +129 -0
- data/lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb +38 -0
- data/lib/adhearsion/voip/freeswitch/oes_server.rb +195 -0
- data/lib/adhearsion/voip/menu_state_machine/calculated_match.rb +80 -0
- data/lib/adhearsion/voip/menu_state_machine/matchers.rb +123 -0
- data/lib/adhearsion/voip/menu_state_machine/menu_builder.rb +58 -0
- data/lib/adhearsion/voip/menu_state_machine/menu_class.rb +149 -0
- data/lib/theatre.rb +151 -0
- data/lib/theatre/README.markdown +64 -0
- data/lib/theatre/callback_definition_loader.rb +84 -0
- data/lib/theatre/guid.rb +23 -0
- data/lib/theatre/invocation.rb +121 -0
- data/lib/theatre/namespace_manager.rb +153 -0
- data/lib/theatre/version.rb +2 -0
- metadata +160 -140
- data/.version +0 -1
- data/TODO +0 -71
- data/ahn +0 -223
- data/apps/default/Rakefile +0 -65
- data/apps/default/config/adhearsion.sqlite3 +0 -0
- data/apps/default/config/adhearsion.yml +0 -95
- data/apps/default/config/database.rb +0 -50
- data/apps/default/config/database.yml +0 -12
- data/apps/default/config/helpers/drb_server.yml +0 -43
- data/apps/default/config/helpers/factorial.alien.c.yml +0 -1
- data/apps/default/config/helpers/growler.yml +0 -21
- data/apps/default/config/helpers/lookup.yml +0 -1
- data/apps/default/config/helpers/manager_proxy.yml +0 -8
- data/apps/default/config/helpers/micromenus.yml +0 -1
- data/apps/default/config/helpers/micromenus/collab.rb +0 -60
- data/apps/default/config/helpers/micromenus/images/arrow-off.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/arrow-on.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/error.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/folder-off.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/folder-on.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/folder.png +0 -0
- data/apps/default/config/helpers/micromenus/images/ggbridge.jpg +0 -0
- data/apps/default/config/helpers/micromenus/images/green.png +0 -0
- data/apps/default/config/helpers/micromenus/images/microbrowser.bg.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/red.png +0 -0
- data/apps/default/config/helpers/micromenus/images/tux.bmp +0 -0
- data/apps/default/config/helpers/micromenus/images/url-off.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/url-on.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/yellow.png +0 -0
- data/apps/default/config/helpers/micromenus/javascripts/animation.js +0 -1341
- data/apps/default/config/helpers/micromenus/javascripts/carousel.js +0 -1238
- data/apps/default/config/helpers/micromenus/javascripts/columnav.js +0 -306
- data/apps/default/config/helpers/micromenus/javascripts/connection.js +0 -965
- data/apps/default/config/helpers/micromenus/javascripts/container.js +0 -4727
- data/apps/default/config/helpers/micromenus/javascripts/container_core.js +0 -2915
- data/apps/default/config/helpers/micromenus/javascripts/dom.js +0 -892
- data/apps/default/config/helpers/micromenus/javascripts/dragdrop.js +0 -2958
- data/apps/default/config/helpers/micromenus/javascripts/event.js +0 -1771
- data/apps/default/config/helpers/micromenus/javascripts/yahoo.js +0 -433
- data/apps/default/config/helpers/micromenus/stylesheets/carousel.css +0 -78
- data/apps/default/config/helpers/micromenus/stylesheets/columnav.css +0 -135
- data/apps/default/config/helpers/micromenus/stylesheets/microbrowsers.css +0 -42
- data/apps/default/config/helpers/multi_messenger.yml +0 -9
- data/apps/default/config/helpers/weather.yml +0 -1
- data/apps/default/config/helpers/xbmc.yml +0 -2
- data/apps/default/config/migration.rb +0 -59
- data/apps/default/extensions.rb +0 -41
- data/apps/default/helpers/factorial.alien.c +0 -32
- data/apps/default/helpers/growler.rb +0 -53
- data/apps/default/helpers/lookup.rb +0 -44
- data/apps/default/helpers/manager_proxy.rb +0 -112
- data/apps/default/helpers/micromenus.rb +0 -514
- data/apps/default/helpers/multi_messenger.rb +0 -53
- data/apps/default/helpers/oscar_wilde_quotes.rb +0 -197
- data/apps/default/helpers/weather.rb +0 -85
- data/apps/default/helpers/xbmc.rb +0 -39
- data/apps/default/logs/adhearsion.log +0 -0
- data/apps/default/logs/database.log +0 -0
- data/lib/constants.rb +0 -24
- data/lib/core_extensions.rb +0 -180
- data/lib/drb_server.rb +0 -101
- data/lib/logging.rb +0 -85
- data/lib/phone_number.rb +0 -85
- data/lib/rami.rb +0 -823
- data/lib/servlet_container.rb +0 -174
- data/lib/sexy_migrations.rb +0 -70
- data/test/asterisk_module_test.rb +0 -14
- data/test/core_extensions_test.rb +0 -26
- data/test/dial_test.rb +0 -43
- data/test/specs/numerical_string_spec.rb +0 -53
- 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,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
|
data/apps/default/extensions.rb
DELETED
@@ -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
|