aastra_xml_api 1.0.0 → 1.0.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 +4 -4
- data/.ruby-version +1 -0
- data/README.md +10 -2
- data/aastra_xml_api.gemspec +1 -1
- data/lib/aastra_xml_api.rb +1 -1
- data/lib/aastra_xml_api/array_extensions.rb +61 -0
- data/lib/aastra_xml_api/phone.rb +205 -0
- data/lib/aastra_xml_api/phone_configuration.rb +56 -0
- data/lib/aastra_xml_api/phone_configuration_entry.rb +43 -0
- data/lib/aastra_xml_api/phone_directory.rb +122 -0
- data/lib/aastra_xml_api/phone_directory_entry.rb +34 -0
- data/lib/aastra_xml_api/phone_execute.rb +60 -0
- data/lib/aastra_xml_api/phone_execute_entry.rb +32 -0
- data/lib/aastra_xml_api/phone_formatted_text_screen.rb +119 -0
- data/lib/aastra_xml_api/phone_formatted_text_screen_entry.rb +50 -0
- data/lib/aastra_xml_api/phone_gd_image.rb +187 -0
- data/lib/aastra_xml_api/phone_icon_entry.rb +29 -0
- data/lib/aastra_xml_api/phone_image_menu.rb +145 -0
- data/lib/aastra_xml_api/phone_image_menu_entry.rb +27 -0
- data/lib/aastra_xml_api/phone_image_screen.rb +141 -0
- data/lib/aastra_xml_api/phone_input_screen.rb +251 -0
- data/lib/aastra_xml_api/phone_input_screen_entry.rb +86 -0
- data/lib/aastra_xml_api/phone_softkey_entry.rb +39 -0
- data/lib/aastra_xml_api/phone_status.rb +68 -0
- data/lib/aastra_xml_api/phone_status_entry.rb +58 -0
- data/lib/aastra_xml_api/phone_text_menu.rb +148 -0
- data/lib/aastra_xml_api/phone_text_menu_entry.rb +54 -0
- data/lib/aastra_xml_api/phone_text_screen.rb +95 -0
- data/lib/aastra_xml_api/version.rb +1 -1
- metadata +28 -27
- data/lib/aastra_xml_api/AastraIPPhone.rb +0 -203
- data/lib/aastra_xml_api/AastraIPPhoneConfiguration.rb +0 -55
- data/lib/aastra_xml_api/AastraIPPhoneConfigurationEntry.rb +0 -41
- data/lib/aastra_xml_api/AastraIPPhoneDirectory.rb +0 -119
- data/lib/aastra_xml_api/AastraIPPhoneDirectoryEntry.rb +0 -32
- data/lib/aastra_xml_api/AastraIPPhoneExecute.rb +0 -58
- data/lib/aastra_xml_api/AastraIPPhoneExecuteEntry.rb +0 -30
- data/lib/aastra_xml_api/AastraIPPhoneFormattedTextScreen.rb +0 -117
- data/lib/aastra_xml_api/AastraIPPhoneFormattedTextScreenEntry.rb +0 -48
- data/lib/aastra_xml_api/AastraIPPhoneGDImage.rb +0 -185
- data/lib/aastra_xml_api/AastraIPPhoneIconEntry.rb +0 -27
- data/lib/aastra_xml_api/AastraIPPhoneImageMenu.rb +0 -143
- data/lib/aastra_xml_api/AastraIPPhoneImageMenuEntry.rb +0 -25
- data/lib/aastra_xml_api/AastraIPPhoneImageScreen.rb +0 -139
- data/lib/aastra_xml_api/AastraIPPhoneInputScreen.rb +0 -249
- data/lib/aastra_xml_api/AastraIPPhoneInputScreenEntry.rb +0 -84
- data/lib/aastra_xml_api/AastraIPPhoneSoftkeyEntry.rb +0 -37
- data/lib/aastra_xml_api/AastraIPPhoneStatus.rb +0 -66
- data/lib/aastra_xml_api/AastraIPPhoneStatusEntry.rb +0 -56
- data/lib/aastra_xml_api/AastraIPPhoneTextMenu.rb +0 -145
- data/lib/aastra_xml_api/AastraIPPhoneTextMenuEntry.rb +0 -52
- data/lib/aastra_xml_api/AastraIPPhoneTextScreen.rb +0 -93
- data/lib/aastra_xml_api/arraynatsort.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55581e915fa9f7488d01c00c2e7c5c905a9e3571
|
4
|
+
data.tar.gz: 141e8a8e320e51387d4d3db2fcea9fe0333fbf04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 893884155ef0485bd46524f21a3ad083d4365dc0462d2e0768ab14106b5a52695a92cf059e8b6794bbddd06075bd204bc4ca7c29d4a951b45bd32a61f9c22f4c
|
7
|
+
data.tar.gz: 1e6ef1f6a11bb40a59efac744ce156b1ed9b187481406600b7367550ef42ae2176893c59d38d87b83bcc8c4750232cc02de873bf4af8e276093859b487d5e1de
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.2
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# AastraXmlApi
|
2
2
|
|
3
|
-
|
3
|
+
This is a Gem of Carlton O'Riley's port of Aastra XML API Classes
|
4
|
+
|
5
|
+
To view the original project: https://code.google.com/p/ruby-aastra/
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -18,7 +20,9 @@ Or install it yourself as:
|
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
require 'aastra_xml_api'
|
24
|
+
|
25
|
+
AastraIPPhone.new ...
|
22
26
|
|
23
27
|
## Contributing
|
24
28
|
|
@@ -27,3 +31,7 @@ TODO: Write usage instructions here
|
|
27
31
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
32
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
33
|
5. Create new Pull Request
|
34
|
+
|
35
|
+
# License
|
36
|
+
|
37
|
+
GPL v2 - because the original project is GPL v2
|
data/aastra_xml_api.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["emery.miller@easyofficephone.com"]
|
11
11
|
spec.description = %q{Gemified version of Carlton O'Riley's Aastra XML Ruby Port}
|
12
12
|
spec.summary = %q{Aastra XML API for Ruby}
|
13
|
-
spec.homepage = "
|
13
|
+
spec.homepage = "https://github.com/EasyOfficePhone/aastra_xml_api"
|
14
14
|
spec.license = "GNU GPL v2"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/aastra_xml_api.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'cgi'
|
2
2
|
|
3
|
-
(Dir['lib/aastra_xml_api/*'] - ['lib/aastra_xml_api/
|
3
|
+
(Dir['lib/aastra_xml_api/*'] - ['lib/aastra_xml_api/phone_gd_image.rb']).sort.each do |path|
|
4
4
|
name = File.split(path)[1][0..-4]
|
5
5
|
require "aastra_xml_api/#{name}"
|
6
6
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Performs natural order sorting of an array. Natural order is the way in
|
2
|
+
# which a human might sort a list of files that are incremented by
|
3
|
+
# one. They will sort normally as long as they have leading zeros,
|
4
|
+
# however this doesn't look good and is hard to read. What natural sorting
|
5
|
+
# does is allow the following to be sorted properly (as shown):
|
6
|
+
#
|
7
|
+
# file1
|
8
|
+
# file2
|
9
|
+
# file4
|
10
|
+
# file22
|
11
|
+
# file30
|
12
|
+
# file100
|
13
|
+
#
|
14
|
+
# Code used is from http://zijab.blogspot.com/2007/05/natural-order-string-comparison-for.html
|
15
|
+
#
|
16
|
+
|
17
|
+
module AastraXmlApi
|
18
|
+
module ArrayExtension
|
19
|
+
# Method which sort an array composed of strings with embedded numbers by
|
20
|
+
# the 'natural' representation of numbers inside a string.
|
21
|
+
def natsort
|
22
|
+
reg_number = /\d+/
|
23
|
+
# We call the sort method of the Array class.
|
24
|
+
self.sort do |str1, str2|
|
25
|
+
|
26
|
+
# We try to find an embedded number
|
27
|
+
a = str1.match(reg_number)
|
28
|
+
b = str2.match(reg_number)
|
29
|
+
|
30
|
+
# If there is no number
|
31
|
+
if [a,b].include? nil
|
32
|
+
str1 <=> str2
|
33
|
+
else
|
34
|
+
while true
|
35
|
+
begin
|
36
|
+
# We compare strings before the number. If there
|
37
|
+
# are equal, we will have to compare the numbers
|
38
|
+
if (comp = a.pre_match <=> b.pre_match) == 0
|
39
|
+
# If the numbers are equal
|
40
|
+
comp = (a[0] == b[0]) ? comp = a[0] + a.post_match <=> b[0] + b.post_match :
|
41
|
+
comp = a[0].to_i <=> b[0].to_i
|
42
|
+
end
|
43
|
+
|
44
|
+
str1, str2 = a.post_match, b.post_match
|
45
|
+
a = str1.match(reg_number)
|
46
|
+
b = str2.match(reg_number)
|
47
|
+
rescue
|
48
|
+
break
|
49
|
+
end
|
50
|
+
end
|
51
|
+
comp
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Same as 'natsort' but replace in place.
|
57
|
+
def natsort!
|
58
|
+
self.replace(natsort)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# Aastra XML API Classes - Phone
|
3
|
+
# Copyright Aastra Telecom 2008
|
4
|
+
#
|
5
|
+
# Ruby adaptation by Carlton O'Riley
|
6
|
+
#
|
7
|
+
# Phone is the root class for all the Aastra XML objects.
|
8
|
+
#
|
9
|
+
# Public methods
|
10
|
+
# setTitle(Title) to setup the title of an object (optional)
|
11
|
+
# setTitleWrap to set the title to be wrapped on 2 lines (optional)
|
12
|
+
# setCancelAction(uri) to set the cancel parameter with the URI to be called on Cancel (optional)
|
13
|
+
# setDestroyOnExit to set DestroyonExit parameter to 'yes', 'no' by default (optional)
|
14
|
+
# setBeep to enable a notification beep with the object (optional)
|
15
|
+
# setLockIn to set the Lock-in tag to 'yes' (optional)
|
16
|
+
# setAllowAnswer to set the allowAnswer tag to 'yes' (optional)
|
17
|
+
# setTimeout(timeout) to define a specific timeout for the XML object (optional)
|
18
|
+
# addSoftkey(index,label,uri,icon_index) to add custom soktkeys to the object (optional)
|
19
|
+
# setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
|
20
|
+
# addIcon(index,icon) to add custom icons to the object (optional)
|
21
|
+
#
|
22
|
+
###############################################################################
|
23
|
+
|
24
|
+
module AastraXmlApi
|
25
|
+
class Phone
|
26
|
+
@entries
|
27
|
+
@softkeys
|
28
|
+
@icons
|
29
|
+
@title
|
30
|
+
@title_wrap
|
31
|
+
@destroyOnExit
|
32
|
+
@cancelAction
|
33
|
+
@refreshTimeout
|
34
|
+
@refreshURL
|
35
|
+
@beep
|
36
|
+
@lockin
|
37
|
+
@timeout
|
38
|
+
@allowAnswer
|
39
|
+
|
40
|
+
HIGHASCII = {
|
41
|
+
"!\xc0!" => 'A', # A`
|
42
|
+
"!\xe0!" => 'a', # a`
|
43
|
+
"!\xc1!" => 'A', # A'
|
44
|
+
"!\xe1!" => 'a', # a'
|
45
|
+
"!\xc2!" => 'A', # A^
|
46
|
+
"!\xe2!" => 'a', # a^
|
47
|
+
"!\xc4!" => 'Ae', # A:
|
48
|
+
"!\xe4!" => 'ae', # a:
|
49
|
+
"!\xc3!" => 'A', # A~
|
50
|
+
"!\xe3!" => 'a', # a~
|
51
|
+
"!\xc8!" => 'E', # E`
|
52
|
+
"!\xe8!" => 'e', # e`
|
53
|
+
"!\xc9!" => 'E', # E'
|
54
|
+
"!\xe9!" => 'e', # e'
|
55
|
+
"!\xca!" => 'E', # E^
|
56
|
+
"!\xea!" => 'e', # e^
|
57
|
+
"!\xcb!" => 'Ee', # E:
|
58
|
+
"!\xeb!" => 'ee', # e:
|
59
|
+
"!\xcc!" => 'I', # I`
|
60
|
+
"!\xec!" => 'i', # i`
|
61
|
+
"!\xcd!" => 'I', # I'
|
62
|
+
"!\xed!" => 'i', # i'
|
63
|
+
"!\xce!" => 'I', # I^
|
64
|
+
"!\xee!" => 'i', # i^
|
65
|
+
"!\xcf!" => 'Ie', # I:
|
66
|
+
"!\xef!" => 'ie', # i:
|
67
|
+
"!\xd2!" => 'O', # O`
|
68
|
+
"!\xf2!" => 'o', # o`
|
69
|
+
"!\xd3!" => 'O', # O'
|
70
|
+
"!\xf3!" => 'o', # o'
|
71
|
+
"!\xd4!" => 'O', # O^
|
72
|
+
"!\xf4!" => 'o', # o^
|
73
|
+
"!\xd6!" => 'Oe', # O:
|
74
|
+
"!\xf6!" => 'oe', # o:
|
75
|
+
"!\xd5!" => 'O', # O~
|
76
|
+
"!\xf5!" => 'o', # o~
|
77
|
+
"!\xd8!" => 'Oe', # O/
|
78
|
+
"!\xf8!" => 'oe', # o/
|
79
|
+
"!\xd9!" => 'U', # U`
|
80
|
+
"!\xf9!" => 'u', # u`
|
81
|
+
"!\xda!" => 'U', # U'
|
82
|
+
"!\xfa!" => 'u', # u'
|
83
|
+
"!\xdb!" => 'U', # U^
|
84
|
+
"!\xfb!" => 'u', # u^
|
85
|
+
"!\xdc!" => 'Ue', # U:
|
86
|
+
"!\xfc!" => 'ue', # u:
|
87
|
+
"!\xc7!" => 'C', # ,C
|
88
|
+
"!\xe7!" => 'c', # ,c
|
89
|
+
"!\xd1!" => 'N', # N~
|
90
|
+
"!\xf1!" => 'n', # n~
|
91
|
+
"!\xdf!" => 'ss'
|
92
|
+
}
|
93
|
+
|
94
|
+
# Create an Phone object and set initial values. Everything
|
95
|
+
# sent to the phone will inherit from this class.
|
96
|
+
def initialize
|
97
|
+
@entries = []
|
98
|
+
@softkeys = []
|
99
|
+
@icons = []
|
100
|
+
@refreshTimeout = 0
|
101
|
+
@timeout = 0
|
102
|
+
end
|
103
|
+
|
104
|
+
# Set the title of the Phone object. Typically displayed on the
|
105
|
+
# top of the phone.
|
106
|
+
def setTitle(title)
|
107
|
+
@title = title
|
108
|
+
end
|
109
|
+
|
110
|
+
# Allow the title to wrap over multiple lines when displayed.
|
111
|
+
def setTitleWrap
|
112
|
+
@title_wrap = "yes"
|
113
|
+
end
|
114
|
+
|
115
|
+
# Set refresh timeout (seconds) and the URI to load when the
|
116
|
+
# timeout is reached.
|
117
|
+
def setRefresh(timeout, url)
|
118
|
+
@refreshTimeout = timeout
|
119
|
+
@refreshURL = url
|
120
|
+
end
|
121
|
+
|
122
|
+
# Beep phone when XML is received.
|
123
|
+
def setBeep
|
124
|
+
@beep = "yes"
|
125
|
+
end
|
126
|
+
|
127
|
+
# Do not keep the object in the phone browser after exit.
|
128
|
+
def setDestroyOnExit
|
129
|
+
@destroyOnExit = "yes"
|
130
|
+
end
|
131
|
+
|
132
|
+
# Defines the URI to call when the user cancels the XML object.
|
133
|
+
def setCancelAction(cancelAction)
|
134
|
+
@cancelAction = cancelAction
|
135
|
+
end
|
136
|
+
|
137
|
+
# Ignores all keys that would cause the screen to exit without using
|
138
|
+
# keys defined by the object.
|
139
|
+
def setLockIn
|
140
|
+
@lockin = "yes"
|
141
|
+
end
|
142
|
+
|
143
|
+
# Override the default 45 second timeout. A value of 0 will disable
|
144
|
+
# timeout.
|
145
|
+
def setTimeout(timeout)
|
146
|
+
@timeout = timeout
|
147
|
+
end
|
148
|
+
|
149
|
+
# Applies only to the non-softkey phones (53i). When set, the phone
|
150
|
+
# displays 'Ignore' and 'Answer' if the XML object is displayed when
|
151
|
+
# the phone is ringing.
|
152
|
+
def setAllowAnswer
|
153
|
+
@allowAnswer = "yes"
|
154
|
+
end
|
155
|
+
|
156
|
+
# Returns the set refresh timeout value.
|
157
|
+
def getRefreshTimeout
|
158
|
+
return @refreshTimeout
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns the set refresh URI.
|
162
|
+
def getRefreshURL
|
163
|
+
return @refreshURL
|
164
|
+
end
|
165
|
+
|
166
|
+
# Add a softkey to be displayed while the XML object is on the screen.
|
167
|
+
# Only available on the 9480i, 9480iCT, 55i, 57i, and 57iCT. Softkey
|
168
|
+
# will be at position index. label is what is displayed next to the
|
169
|
+
# softkey button. uri is what is called when the softkey is pressed.
|
170
|
+
# Optionally, icon is the index of the icon to display to the left of
|
171
|
+
# the label.
|
172
|
+
def addSoftkey(index, label, uri, icon=nil)
|
173
|
+
@softkeys += [PhoneSoftkeyEntry.new(index, escape(label), escape(uri), icon)]
|
174
|
+
end
|
175
|
+
|
176
|
+
# Add an icon to be used by either a softkey of PhoneTextMenu.
|
177
|
+
# Only available on the 55i, 57i, and 57iCT. The index is the same as
|
178
|
+
# what is referenced by addSoftkey or PhoneTextMenu.addEntry.
|
179
|
+
# The icon can be either a predefined icon or the hex of an icon image.
|
180
|
+
def addIcon(index, icon)
|
181
|
+
@icons += [PhoneIconEntry.new(index, icon)]
|
182
|
+
end
|
183
|
+
|
184
|
+
# Convert any HTML characters to the proper escaped format.
|
185
|
+
# i.e. > becomes >
|
186
|
+
def escape(s)
|
187
|
+
return nil if s.nil?
|
188
|
+
CGI.escapeHTML(s)
|
189
|
+
end
|
190
|
+
|
191
|
+
# Convert characters when using double sized text in
|
192
|
+
# PhoneFormattedTextScreen.
|
193
|
+
def convert_high_ascii(s)
|
194
|
+
ret = ""
|
195
|
+
s.each do |char|
|
196
|
+
if not HIGHASCII[char].nil? then
|
197
|
+
ret += HIGHASCII[char]
|
198
|
+
else
|
199
|
+
ret += char
|
200
|
+
end
|
201
|
+
end
|
202
|
+
return ret
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Aastra XML API Classes - PhoneConfiguration
|
3
|
+
# Copyright Aastra Telecom 8007
|
4
|
+
#
|
5
|
+
# Ruby adaptation by Carlton O'Riley
|
6
|
+
#
|
7
|
+
# PhoneConfiguration object.
|
8
|
+
#
|
9
|
+
# Public methods
|
10
|
+
#
|
11
|
+
# Inherited from Phone
|
12
|
+
# setBeep to enable a notification beep with the object (optional)
|
13
|
+
#
|
14
|
+
# Specific to the object
|
15
|
+
# addEntry(parameter,value) to add a configuration change.
|
16
|
+
# setTriggerDestroyOnExit to set the triggerDestroyOnExit tag to
|
17
|
+
# "yes" (optional)
|
18
|
+
#
|
19
|
+
# Example
|
20
|
+
# require 'PhoneConfiguration.rb'
|
21
|
+
# configuration = PhoneConfiguration.new
|
22
|
+
# configuration.addEntry('softkey1 label','Test')
|
23
|
+
# configuration.addEntry('softkey1 type','xml')
|
24
|
+
# configuration.setTriggerDestroyOnExit
|
25
|
+
# configuration.setBeep
|
26
|
+
# aastra_output configuration
|
27
|
+
#
|
28
|
+
################################################################################
|
29
|
+
|
30
|
+
module AastraXmlApi
|
31
|
+
class PhoneConfiguration < Phone
|
32
|
+
# Adds a parameter and value entry to the list.
|
33
|
+
def addEntry(parameter, value)
|
34
|
+
@entries += [PhoneConfigurationEntry.new(parameter, value)]
|
35
|
+
end
|
36
|
+
|
37
|
+
# When set, the previous user interface XML object is destroyed
|
38
|
+
# if its destroyOnExit tag is also set to yes.
|
39
|
+
def setTriggerDestroyOnExit
|
40
|
+
@triggerDestroyOnExit = "yes"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Create XML text output.
|
44
|
+
def render
|
45
|
+
out = "<PhoneConfiguration"
|
46
|
+
out += " Beep=\"yes\"" if @beep == "yes"
|
47
|
+
out += " triggerDestroyOnExit=\"yes\"" if @triggerDestroyOnExit == "yes"
|
48
|
+
out += ">\n"
|
49
|
+
@entries.each do |entry|
|
50
|
+
out += entry.render
|
51
|
+
end
|
52
|
+
out += "</PhoneConfiguration>\n"
|
53
|
+
return out
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Aastra XML API Classes - PhoneConfigurationEntry
|
3
|
+
# Firmware 2.0 or better
|
4
|
+
# Copyright Aastra Telecom 2008
|
5
|
+
#
|
6
|
+
# Ruby adaptation by Carlton O'Riley
|
7
|
+
#
|
8
|
+
# Internal class for PhoneConfiguration object.
|
9
|
+
################################################################################
|
10
|
+
module AastraXmlApi
|
11
|
+
class PhoneConfigurationEntry < Phone
|
12
|
+
@parameter
|
13
|
+
@value
|
14
|
+
|
15
|
+
# Create a new parameter/value pair. This overrides the
|
16
|
+
# initialize method in Phone.
|
17
|
+
def initialize(parameter, value)
|
18
|
+
@parameter = parameter
|
19
|
+
@value = value
|
20
|
+
end
|
21
|
+
|
22
|
+
# Set the parameter for this entry.
|
23
|
+
def setParameter(parameter)
|
24
|
+
@parameter = parameter
|
25
|
+
end
|
26
|
+
|
27
|
+
# Set the value for this entry.
|
28
|
+
def setValue(value)
|
29
|
+
@value = value
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create XML text output for this entry.
|
33
|
+
def render
|
34
|
+
parameter = escape(@parameter)
|
35
|
+
value = escape(@value)
|
36
|
+
xml = "<ConfigurationItem>\n"
|
37
|
+
xml += "<Parameter>#{parameter}</Parameter>\n"
|
38
|
+
xml += "<Value>#{value}</Value>\n"
|
39
|
+
xml += "</ConfigurationItem>\n"
|
40
|
+
return xml
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Aastra XML API Classes - PhoneDirectory
|
3
|
+
# Copyright Aastra Telecom 2008
|
4
|
+
#
|
5
|
+
# Ruby adaptation by Carlton O'Riley
|
6
|
+
#
|
7
|
+
# PhoneDirectory object.
|
8
|
+
#
|
9
|
+
# Public methods
|
10
|
+
#
|
11
|
+
# Inherited from Phone
|
12
|
+
# setTitle(Title) to setup the title of an object (optional)
|
13
|
+
# setTitleWrap to set the title to be wrapped on 2 lines (optional)
|
14
|
+
# setDestroyOnExit to set DestroyonExit parameter to 'yes', 'no' by default (optional)
|
15
|
+
# setCancelAction(uri) to set the cancel parameter with the URI to be called on Cancel (optional)
|
16
|
+
# setBeep to enable a notification beep with the object (optional)
|
17
|
+
# setLockIn to set the Lock-in tag to 'yes' (optional)
|
18
|
+
# setTimeout(timeout) to define a specific timeout for the XML object (optional)
|
19
|
+
# addSoftkey(index,label,uri,icon_index) to add custom softkeys to the object (optional)
|
20
|
+
# addIcon(index,icon) to add custom icons to the object (optional)
|
21
|
+
# setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
|
22
|
+
#
|
23
|
+
# Specific to the object
|
24
|
+
# setNext(next) to set URI of the next page (optional)
|
25
|
+
# setPrevious(previous) to set URI of the previous page (optional)
|
26
|
+
# addEntry(name,phone) to add an element in the list to be displayed, at least one is needed.
|
27
|
+
# natsortbyname to order the list
|
28
|
+
#
|
29
|
+
# Example
|
30
|
+
# require 'PhoneDirectory.rb'
|
31
|
+
# directory = PhoneDirectory.new
|
32
|
+
# directory.setTitle('Title')
|
33
|
+
# directory.setNext('http://myserver.com/script.php?page=2')
|
34
|
+
# directory.setPrevious('http://myserver.com/script.php?page=0')
|
35
|
+
# directory.setDestroyOnExit
|
36
|
+
# directory.addEntry('John Doe', '200')
|
37
|
+
# directory.addEntry('Jane Doe', '201')
|
38
|
+
# directory.natsortByName
|
39
|
+
# directory.addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1')
|
40
|
+
# directory.addSoftkey('6', 'Exit', 'SoftKey:Exit')
|
41
|
+
# aastra_output directory
|
42
|
+
#
|
43
|
+
################################################################################
|
44
|
+
|
45
|
+
module AastraXmlApi
|
46
|
+
class PhoneDirectory < Phone
|
47
|
+
@next
|
48
|
+
@previous
|
49
|
+
|
50
|
+
# Set the URI to load the next page of the directory.
|
51
|
+
def setNext(nextval)
|
52
|
+
@next = nextval
|
53
|
+
end
|
54
|
+
|
55
|
+
# Set the URI to load the previous page of the directory.
|
56
|
+
def setPrevious(previous)
|
57
|
+
@previous = previous
|
58
|
+
end
|
59
|
+
|
60
|
+
# Add directory entry with a name to be displayed and a telephone
|
61
|
+
# number to dial.
|
62
|
+
def addEntry(name, telephone)
|
63
|
+
@entries += [PhoneDirectoryEntry.new(name, telephone)]
|
64
|
+
end
|
65
|
+
|
66
|
+
# Sort array of names using natural sort order. i.e. Bob2 comes
|
67
|
+
# before Bob10.
|
68
|
+
def natsortByName
|
69
|
+
tmparray = []
|
70
|
+
tmp_array.include(ArrayExtension)
|
71
|
+
linklist = {}
|
72
|
+
for i in 0..@entries.size-1
|
73
|
+
tmparray += [@entries[i].getName]
|
74
|
+
linklist[@entries[i].getName] = i
|
75
|
+
end
|
76
|
+
tmparray.natsort!
|
77
|
+
newentries = []
|
78
|
+
tmparray.each do |name|
|
79
|
+
newentries += [@entries[linklist[name]]]
|
80
|
+
end
|
81
|
+
@entries = newentries
|
82
|
+
end
|
83
|
+
|
84
|
+
# Create XML text output.
|
85
|
+
def render
|
86
|
+
out = "<PhoneDirectory"
|
87
|
+
if not @previous.nil? then
|
88
|
+
previous = escape(@previous)
|
89
|
+
out += " previous=\"#{previous}\""
|
90
|
+
end
|
91
|
+
if not @next.nil? then
|
92
|
+
nextval = escape(@next)
|
93
|
+
out += " next=\"#{nextval}\""
|
94
|
+
end
|
95
|
+
out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
|
96
|
+
if not @cancelAction.nil? then
|
97
|
+
cancelAction = escape(@cancelAction)
|
98
|
+
out += " cancelAction=\"#{cancelAction}\""
|
99
|
+
end
|
100
|
+
out += " Beep=\"yes\"" if @beep == "yes"
|
101
|
+
out += " LockIn=\"yes\"" if @lockin == "yes"
|
102
|
+
out += " Timeout=\"#{@timeout}\"" if @timeout != 0
|
103
|
+
out += ">\n"
|
104
|
+
if not @title.nil? then
|
105
|
+
title = escape(title)
|
106
|
+
out += "<Title"
|
107
|
+
out += " wrap=\"yes\"" if @title_wrap == "yes"
|
108
|
+
out += ">#{title}</Title>\n"
|
109
|
+
end
|
110
|
+
index = 0
|
111
|
+
@entries.each do |entry|
|
112
|
+
out += entry.render if index < 30
|
113
|
+
index += 1
|
114
|
+
end
|
115
|
+
@softkeys.each do |softkey|
|
116
|
+
out += softkey.render
|
117
|
+
end
|
118
|
+
out += "</PhoneDirectory>\n"
|
119
|
+
return out
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|