home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 December
/
PCWorld_2006-12_cd.bin
/
komunikace
/
netscape
/
nsb-install-8-1-2.exe
/
chrome
/
aim.jar
/
content
/
aim
/
sendfile.js
< prev
next >
Wrap
Text File
|
2006-01-06
|
3KB
|
97 lines
// globals
// window arguments defined here, but may not be used.
// mainly to test & explain valid arguments.
inviteArgsObj = window.arguments[0];
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
var fileXferSession;
function SendFileCapListener()
{
}
SendFileCapListener.prototype = {
OnRequestUserInfoCapabilitiesComplete: function(aScreenName, aUserObj)
{
try {
var capMask = aUserObj.GetCapabilities();
var capEnums = Components.interfaces.nsAimCapabilitesMask;
if (!(capEnums.filexfer & capMask) )
{
aimErrorBox(aimString("file.nosupport").replace(/%ScreenName%/, "" + inviteArgsObj.inviteProposalScreenName));;
window.close();
}
document.getElementById("ok").setAttribute("disabled", "false");
} catch (e) {}
},
OnRequestUserInfoCapabilitiesError: function(aScreenName, aError)
{
aimErrorBox (aError);
}
};
function outgoingFileOnWinLoad(){
doSetOKCancel(sendfile, 0);
document.getElementById("ok").setAttribute("label", aimString('file.send'));
document.getElementById("ok").setAttribute("disabled", "true");
// send the request and wait for callback
var listenerCap = new SendFileCapListener();
try {
aimLocateManager().RequestUserInfoCapabilities(listenerCap, inviteArgsObj.inviteProposalScreenName);
} catch (ex) {
//ERROR: unable to retrieve AIM user info for name
}
// doSetOKCancel(outgoingFileCmdAcceptRendezvous, outgoingfileCmdDeclineRendezvous);
document.getElementById("OutgoingFile").setAttribute("title",aimString("file.sendtitle").replace(/%ScreenName%/, "" + inviteArgsObj.inviteProposalScreenName));;
}
function outgoingFileOnWinUnLoad(){
//window.close();
}
function sendfile(){
var fileLocation = document.getElementById("filelocation").value;
if (fileLocation && fileLocation.length > 0)
inviteArgsObj.filepath = document.getElementById("filelocation").value;
else
{
aimErrorBox(aimString('file.pickdirectory'));
return;
}
var message = document.getElementById("message").value;
if ((message.length) > 7168)
{
aimErrorBox(aimString("file.error.long.desc").replace(/%BigBy%/, ""+ (message.length-7168)));
document.getElementById("message").select();
document.getElementById("message").focus();
return;
}
inviteArgsObj.fileXferSession = fileXfer().Send(inviteArgsObj.inviteProposalScreenName, inviteArgsObj.filepath, message);
window.openDialog('chrome://aim/content/transfer.xul','_blank','chrome,all,dialog=no',inviteArgsObj);
window.close();
}
function openfilepicker()
{
fp.init(window, aimString('file.choose'), nsIFilePicker.modeOpen);
// fp.defaultString = fileName;
fp.appendFilters(nsIFilePicker.filterAll);
try {
fp.show();
}
catch (ex) {
dump ("filePicker.chooseInputFile threw an exception\n");
return false;
}
if (fp.file && fp.file.path.length > 0)
document.getElementById("filelocation").setAttribute("value", fp.file.path);
}