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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +10 -2
- data/aastra_xml_api.gemspec +1 -1
- data/lib/aastra_xml_api.rb +1 -1
- data/lib/aastra_xml_api/array_extensions.rb +61 -0
- data/lib/aastra_xml_api/phone.rb +205 -0
- data/lib/aastra_xml_api/phone_configuration.rb +56 -0
- data/lib/aastra_xml_api/phone_configuration_entry.rb +43 -0
- data/lib/aastra_xml_api/phone_directory.rb +122 -0
- data/lib/aastra_xml_api/phone_directory_entry.rb +34 -0
- data/lib/aastra_xml_api/phone_execute.rb +60 -0
- data/lib/aastra_xml_api/phone_execute_entry.rb +32 -0
- data/lib/aastra_xml_api/phone_formatted_text_screen.rb +119 -0
- data/lib/aastra_xml_api/phone_formatted_text_screen_entry.rb +50 -0
- data/lib/aastra_xml_api/phone_gd_image.rb +187 -0
- data/lib/aastra_xml_api/phone_icon_entry.rb +29 -0
- data/lib/aastra_xml_api/phone_image_menu.rb +145 -0
- data/lib/aastra_xml_api/phone_image_menu_entry.rb +27 -0
- data/lib/aastra_xml_api/phone_image_screen.rb +141 -0
- data/lib/aastra_xml_api/phone_input_screen.rb +251 -0
- data/lib/aastra_xml_api/phone_input_screen_entry.rb +86 -0
- data/lib/aastra_xml_api/phone_softkey_entry.rb +39 -0
- data/lib/aastra_xml_api/phone_status.rb +68 -0
- data/lib/aastra_xml_api/phone_status_entry.rb +58 -0
- data/lib/aastra_xml_api/phone_text_menu.rb +148 -0
- data/lib/aastra_xml_api/phone_text_menu_entry.rb +54 -0
- data/lib/aastra_xml_api/phone_text_screen.rb +95 -0
- data/lib/aastra_xml_api/version.rb +1 -1
- metadata +28 -27
- data/lib/aastra_xml_api/AastraIPPhone.rb +0 -203
- data/lib/aastra_xml_api/AastraIPPhoneConfiguration.rb +0 -55
- data/lib/aastra_xml_api/AastraIPPhoneConfigurationEntry.rb +0 -41
- data/lib/aastra_xml_api/AastraIPPhoneDirectory.rb +0 -119
- data/lib/aastra_xml_api/AastraIPPhoneDirectoryEntry.rb +0 -32
- data/lib/aastra_xml_api/AastraIPPhoneExecute.rb +0 -58
- data/lib/aastra_xml_api/AastraIPPhoneExecuteEntry.rb +0 -30
- data/lib/aastra_xml_api/AastraIPPhoneFormattedTextScreen.rb +0 -117
- data/lib/aastra_xml_api/AastraIPPhoneFormattedTextScreenEntry.rb +0 -48
- data/lib/aastra_xml_api/AastraIPPhoneGDImage.rb +0 -185
- data/lib/aastra_xml_api/AastraIPPhoneIconEntry.rb +0 -27
- data/lib/aastra_xml_api/AastraIPPhoneImageMenu.rb +0 -143
- data/lib/aastra_xml_api/AastraIPPhoneImageMenuEntry.rb +0 -25
- data/lib/aastra_xml_api/AastraIPPhoneImageScreen.rb +0 -139
- data/lib/aastra_xml_api/AastraIPPhoneInputScreen.rb +0 -249
- data/lib/aastra_xml_api/AastraIPPhoneInputScreenEntry.rb +0 -84
- data/lib/aastra_xml_api/AastraIPPhoneSoftkeyEntry.rb +0 -37
- data/lib/aastra_xml_api/AastraIPPhoneStatus.rb +0 -66
- data/lib/aastra_xml_api/AastraIPPhoneStatusEntry.rb +0 -56
- data/lib/aastra_xml_api/AastraIPPhoneTextMenu.rb +0 -145
- data/lib/aastra_xml_api/AastraIPPhoneTextMenuEntry.rb +0 -52
- data/lib/aastra_xml_api/AastraIPPhoneTextScreen.rb +0 -93
- data/lib/aastra_xml_api/arraynatsort.rb +0 -63
@@ -1,185 +0,0 @@
|
|
1
|
-
require 'GD'
|
2
|
-
|
3
|
-
################################################################################
|
4
|
-
# Aastra XML API Classes - Aastra XML API Classes - AastraIPPhoneGDImage
|
5
|
-
# Copyright Aastra Telecom 2008
|
6
|
-
#
|
7
|
-
# Ruby adaptation by Carlton O'Riley
|
8
|
-
#
|
9
|
-
# Firmware 2.2.0 or better
|
10
|
-
#
|
11
|
-
# AastraIPPhoneGDImage for AastraIPPhoneImageScreen and AastraIPPhoneImageScreen.
|
12
|
-
#
|
13
|
-
# ruby needs ruby-gd gem installed
|
14
|
-
# ------------------------------
|
15
|
-
#
|
16
|
-
# Public methods
|
17
|
-
#
|
18
|
-
# drawttftext(fontsize,angle,x,y,text,colorIndex,fontfile)
|
19
|
-
# Writes text to the image using TrueType fonts
|
20
|
-
# fontsize The font size. Depending on your version of GD, this should be specified as the pixel
|
21
|
-
# size (GD1) or point size (GD2)
|
22
|
-
# angle The angle in degrees, with 0 degrees being left-to-right reading text. Higher values
|
23
|
-
# represent a counter-clockwise rotation. For example, a value of 90 would result in
|
24
|
-
# bottom-to-top reading text.
|
25
|
-
# x,y The coordinates given by x and y will define the basepoint of the first character
|
26
|
-
# (roughly the lower-left corner of the character).
|
27
|
-
# colorIndex 0=White 1=Black
|
28
|
-
# fontfile Location and name of the ttf file to use
|
29
|
-
#
|
30
|
-
# drawtext(fontsize,x,y,text,colorIndex)
|
31
|
-
# Writes text to the image using built-in font
|
32
|
-
# fontsize The font size. From 1 to 5
|
33
|
-
# x,y The coordinates given by x and y will define the basepoint of the first character
|
34
|
-
# (roughly the lower-left corner of the character).
|
35
|
-
# colorIndex 0=White 1=Black
|
36
|
-
#
|
37
|
-
# rectangle(x1,y1,x2,y2,colorIndex,filled)
|
38
|
-
# Creates a rectangle starting at the specified coordinates.
|
39
|
-
# x1,y1 Upper left x,y coordinate. 0,0 is the top left corner of the image.
|
40
|
-
# x2,y2 Bottom right x,y coordinate
|
41
|
-
# colorIndex 0=White 1=Black
|
42
|
-
# filled Boolean, optional (default if False)
|
43
|
-
#
|
44
|
-
# ellipse(cx,cy,width,height,colorIndex,filled)
|
45
|
-
# Draws an ellipse centered at the specified coordinates.
|
46
|
-
# cx,cy x-coordinate and y-coordinate of the center
|
47
|
-
# width the ellipse width
|
48
|
-
# height the ellipse height
|
49
|
-
# colorIndex 0=White 1=Black
|
50
|
-
# filled Boolean, optional (default if False)
|
51
|
-
#
|
52
|
-
# line(x1,y1,x2,y2,colorIndex)
|
53
|
-
# Draws a line
|
54
|
-
# x1,y1 x,y coordinates for the first point
|
55
|
-
# x2,y2 x,y coordinates for the second point
|
56
|
-
# colorIndex 0=White 1=Black
|
57
|
-
#
|
58
|
-
# setGDImage(image)
|
59
|
-
# Imports an externally generated GD image
|
60
|
-
# image GD image to import
|
61
|
-
#
|
62
|
-
# getGDImage()
|
63
|
-
# Exports the current GD image
|
64
|
-
#
|
65
|
-
# setFontPath(fontpath)
|
66
|
-
# Set directory path for the fonts to use
|
67
|
-
# fontpath Directory for the ttf fonts
|
68
|
-
# Default value
|
69
|
-
# Windows based platform C:\Windows\Fonts
|
70
|
-
# Linux based platform ../fonts
|
71
|
-
# Mac OS X based platform ../fonts
|
72
|
-
# Rails based platform RAILS_ROOT/fonts
|
73
|
-
#
|
74
|
-
# Example 1
|
75
|
-
# require 'AastraIPPhoneGDImage.rb'
|
76
|
-
# phoneImageGD = AastraIPPhoneGDImage.new
|
77
|
-
# time = Time.now.strftime("%H:%M")
|
78
|
-
# phoneImageGD.drawttftext(30, 0, 10, 39, time, 1,'Ni7seg.ttf')
|
79
|
-
#
|
80
|
-
# Example 2
|
81
|
-
# require 'AastraIPPhoneGDImage.rb'
|
82
|
-
# phoneImageGD = AastraIPPhoneGDImage.new
|
83
|
-
# utf8text = "东丝丞丟丸"
|
84
|
-
# phoneImageGD.drawttftext(20, 0, 5, 35, utf8text, 1, 'arialuni.ttf')
|
85
|
-
#
|
86
|
-
################################################################################
|
87
|
-
|
88
|
-
class AastraIPPhoneGDImage
|
89
|
-
@img
|
90
|
-
@white
|
91
|
-
@black
|
92
|
-
@blackNoAntiAliasing
|
93
|
-
@font
|
94
|
-
@fontpath
|
95
|
-
|
96
|
-
# Creates a new GD image of size 144x40 (maximum allowed on phone). Also
|
97
|
-
# creates black and white colors to be used and sets default font path
|
98
|
-
# based on whether this is running under rails or a specific
|
99
|
-
# operating system.
|
100
|
-
def initialize
|
101
|
-
# create image
|
102
|
-
@img = GD::Image.new(144, 40)
|
103
|
-
|
104
|
-
# define black and white
|
105
|
-
@white = @img.colorAllocate(255, 255, 255)
|
106
|
-
@black = @img.colorAllocate(0, 0, 0)
|
107
|
-
|
108
|
-
# black and white only so disable anti-aliasing
|
109
|
-
@black *= -1
|
110
|
-
@white *= -1
|
111
|
-
|
112
|
-
# define a default font path
|
113
|
-
if defined?(RAILS_ROOT) then
|
114
|
-
@fontpath = "#{RAILS_ROOT}/fonts"
|
115
|
-
else
|
116
|
-
os = RUBY_PLATFORM.downcase
|
117
|
-
@fontpath = "C:\\Windows\\Fonts" if not os.scan(/win/).nil?
|
118
|
-
@fontpath = "../fonts" if not os.scan(/linux$/).nil?
|
119
|
-
@fontpath = "../fonts" if not os.scan(/darwin\d+\.\d+$/).nil?
|
120
|
-
end
|
121
|
-
ENV['GDFONTPATH'] = @fontpath
|
122
|
-
end
|
123
|
-
|
124
|
-
# Set font path for GD.
|
125
|
-
def setFontPath(fontpath)
|
126
|
-
@fontpath = fontpath
|
127
|
-
ENV['GDFONTPATH'] = @fontpath
|
128
|
-
end
|
129
|
-
|
130
|
-
# Draw text on the image using a specific true type font.
|
131
|
-
# See GD documentation for parameters.
|
132
|
-
def drawttftext(size, angle, x, y, text, colorIndex, font)
|
133
|
-
@img.stringTTF(getColor(colorIndex), font, size, angle, x, y, text)
|
134
|
-
end
|
135
|
-
|
136
|
-
# Draw text on the image.
|
137
|
-
def drawtext(size, x, y, text, colorIndex)
|
138
|
-
@img.string(size, x, y, text, getColor(colorIndex))
|
139
|
-
end
|
140
|
-
|
141
|
-
# Set the image from an externally created GD image.
|
142
|
-
def setGDImage(image)
|
143
|
-
@img = image
|
144
|
-
end
|
145
|
-
|
146
|
-
# Get the GD image created.
|
147
|
-
def getGDImage
|
148
|
-
return @img
|
149
|
-
end
|
150
|
-
|
151
|
-
# Draw a rectangle on the image. Rectangle will be unfilled by default.
|
152
|
-
def rectangle(x1, y1, x2, y2, colorIndex, filled=false)
|
153
|
-
if filled then
|
154
|
-
@img.filledRectangle(x1, y1, x2, y2, getColor(colorIndex))
|
155
|
-
else
|
156
|
-
@img.rectangle(x1, y1, x2, y2, getColor(colorIndex))
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
# Draw an ellipse on the image. Ellipse will be unfilled by default.
|
161
|
-
def ellipse(cx, cy, width, height, colorIndex, filled=false)
|
162
|
-
if filled then
|
163
|
-
@img.filledEllipse(cx, cy, width, height, 0, 360, getColor(colorIndex))
|
164
|
-
else
|
165
|
-
@img.ellipse(cx, cy, width, height, 0, 360, getColor(colorIndex))
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
# Draw a line on the image. Line will be solid by default.
|
170
|
-
def line(x1, y1, x2, y2, colorIndex, dashed=false)
|
171
|
-
if dashed then
|
172
|
-
@img.dashedLine(x1, y2, x2, y2, getColor(colorIndex))
|
173
|
-
else
|
174
|
-
@img.line(x1, y2, x2, y2, getColor(colorIndex))
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
# Get the GD color element based on an index.
|
179
|
-
# 0:: white
|
180
|
-
# 1:: black
|
181
|
-
def getColor(index)
|
182
|
-
return @white if index == 0
|
183
|
-
return @black
|
184
|
-
end
|
185
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Aastra XML API Classes - AastraIPIconEntry
|
3
|
-
# Firmware 2.0 or better
|
4
|
-
# Copyright Aastra Telecom 8007
|
5
|
-
#
|
6
|
-
# Ruby adaptation by Carlton O'Riley
|
7
|
-
#
|
8
|
-
# Internal class for AastraIPPhone object.
|
9
|
-
################################################################################
|
10
|
-
|
11
|
-
class AastraIPPhoneIconEntry
|
12
|
-
@index
|
13
|
-
@icon
|
14
|
-
|
15
|
-
# Create new icon entry available to be referenced as index. The icon
|
16
|
-
# can either be a predefined icon (i.e. Icon:PhoneOnHook) or the actual
|
17
|
-
# hex data (as a string) of the icon.
|
18
|
-
def initialize(index, icon)
|
19
|
-
@index = index
|
20
|
-
@icon = icon
|
21
|
-
end
|
22
|
-
|
23
|
-
# Create XML text output for this entry.
|
24
|
-
def render
|
25
|
-
return "<Icon index=\"#{@index}\">#{@icon}</Icon>\n"
|
26
|
-
end
|
27
|
-
end
|
@@ -1,143 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Aastra XML API Classes - AastraIPPhoneImageMenu
|
3
|
-
# Copyright Aastra Telecom 2008
|
4
|
-
#
|
5
|
-
# Ruby adaptation by Carlton O'Riley
|
6
|
-
#
|
7
|
-
# AastraIPPhoneImageMenu object.
|
8
|
-
#
|
9
|
-
# Public methods
|
10
|
-
#
|
11
|
-
# Inherited from AastraIPPhone
|
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 'AastraIPPhoneImageMenu.rb'
|
29
|
-
# imagem = AastraIPPhoneImageMenu.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
|
-
class AastraIPPhoneImageMenu < AastraIPPhone
|
44
|
-
@image
|
45
|
-
@verticalAlign
|
46
|
-
@horizontalAlign
|
47
|
-
@height
|
48
|
-
@width
|
49
|
-
@uriBase
|
50
|
-
|
51
|
-
# Sets the image to be displayed. image must be a string of hex.
|
52
|
-
def setImage(image)
|
53
|
-
@image = image
|
54
|
-
end
|
55
|
-
|
56
|
-
# Sets the alignment of the image. veritcal is one of 'top',
|
57
|
-
# 'middle' (default), or 'bottom'. horizontal is one of 'left',
|
58
|
-
# 'middle' (default), or 'right'.
|
59
|
-
def setAlignment(vertical=nil, horizontal=nil)
|
60
|
-
@verticalAlign = vertical
|
61
|
-
@horizontalAlign = horizontal
|
62
|
-
end
|
63
|
-
|
64
|
-
# Sets the size of the image to be displayed which must match the
|
65
|
-
# actual images height and width.
|
66
|
-
def setSize(height, width)
|
67
|
-
@height = height
|
68
|
-
@width = width
|
69
|
-
end
|
70
|
-
|
71
|
-
# Sets the base URI that is prepended to the URI for a specific key.
|
72
|
-
def setURIBase(uriBase)
|
73
|
-
@uriBase = uriBase
|
74
|
-
end
|
75
|
-
|
76
|
-
# Adds a URI and key pair that is associated with the given key pressed
|
77
|
-
# by the user. The full URI is the one set by setURIBase followed
|
78
|
-
# by this uri.
|
79
|
-
def addURI(key, uri)
|
80
|
-
@entries += [AastraIPPhoneImageMenuEntry.new(key, uri)]
|
81
|
-
end
|
82
|
-
|
83
|
-
# Sets the image based on an externally generated GD image. Image must
|
84
|
-
# be 40x144 in size and should be created using AastraIPPhoneGDImage.
|
85
|
-
def setGDImage(gdImage)
|
86
|
-
img = gdImage.getGDImage
|
87
|
-
byte = 0
|
88
|
-
i = 0
|
89
|
-
imageHexString = ""
|
90
|
-
for x in 0..143
|
91
|
-
for y in 0..39
|
92
|
-
rgb = img.getPixel(x, y)
|
93
|
-
byte += 2**(7-(i%8)) if rgb > 0
|
94
|
-
if (i%8) == 7 then
|
95
|
-
byteHex ="%02x" % byte
|
96
|
-
imageHexString += byteHex
|
97
|
-
byte = 0
|
98
|
-
end
|
99
|
-
i += 1
|
100
|
-
end
|
101
|
-
end
|
102
|
-
setImage(imageHexString)
|
103
|
-
setSize(40,144)
|
104
|
-
end
|
105
|
-
|
106
|
-
# Create XML text output.
|
107
|
-
def render
|
108
|
-
title = escape(@title)
|
109
|
-
out = "<AastraIPPhoneImageMenu"
|
110
|
-
out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
|
111
|
-
if not @cancelAction.nil? then
|
112
|
-
cancelAction = escape(@cancelAction)
|
113
|
-
out += " cancelAction=\"#{cancelAction}\""
|
114
|
-
end
|
115
|
-
out += " Beep=\"yes\"" if @beep == "yes"
|
116
|
-
out += " LockIn=\"yes\"" if @locking == "yes"
|
117
|
-
out += " Timeout=\"#{@timeout}\"" if @timeout != 0
|
118
|
-
out += ">\n"
|
119
|
-
out += "<Image"
|
120
|
-
out += " verticalAlign=\"#{@verticalAlign}\"" if not @verticalAlign.nil?
|
121
|
-
out += " horizontalAlign=\"#{@horizontalAlign}\"" if not @horizontalAlign.nil?
|
122
|
-
out += " height=\"#{@height}\"" if not @height.nil?
|
123
|
-
out += " width=\"#{@width}\"" if not @width.nil?
|
124
|
-
out += ">#{@image}</Image>\n"
|
125
|
-
out += "<URIList"
|
126
|
-
out += " base=\"#{escape(@uriBase)}\"" if not @uriBase.nil?
|
127
|
-
out += ">\n"
|
128
|
-
@entries.each { |entry| out += entry.render }
|
129
|
-
out += "</URIList>\n"
|
130
|
-
@softkeys.each { |softkey| out += softkey.render }
|
131
|
-
iconList = 0
|
132
|
-
@icons.each do |icon|
|
133
|
-
if iconList == 0
|
134
|
-
out += "<IconList>\n"
|
135
|
-
iconList = 1
|
136
|
-
end
|
137
|
-
out += icon.render
|
138
|
-
end
|
139
|
-
out += "</IconList>\n" if iconList != 0
|
140
|
-
out += "</AastraIPPhoneImageMenu>\n"
|
141
|
-
return out
|
142
|
-
end
|
143
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Aastra XML API Classes - AastraIPPhoneImageMenuEntry
|
3
|
-
# Firmware 2.0 or better
|
4
|
-
# Copyright Aastra Telecom 2008
|
5
|
-
#
|
6
|
-
# Ruby adaptation by Carlton O'Riley
|
7
|
-
#
|
8
|
-
# Internal class for AastraIPPhoneImageMenu object.
|
9
|
-
################################################################################
|
10
|
-
|
11
|
-
class AastraIPPhoneImageMenuEntry < AastraIPPhone
|
12
|
-
@key
|
13
|
-
@uri
|
14
|
-
|
15
|
-
# Create a new mapping for a user pressed key and a URI to call.
|
16
|
-
def initialize(key, uri)
|
17
|
-
@key = key
|
18
|
-
@uri = uri
|
19
|
-
end
|
20
|
-
|
21
|
-
# Create XML text output for this entry.
|
22
|
-
def render
|
23
|
-
return "<URI key=\"#{@key}\">#{escape(@uri)}</URI>\n"
|
24
|
-
end
|
25
|
-
end
|
@@ -1,139 +0,0 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Aastra XML API Classes - AastraIPPhoneImageScreen
|
3
|
-
# Copyright Aastra Telecom 2008
|
4
|
-
#
|
5
|
-
# Ruby adaptation by Carlton O'Riley
|
6
|
-
#
|
7
|
-
# AastraIPPhoneImageScreen object.
|
8
|
-
#
|
9
|
-
# Public methods
|
10
|
-
#
|
11
|
-
# Inherited from AastraIPPhone
|
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 AastraIPPhoneImageScreen.rb'
|
32
|
-
# images = AastraIPPhoneImageScreen.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 'AastraIPPhoneGDImage.class.php'
|
44
|
-
# require 'AastraIPPhoneImageScreen.class.php'
|
45
|
-
# phoneImageGD = AastraIPPhoneGDImage.new
|
46
|
-
# object = AastraIPPhoneImageScreen.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
|
-
class AastraIPPhoneImageScreen < AastraIPPhone
|
55
|
-
@image
|
56
|
-
@verticalAlign
|
57
|
-
@horizontalAlign
|
58
|
-
@height
|
59
|
-
@width
|
60
|
-
@allowDTMF
|
61
|
-
|
62
|
-
# Set the image as a string of hex characters.
|
63
|
-
def setImage(image)
|
64
|
-
@image = image
|
65
|
-
end
|
66
|
-
|
67
|
-
# Set the alignment of the image. vertical is one of 'top',
|
68
|
-
# 'middle' (default), or 'bottom'. horizontal is one of 'left',
|
69
|
-
# 'middle' (default), or 'right'.
|
70
|
-
def setAlignment(vertical=nil, horizontal=nil)
|
71
|
-
@verticalAlign = vertical
|
72
|
-
@horizontalAlign = horizontal
|
73
|
-
end
|
74
|
-
|
75
|
-
# Sets the size of the image. Must match the actual image size.
|
76
|
-
def setSize(height, width)
|
77
|
-
@height = height
|
78
|
-
@width = width
|
79
|
-
end
|
80
|
-
|
81
|
-
# Sets the image using an externally generated GD image. This should be
|
82
|
-
# done with an AastraIPPhoneGDImage.
|
83
|
-
def setGDImage(gdImage)
|
84
|
-
img = gdImage.getGDImage
|
85
|
-
byte = 0
|
86
|
-
i = 0
|
87
|
-
imageHexString = ""
|
88
|
-
for x in 0..143
|
89
|
-
for y in 0..39
|
90
|
-
rgb = img.getPixel(x, y)
|
91
|
-
byte += 2**(7-(i%8)) if rgb > 0
|
92
|
-
if (i%8) == 7 then
|
93
|
-
byteHex ="%02x" % byte
|
94
|
-
imageHexString += byteHex
|
95
|
-
byte = 0
|
96
|
-
end
|
97
|
-
i += 1
|
98
|
-
end
|
99
|
-
end
|
100
|
-
setImage(imageHexString)
|
101
|
-
setSize(40,144)
|
102
|
-
end
|
103
|
-
|
104
|
-
# When set, allows the user's pressed keys to be sent as DTMF through
|
105
|
-
# the phone when the phone is in an active call.
|
106
|
-
def setAllowDTMF
|
107
|
-
@allowDTMF = "yes"
|
108
|
-
end
|
109
|
-
|
110
|
-
# Creates XML text output.
|
111
|
-
def render
|
112
|
-
out = "<AastraIPPhoneImageScreen"
|
113
|
-
out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes"
|
114
|
-
out += " cancelAction=\"#{escape(@cancelAction)}\"" if not @cancelAction.nil?
|
115
|
-
out += " Beep=\"yes\"" if @beep == "yes"
|
116
|
-
out += " LockIn=\"yes\"" if @locking == "yes"
|
117
|
-
out += " Timeout=\"#{@timeout}\"" if @timeout != 0
|
118
|
-
out += " allowDTMF=\"yes\"" if @allowDTMF == "yes"
|
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
|
-
@softkeys.each { |softkey| out += softkey.render }
|
127
|
-
iconList = 0
|
128
|
-
@icons.each do |icon|
|
129
|
-
if iconList == 0 then
|
130
|
-
out += "<IconList>\n"
|
131
|
-
iconList = 1
|
132
|
-
end
|
133
|
-
out += icon.render
|
134
|
-
end
|
135
|
-
out += "</IconList>\n" if iconList != 0
|
136
|
-
out += "</AastraIPPhoneImageScreen>\n"
|
137
|
-
return out
|
138
|
-
end
|
139
|
-
end
|