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,86 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneInputScreenEntry
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 PhoneInputScreen object.
9
+ ################################################################################
10
+
11
+ module AastraXmlApi
12
+ class PhoneInputScreenEntry
13
+ @type
14
+ @password
15
+ @editable
16
+ @parameter
17
+ @prompt
18
+ @default
19
+ @selection
20
+ @softkeys
21
+
22
+ # Create new input field as a given type. The type can be one of IP,
23
+ # string (default), number, timeUS, timeInt, dateUS, or dateInt.
24
+ def initialize(type)
25
+ @type = type
26
+ @softkeys = []
27
+ end
28
+
29
+ # Set the type (see initialize for values) of this input field.
30
+ def setType(type)
31
+ @type = type
32
+ end
33
+
34
+ # Set this input field as a password field masked by "*" characters.
35
+ def setPassword
36
+ @password = "yes"
37
+ end
38
+
39
+ # Make this input field editable, i.e. not read only.
40
+ def setEditable
41
+ @editable = "yes"
42
+ end
43
+
44
+ # Set paramter name value to be used to identify this field on submit.
45
+ def setParameter(parameter)
46
+ @parameter = parameter
47
+ end
48
+
49
+ # Set prompt to be displayed to let user know what this field is for.
50
+ def setPrompt(prompt)
51
+ @prompt = prompt
52
+ end
53
+
54
+ # Set default value to load this field with.
55
+ def setDefault(default)
56
+ @default = default
57
+ end
58
+
59
+ # The contents of this will be added when the submit key is pressed while
60
+ # editing this field.
61
+ def setSelection(selection)
62
+ @selection = selection
63
+ end
64
+
65
+ # Adds softkey to be displayed when editing this field.
66
+ def addSoftkey(index, label, uri, icon=nil)
67
+ @softkeys += [PhoneSoftkeyEntry.new(index, label, uri, icon)]
68
+ end
69
+
70
+ # Create XML text output for this entry.
71
+ def render
72
+ xml = "<InputField"
73
+ xml += " type=\"#{@type}\"" if not @type.nil?
74
+ xml += " password=\"yes\"" if @password == "yes"
75
+ xml += " editable=\"yes\"" if @editable == "yes"
76
+ xml += ">\n"
77
+ xml += "<Prompt>#{@prompt}</Prompt>\n" if not @prompt.nil?
78
+ xml += "<Parameter>#{@parameter}</Parameter>\n" if not @parameter.nil?
79
+ xml += "<Selection>#{@selection}</Selection>\n" if not @selection.nil?
80
+ xml += "<Default>#{@default}</Default>\n" if not @default.nil?
81
+ @softkeys.each { |softkey| xml += softkey.render }
82
+ xml += "</InputField>\n"
83
+ return xml
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,39 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneSoftkeyEntry
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 Phone object.
9
+ ################################################################################
10
+
11
+ module AastraXmlApi
12
+ class PhoneSoftkeyEntry
13
+ @index
14
+ @label
15
+ @uri
16
+ @icon
17
+
18
+ # Create new softkey entry at index showing on screen with label. When
19
+ # pressed will call URI. Next to the label text the given icon
20
+ # will be shown.
21
+ def initialize(index, label, uri, icon)
22
+ @index = index
23
+ @label = label
24
+ @uri = uri
25
+ @icon = icon
26
+ end
27
+
28
+ # Create XML text output for this entry.
29
+ def render
30
+ xml = "<SoftKey index=\"#{@index}\""
31
+ xml += " icon=\"#{@icon}\"" if not @icon.nil?
32
+ xml += ">\n"
33
+ xml += "<Label>#{@label}</Label>\n"
34
+ xml += "<URI>#{@uri}</URI>\n"
35
+ xml += "</SoftKey>\n"
36
+ return xml
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,68 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneStatus
3
+ # Copyright Aastra Telecom 2008
4
+ #
5
+ # Ruby adaptation by Carlton O'Riley
6
+ #
7
+ # PhoneStatus object.
8
+ #
9
+ # Public methods
10
+ #
11
+ # Inherited from Phone
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 'PhoneStatus.rb'
23
+ # status = PhoneStatus.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
+ module AastraXmlApi
33
+ class PhoneStatus < Phone
34
+ @session
35
+ @triggerDestroyOnExit
36
+
37
+ # Sets the session associated with this status message. Only important
38
+ # if more than one application is sending status messages.
39
+ def setSession(session)
40
+ @session = session
41
+ end
42
+
43
+ # When set, the previous user interface XML object is destroyed
44
+ # if its destroyOnExit tag is also set to yes.
45
+ def setTriggerDestroyOnExit
46
+ @triggerDestroyOnExit = "yes"
47
+ end
48
+
49
+ # Adds a new status message to be displayed at index. The type can only
50
+ # be nothing (default) or alert which shows the message for 3 seconds.
51
+ # The timeout can override the default 3 seconds for an alert message.
52
+ def addEntry(index, message, type=nil, timeout=nil)
53
+ @entries += [PhoneStatusEntry.new(index, message, type, timeout)]
54
+ end
55
+
56
+ # Create XML text output.
57
+ def render
58
+ xml = "<PhoneStatus"
59
+ xml += " Beep=\"yes\"" if @beep == "yes"
60
+ xml += " triggerDestroyOnExit=\"yes\"" if @triggerDestroyOnExit == "yes"
61
+ xml += ">\n"
62
+ xml += "<Session>#{@session}</Session>\n"
63
+ @entries.each { |entry| xml += entry.render }
64
+ xml += "</PhoneStatus>\n"
65
+ return xml
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,58 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneStatusEntry
3
+ # Copyright Aastra Telecom 2008
4
+ #
5
+ # Ruby adaptation by Carlton O'Riley
6
+ #
7
+ # Internal class for PhoneStatus object.
8
+ ################################################################################
9
+
10
+ module AastraXmlApi
11
+ class PhoneStatusEntry < Phone
12
+ @index
13
+ @message
14
+ @type
15
+ @timeout
16
+
17
+ # Create new status message at index. Type can only be "alert" or left
18
+ # blank. If the type is anything but blank, it is automatically set
19
+ # to "alert". The timeout overrides the default 3 seconds for an
20
+ # alert message.
21
+ def initialize(index, message, type=nil, timeout=nil)
22
+ @index = index
23
+ @message = message
24
+ setType(type)
25
+ @timeout = timeout
26
+ end
27
+
28
+ # Set the index of this message.
29
+ def setIndex(index)
30
+ @index = index
31
+ end
32
+
33
+ # Set the text of the message.
34
+ def setMessage(message)
35
+ @message = message
36
+ end
37
+
38
+ # Set the type of the message. Either "alert" or normal (blank and default)
39
+ def setType(type)
40
+ @type = type if type.nil?
41
+ @type = "alert" if not type.nil?
42
+ end
43
+
44
+ # Set the timeout (in seconds) of an alert message
45
+ def setTimeout(timeout)
46
+ @timeout = timeout
47
+ end
48
+
49
+ # Create XML text output of this entry
50
+ def render
51
+ xml = "<Message index=\"#{escape(@index)}\""
52
+ xml += " type=\"#{escape(@type)}\"" if not @type.nil?
53
+ xml += " Timeout=\"#{@timeout}\"" if not @timeout.nil?
54
+ xml += ">#{escape(@message)}</Message>\n"
55
+ return xml
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,148 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneTextMenu
3
+ # Copyright Aastra Telecom 2008
4
+ #
5
+ # PhoneTextMenu object.
6
+ #
7
+ # Public methods
8
+ #
9
+ # Inherited from Phone
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 'PhoneTextMenu.rb'
31
+ # menu = PhoneTextMenu.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 'PhoneTextMenu.rb'
45
+ # menu = PhoneTextMenu.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
+ module AastraXmlApi
63
+ class PhoneTextMenu < Phone
64
+ @defaultIndex
65
+ @style
66
+ @wraplist
67
+ @maxitems
68
+
69
+ # Sets the default index to highlight when first shown.
70
+ def setDefaultIndex(defaultIndex)
71
+ @defaultIndex = defaultIndex
72
+ end
73
+
74
+ # Set the style to one of numbered (default), none, or radio.
75
+ def setStyle(style)
76
+ @style = style
77
+ end
78
+
79
+ # Add a menu entry with name displayed and calls url when selected. The
80
+ # selection option is the value appended to a custom softkey URL when
81
+ # this item is highlighted. icon is a reference to an included icon
82
+ # that is shown with the menu entry. dial is what is called when
83
+ # the user hits a softkey with the URI "SoftKey:Dial2".
84
+ def addEntry(name, url, selection=nil, icon=nil, dial=nil)
85
+ @entries += [PhoneTextMenuEntry.new(name, url, selection, icon, dial)]
86
+ end
87
+
88
+ # Allows entries in the list to wrap.
89
+ def setWrapList
90
+ @wraplist = "yes"
91
+ end
92
+
93
+ # Use natural order sorting to sort the menu by name.
94
+ def natsortByName
95
+ tmparray = []
96
+ tmp_array.include(ArrayExtension)
97
+ linklist = {}
98
+ for i in 0..@entries.size-1
99
+ tmparray += [@entries[i].getName]
100
+ linklist[@entries[i].getName] = i
101
+ end
102
+ tmparray.natsort!
103
+ newentries = []
104
+ tmparray.each do |name|
105
+ newentries += [@entries[linklist[name]]]
106
+ end
107
+ @entries = newentries
108
+ end
109
+
110
+ # Create XML text output.
111
+ def render
112
+ @maxitems = 30 if @maxitems.nil?
113
+ xml = "<PhoneTextMenu"
114
+ xml += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
115
+ xml += " cancelAction=\"#{escape(@cancelAction)}\"" if not @cancelAction.nil?
116
+ xml += " defaultIndex=\"#{@defaultIndex}\"" if not @defaultIndex.nil?
117
+ xml += " style=\"#{@style}\"" if not @style.nil?
118
+ xml += " Beep=\"yes\"" if @beep == "yes"
119
+ xml += " LockIn=\"yes\"" if @lockin == "yes"
120
+ xml += " wrapList=\"yes\"" if @wraplist == "yes"
121
+ xml += " allowAnswer=\"yes\"" if @allowAnswer == "yes"
122
+ xml += " Timeout=\"#{@timeout}\"" if @timeout != 0
123
+ xml += ">\n"
124
+ if not @title.nil? then
125
+ xml += "<Title"
126
+ xml += " wrap=\"yes\"" if @title_wrap == "yes"
127
+ xml += ">#{escape(@title)}</Title>\n"
128
+ end
129
+ index = 0
130
+ @entries.each do |entry|
131
+ xml += entry.render if index < @maxitems
132
+ index += 1
133
+ end
134
+ @softkeys.each { |softkey| xml += softkey.render }
135
+ iconList = 0
136
+ @icons.each do |icon|
137
+ if iconList == 0 then
138
+ xml += "<IconList>\n"
139
+ iconList = 1
140
+ end
141
+ xml += icon.render
142
+ end
143
+ xml += "</IconList>\n" if iconList != 0
144
+ xml += "</PhoneTextMenu>\n"
145
+ return xml
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,54 @@
1
+ ################################################################################
2
+ # Aastra XML API Classes - PhoneTextMenuEntry
3
+ # Copyright Aastra Telecom 2008
4
+ #
5
+ # Ruby adaptation by Carlton O'Riley
6
+ #
7
+ # Internal class for PhoneTextMenu object.
8
+ ################################################################################
9
+
10
+ module AastraXmlApi
11
+ class PhoneTextMenuEntry < Phone
12
+ @name
13
+ @url
14
+ @selection
15
+ @icon
16
+ @dial
17
+
18
+ # Create new text menu entry with given name to be displayed, url to be
19
+ # called when selected. Selection is the value appended to a custom URI
20
+ # attached to a softkey. This will be added as either ?selection=value
21
+ # or &selection=value depending on if the URI already has parameters.
22
+ # icon is the index of the icon to be displayed to the left of the
23
+ # given entry. dial is the number to call if the user pushes a softkey
24
+ # with URI SoftKey:Dial2.
25
+ def initialize(name, url, selection, icon, dial)
26
+ @name = name
27
+ @url = url
28
+ @selection = selection
29
+ @icon = icon
30
+ @dial = dial
31
+ @selection = nil if @selection == ''
32
+ @icon = nil if @icon == ''
33
+ @dial = nil if @dial == ''
34
+ end
35
+
36
+ # Returns the name associated with this entry.
37
+ def getName
38
+ return @name
39
+ end
40
+
41
+ # Create XML text output of this entry.
42
+ def render
43
+ xml = "<MenuItem"
44
+ xml += " icon=\"#{@icon}\"" if not @icon.nil?
45
+ xml += ">\n"
46
+ xml += "<Prompt>#{escape(@name)}</Prompt>\n"
47
+ xml += "<URI>#{escape(@url)}</URI>\n"
48
+ xml += "<Selection>#{escape(@selection)}</Selection>\n" if not @selection.nil?
49
+ xml += "<Dial>#{@dial}</Dial>\n" if not @dial.nil?
50
+ xml += "</MenuItem>\n"
51
+ return xml
52
+ end
53
+ end
54
+ end