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,145 +0,0 @@
1
- ################################################################################
2
- # Aastra XML API Classes - AastraIPPhoneTextMenu
3
- # Copyright Aastra Telecom 2008
4
- #
5
- # AastraIPPhoneTextMenu object.
6
- #
7
- # Public methods
8
- #
9
- # Inherited from AastraIPPhone
10
- # setTitle(Title) to setup the title of an object (optional)
11
- # setTitleWrap to set the title to be wrapped on 2 lines (optional)
12
- # setDestroyOnExit to set DestroyOnExit parameter to "yes" (optional)
13
- # setCancelAction(uri) to set the cancel parameter with the URI to be called on Cancel (optional)
14
- # setBeep to enable a notification beep with the object (optional)
15
- # setLockIn to set the Lock-in tag to 'yes' (optional)
16
- # setAllowAnswer to set the allowAnswer tag to 'yes' (optional)
17
- # setTimeout(timeout) to define a specific timeout for the XML object (optional)
18
- # addSoftkey(index,label,uri,icon_index) to add custom softkeys to the object (optional)
19
- # addIcon(index,icon) to add custom icons to the object (optional)
20
- # setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
21
- #
22
- # Specific to the object
23
- # setDefaultIndex(index) to set the default selection in the list (optional)
24
- # setStyle(style) to set the style of the list numbered/none/radio (optional)
25
- # setWrapList to allow 2 lines items (optional)
26
- # addEntry(name,url,selection,icon,dial) to add an element in the list to be displayed
27
- # natsortbyname to order the list
28
- #
29
- # Example 1
30
- # require 'AastraIPPhoneTextMenu.rb'
31
- # menu = AastraIPPhoneTextMenu.new
32
- # menu.setTitle('Title')
33
- # menu.setDestroyOnExit
34
- # menu.setDeFaultIndex('3')
35
- # menu.addEntry('Choice 2', 'http://myserver.com/script.php?choice=2', 'Value=2')
36
- # menu.addEntry('Choice 1', 'http://myserver.com/script.php?choice=1', 'Value=1')
37
- # menu.addEntry('Choice 3', 'http://myserver.com/script.php?choice=3', 'Value=3')
38
- # menu.natsortByName
39
- # menu.addSoftkey('1', 'My Select', 'http://myserver.com/script.php?action=1')
40
- # menu.addSoftkey('6', 'Exit', 'SoftKey:Exit')
41
- # aastra_output menu
42
- #
43
- # Example 2
44
- # require 'AastraIPPhoneTextMenu.rb'
45
- # menu = AastraIPPhoneTextMenu.new
46
- # menu.setTitle('Title')
47
- # menu.setDestroyOnExit
48
- # menu.setDeFaultIndex('2')
49
- # menu.addEntry('Choice 2', 'http://myserver.com/script.php?choice=2', 'Value=2','1')
50
- # menu.addEntry('Choice 1', 'http://myserver.com/script.php?choice=1', 'Value=1','2')
51
- # menu.addEntry('Choice 3', 'http://myserver.com/script.php?choice=3', 'Value=3','3')
52
- # menu.natsortByName
53
- # menu.addSoftkey('1', 'My Select', 'http://myserver.com/script.php?action=1')
54
- # menu.addSoftkey('6', 'Exit', 'SoftKey:Exit')
55
- # menu.addIcon('1', 'Icon:PhoneOnHook')
56
- # menu.addIcon('2', 'Icon:PhoneOffHook')
57
- # menu.addIcon('3', 'Icon:PhoneRinging')
58
- # aastra_output menu
59
- #
60
- ################################################################################
61
-
62
- class AastraIPPhoneTextMenu < AastraIPPhone
63
- @defaultIndex
64
- @style
65
- @wraplist
66
- @maxitems
67
-
68
- # Sets the default index to highlight when first shown.
69
- def setDefaultIndex(defaultIndex)
70
- @defaultIndex = defaultIndex
71
- end
72
-
73
- # Set the style to one of numbered (default), none, or radio.
74
- def setStyle(style)
75
- @style = style
76
- end
77
-
78
- # Add a menu entry with name displayed and calls url when selected. The
79
- # selection option is the value appended to a custom softkey URL when
80
- # this item is highlighted. icon is a reference to an included icon
81
- # that is shown with the menu entry. dial is what is called when
82
- # the user hits a softkey with the URI "SoftKey:Dial2".
83
- def addEntry(name, url, selection=nil, icon=nil, dial=nil)
84
- @entries += [AastraIPPhoneTextMenuEntry.new(name, url, selection, icon, dial)]
85
- end
86
-
87
- # Allows entries in the list to wrap.
88
- def setWrapList
89
- @wraplist = "yes"
90
- end
91
-
92
- # Use natural order sorting to sort the menu by name.
93
- def natsortByName
94
- tmparray = []
95
- linklist = {}
96
- for i in 0..@entries.size-1
97
- tmparray += [@entries[i].getName]
98
- linklist[@entries[i].getName] = i
99
- end
100
- tmparray.natsort!
101
- newentries = []
102
- tmparray.each do |name|
103
- newentries += [@entries[linklist[name]]]
104
- end
105
- @entries = newentries
106
- end
107
-
108
- # Create XML text output.
109
- def render
110
- @maxitems = 30 if @maxitems.nil?
111
- xml = "<AastraIPPhoneTextMenu"
112
- xml += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
113
- xml += " cancelAction=\"#{escape(@cancelAction)}\"" if not @cancelAction.nil?
114
- xml += " defaultIndex=\"#{@defaultIndex}\"" if not @defaultIndex.nil?
115
- xml += " style=\"#{@style}\"" if not @style.nil?
116
- xml += " Beep=\"yes\"" if @beep == "yes"
117
- xml += " LockIn=\"yes\"" if @lockin == "yes"
118
- xml += " wrapList=\"yes\"" if @wraplist == "yes"
119
- xml += " allowAnswer=\"yes\"" if @allowAnswer == "yes"
120
- xml += " Timeout=\"#{@timeout}\"" if @timeout != 0
121
- xml += ">\n"
122
- if not @title.nil? then
123
- xml += "<Title"
124
- xml += " wrap=\"yes\"" if @title_wrap == "yes"
125
- xml += ">#{escape(@title)}</Title>\n"
126
- end
127
- index = 0
128
- @entries.each do |entry|
129
- xml += entry.render if index < @maxitems
130
- index += 1
131
- end
132
- @softkeys.each { |softkey| xml += softkey.render }
133
- iconList = 0
134
- @icons.each do |icon|
135
- if iconList == 0 then
136
- xml += "<IconList>\n"
137
- iconList = 1
138
- end
139
- xml += icon.render
140
- end
141
- xml += "</IconList>\n" if iconList != 0
142
- xml += "</AastraIPPhoneTextMenu>\n"
143
- return xml
144
- end
145
- end
@@ -1,52 +0,0 @@
1
- ################################################################################
2
- # Aastra XML API Classes - AastraIPPhoneTextMenuEntry
3
- # Copyright Aastra Telecom 2008
4
- #
5
- # Ruby adaptation by Carlton O'Riley
6
- #
7
- # Internal class for AastraIPPhoneTextMenu object.
8
- ################################################################################
9
-
10
- class AastraIPPhoneTextMenuEntry < AastraIPPhone
11
- @name
12
- @url
13
- @selection
14
- @icon
15
- @dial
16
-
17
- # Create new text menu entry with given name to be displayed, url to be
18
- # called when selected. Selection is the value appended to a custom URI
19
- # attached to a softkey. This will be added as either ?selection=value
20
- # or &selection=value depending on if the URI already has parameters.
21
- # icon is the index of the icon to be displayed to the left of the
22
- # given entry. dial is the number to call if the user pushes a softkey
23
- # with URI SoftKey:Dial2.
24
- def initialize(name, url, selection, icon, dial)
25
- @name = name
26
- @url = url
27
- @selection = selection
28
- @icon = icon
29
- @dial = dial
30
- @selection = nil if @selection == ''
31
- @icon = nil if @icon == ''
32
- @dial = nil if @dial == ''
33
- end
34
-
35
- # Returns the name associated with this entry.
36
- def getName
37
- return @name
38
- end
39
-
40
- # Create XML text output of this entry.
41
- def render
42
- xml = "<MenuItem"
43
- xml += " icon=\"#{@icon}\"" if not @icon.nil?
44
- xml += ">\n"
45
- xml += "<Prompt>#{escape(@name)}</Prompt>\n"
46
- xml += "<URI>#{escape(@url)}</URI>\n"
47
- xml += "<Selection>#{escape(@selection)}</Selection>\n" if not @selection.nil?
48
- xml += "<Dial>#{@dial}</Dial>\n" if not @dial.nil?
49
- xml += "</MenuItem>\n"
50
- return xml
51
- end
52
- end
@@ -1,93 +0,0 @@
1
- ################################################################################
2
- # Aastra XML API Classes - AastraIPPhoneTextScreen
3
- # Copyright Aastra Telecom 2008
4
- #
5
- # Ruby adaptation by Carlton O'Riley
6
- #
7
- # AastraIPPhoneTextScreen 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,iconindex) to add custom softkeys to the object (optional)
21
- # addIcon(index,icon) to add custom icons to the object (optional)
22
- # setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
23
- #
24
- # Specific to the object
25
- # setText(text) to set the text to be displayed.
26
- # setDoneAction(uri) to set the URI to be called when the user selects the default "Done" key (optional)
27
- # setAllowDTMF to allow DTMF passthrough on the object
28
- #
29
- # Example
30
- # require 'AastraIPPhoneTextScreen.rb'
31
- # text = AastraIPPhoneTextScreen.new
32
- # text.setTitle('Title')
33
- # text.setText('Text to be displayed.')
34
- # text.setDestroyOnExit
35
- # text.addSoftkey('1', 'Mail', 'http://myserver.com/script.php?action=1', '1')
36
- # text.addSoftkey('6', 'Exit', 'SoftKey:Exit')
37
- # text.addIcon('1', 'Icon:Envelope')
38
- # aastra_output text
39
- #
40
- ################################################################################
41
-
42
- class AastraIPPhoneTextScreen < AastraIPPhone
43
- @text
44
- @doneAction
45
- @allowDTMF
46
-
47
- # Set the text to be displayed on this screen.
48
- def setText(text)
49
- @text = text
50
- end
51
-
52
- # Set the URI to be called when done viewing this screen.
53
- def setDoneAction(uri)
54
- @doneAction = uri
55
- end
56
-
57
- # When set allows DTMF tones to be sent while viewing this screen.
58
- def setAllowDTMF
59
- @allowDTMF = "yes"
60
- end
61
-
62
- # Create XML text output.
63
- def render
64
- xml = "<AastraIPPhoneTextScreen"
65
- xml += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
66
- xml += " cancelAction=\"#{escape(@cancelAction)}\"" if not @cancelAction.nil?
67
- xml += " doneAction=\"#{escape(@doneAction)}\"" if not @doneAction.nil?
68
- xml += " Beep=\"yes\"" if @beep == "yes"
69
- xml += " Timeout=\"#{@timeout}\"" if @timeout != 0
70
- xml += " LockIn=\"yes\"" if @lockin == "yes"
71
- xml += " allowAnswer=\"yes\"" if @allowAnswer == "yes"
72
- xml += " allowDTMF=\"yes\"" if @allowDTMF == "yes"
73
- xml += ">\n"
74
- if not @title.nil? then
75
- xml += "<Title"
76
- xml += " wrap=\"yes\"" if @title_wrap == "yes"
77
- xml += ">#{escape(@title)}</Title>\n"
78
- end
79
- xml += "<Text>#{escape(@text)}</Text>\n"
80
- @softkeys.each { |softkey| xml += softkey.render }
81
- iconList = 0
82
- @icons.each do |icon|
83
- if iconList == 0 then
84
- xml += "<IconList>\n"
85
- iconList = 1
86
- end
87
- xml += icon.render
88
- end
89
- xml += "</IconList>\n" if iconList != 0
90
- xml += "</AastraIPPhoneTextScreen>\n"
91
- return xml
92
- end
93
- end
@@ -1,63 +0,0 @@
1
- # Performs natural order sorting of an array. Natural order is the way in
2
- # which a human might sort a list of files that are incremented by
3
- # one. They will sort normally as long as they have leading zeros,
4
- # however this doesn't look good and is hard to read. What natural sorting
5
- # does is allow the following to be sorted properly (as shown):
6
- #
7
- # file1
8
- # file2
9
- # file4
10
- # file22
11
- # file30
12
- # file100
13
- #
14
- # Code used is from http://zijab.blogspot.com/2007/05/natural-order-string-comparison-for.html
15
- #
16
-
17
- class Array
18
-
19
- # Method which sort an array composed of strings with embedded numbers by
20
- # the 'natural' representation of numbers inside a string.
21
- def natsort
22
-
23
- reg_number = /\d+/
24
-
25
- # We call the sort method of the Array class.
26
- self.sort do |str1, str2|
27
-
28
- # We try to find an embedded number
29
- a = str1.match(reg_number)
30
- b = str2.match(reg_number)
31
-
32
- # If there is no number
33
- if [a,b].include? nil
34
- str1 <=> str2
35
- else
36
- while true
37
- begin
38
- # We compare strings before the number. If there
39
- # are equal, we will have to compare the numbers
40
- if (comp = a.pre_match <=> b.pre_match) == 0
41
- # If the numbers are equal
42
- comp = (a[0] == b[0]) ? comp = a[0] + a.post_match <=> b[0] + b.post_match :
43
- comp = a[0].to_i <=> b[0].to_i
44
- end
45
-
46
- str1, str2 = a.post_match, b.post_match
47
- a = str1.match(reg_number)
48
- b = str2.match(reg_number)
49
- rescue
50
- break
51
- end
52
- end
53
- comp
54
- end
55
- end
56
- end
57
-
58
- # Same as 'natsort' but replace in place.
59
- def natsort!
60
- self.replace(natsort)
61
- end
62
-
63
- end