aastra_xml_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +341 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/aastra_xml_api.gemspec +22 -0
  8. data/lib/aastra_xml_api/AastraIPPhone.rb +203 -0
  9. data/lib/aastra_xml_api/AastraIPPhoneConfiguration.rb +55 -0
  10. data/lib/aastra_xml_api/AastraIPPhoneConfigurationEntry.rb +41 -0
  11. data/lib/aastra_xml_api/AastraIPPhoneDirectory.rb +119 -0
  12. data/lib/aastra_xml_api/AastraIPPhoneDirectoryEntry.rb +32 -0
  13. data/lib/aastra_xml_api/AastraIPPhoneExecute.rb +58 -0
  14. data/lib/aastra_xml_api/AastraIPPhoneExecuteEntry.rb +30 -0
  15. data/lib/aastra_xml_api/AastraIPPhoneFormattedTextScreen.rb +117 -0
  16. data/lib/aastra_xml_api/AastraIPPhoneFormattedTextScreenEntry.rb +48 -0
  17. data/lib/aastra_xml_api/AastraIPPhoneGDImage.rb +185 -0
  18. data/lib/aastra_xml_api/AastraIPPhoneIconEntry.rb +27 -0
  19. data/lib/aastra_xml_api/AastraIPPhoneImageMenu.rb +143 -0
  20. data/lib/aastra_xml_api/AastraIPPhoneImageMenuEntry.rb +25 -0
  21. data/lib/aastra_xml_api/AastraIPPhoneImageScreen.rb +139 -0
  22. data/lib/aastra_xml_api/AastraIPPhoneInputScreen.rb +249 -0
  23. data/lib/aastra_xml_api/AastraIPPhoneInputScreenEntry.rb +84 -0
  24. data/lib/aastra_xml_api/AastraIPPhoneSoftkeyEntry.rb +37 -0
  25. data/lib/aastra_xml_api/AastraIPPhoneStatus.rb +66 -0
  26. data/lib/aastra_xml_api/AastraIPPhoneStatusEntry.rb +56 -0
  27. data/lib/aastra_xml_api/AastraIPPhoneTextMenu.rb +145 -0
  28. data/lib/aastra_xml_api/AastraIPPhoneTextMenuEntry.rb +52 -0
  29. data/lib/aastra_xml_api/AastraIPPhoneTextScreen.rb +93 -0
  30. data/lib/aastra_xml_api/arraynatsort.rb +63 -0
  31. data/lib/aastra_xml_api/version.rb +3 -0
  32. data/lib/aastra_xml_api.rb +9 -0
  33. metadata +89 -0
@@ -0,0 +1,27 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - AastraIPIconEntry
3
+ # Firmware 2.0 or better
4
+ # Copyright Aastra Telecom 8007
5
+ #
6
+ # Ruby adaptation by Carlton O'Riley
7
+ #
8
+ # Internal class for AastraIPPhone object.
9
+ ################################################################################
10
+
11
+ class AastraIPPhoneIconEntry
12
+ @index
13
+ @icon
14
+
15
+ # Create new icon entry available to be referenced as index. The icon
16
+ # can either be a predefined icon (i.e. Icon:PhoneOnHook) or the actual
17
+ # hex data (as a string) of the icon.
18
+ def initialize(index, icon)
19
+ @index = index
20
+ @icon = icon
21
+ end
22
+
23
+ # Create XML text output for this entry.
24
+ def render
25
+ return "<Icon index=\"#{@index}\">#{@icon}</Icon>\n"
26
+ end
27
+ end
@@ -0,0 +1,143 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - AastraIPPhoneImageMenu
3
+ # Copyright Aastra Telecom 2008
4
+ #
5
+ # Ruby adaptation by Carlton O'Riley
6
+ #
7
+ # AastraIPPhoneImageMenu object.
8
+ #
9
+ # Public methods
10
+ #
11
+ # Inherited from AastraIPPhone
12
+ # setCancelAction(uri) to set the cancel parameter with the URI to be called on Cancel (optional)
13
+ # setBeep to enable a notification beep with the object (optional)
14
+ # setTimeout(timeout) to define a specific timeout for the XML object (optional)
15
+ # setLockIn to set the Lock-in tag to 'yes' (optional)
16
+ # addSoftkey(index,label,uri,icon_index) to add custom softkeys to the object (optional)
17
+ # setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
18
+ #
19
+ # Specific to the object
20
+ # setImage(image)to define the image to be displayed
21
+ # setGDImage(GDImage) to use a GDImage for display, the size is forced to 40x144
22
+ # setAlignment(vertical,horizontal) to define image alignment
23
+ # setSize(height,width) to define image size
24
+ # setURIBase(uriBase) to define the base URI for the selections
25
+ # addURI(key,uri) to add a selection key with its URI
26
+ #
27
+ # Example
28
+ # require 'AastraIPPhoneImageMenu.rb'
29
+ # imagem = AastraIPPhoneImageMenu.new
30
+ # imagem.setDestroyOnExit
31
+ # imagem.setSize(40,144)
32
+ # imagem.setImage('fffffffc02fffffffee4ffffbfffc05fffe7ff7a7ffffffffeffeebd7fffffea6bcfffffe796f3feff6fa289f0a86f4866fa20df42414595dd0134f8037ed1637f0e2522b2dd003b6eb936f05fffbd4f4107bba6eb0080e93715000010b754001281271408c640252081b1b22500013c5c66201368004e04467520dc11067152b82094d418e100247205805494780105002601530020131400020a05c91088b002b08c21c0000c200000001fe800000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020041000004008300000ff08500000000c900000000710000000000000001401400000140140000014014000001401400000140140000000000000007c0ff00000c30880000081088000008108800000c30700000062000000000003f000001e02000000330200000021000000003301e000001e0330000000021000003f033000002001e0000020000000000001e000c03fc33003c013021007c02101201f00330ff03f001e000039000003e039001e00103f003300101f8021003007c03303f003c01e000000c00001e001c03f033007802002100f002002103e000001203c401702003cc0290ff039c02902101fc02b000007c03f01a003c020039018c0ff02d03c402102703c400001203ec01e000026402b0000264029000026c029000027c01a0000338000000033800000003100000000300000000030003f00003fc03000003fc02000003fc020000030001f0000300000000030001e000030002b000030002900003fc02900003fc01a00003f00000000310030000031c01e000031f003000033f81e00003f383000001e081e000008c003000003c01e00000fc03000001f000000003d001a0000390039000039002d00003f002700000f8012000007c000000001c0000000004000000000000000000000000000')
33
+ # imagem.addURI('1','http://myserver.com?choice=1')
34
+ # imagem.addURI('2','http://myserver.com?Choice=2')
35
+ # imagem.addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1', '1')
36
+ # imagem.addSoftkey('6', 'Exit', 'SoftKey:Exit')
37
+ # imagem.addIcon('1', 'Icon:Envelope')
38
+ # imagem.addIcon('2', 'FFFF0000FFFF0000')
39
+ # aastra_output imagem
40
+ #
41
+ ################################################################################
42
+
43
+ class AastraIPPhoneImageMenu < AastraIPPhone
44
+ @image
45
+ @verticalAlign
46
+ @horizontalAlign
47
+ @height
48
+ @width
49
+ @uriBase
50
+
51
+ # Sets the image to be displayed. image must be a string of hex.
52
+ def setImage(image)
53
+ @image = image
54
+ end
55
+
56
+ # Sets the alignment of the image. veritcal is one of 'top',
57
+ # 'middle' (default), or 'bottom'. horizontal is one of 'left',
58
+ # 'middle' (default), or 'right'.
59
+ def setAlignment(vertical=nil, horizontal=nil)
60
+ @verticalAlign = vertical
61
+ @horizontalAlign = horizontal
62
+ end
63
+
64
+ # Sets the size of the image to be displayed which must match the
65
+ # actual images height and width.
66
+ def setSize(height, width)
67
+ @height = height
68
+ @width = width
69
+ end
70
+
71
+ # Sets the base URI that is prepended to the URI for a specific key.
72
+ def setURIBase(uriBase)
73
+ @uriBase = uriBase
74
+ end
75
+
76
+ # Adds a URI and key pair that is associated with the given key pressed
77
+ # by the user. The full URI is the one set by setURIBase followed
78
+ # by this uri.
79
+ def addURI(key, uri)
80
+ @entries += [AastraIPPhoneImageMenuEntry.new(key, uri)]
81
+ end
82
+
83
+ # Sets the image based on an externally generated GD image. Image must
84
+ # be 40x144 in size and should be created using AastraIPPhoneGDImage.
85
+ def setGDImage(gdImage)
86
+ img = gdImage.getGDImage
87
+ byte = 0
88
+ i = 0
89
+ imageHexString = ""
90
+ for x in 0..143
91
+ for y in 0..39
92
+ rgb = img.getPixel(x, y)
93
+ byte += 2**(7-(i%8)) if rgb > 0
94
+ if (i%8) == 7 then
95
+ byteHex ="%02x" % byte
96
+ imageHexString += byteHex
97
+ byte = 0
98
+ end
99
+ i += 1
100
+ end
101
+ end
102
+ setImage(imageHexString)
103
+ setSize(40,144)
104
+ end
105
+
106
+ # Create XML text output.
107
+ def render
108
+ title = escape(@title)
109
+ out = "<AastraIPPhoneImageMenu"
110
+ out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
111
+ if not @cancelAction.nil? then
112
+ cancelAction = escape(@cancelAction)
113
+ out += " cancelAction=\"#{cancelAction}\""
114
+ end
115
+ out += " Beep=\"yes\"" if @beep == "yes"
116
+ out += " LockIn=\"yes\"" if @locking == "yes"
117
+ out += " Timeout=\"#{@timeout}\"" if @timeout != 0
118
+ out += ">\n"
119
+ out += "<Image"
120
+ out += " verticalAlign=\"#{@verticalAlign}\"" if not @verticalAlign.nil?
121
+ out += " horizontalAlign=\"#{@horizontalAlign}\"" if not @horizontalAlign.nil?
122
+ out += " height=\"#{@height}\"" if not @height.nil?
123
+ out += " width=\"#{@width}\"" if not @width.nil?
124
+ out += ">#{@image}</Image>\n"
125
+ out += "<URIList"
126
+ out += " base=\"#{escape(@uriBase)}\"" if not @uriBase.nil?
127
+ out += ">\n"
128
+ @entries.each { |entry| out += entry.render }
129
+ out += "</URIList>\n"
130
+ @softkeys.each { |softkey| out += softkey.render }
131
+ iconList = 0
132
+ @icons.each do |icon|
133
+ if iconList == 0
134
+ out += "<IconList>\n"
135
+ iconList = 1
136
+ end
137
+ out += icon.render
138
+ end
139
+ out += "</IconList>\n" if iconList != 0
140
+ out += "</AastraIPPhoneImageMenu>\n"
141
+ return out
142
+ end
143
+ end
@@ -0,0 +1,25 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - AastraIPPhoneImageMenuEntry
3
+ # Firmware 2.0 or better
4
+ # Copyright Aastra Telecom 2008
5
+ #
6
+ # Ruby adaptation by Carlton O'Riley
7
+ #
8
+ # Internal class for AastraIPPhoneImageMenu object.
9
+ ################################################################################
10
+
11
+ class AastraIPPhoneImageMenuEntry < AastraIPPhone
12
+ @key
13
+ @uri
14
+
15
+ # Create a new mapping for a user pressed key and a URI to call.
16
+ def initialize(key, uri)
17
+ @key = key
18
+ @uri = uri
19
+ end
20
+
21
+ # Create XML text output for this entry.
22
+ def render
23
+ return "<URI key=\"#{@key}\">#{escape(@uri)}</URI>\n"
24
+ end
25
+ end
@@ -0,0 +1,139 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - AastraIPPhoneImageScreen
3
+ # Copyright Aastra Telecom 2008
4
+ #
5
+ # Ruby adaptation by Carlton O'Riley
6
+ #
7
+ # AastraIPPhoneImageScreen object.
8
+ #
9
+ # Public methods
10
+ #
11
+ # Inherited from AastraIPPhone
12
+ # setCancelAction(uri) to set the cancel parameter with the URI to be called on Cancel (optional)
13
+ # setBeep to enable a notification beep with the object (optional)
14
+ # setLockIn to set the Lock-in tag to 'yes' (optional)
15
+ # setTimeout(timeout) to define a specific timeout for the XML object (optional)
16
+ # addSoftkey(index,label,uri,icon_index) to add custom softkeys to the object (optional)
17
+ # addIcon(index,icon) to add custom icons to the object (optional)
18
+ # setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
19
+ #
20
+ # Specific to the object
21
+ # setImage(image) to define the image to be displayed
22
+ # setGDImage(GDImage) to use a GDImage for display, the size is forced to 40x144
23
+ # setAlignment(vertical,horizontal) to define image alignment
24
+ # setSize(height,width) to define image size
25
+ # setAllowDTMF to allow DTMF passthrough on the object
26
+ #
27
+ # Example
28
+ #
29
+ # Using a Pixel image
30
+ #
31
+ # require AastraIPPhoneImageScreen.rb'
32
+ # images = AastraIPPhoneImageScreen.new
33
+ # images.setDestroyOnExit
34
+ # images.setSize(40, 40)
35
+ # images.setImage('fffffffc02fffffffee4ffffbfffc05fffe7ff7a7ffffffffeffeebd7fffffea6bcfffffe796f3feff6fa289f0a86f4866fa20df42414595dd0134f8037ed1637f0e2522b2dd003b6eb936f05fffbd4f4107bba6eb0080e93715000010b754001281271408c640252081b1b22500013c5c66201368004e04467520dc11067152b82094d418e100247205805494780105002601530020931400020ac5c91088b0f2b08c21c07d0c2006009fdfe81f80efe0107fe0fb1c3ffff8ffc3fffef8f7febffbfcf87ffbff64')
36
+ # images.addSoftkey('1', 'Mail', 'http://myserver.com/script.php?action=1', '1')
37
+ # images.addSoftkey('6', 'Exit', 'SoftKey:Exit')
38
+ # images.addIcon('1', 'Icon:Envelope')
39
+ # aastra_output images
40
+ #
41
+ # Using a GD image
42
+ #
43
+ # require 'AastraIPPhoneGDImage.class.php'
44
+ # require 'AastraIPPhoneImageScreen.class.php'
45
+ # phoneImageGD = AastraIPPhoneGDImage.new
46
+ # object = AastraIPPhoneImageScreen.new
47
+ # time = Time.now.strftime("%H:%M")
48
+ # phoneImageGD.drawttftext(30, 0, 10, 39, time, 1, 'Ni7seg.ttf');
49
+ # object.setGDImage(phoneImageGD)
50
+ # aastra_output object
51
+ #
52
+ ################################################################################
53
+
54
+ class AastraIPPhoneImageScreen < AastraIPPhone
55
+ @image
56
+ @verticalAlign
57
+ @horizontalAlign
58
+ @height
59
+ @width
60
+ @allowDTMF
61
+
62
+ # Set the image as a string of hex characters.
63
+ def setImage(image)
64
+ @image = image
65
+ end
66
+
67
+ # Set the alignment of the image. vertical is one of 'top',
68
+ # 'middle' (default), or 'bottom'. horizontal is one of 'left',
69
+ # 'middle' (default), or 'right'.
70
+ def setAlignment(vertical=nil, horizontal=nil)
71
+ @verticalAlign = vertical
72
+ @horizontalAlign = horizontal
73
+ end
74
+
75
+ # Sets the size of the image. Must match the actual image size.
76
+ def setSize(height, width)
77
+ @height = height
78
+ @width = width
79
+ end
80
+
81
+ # Sets the image using an externally generated GD image. This should be
82
+ # done with an AastraIPPhoneGDImage.
83
+ def setGDImage(gdImage)
84
+ img = gdImage.getGDImage
85
+ byte = 0
86
+ i = 0
87
+ imageHexString = ""
88
+ for x in 0..143
89
+ for y in 0..39
90
+ rgb = img.getPixel(x, y)
91
+ byte += 2**(7-(i%8)) if rgb > 0
92
+ if (i%8) == 7 then
93
+ byteHex ="%02x" % byte
94
+ imageHexString += byteHex
95
+ byte = 0
96
+ end
97
+ i += 1
98
+ end
99
+ end
100
+ setImage(imageHexString)
101
+ setSize(40,144)
102
+ end
103
+
104
+ # When set, allows the user's pressed keys to be sent as DTMF through
105
+ # the phone when the phone is in an active call.
106
+ def setAllowDTMF
107
+ @allowDTMF = "yes"
108
+ end
109
+
110
+ # Creates XML text output.
111
+ def render
112
+ out = "<AastraIPPhoneImageScreen"
113
+ out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
114
+ out += " cancelAction=\"#{escape(@cancelAction)}\"" if not @cancelAction.nil?
115
+ out += " Beep=\"yes\"" if @beep == "yes"
116
+ out += " LockIn=\"yes\"" if @locking == "yes"
117
+ out += " Timeout=\"#{@timeout}\"" if @timeout != 0
118
+ out += " allowDTMF=\"yes\"" if @allowDTMF == "yes"
119
+ out += ">\n"
120
+ out += "<Image"
121
+ out += " verticalAlign=\"#{@verticalAlign}\"" if not @verticalAlign.nil?
122
+ out += " horizontalAlign=\"#{@horizontalAlign}\"" if not @horizontalAlign.nil?
123
+ out += " height=\"#{@height}\"" if not @height.nil?
124
+ out += " width=\"#{@width}\"" if not @width.nil?
125
+ out += ">#{@image}</Image>\n"
126
+ @softkeys.each { |softkey| out += softkey.render }
127
+ iconList = 0
128
+ @icons.each do |icon|
129
+ if iconList == 0 then
130
+ out += "<IconList>\n"
131
+ iconList = 1
132
+ end
133
+ out += icon.render
134
+ end
135
+ out += "</IconList>\n" if iconList != 0
136
+ out += "</AastraIPPhoneImageScreen>\n"
137
+ return out
138
+ end
139
+ end
@@ -0,0 +1,249 @@
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
@@ -0,0 +1,84 @@
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