Class: AastraXmlApi::PhoneTextMenu

Inherits:
Phone
  • Object
show all
Defined in:
lib/aastra_xml_api/phone_text_menu.rb

Constant Summary

Constants inherited from Phone

AastraXmlApi::Phone::HIGHASCII

Instance Method Summary collapse

Methods inherited from Phone

#addIcon, #addSoftkey, #convert_high_ascii, #escape, #getRefreshTimeout, #getRefreshURL, #initialize, #setAllowAnswer, #setBeep, #setCancelAction, #setDestroyOnExit, #setLockIn, #setRefresh, #setTimeout, #setTitle, #setTitleWrap

Constructor Details

This class inherits a constructor from AastraXmlApi::Phone

Instance Method Details

#addEntry(name, url, selection = nil, icon = nil, dial = nil) ⇒ Object

Add a menu entry with name displayed and calls url when selected. The selection option is the value appended to a custom softkey URL when this item is highlighted. icon is a reference to an included icon that is shown with the menu entry. dial is what is called when the user hits a softkey with the URI “SoftKey:Dial2”.



84
85
86
# File 'lib/aastra_xml_api/phone_text_menu.rb', line 84

def addEntry(name, url, selection=nil, icon=nil, dial=nil)
  @entries += [PhoneTextMenuEntry.new(name, url, selection, icon, dial)]
end

#natsortByNameObject

Use natural order sorting to sort the menu by name.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/aastra_xml_api/phone_text_menu.rb', line 94

def natsortByName
  tmparray = []
  tmp_array.include(ArrayExtension)
  linklist = {}
  for i in 0..@entries.size-1
    tmparray += [@entries[i].getName]
    linklist[@entries[i].getName] = i
  end
  tmparray.natsort!
  newentries = []
  tmparray.each do |name|
    newentries += [@entries[linklist[name]]]
  end
  @entries = newentries
end

#renderObject

Create XML text output.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/aastra_xml_api/phone_text_menu.rb', line 111

def render
  @maxitems = 30 if @maxitems.nil?
  xml = "<PhoneTextMenu"
  xml += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
  xml += " cancelAction=\"#{escape(@cancelAction)}\"" if not @cancelAction.nil?
  xml += " defaultIndex=\"#{@defaultIndex}\"" if not @defaultIndex.nil?
  xml += " style=\"#{@style}\"" if not @style.nil?
  xml += " Beep=\"yes\"" if @beep == "yes"
  xml += " LockIn=\"yes\"" if @lockin == "yes"
  xml += " wrapList=\"yes\"" if @wraplist == "yes"
  xml += " allowAnswer=\"yes\"" if @allowAnswer == "yes"
  xml += " Timeout=\"#{@timeout}\"" if @timeout != 0
  xml += ">\n"
  if not @title.nil? then
    xml += "<Title"
    xml += " wrap=\"yes\"" if @title_wrap == "yes"
    xml += ">#{escape(@title)}</Title>\n"
  end
  index = 0
  @entries.each do |entry|
    xml += entry.render if index < @maxitems
    index += 1
  end
  @softkeys.each { |softkey| xml += softkey.render }
  iconList = 0
  @icons.each do |icon|
    if iconList == 0 then
      xml += "<IconList>\n"
      iconList = 1
    end
    xml += icon.render
  end
  xml += "</IconList>\n" if iconList != 0
  xml += "</PhoneTextMenu>\n"
  return xml
end

#setDefaultIndex(defaultIndex) ⇒ Object

Sets the default index to highlight when first shown.



70
71
72
# File 'lib/aastra_xml_api/phone_text_menu.rb', line 70

def setDefaultIndex(defaultIndex)
  @defaultIndex = defaultIndex
end

#setStyle(style) ⇒ Object

Set the style to one of numbered (default), none, or radio.



75
76
77
# File 'lib/aastra_xml_api/phone_text_menu.rb', line 75

def setStyle(style)
  @style = style
end

#setWrapListObject

Allows entries in the list to wrap.



89
90
91
# File 'lib/aastra_xml_api/phone_text_menu.rb', line 89

def setWrapList
  @wraplist = "yes"
end