aastra_xml_api 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,249 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Aastra XML API Classes - AastraIPPhoneInputScreen
|
3
|
-
# Copyright Aastra Telecom 2008
|
4
|
-
#
|
5
|
-
# Ruby adaptation by Carlton O'Riley
|
6
|
-
#
|
7
|
-
# AastraIPPhoneInputScreen object.
|
8
|
-
#
|
9
|
-
# Public methods
|
10
|
-
#
|
11
|
-
# Inherited from AastraIPPhone
|
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
|
-
# setAllowAnswer to set the allowAnswer tag to 'yes' (optional)
|
19
|
-
# setTimeout(timeout) to define a specific timeout for the XML object (optional)
|
20
|
-
# addSoftkey(index,label,uri,icon_index) to add custom softkeys to the object (optional)
|
21
|
-
# addIcon(index,icon) to add custom icons to the object (optional)
|
22
|
-
#
|
23
|
-
# Specific to the object - Single Input
|
24
|
-
# setURL(url) to set the URL to called after the input
|
25
|
-
# setType(type) to set type of input ('IP', 'string', 'number', 'dateUS'...), 'string' by default
|
26
|
-
# setDefault(default) to set default value for the input (optional)
|
27
|
-
# setParameter(param) to set the parameter name to be parsed after the input
|
28
|
-
# setInputLanguage(language) to set the language of the input (optional)
|
29
|
-
# setPassword to set the Password parameter to 'yes', 'no' by default (optional)
|
30
|
-
# setNotEditable to set the editable parameter to 'no', 'yes' by default (optional)
|
31
|
-
# setEditable is now replaced by setNotEditable but kept for compatibility reasons (optional)
|
32
|
-
# setPrompt(prompt) to set the prompt to be displayed for the input.
|
33
|
-
#
|
34
|
-
# Specific to the object - Multiple Inputs
|
35
|
-
# setURL(url) to set the URL to called after the input
|
36
|
-
# setType(type) to set the default type of input ('IP', 'string', 'number', 'dateUS'...), 'string' by default
|
37
|
-
# setDefault(default) to set default default value for the input (optional)
|
38
|
-
# setParameter(param) to set the default parameter name to be parsed after the input
|
39
|
-
# setPassword to set the default Password parameter to 'yes', 'no' by default (optional)
|
40
|
-
# setNotEditable to set the default editable parameter to 'no', 'yes' by default (optional)
|
41
|
-
# setEditable is now replaced by setNotEditable but kept for compatibility reasons (optional)
|
42
|
-
# setPrompt(prompt) to set the default prompt to be displayed for the input.
|
43
|
-
# setDefaultIndex(index) to define the field index the object will use to start (optional) default is 1
|
44
|
-
# setDisplayMode(display) to define the aspect of the display, normal/condensed (optional) default is normal.
|
45
|
-
# setInputLanguage(language) to set the language of the input (optional)
|
46
|
-
# addField(type) to add an input field and setting its type (IP, string, number, dateUS, timeUS,dateInt, timeInt or empty) if the type is an empty string then the type is inherited from the main object.
|
47
|
-
# setFieldPassword(password) to set the password mode for the input field ('yes', no'), overrides the value set by setPassword for the field
|
48
|
-
# setFieldEditable(editable) to set the input field editable mode ('yes', no'), overrides the value set by setEditable or setNotEditable for the field
|
49
|
-
# setFieldParameter(parameter) to set the parameter name to be parsed after the global input, overrides the value set by setParameter for the field
|
50
|
-
# setFieldPrompt(prompt)to set the prompt to be displayed for the input field, overrides the value set by setPrompt for the field
|
51
|
-
# setFieldSelection(selection) to set the Selection tag for the field
|
52
|
-
# setFieldDefault(default) to set default value for the input field, overrides the value set by setDefault for the field
|
53
|
-
# addFieldSoftkey(index,label,uri,icon) to add custom softkeys to the input field, overrides the softkeys set by addSoftkey.
|
54
|
-
#
|
55
|
-
# Example 1 - Single Input
|
56
|
-
# require 'AastraIPPhoneInputScreen.rb'
|
57
|
-
# input = AastraIPPhoneInputScreen.new
|
58
|
-
# input.setTitle('Title')
|
59
|
-
# input.setPrompt('Enter your password')
|
60
|
-
# input.setParameter('param')
|
61
|
-
# input.setType('string')
|
62
|
-
# input.setURL('http://myserver.com/script.php')
|
63
|
-
# input.setPassword
|
64
|
-
# input.setDestroyOnExit
|
65
|
-
# input.setDefault('Default')
|
66
|
-
# aastra_output input
|
67
|
-
#
|
68
|
-
# Example 2 - Multiple Inputs
|
69
|
-
# require 'AastraIPPhoneInputScreen.rb'
|
70
|
-
# input = AastraIPPhoneInputScreen.new
|
71
|
-
# input.setTitle('Example 2')
|
72
|
-
# input.setDisplayMode('condensed')
|
73
|
-
# input.setURL('http://myserver.com/script.php')
|
74
|
-
# input.setDestroyOnExit
|
75
|
-
# input.addSoftkey('5', 'Done', 'SoftKey:Submit')
|
76
|
-
# input.addField('string')
|
77
|
-
# input.setFieldPrompt('Username:')
|
78
|
-
# input.setFieldParameter('user')
|
79
|
-
# input.addFieldSoftkey('3', 'ABC', 'SoftKey:ChangeMode')
|
80
|
-
# input.addField('number')
|
81
|
-
# input.setFieldPassword('yes')
|
82
|
-
# input.setFieldPrompt('Pass:')
|
83
|
-
# input.setFieldParameter('passwd')
|
84
|
-
# aastra_output input
|
85
|
-
#
|
86
|
-
################################################################################
|
87
|
-
|
88
|
-
class AastraIPPhoneInputScreen < AastraIPPhone
|
89
|
-
@url
|
90
|
-
@type
|
91
|
-
@parameter
|
92
|
-
@prompt
|
93
|
-
@editable
|
94
|
-
@default
|
95
|
-
@password
|
96
|
-
@defaultindex
|
97
|
-
@displaymode
|
98
|
-
@inputlanguage
|
99
|
-
|
100
|
-
# Set URL to be called (html post) when the input is submitted.
|
101
|
-
def setURL(url)
|
102
|
-
@url = url
|
103
|
-
end
|
104
|
-
|
105
|
-
# Sets the type of all fields (see addField for values) unless overriden
|
106
|
-
# by setFieldType.
|
107
|
-
def setType(type)
|
108
|
-
@type = type
|
109
|
-
end
|
110
|
-
|
111
|
-
# Sets all fields are editable. Kept only for compatibility.
|
112
|
-
def setEditable
|
113
|
-
@editable = "yes"
|
114
|
-
end
|
115
|
-
|
116
|
-
# Sets all fields as read only if not overriden by setFieldEditable.
|
117
|
-
def setNotEditable
|
118
|
-
@editable = "no"
|
119
|
-
end
|
120
|
-
|
121
|
-
# Set default value for all fields if not overriden by setFieldDefault.
|
122
|
-
def setDefault(default)
|
123
|
-
@default = default
|
124
|
-
end
|
125
|
-
|
126
|
-
# Set parameter name for all fields if not overriden by setFieldParameter.
|
127
|
-
def setParameter(parameter)
|
128
|
-
@parameter = parameter
|
129
|
-
end
|
130
|
-
|
131
|
-
# Set password input for all fields, masked by "*" characters if not
|
132
|
-
# overriden by setFieldPassword.
|
133
|
-
def setPassword
|
134
|
-
@password = "yes"
|
135
|
-
end
|
136
|
-
|
137
|
-
# Prompt for all input fields, if not overriden by setFieldPrompt.
|
138
|
-
def setPrompt(prompt)
|
139
|
-
@prompt = prompt
|
140
|
-
end
|
141
|
-
|
142
|
-
# Defines which field 1 (default) through 6 the user will start input on.
|
143
|
-
def setDefaultIndex(index)
|
144
|
-
@defaultindex = index
|
145
|
-
end
|
146
|
-
|
147
|
-
# Can be one of normal (default) or condensed.
|
148
|
-
def setDisplayMode(display)
|
149
|
-
@displaymode = display
|
150
|
-
end
|
151
|
-
|
152
|
-
# Defines the language character set used for input.
|
153
|
-
def setInputLanguage(input)
|
154
|
-
@inputlanguage = input
|
155
|
-
end
|
156
|
-
|
157
|
-
# Add a new field to get input for. The type can be one of IP,
|
158
|
-
# string (default), number, timeUS, timeInt, dateUS, or dateInt.
|
159
|
-
def addField(type=nil)
|
160
|
-
@entries += [AastraIPPhoneInputScreenEntry.new(type)]
|
161
|
-
end
|
162
|
-
|
163
|
-
# Sets the type (see addField for values) of the most recently added
|
164
|
-
# field.
|
165
|
-
def setFieldType(type)
|
166
|
-
@entries[@entries.size-1].setType(type)
|
167
|
-
end
|
168
|
-
|
169
|
-
# Set the most recently added field as a password field and mask input
|
170
|
-
# by "*" characters.
|
171
|
-
def setFieldPassword
|
172
|
-
@entries[@entries.size-1].setPassword
|
173
|
-
end
|
174
|
-
|
175
|
-
# Set the most recently added field as editable. This is the default.
|
176
|
-
def setFieldEditable
|
177
|
-
@entries[@entries.size-1].setEditable
|
178
|
-
end
|
179
|
-
|
180
|
-
# Set the most recently added field's parameter name in the form post
|
181
|
-
# when submitted.
|
182
|
-
def setFieldParameter(parameter)
|
183
|
-
@entries[@entries.size-1].setParameter(parameter)
|
184
|
-
end
|
185
|
-
|
186
|
-
# Set the most recently added field's prompt text.
|
187
|
-
def setFieldPrompt(prompt)
|
188
|
-
@entries[@entries.size-1].setPrompt(prompt)
|
189
|
-
end
|
190
|
-
|
191
|
-
# Set the most recently added field's default value.This is what is
|
192
|
-
# displayed when first shown.
|
193
|
-
def setFieldDefault(default)
|
194
|
-
@entries[@entries.size-1].setDefault(default)
|
195
|
-
end
|
196
|
-
|
197
|
-
# Sets the most recently added field's selection tag which is added
|
198
|
-
# to the request when the submit button is pressed while editing this
|
199
|
-
# field.
|
200
|
-
def setFieldSelection(selection)
|
201
|
-
@entries[@entries.size-1].setSelection(selection)
|
202
|
-
end
|
203
|
-
|
204
|
-
# Adds a softkey to be displayed when the most recently added field
|
205
|
-
# is highlighted.
|
206
|
-
def addFieldSoftkey(index, label, uri, icon=nil)
|
207
|
-
@entries[@entries.size-1].addSoftkey(index, label, uri, icon)
|
208
|
-
end
|
209
|
-
|
210
|
-
# Create XML text output.
|
211
|
-
def render
|
212
|
-
@type = 'string' if @type.nil?
|
213
|
-
xml = "<AastraIPPhoneInputScreen type=\"#{@type}\""
|
214
|
-
xml += " password=\"yes\"" if @password == "yes"
|
215
|
-
xml += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
|
216
|
-
xml += " cancelAction=\"#{escape(@cancelAction)}\"" if not @cancelAction.nil?
|
217
|
-
xml += " editable=\"no\"" if @editable == "no"
|
218
|
-
xml += " Beep=\"yes\"" if @beep == "yes"
|
219
|
-
xml += " defaultIndex=\"#{@defaultindex}\"" if not @defaultindex.nil?
|
220
|
-
xml += " inputLanguage=\"#{@inputlanguage}\"" if not @inputlanguage.nil?
|
221
|
-
xml += " displayMode=\"#{@displaymode}\"" if not @displaymode.nil?
|
222
|
-
xml += " LockIn=\"yes\"" if @lockin == "yes"
|
223
|
-
xml += " allowAnswer=\"yes\"" if @allowAnswer == "yes"
|
224
|
-
xml += " Timeout=\"#{@timeout}\"" if @timeout != 0
|
225
|
-
xml += ">\n"
|
226
|
-
if not @title.nil? then
|
227
|
-
xml += "<Title"
|
228
|
-
out += " wrap=\"yes\"" if @title_wrap == "yes"
|
229
|
-
xml += ">#{escape(@title)}</Title>\n"
|
230
|
-
end
|
231
|
-
xml += "<Prompt>#{escape(@prompt)}</Prompt>\n" if not @prompt.nil?
|
232
|
-
xml += "<URL>#{escape(@url)}</URL>\n"
|
233
|
-
xml += "<Parameter>#{@parameter}</Parameter>\n" if not @parameter.nil?
|
234
|
-
xml += "<Default>#{@default}</Default>\n"
|
235
|
-
@entries.each { |entry| xml += entry.render }
|
236
|
-
@softkeys.each { |softkey| xml += softkey.render }
|
237
|
-
iconList = 0
|
238
|
-
@icons.each do |icon|
|
239
|
-
if iconList == 0 then
|
240
|
-
xml += "<IconList>\n"
|
241
|
-
iconList = 1
|
242
|
-
end
|
243
|
-
xml += icon.render
|
244
|
-
end
|
245
|
-
xml += "</IconList>\n" if iconList != 0
|
246
|
-
xml += "</AastraIPPhoneInputScreen>\n"
|
247
|
-
return xml
|
248
|
-
end
|
249
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Aastra XML API Classes - AastraIPPhoneInputScreenEntry
|
3
|
-
# Firmware 2.2.0 or better
|
4
|
-
# Copyright Aastra Telecom 2008
|
5
|
-
#
|
6
|
-
# Ruby adaptation by Carlton O'Riley
|
7
|
-
#
|
8
|
-
# Internal class for AastraIPPhoneInputScreen object.
|
9
|
-
################################################################################
|
10
|
-
|
11
|
-
class AastraIPPhoneInputScreenEntry
|
12
|
-
@type
|
13
|
-
@password
|
14
|
-
@editable
|
15
|
-
@parameter
|
16
|
-
@prompt
|
17
|
-
@default
|
18
|
-
@selection
|
19
|
-
@softkeys
|
20
|
-
|
21
|
-
# Create new input field as a given type. The type can be one of IP,
|
22
|
-
# string (default), number, timeUS, timeInt, dateUS, or dateInt.
|
23
|
-
def initialize(type)
|
24
|
-
@type = type
|
25
|
-
@softkeys = []
|
26
|
-
end
|
27
|
-
|
28
|
-
# Set the type (see initialize for values) of this input field.
|
29
|
-
def setType(type)
|
30
|
-
@type = type
|
31
|
-
end
|
32
|
-
|
33
|
-
# Set this input field as a password field masked by "*" characters.
|
34
|
-
def setPassword
|
35
|
-
@password = "yes"
|
36
|
-
end
|
37
|
-
|
38
|
-
# Make this input field editable, i.e. not read only.
|
39
|
-
def setEditable
|
40
|
-
@editable = "yes"
|
41
|
-
end
|
42
|
-
|
43
|
-
# Set paramter name value to be used to identify this field on submit.
|
44
|
-
def setParameter(parameter)
|
45
|
-
@parameter = parameter
|
46
|
-
end
|
47
|
-
|
48
|
-
# Set prompt to be displayed to let user know what this field is for.
|
49
|
-
def setPrompt(prompt)
|
50
|
-
@prompt = prompt
|
51
|
-
end
|
52
|
-
|
53
|
-
# Set default value to load this field with.
|
54
|
-
def setDefault(default)
|
55
|
-
@default = default
|
56
|
-
end
|
57
|
-
|
58
|
-
# The contents of this will be added when the submit key is pressed while
|
59
|
-
# editing this field.
|
60
|
-
def setSelection(selection)
|
61
|
-
@selection = selection
|
62
|
-
end
|
63
|
-
|
64
|
-
# Adds softkey to be displayed when editing this field.
|
65
|
-
def addSoftkey(index, label, uri, icon=nil)
|
66
|
-
@softkeys += [AastraIPPhoneSoftkeyEntry.new(index, label, uri, icon)]
|
67
|
-
end
|
68
|
-
|
69
|
-
# Create XML text output for this entry.
|
70
|
-
def render
|
71
|
-
xml = "<InputField"
|
72
|
-
xml += " type=\"#{@type}\"" if not @type.nil?
|
73
|
-
xml += " password=\"yes\"" if @password == "yes"
|
74
|
-
xml += " editable=\"yes\"" if @editable == "yes"
|
75
|
-
xml += ">\n"
|
76
|
-
xml += "<Prompt>#{@prompt}</Prompt>\n" if not @prompt.nil?
|
77
|
-
xml += "<Parameter>#{@parameter}</Parameter>\n" if not @parameter.nil?
|
78
|
-
xml += "<Selection>#{@selection}</Selection>\n" if not @selection.nil?
|
79
|
-
xml += "<Default>#{@default}</Default>\n" if not @default.nil?
|
80
|
-
@softkeys.each { |softkey| xml += softkey.render }
|
81
|
-
xml += "</InputField>\n"
|
82
|
-
return xml
|
83
|
-
end
|
84
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Aastra XML API Classes - AastraIPPhoneSoftkeyEntry
|
3
|
-
# Firmware 2.2.0 or better
|
4
|
-
# Copyright Aastra Telecom 2008
|
5
|
-
#
|
6
|
-
# Ruby adaptation by Carlton O'Riley
|
7
|
-
#
|
8
|
-
# Internal class for AastraIPPhone object.
|
9
|
-
################################################################################
|
10
|
-
|
11
|
-
class AastraIPPhoneSoftkeyEntry
|
12
|
-
@index
|
13
|
-
@label
|
14
|
-
@uri
|
15
|
-
@icon
|
16
|
-
|
17
|
-
# Create new softkey entry at index showing on screen with label. When
|
18
|
-
# pressed will call URI. Next to the label text the given icon
|
19
|
-
# will be shown.
|
20
|
-
def initialize(index, label, uri, icon)
|
21
|
-
@index = index
|
22
|
-
@label = label
|
23
|
-
@uri = uri
|
24
|
-
@icon = icon
|
25
|
-
end
|
26
|
-
|
27
|
-
# Create XML text output for this entry.
|
28
|
-
def render
|
29
|
-
xml = "<SoftKey index=\"#{@index}\""
|
30
|
-
xml += " icon=\"#{@icon}\"" if not @icon.nil?
|
31
|
-
xml += ">\n"
|
32
|
-
xml += "<Label>#{@label}</Label>\n"
|
33
|
-
xml += "<URI>#{@uri}</URI>\n"
|
34
|
-
xml += "</SoftKey>\n"
|
35
|
-
return xml
|
36
|
-
end
|
37
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Aastra XML API Classes - AastraIPPhoneStatus
|
3
|
-
# Copyright Aastra Telecom 2008
|
4
|
-
#
|
5
|
-
# Ruby adaptation by Carlton O'Riley
|
6
|
-
#
|
7
|
-
# AastraIPPhoneStatus object.
|
8
|
-
#
|
9
|
-
# Public methods
|
10
|
-
#
|
11
|
-
# Inherited from AastraIPPhone
|
12
|
-
# setBeep to enable a notification beep with the object (optional)
|
13
|
-
#
|
14
|
-
# Specific to the object
|
15
|
-
# setSession(session) to setup the session ID
|
16
|
-
# setTriggerDestroyOnExit to set the triggerDestroyOnExit tag to
|
17
|
-
# "yes" (optional)
|
18
|
-
# addEntry(index,message,type,timeout) to add a message to be displayed
|
19
|
-
# on the idle screen.
|
20
|
-
#
|
21
|
-
# Example
|
22
|
-
# require 'AastraIPPhoneStatus.rb'
|
23
|
-
# status = AastraIPPhoneStatus.new
|
24
|
-
# status.setSession('Session');
|
25
|
-
# status.setBeep
|
26
|
-
# status.addEntry('1', 'Message 1', '', 0)
|
27
|
-
# status.addEntry('2', 'Message 2', 'alert', 5)
|
28
|
-
# aastra_output status
|
29
|
-
#
|
30
|
-
################################################################################
|
31
|
-
|
32
|
-
class AastraIPPhoneStatus < AastraIPPhone
|
33
|
-
@session
|
34
|
-
@triggerDestroyOnExit
|
35
|
-
|
36
|
-
# Sets the session associated with this status message. Only important
|
37
|
-
# if more than one application is sending status messages.
|
38
|
-
def setSession(session)
|
39
|
-
@session = session
|
40
|
-
end
|
41
|
-
|
42
|
-
# When set, the previous user interface XML object is destroyed
|
43
|
-
# if its destroyOnExit tag is also set to yes.
|
44
|
-
def setTriggerDestroyOnExit
|
45
|
-
@triggerDestroyOnExit = "yes"
|
46
|
-
end
|
47
|
-
|
48
|
-
# Adds a new status message to be displayed at index. The type can only
|
49
|
-
# be nothing (default) or alert which shows the message for 3 seconds.
|
50
|
-
# The timeout can override the default 3 seconds for an alert message.
|
51
|
-
def addEntry(index, message, type=nil, timeout=nil)
|
52
|
-
@entries += [AastraIPPhoneStatusEntry.new(index, message, type, timeout)]
|
53
|
-
end
|
54
|
-
|
55
|
-
# Create XML text output.
|
56
|
-
def render
|
57
|
-
xml = "<AastraIPPhoneStatus"
|
58
|
-
xml += " Beep=\"yes\"" if @beep == "yes"
|
59
|
-
xml += " triggerDestroyOnExit=\"yes\"" if @triggerDestroyOnExit == "yes"
|
60
|
-
xml += ">\n"
|
61
|
-
xml += "<Session>#{@session}</Session>\n"
|
62
|
-
@entries.each { |entry| xml += entry.render }
|
63
|
-
xml += "</AastraIPPhoneStatus>\n"
|
64
|
-
return xml
|
65
|
-
end
|
66
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Aastra XML API Classes - AastraIPPhoneStatusEntry
|
3
|
-
# Copyright Aastra Telecom 2008
|
4
|
-
#
|
5
|
-
# Ruby adaptation by Carlton O'Riley
|
6
|
-
#
|
7
|
-
# Internal class for AastraIPPhoneStatus object.
|
8
|
-
################################################################################
|
9
|
-
|
10
|
-
class AastraIPPhoneStatusEntry < AastraIPPhone
|
11
|
-
@index
|
12
|
-
@message
|
13
|
-
@type
|
14
|
-
@timeout
|
15
|
-
|
16
|
-
# Create new status message at index. Type can only be "alert" or left
|
17
|
-
# blank. If the type is anything but blank, it is automatically set
|
18
|
-
# to "alert". The timeout overrides the default 3 seconds for an
|
19
|
-
# alert message.
|
20
|
-
def initialize(index, message, type=nil, timeout=nil)
|
21
|
-
@index = index
|
22
|
-
@message = message
|
23
|
-
setType(type)
|
24
|
-
@timeout = timeout
|
25
|
-
end
|
26
|
-
|
27
|
-
# Set the index of this message.
|
28
|
-
def setIndex(index)
|
29
|
-
@index = index
|
30
|
-
end
|
31
|
-
|
32
|
-
# Set the text of the message.
|
33
|
-
def setMessage(message)
|
34
|
-
@message = message
|
35
|
-
end
|
36
|
-
|
37
|
-
# Set the type of the message. Either "alert" or normal (blank and default)
|
38
|
-
def setType(type)
|
39
|
-
@type = type if type.nil?
|
40
|
-
@type = "alert" if not type.nil?
|
41
|
-
end
|
42
|
-
|
43
|
-
# Set the timeout (in seconds) of an alert message
|
44
|
-
def setTimeout(timeout)
|
45
|
-
@timeout = timeout
|
46
|
-
end
|
47
|
-
|
48
|
-
# Create XML text output of this entry
|
49
|
-
def render
|
50
|
-
xml = "<Message index=\"#{escape(@index)}\""
|
51
|
-
xml += " type=\"#{escape(@type)}\"" if not @type.nil?
|
52
|
-
xml += " Timeout=\"#{@timeout}\"" if not @timeout.nil?
|
53
|
-
xml += ">#{escape(@message)}</Message>\n"
|
54
|
-
return xml
|
55
|
-
end
|
56
|
-
end
|