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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/README.md +10 -2
  4. data/aastra_xml_api.gemspec +1 -1
  5. data/lib/aastra_xml_api.rb +1 -1
  6. data/lib/aastra_xml_api/array_extensions.rb +61 -0
  7. data/lib/aastra_xml_api/phone.rb +205 -0
  8. data/lib/aastra_xml_api/phone_configuration.rb +56 -0
  9. data/lib/aastra_xml_api/phone_configuration_entry.rb +43 -0
  10. data/lib/aastra_xml_api/phone_directory.rb +122 -0
  11. data/lib/aastra_xml_api/phone_directory_entry.rb +34 -0
  12. data/lib/aastra_xml_api/phone_execute.rb +60 -0
  13. data/lib/aastra_xml_api/phone_execute_entry.rb +32 -0
  14. data/lib/aastra_xml_api/phone_formatted_text_screen.rb +119 -0
  15. data/lib/aastra_xml_api/phone_formatted_text_screen_entry.rb +50 -0
  16. data/lib/aastra_xml_api/phone_gd_image.rb +187 -0
  17. data/lib/aastra_xml_api/phone_icon_entry.rb +29 -0
  18. data/lib/aastra_xml_api/phone_image_menu.rb +145 -0
  19. data/lib/aastra_xml_api/phone_image_menu_entry.rb +27 -0
  20. data/lib/aastra_xml_api/phone_image_screen.rb +141 -0
  21. data/lib/aastra_xml_api/phone_input_screen.rb +251 -0
  22. data/lib/aastra_xml_api/phone_input_screen_entry.rb +86 -0
  23. data/lib/aastra_xml_api/phone_softkey_entry.rb +39 -0
  24. data/lib/aastra_xml_api/phone_status.rb +68 -0
  25. data/lib/aastra_xml_api/phone_status_entry.rb +58 -0
  26. data/lib/aastra_xml_api/phone_text_menu.rb +148 -0
  27. data/lib/aastra_xml_api/phone_text_menu_entry.rb +54 -0
  28. data/lib/aastra_xml_api/phone_text_screen.rb +95 -0
  29. data/lib/aastra_xml_api/version.rb +1 -1
  30. metadata +28 -27
  31. data/lib/aastra_xml_api/AastraIPPhone.rb +0 -203
  32. data/lib/aastra_xml_api/AastraIPPhoneConfiguration.rb +0 -55
  33. data/lib/aastra_xml_api/AastraIPPhoneConfigurationEntry.rb +0 -41
  34. data/lib/aastra_xml_api/AastraIPPhoneDirectory.rb +0 -119
  35. data/lib/aastra_xml_api/AastraIPPhoneDirectoryEntry.rb +0 -32
  36. data/lib/aastra_xml_api/AastraIPPhoneExecute.rb +0 -58
  37. data/lib/aastra_xml_api/AastraIPPhoneExecuteEntry.rb +0 -30
  38. data/lib/aastra_xml_api/AastraIPPhoneFormattedTextScreen.rb +0 -117
  39. data/lib/aastra_xml_api/AastraIPPhoneFormattedTextScreenEntry.rb +0 -48
  40. data/lib/aastra_xml_api/AastraIPPhoneGDImage.rb +0 -185
  41. data/lib/aastra_xml_api/AastraIPPhoneIconEntry.rb +0 -27
  42. data/lib/aastra_xml_api/AastraIPPhoneImageMenu.rb +0 -143
  43. data/lib/aastra_xml_api/AastraIPPhoneImageMenuEntry.rb +0 -25
  44. data/lib/aastra_xml_api/AastraIPPhoneImageScreen.rb +0 -139
  45. data/lib/aastra_xml_api/AastraIPPhoneInputScreen.rb +0 -249
  46. data/lib/aastra_xml_api/AastraIPPhoneInputScreenEntry.rb +0 -84
  47. data/lib/aastra_xml_api/AastraIPPhoneSoftkeyEntry.rb +0 -37
  48. data/lib/aastra_xml_api/AastraIPPhoneStatus.rb +0 -66
  49. data/lib/aastra_xml_api/AastraIPPhoneStatusEntry.rb +0 -56
  50. data/lib/aastra_xml_api/AastraIPPhoneTextMenu.rb +0 -145
  51. data/lib/aastra_xml_api/AastraIPPhoneTextMenuEntry.rb +0 -52
  52. data/lib/aastra_xml_api/AastraIPPhoneTextScreen.rb +0 -93
  53. data/lib/aastra_xml_api/arraynatsort.rb +0 -63
@@ -0,0 +1,29 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - IconEntry
3
+ # Firmware 2.0 or better
4
+ # Copyright Aastra Telecom 8007
5
+ #
6
+ # Ruby adaptation by Carlton O'Riley
7
+ #
8
+ # Internal class for Phone object.
9
+ ################################################################################
10
+
11
+ module AastraXmlApi
12
+ class PhoneIconEntry
13
+ @index
14
+ @icon
15
+
16
+ # Create new icon entry available to be referenced as index. The icon
17
+ # can either be a predefined icon (i.e. Icon:PhoneOnHook) or the actual
18
+ # hex data (as a string) of the icon.
19
+ def initialize(index, icon)
20
+ @index = index
21
+ @icon = icon
22
+ end
23
+
24
+ # Create XML text output for this entry.
25
+ def render
26
+ return "<Icon index=\"#{@index}\">#{@icon}</Icon>\n"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,145 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneImageMenu
3
+ # Copyright Aastra Telecom 2008
4
+ #
5
+ # Ruby adaptation by Carlton O'Riley
6
+ #
7
+ # PhoneImageMenu object.
8
+ #
9
+ # Public methods
10
+ #
11
+ # Inherited from Phone
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 'PhoneImageMenu.rb'
29
+ # imagem = PhoneImageMenu.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
+ module AastraXmlApi
44
+ class PhoneImageMenu < Phone
45
+ @image
46
+ @verticalAlign
47
+ @horizontalAlign
48
+ @height
49
+ @width
50
+ @uriBase
51
+
52
+ # Sets the image to be displayed. image must be a string of hex.
53
+ def setImage(image)
54
+ @image = image
55
+ end
56
+
57
+ # Sets the alignment of the image. veritcal is one of 'top',
58
+ # 'middle' (default), or 'bottom'. horizontal is one of 'left',
59
+ # 'middle' (default), or 'right'.
60
+ def setAlignment(vertical=nil, horizontal=nil)
61
+ @verticalAlign = vertical
62
+ @horizontalAlign = horizontal
63
+ end
64
+
65
+ # Sets the size of the image to be displayed which must match the
66
+ # actual images height and width.
67
+ def setSize(height, width)
68
+ @height = height
69
+ @width = width
70
+ end
71
+
72
+ # Sets the base URI that is prepended to the URI for a specific key.
73
+ def setURIBase(uriBase)
74
+ @uriBase = uriBase
75
+ end
76
+
77
+ # Adds a URI and key pair that is associated with the given key pressed
78
+ # by the user. The full URI is the one set by setURIBase followed
79
+ # by this uri.
80
+ def addURI(key, uri)
81
+ @entries += [PhoneImageMenuEntry.new(key, uri)]
82
+ end
83
+
84
+ # Sets the image based on an externally generated GD image. Image must
85
+ # be 40x144 in size and should be created using PhoneGDImage.
86
+ def setGDImage(gdImage)
87
+ img = gdImage.getGDImage
88
+ byte = 0
89
+ i = 0
90
+ imageHexString = ""
91
+ for x in 0..143
92
+ for y in 0..39
93
+ rgb = img.getPixel(x, y)
94
+ byte += 2**(7-(i%8)) if rgb > 0
95
+ if (i%8) == 7 then
96
+ byteHex ="%02x" % byte
97
+ imageHexString += byteHex
98
+ byte = 0
99
+ end
100
+ i += 1
101
+ end
102
+ end
103
+ setImage(imageHexString)
104
+ setSize(40,144)
105
+ end
106
+
107
+ # Create XML text output.
108
+ def render
109
+ title = escape(@title)
110
+ out = "<PhoneImageMenu"
111
+ out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
112
+ if not @cancelAction.nil? then
113
+ cancelAction = escape(@cancelAction)
114
+ out += " cancelAction=\"#{cancelAction}\""
115
+ end
116
+ out += " Beep=\"yes\"" if @beep == "yes"
117
+ out += " LockIn=\"yes\"" if @locking == "yes"
118
+ out += " Timeout=\"#{@timeout}\"" if @timeout != 0
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
+ out += "<URIList"
127
+ out += " base=\"#{escape(@uriBase)}\"" if not @uriBase.nil?
128
+ out += ">\n"
129
+ @entries.each { |entry| out += entry.render }
130
+ out += "</URIList>\n"
131
+ @softkeys.each { |softkey| out += softkey.render }
132
+ iconList = 0
133
+ @icons.each do |icon|
134
+ if iconList == 0
135
+ out += "<IconList>\n"
136
+ iconList = 1
137
+ end
138
+ out += icon.render
139
+ end
140
+ out += "</IconList>\n" if iconList != 0
141
+ out += "</PhoneImageMenu>\n"
142
+ return out
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,27 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneImageMenuEntry
3
+ # Firmware 2.0 or better
4
+ # Copyright Aastra Telecom 2008
5
+ #
6
+ # Ruby adaptation by Carlton O'Riley
7
+ #
8
+ # Internal class for PhoneImageMenu object.
9
+ ################################################################################
10
+
11
+ module AastraXmlApi
12
+ class PhoneImageMenuEntry < Phone
13
+ @key
14
+ @uri
15
+
16
+ # Create a new mapping for a user pressed key and a URI to call.
17
+ def initialize(key, uri)
18
+ @key = key
19
+ @uri = uri
20
+ end
21
+
22
+ # Create XML text output for this entry.
23
+ def render
24
+ return "<URI key=\"#{@key}\">#{escape(@uri)}</URI>\n"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,141 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneImageScreen
3
+ # Copyright Aastra Telecom 2008
4
+ #
5
+ # Ruby adaptation by Carlton O'Riley
6
+ #
7
+ # PhoneImageScreen object.
8
+ #
9
+ # Public methods
10
+ #
11
+ # Inherited from Phone
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 PhoneImageScreen.rb'
32
+ # images = PhoneImageScreen.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 'PhoneGDImage.class.php'
44
+ # require 'PhoneImageScreen.class.php'
45
+ # phoneImageGD = PhoneGDImage.new
46
+ # object = PhoneImageScreen.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
+ module AastraXmlApi
55
+ class PhoneImageScreen < Phone
56
+ @image
57
+ @verticalAlign
58
+ @horizontalAlign
59
+ @height
60
+ @width
61
+ @allowDTMF
62
+
63
+ # Set the image as a string of hex characters.
64
+ def setImage(image)
65
+ @image = image
66
+ end
67
+
68
+ # Set the alignment of the image. vertical is one of 'top',
69
+ # 'middle' (default), or 'bottom'. horizontal is one of 'left',
70
+ # 'middle' (default), or 'right'.
71
+ def setAlignment(vertical=nil, horizontal=nil)
72
+ @verticalAlign = vertical
73
+ @horizontalAlign = horizontal
74
+ end
75
+
76
+ # Sets the size of the image. Must match the actual image size.
77
+ def setSize(height, width)
78
+ @height = height
79
+ @width = width
80
+ end
81
+
82
+ # Sets the image using an externally generated GD image. This should be
83
+ # done with an PhoneGDImage.
84
+ def setGDImage(gdImage)
85
+ img = gdImage.getGDImage
86
+ byte = 0
87
+ i = 0
88
+ imageHexString = ""
89
+ for x in 0..143
90
+ for y in 0..39
91
+ rgb = img.getPixel(x, y)
92
+ byte += 2**(7-(i%8)) if rgb > 0
93
+ if (i%8) == 7 then
94
+ byteHex ="%02x" % byte
95
+ imageHexString += byteHex
96
+ byte = 0
97
+ end
98
+ i += 1
99
+ end
100
+ end
101
+ setImage(imageHexString)
102
+ setSize(40,144)
103
+ end
104
+
105
+ # When set, allows the user's pressed keys to be sent as DTMF through
106
+ # the phone when the phone is in an active call.
107
+ def setAllowDTMF
108
+ @allowDTMF = "yes"
109
+ end
110
+
111
+ # Creates XML text output.
112
+ def render
113
+ out = "<PhoneImageScreen"
114
+ out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
115
+ out += " cancelAction=\"#{escape(@cancelAction)}\"" if not @cancelAction.nil?
116
+ out += " Beep=\"yes\"" if @beep == "yes"
117
+ out += " LockIn=\"yes\"" if @locking == "yes"
118
+ out += " Timeout=\"#{@timeout}\"" if @timeout != 0
119
+ out += " allowDTMF=\"yes\"" if @allowDTMF == "yes"
120
+ out += ">\n"
121
+ out += "<Image"
122
+ out += " verticalAlign=\"#{@verticalAlign}\"" if not @verticalAlign.nil?
123
+ out += " horizontalAlign=\"#{@horizontalAlign}\"" if not @horizontalAlign.nil?
124
+ out += " height=\"#{@height}\"" if not @height.nil?
125
+ out += " width=\"#{@width}\"" if not @width.nil?
126
+ out += ">#{@image}</Image>\n"
127
+ @softkeys.each { |softkey| out += softkey.render }
128
+ iconList = 0
129
+ @icons.each do |icon|
130
+ if iconList == 0 then
131
+ out += "<IconList>\n"
132
+ iconList = 1
133
+ end
134
+ out += icon.render
135
+ end
136
+ out += "</IconList>\n" if iconList != 0
137
+ out += "</PhoneImageScreen>\n"
138
+ return out
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,251 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneInputScreen
3
+ # Copyright Aastra Telecom 2008
4
+ #
5
+ # Ruby adaptation by Carlton O'Riley
6
+ #
7
+ # PhoneInputScreen 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
+ # 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 'PhoneInputScreen.rb'
57
+ # input = PhoneInputScreen.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 'PhoneInputScreen.rb'
70
+ # input = PhoneInputScreen.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
+ module AastraXmlApi
89
+ class PhoneInputScreen < Phone
90
+ @url
91
+ @type
92
+ @parameter
93
+ @prompt
94
+ @editable
95
+ @default
96
+ @password
97
+ @defaultindex
98
+ @displaymode
99
+ @inputlanguage
100
+
101
+ # Set URL to be called (html post) when the input is submitted.
102
+ def setURL(url)
103
+ @url = url
104
+ end
105
+
106
+ # Sets the type of all fields (see addField for values) unless overriden
107
+ # by setFieldType.
108
+ def setType(type)
109
+ @type = type
110
+ end
111
+
112
+ # Sets all fields are editable. Kept only for compatibility.
113
+ def setEditable
114
+ @editable = "yes"
115
+ end
116
+
117
+ # Sets all fields as read only if not overriden by setFieldEditable.
118
+ def setNotEditable
119
+ @editable = "no"
120
+ end
121
+
122
+ # Set default value for all fields if not overriden by setFieldDefault.
123
+ def setDefault(default)
124
+ @default = default
125
+ end
126
+
127
+ # Set parameter name for all fields if not overriden by setFieldParameter.
128
+ def setParameter(parameter)
129
+ @parameter = parameter
130
+ end
131
+
132
+ # Set password input for all fields, masked by "*" characters if not
133
+ # overriden by setFieldPassword.
134
+ def setPassword
135
+ @password = "yes"
136
+ end
137
+
138
+ # Prompt for all input fields, if not overriden by setFieldPrompt.
139
+ def setPrompt(prompt)
140
+ @prompt = prompt
141
+ end
142
+
143
+ # Defines which field 1 (default) through 6 the user will start input on.
144
+ def setDefaultIndex(index)
145
+ @defaultindex = index
146
+ end
147
+
148
+ # Can be one of normal (default) or condensed.
149
+ def setDisplayMode(display)
150
+ @displaymode = display
151
+ end
152
+
153
+ # Defines the language character set used for input.
154
+ def setInputLanguage(input)
155
+ @inputlanguage = input
156
+ end
157
+
158
+ # Add a new field to get input for. The type can be one of IP,
159
+ # string (default), number, timeUS, timeInt, dateUS, or dateInt.
160
+ def addField(type=nil)
161
+ @entries += [PhoneInputScreenEntry.new(type)]
162
+ end
163
+
164
+ # Sets the type (see addField for values) of the most recently added
165
+ # field.
166
+ def setFieldType(type)
167
+ @entries[@entries.size-1].setType(type)
168
+ end
169
+
170
+ # Set the most recently added field as a password field and mask input
171
+ # by "*" characters.
172
+ def setFieldPassword
173
+ @entries[@entries.size-1].setPassword
174
+ end
175
+
176
+ # Set the most recently added field as editable. This is the default.
177
+ def setFieldEditable
178
+ @entries[@entries.size-1].setEditable
179
+ end
180
+
181
+ # Set the most recently added field's parameter name in the form post
182
+ # when submitted.
183
+ def setFieldParameter(parameter)
184
+ @entries[@entries.size-1].setParameter(parameter)
185
+ end
186
+
187
+ # Set the most recently added field's prompt text.
188
+ def setFieldPrompt(prompt)
189
+ @entries[@entries.size-1].setPrompt(prompt)
190
+ end
191
+
192
+ # Set the most recently added field's default value.This is what is
193
+ # displayed when first shown.
194
+ def setFieldDefault(default)
195
+ @entries[@entries.size-1].setDefault(default)
196
+ end
197
+
198
+ # Sets the most recently added field's selection tag which is added
199
+ # to the request when the submit button is pressed while editing this
200
+ # field.
201
+ def setFieldSelection(selection)
202
+ @entries[@entries.size-1].setSelection(selection)
203
+ end
204
+
205
+ # Adds a softkey to be displayed when the most recently added field
206
+ # is highlighted.
207
+ def addFieldSoftkey(index, label, uri, icon=nil)
208
+ @entries[@entries.size-1].addSoftkey(index, label, uri, icon)
209
+ end
210
+
211
+ # Create XML text output.
212
+ def render
213
+ @type = 'string' if @type.nil?
214
+ xml = "<PhoneInputScreen type=\"#{@type}\""
215
+ xml += " password=\"yes\"" if @password == "yes"
216
+ xml += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
217
+ xml += " cancelAction=\"#{escape(@cancelAction)}\"" if not @cancelAction.nil?
218
+ xml += " editable=\"no\"" if @editable == "no"
219
+ xml += " Beep=\"yes\"" if @beep == "yes"
220
+ xml += " defaultIndex=\"#{@defaultindex}\"" if not @defaultindex.nil?
221
+ xml += " inputLanguage=\"#{@inputlanguage}\"" if not @inputlanguage.nil?
222
+ xml += " displayMode=\"#{@displaymode}\"" if not @displaymode.nil?
223
+ xml += " LockIn=\"yes\"" if @lockin == "yes"
224
+ xml += " allowAnswer=\"yes\"" if @allowAnswer == "yes"
225
+ xml += " Timeout=\"#{@timeout}\"" if @timeout != 0
226
+ xml += ">\n"
227
+ if not @title.nil? then
228
+ xml += "<Title"
229
+ out += " wrap=\"yes\"" if @title_wrap == "yes"
230
+ xml += ">#{escape(@title)}</Title>\n"
231
+ end
232
+ xml += "<Prompt>#{escape(@prompt)}</Prompt>\n" if not @prompt.nil?
233
+ xml += "<URL>#{escape(@url)}</URL>\n"
234
+ xml += "<Parameter>#{@parameter}</Parameter>\n" if not @parameter.nil?
235
+ xml += "<Default>#{@default}</Default>\n"
236
+ @entries.each { |entry| xml += entry.render }
237
+ @softkeys.each { |softkey| xml += softkey.render }
238
+ iconList = 0
239
+ @icons.each do |icon|
240
+ if iconList == 0 then
241
+ xml += "<IconList>\n"
242
+ iconList = 1
243
+ end
244
+ xml += icon.render
245
+ end
246
+ xml += "</IconList>\n" if iconList != 0
247
+ xml += "</PhoneInputScreen>\n"
248
+ return xml
249
+ end
250
+ end
251
+ end