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
@@ -1,41 +0,0 @@
1
- ################################################################################
2
- # Aastra XML API Classes - AastraIPPhoneConfigurationEntry
3
- # Firmware 2.0 or better
4
- # Copyright Aastra Telecom 2008
5
- #
6
- # Ruby adaptation by Carlton O'Riley
7
- #
8
- # Internal class for AastraIPPhoneConfiguration object.
9
- ################################################################################
10
- class AastraIPPhoneConfigurationEntry < AastraIPPhone
11
- @parameter
12
- @value
13
-
14
- # Create a new parameter/value pair. This overrides the
15
- # initialize method in AastraIPPhone.
16
- def initialize(parameter, value)
17
- @parameter = parameter
18
- @value = value
19
- end
20
-
21
- # Set the parameter for this entry.
22
- def setParameter(parameter)
23
- @parameter = parameter
24
- end
25
-
26
- # Set the value for this entry.
27
- def setValue(value)
28
- @value = value
29
- end
30
-
31
- # Create XML text output for this entry.
32
- def render
33
- parameter = escape(@parameter)
34
- value = escape(@value)
35
- xml = "<ConfigurationItem>\n"
36
- xml += "<Parameter>#{parameter}</Parameter>\n"
37
- xml += "<Value>#{value}</Value>\n"
38
- xml += "</ConfigurationItem>\n"
39
- return xml
40
- end
41
- end
@@ -1,119 +0,0 @@
1
- ################################################################################
2
- # Aastra XML API Classes - AastraIPPhoneDirectory
3
- # Copyright Aastra Telecom 2008
4
- #
5
- # Ruby adaptation by Carlton O'Riley
6
- #
7
- # AastraIPPhoneDirectory 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
- # 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 'AastraIPPhoneDirectory.rb'
31
- # directory = AastraIPPhoneDirectory.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
- class AastraIPPhoneDirectory < AastraIPPhone
46
- @next
47
- @previous
48
-
49
- # Set the URI to load the next page of the directory.
50
- def setNext(nextval)
51
- @next = nextval
52
- end
53
-
54
- # Set the URI to load the previous page of the directory.
55
- def setPrevious(previous)
56
- @previous = previous
57
- end
58
-
59
- # Add directory entry with a name to be displayed and a telephone
60
- # number to dial.
61
- def addEntry(name, telephone)
62
- @entries += [AastraIPPhoneDirectoryEntry.new(name, telephone)]
63
- end
64
-
65
- # Sort array of names using natural sort order. i.e. Bob2 comes
66
- # before Bob10.
67
- def natsortByName
68
- tmparray = []
69
- linklist = {}
70
- for i in 0..@entries.size-1
71
- tmparray += [@entries[i].getName]
72
- linklist[@entries[i].getName] = i
73
- end
74
- tmparray.natsort!
75
- newentries = []
76
- tmparray.each do |name|
77
- newentries += [@entries[linklist[name]]]
78
- end
79
- @entries = newentries
80
- end
81
-
82
- # Create XML text output.
83
- def render
84
- out = "<AastraIPPhoneDirectory"
85
- if not @previous.nil? then
86
- previous = escape(@previous)
87
- out += " previous=\"#{previous}\""
88
- end
89
- if not @next.nil? then
90
- nextval = escape(@next)
91
- out += " next=\"#{nextval}\""
92
- end
93
- out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
94
- if not @cancelAction.nil? then
95
- cancelAction = escape(@cancelAction)
96
- out += " cancelAction=\"#{cancelAction}\""
97
- end
98
- out += " Beep=\"yes\"" if @beep == "yes"
99
- out += " LockIn=\"yes\"" if @lockin == "yes"
100
- out += " Timeout=\"#{@timeout}\"" if @timeout != 0
101
- out += ">\n"
102
- if not @title.nil? then
103
- title = escape(title)
104
- out += "<Title"
105
- out += " wrap=\"yes\"" if @title_wrap == "yes"
106
- out += ">#{title}</Title>\n"
107
- end
108
- index = 0
109
- @entries.each do |entry|
110
- out += entry.render if index < 30
111
- index += 1
112
- end
113
- @softkeys.each do |softkey|
114
- out += softkey.render
115
- end
116
- out += "</AastraIPPhoneDirectory>\n"
117
- return out
118
- end
119
- end
@@ -1,32 +0,0 @@
1
- ########################################################################################################
2
- # Aastra XML API Classes - AastraIPPhoneDirectoryEntry
3
- # Copyright Aastra Telecom 2008
4
- #
5
- # Ruby adaptation by Carlton O'Riley
6
- #
7
- # Internal class for AastraIPPhoneDirectory object.
8
- ########################################################################################################
9
-
10
- class AastraIPPhoneDirectoryEntry < AastraIPPhone
11
- @name
12
- @telephone
13
-
14
- # Create new name and number entry. Overrides the initialize method
15
- # of AastraIPPhone.
16
- def initialize(name, telephone)
17
- @name = name
18
- @telephone = telephone
19
- end
20
-
21
- # Get the name associated with this entry.
22
- def getName
23
- @name
24
- end
25
-
26
- # Create XML text output for this entry.
27
- def render
28
- name = escape(@name)
29
- telephone = escape(@telephone)
30
- return "<MenuItem>\n<Prompt>#{name}</Prompt>\n<URI>#{telephone}</URI>\n</MenuItem>\n"
31
- end
32
- end
@@ -1,58 +0,0 @@
1
- ################################################################################
2
- # Aastra XML API Classes - AastraIPPhoneExecute
3
- # Copyright Aastra Telecom 2008
4
- #
5
- # Ruby adaptation by Carlton O'Riley
6
- #
7
- # AastraIPPhoneExecute 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
- # setTriggerDestroyOnExit to set the triggerDestroyOnExit tag to "yes" (optional)
16
- # addEntry(url,interruptCall) to add an action to be executed.
17
- #
18
- # Example
19
- # require 'AastraIPPhoneExecute.class.php'
20
- # execute = AastraIPPhoneExecute.new
21
- # execute.addEntry('http://myserver.com/script.php?choice=2')
22
- # execute.addEntry('Command: Reset')
23
- # aastra_output execute
24
- #
25
- ################################################################################
26
-
27
- class AastraIPPhoneExecute < AastraIPPhone
28
- @defaultIndex
29
- @triggerDestroyOnExit
30
-
31
- # Add a url (action to be performed). If interruptCall is not nil, then
32
- # then if a dial action is given, the current call will be put on hold.
33
- # Default behavior is to not allow a current active call to be
34
- # interrupted.
35
- def addEntry(url, interruptCall=nil)
36
- @entries += [AastraIPPhoneExecuteEntry.new(url, interruptCall)]
37
- end
38
-
39
- # When set, the previous user interface XML object is destroyed
40
- # if its destroyOnExit tag is also set to yes.
41
- def setTriggerDestroyOnExit
42
- @triggerDestroyOnExit = "yes"
43
- end
44
-
45
- # Create XML text output.
46
- def render
47
- title = escape(@title)
48
- out = "<AastraIPPhoneExecute"
49
- out += " Beep=\"yes\"" if @beep == "yes"
50
- out += " triggerDestroyOnExit=\"yes\"" if @triggerDestroyOnExit == "yes"
51
- out += ">\n"
52
- @entries.each do |entry|
53
- out += entry.render
54
- end
55
- out += "</AastraIPPhoneExecute>\n"
56
- return out
57
- end
58
- end
@@ -1,30 +0,0 @@
1
- ################################################################################
2
- # Aastra XML API Classes - AastraIPPhoneExecuteEntry
3
- # Firmware 1.4.1 or better
4
- # Copyright Aastra Telecom 2008
5
- #
6
- # Ruby adaptation by Carlton O'Riley
7
- #
8
- # Internal class for AastraIPPhoneExecute object.
9
- ################################################################################
10
-
11
- class AastraIPPhoneExecuteEntry < AastraIPPhone
12
- @url
13
- @interruptCall
14
-
15
- # Create a new action to be performed. if interruptCall is not nil then
16
- # a currently active call can be interrupted by this action.
17
- def initialize(url, interruptCall)
18
- @url = url
19
- @interruptCall = interruptCall
20
- end
21
-
22
- # Create XML text output for this entry.
23
- def render
24
- url = escape(@url)
25
- xml = "<ExecuteItem URI=\"#{url}\""
26
- xml += " interruptCall=\"no\"" if @interruptCall == "no"
27
- xml += "/>\n"
28
- return xml
29
- end
30
- end
@@ -1,117 +0,0 @@
1
- ################################################################################
2
- # Aastra XML API Classes - AastraIPFormattedPhoneTextScreen
3
- # Copyright Aastra Telecom 2008
4
- #
5
- # AastraIPPhoneFormattedTextScreen object.
6
- #
7
- # Public methods
8
- #
9
- # Inherited from AastraIPPhone
10
- # setDestroyOnExit to set DestroyonExit parameter to 'yes', 'no' by default (optional)
11
- # setCancelAction(uri) to set the cancel parameter with the URI to be called on Cancel (optional)
12
- # setBeep to enable a notification beep with the object (optional)
13
- # setLockIn to set the Lock-in tag to 'yes' (optional)
14
- # setAllowAnswer to set the allowAnswer tag to 'yes' (optional)
15
- # setTimeout(timeout) to define a specific timeout for the XML object (optional)
16
- # addSoftkey(index, label, uri) 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
- # addLine(text,size,align) to add a formatted line
22
- # setScrollStart(height) to define the beginning of the scrolling section and its height
23
- # setScrollEnd to define the end of the scrolling section
24
- # setAllowDTMF to allow DTMF passthrough on the object
25
- # setDoneAction(uri) to set the URI to be called when the user selects the default "Done" key (optional)
26
- #
27
- # Example
28
- # require 'AastraIPPhoneFormattedTextScreen.rb'
29
- # ftext = AastraIPPhoneFormattedTextScreen.new
30
- # ftext.setDestroyOnExit
31
- # ftext.addLine('Formatted Screen', 'double', 'center')
32
- # ftext.setScrollStart('2')
33
- # ftext.addLine('Scrolled text1')
34
- # ftext.addLine('Scrolled text2')
35
- # ftext.addLine('Scrolled text3')
36
- # ftext.addLine('Scrolled text4')
37
- # ftext.addLine('Scrolled text5')
38
- # ftext.setScrollEnd
39
- # ftext.addLine('Footer',NULL,'center')
40
- # ftext.addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1','1')
41
- # ftext.addSoftkey('6', 'Exit', 'SoftKey:Exit')
42
- # ftext.addIcon('1', 'Icon:Envelope')
43
- # aastra_output ftext
44
- #
45
- ################################################################################
46
-
47
- class AastraIPPhoneFormattedTextScreen < AastraIPPhone
48
- @doneAction
49
- @allowDTMF
50
-
51
- # Add a line of formatted text. size can only be 'normal' (default)
52
- # or 'double'. align can be one of 'left' (default), 'center',
53
- # or 'right'.
54
- def addLine(text, size=nil, align=nil)
55
- @entries += [AastraIPPhoneFormattedTextScreenEntry.new(text, size, align, 'normal')]
56
- end
57
-
58
- # Starts the beginning of a scrolling section on the display. If height
59
- # is not given, then all available space is used to display the scrolling
60
- # section. Otherwise, height cannot be bigger than 2.
61
- def setScrollStart(height=nil)
62
- @entries += [AastraIPPhoneFormattedTextScreenEntry.new(nil, height, nil, 'scrollstart')]
63
- end
64
-
65
- # Sets the end of a scrolling section on the display.
66
- def setScrollEnd
67
- @entries += [AastraIPPhoneFormattedTextScreenEntry.new(nil, nil, nil, 'scrollend')]
68
- end
69
-
70
- # Defines URI to call when the user selects the 'Done' softkey.
71
- def setDoneAction(uri)
72
- @doneAction = uri
73
- end
74
-
75
- # Allows keypad strokes to generate DTMF when a call is in progress
76
- # while this object is displayed.
77
- def setAllowDTMF
78
- @allowDTMF = "yes"
79
- end
80
-
81
- # Create XML text output.
82
- def render
83
- out = "<AastraIPPhoneFormattedTextScreen"
84
- out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
85
- if not @cancelAction.nil? then
86
- cancelAction = escape(@cancelAction)
87
- out += " cancelAction=\"#{cancelAction}\""
88
- end
89
- if not @doneAction.nil? then
90
- doneAction = escape(@doneAction)
91
- out += " doneAction=\"#{doneAction}\""
92
- end
93
- out += " Beep=\"yes\"" if @beep == "yes"
94
- out += " LockIn=\"yes\"" if @lockin == "yes"
95
- out += " allowAnswer=\"yes\"" if @allowAnswer == "yes"
96
- out += " Timeout=\"#{@timeout}\"" if @timeout != 0
97
- out += " allowDTMF=\"#{yes}\"" if @allowDTMF == "yes"
98
- out += ">\n"
99
- @entries.each do |entry|
100
- out += entry.render
101
- end
102
- @softkeys.each do |softkey|
103
- out += softkey.render
104
- end
105
- iconList = 0
106
- @icons.each do |icon|
107
- if iconList == 0 then
108
- out += "<IconList>\n"
109
- iconList = 1
110
- end
111
- out += icon.render
112
- end
113
- out += "</IconList>\n" if iconList != 0
114
- out += "</AastraIPPhoneFormattedTextScreen>\n"
115
- return out
116
- end
117
- end
@@ -1,48 +0,0 @@
1
- ################################################################################
2
- # Aastra XML API Classes - AastraIPPhoneFormattedTextScreenEntry
3
- # Firmware 2.0 or better
4
- # Copyright Aastra Telecom 2008
5
- #
6
- # Ruby adaptation by Carlton O'Riley
7
- #
8
- # Internal class for AastraIPPhoneFormattedTextScreen object.
9
- ################################################################################
10
-
11
- class AastraIPPhoneFormattedTextScreenEntry < AastraIPPhone
12
- @text
13
- @size
14
- @align
15
- @type
16
-
17
- # Creates new formatted text entry. size is one of 'normal' (default)
18
- # or 'double'. align is one of 'left' (default), 'center', or 'right'.
19
- # type must be one of 'normal', 'scrollstart', or 'scrollend'.
20
- def initialize(text, size, align, type)
21
- if size == 'double' then
22
- @text = convert_high_ascii(text)
23
- else
24
- @text = text
25
- end
26
- @size = size
27
- @align = align
28
- @type = type
29
- end
30
-
31
- # Create XML text output for this entry.
32
- def render
33
- case @type
34
- when "normal"
35
- xml = "<Line"
36
- xml += " Size=\"#{@size}\"" if not @size.nil?
37
- xml += " Align=\"#{@align}\"" if not @align.nil?
38
- xml += ">"
39
- xml += "#{escape(@text)}</Line>\n"
40
- when "scrollstart"
41
- xml = "<Scroll"
42
- xml += " Height=\"#{@size}\"" if not @size.nil?
43
- xml += ">\n"
44
- when "scrollend" then xml = "</Scroll>\n"
45
- end
46
- return xml
47
- end
48
- end