[cisco-voip] changing background image 7940
Marcos Silva
marcos.silva at sconrado.pt
Mon Dec 29 11:21:26 EST 2008
In CUCM 5.0 and above you must have another server with iis enable and point to idleurl.asp
Contents of file
<%
///////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Title: Logo
// Author: kstearns
// Source File(s): logo.asp
//
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Description:
//
// Logo provides a quick and easy method to get company logos or other graphics
// to display on a Cisco IP Phone. It would typically be used as an Idle URL service.
// This script will only access image files which exist in the same directory
// as this logo.asp file, and they must be either GIF or JPEG format.
//
// The script will select the image to be displayed in the following order:
// 1) The image filename specified by the 'logofile' parameter, if it exists
// 2) logo.jpg, if it exists
// 3) logo.gif, if it exists
//
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Requirements and Caveats:
//
// - Client: Cisco IP Phone XML browser
//
// - Required COM Servers: Cisco CIPImage
//
// - The 'includes' file(s) listed in the beginning of this file MUST be reachable
// at the specified web path.
//
// - When creating the Logo Phone Service on CallManager, you should specify a
// a Phone Service Parameter for specifying an image filename.
// The Parameter Name must be 'logofile' and is not a Required Parameter.
//
///////////////////////////////////////////////////////////////////////////////////////////////////////
Response.ContentType = "text/xml";
////////////////////////////////////////////////////////////////////////////
// If "logofile" was specified as a querystring parameter, then use it. //
// Otherwise, use logo.jpg or logo.gif (in that order). //
////////////////////////////////////////////////////////////////////////////
var cipData = "";
var logoDir = getdirectory();
var logoFileExt = "";
var newHeight = 0;
var newWidth = 0;
var cip = new ActiveXObject("CIPIMAGE.ImageProcessor.1");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var logoFile = String(Request.QueryString("logofile").Item);
if ( logoFile == "undefined" || logoFile == "") {
if (fso.FileExists(logoDir + "logo.jpg")) {
logoFile = "logo.jpg";
}
else {
if (fso.FileExists(logoDir+"logo.gif")) {
logoFile = "logo.gif";
}
else {
Response.Write("ERROR: Could not find default logo graphic file logo.jpg or logo.gif");
Response.End;
}
}
}
else {
if (fso.FileExists(logoDir + String(Request.QueryString("logofile").Item))) {
logoFile = String(Request.QueryString("logofile").Item);
}
else {
Response.Write("ERROR: Specified logo graphic file '" + logoDir + logoFile + "' does not exist.");
Response.End;
}
}
////////////////////////////////////////////////////////////
// Load graphic file into the CIP object for processing //
////////////////////////////////////////////////////////////
logoFileExt = logoFile.substring(logoFile.length - 3, logoFile.length);
logoFileExt = logoFileExt.toUpperCase();
if (logoFileExt == "JPG") { // If this file is a JPEG file then ...
cip.LoadJPG(logoDir + logoFile);
}
else {
if (logoFileExt == "GIF") {
cip.LoadGIF(logoDir + logoFile);
}
else {
Response.Write("ERROR: Invalid graphic file extension. Only .JPG and .GIF are supported.");
Response.End;
}
}
/////////////////////////////////////////////////////////////////////////////
// This section of code gets the dimensions of the source image //
// and determines which is proportionally larger compared to the max CIP //
// image size of 133 x 65. This ratio is then used find the new //
// dimensions which maintains aspect ratio. //
/////////////////////////////////////////////////////////////////////////////
newHeight = cip.height;
newWidth = cip.width;
if ((cip.width/133) > (cip.height/65)) {
newWidth = 133;
newHeight = parseInt(cip.height * (newWidth / cip.width));
}
else {
newHeight = 65;
newWidth = parseInt(cip.width * (newHeight / cip.height));
}
//////////////////////////////////////////////////////////////////////////////////
// Resize the image and convert it to CIP format, then store the Data portion //
// of the XML object in a string //
//////////////////////////////////////////////////////////////////////////////////
cip.Resize(newWidth,newHeight);
cip.RGBToPalette();
cip.ColorToGray();
cip.ReducePaletteColors(4);
cipData = cip.SaveCIPDataToBuffer();
/////////////////////////////////////////////////////////////////////////////////////
// For some reason, the cipdata string has some garbage on the end of the string //
// occassionally, so I clip the end of the string according to the length set by //
// the dimensions of the image. //
// Not sure if this is a bug in the COM server, or the ASP scripting engine, but //
// I'm working on it. In the meantime, this is a good workaround. //
/////////////////////////////////////////////////////////////////////////////////////
if ((newWidth*newHeight/4)*2 > parseInt((newWidth*newHeight/4)*2)) {
cipData = cipData.substr(0, (((newWidth*newHeight/4)+1)*2));
}
else {
cipData = cipData.substr(0, ((newWidth*newHeight/4)*2));
}
%>
<CiscoIPPhoneImage>
<LocationX>-1</LocationX>
<LocationY>-1</LocationY>
<Width><%=newWidth%></Width>
<Height><%=newHeight%></Height>
<Depth>2</Depth>
<Data><%=cipData%></Data>
<Prompt></Prompt>
<SoftKeyItem>
<Name>NovaCh.</Name>
<URL>Key:Line1</URL>
<Position>2</Position>
</SoftKeyItem>
<SoftKeyItem>
<Name>Exit</Name>
<URL>SoftKey:Exit</URL>
<Position>4</Position>
</SoftKeyItem>
</CiscoIPPhoneImage>
Above one of my creations the idle url whith two softkeys...
The logo.jpg must be in same directory.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://puck.nether.net/pipermail/cisco-voip/attachments/20081229/97a6c16b/attachment-0001.html>
More information about the cisco-voip
mailing list