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 / transfer.js < prev    next >
Text File  |  2006-01-06  |  2KB  |  68 lines

  1. // globals
  2. // window arguments defined here, but may not be used.
  3. // mainly to test & explain valid arguments.
  4.  
  5. inviteArgsObj = window.arguments[0];
  6.  
  7. var inviteMode                = inviteArgsObj.inviteMode;
  8. var fileProposalScreenName    = inviteArgsObj.inviteProposalScreenName;
  9. var fileXferSession           = inviteArgsObj.fileXferSession;
  10. var filepath                  = inviteArgsObj.filepath;
  11.  
  12. var fileXferSessionCallback = new Object();
  13. var remoteError = false;
  14.  
  15. fileXferSessionCallback.OnStateChange = function (state, msg)
  16. {
  17.     var stateEnum = Components.interfaces.nsAimFileXferStates;
  18.     if (stateEnum.Complete == state)
  19.     {
  20.         window.close();
  21.     }
  22.     if (stateEnum.Progress == state)
  23.     {
  24.         if (document.getElementById("imfileprogress").getAttribute("mode") !="determined"){
  25.             document.getElementById("imfileprogress").setAttribute("mode", "determined");
  26.         }
  27.         document.getElementById("filestate").setAttribute("value", fileXferSession.GetTotalBytes() + " / " + fileXferSession.GetTotalSize() * 100);
  28.         document.getElementById("imfileprogress").setAttribute("value", fileXferSession.GetTotalBytes() / fileXferSession.GetTotalSize() * 100);
  29.     }
  30.         if (stateEnum.Error == state)
  31.         {
  32.                 alert(msg);
  33.                 remoteError = true;
  34.                 window.close();
  35.         }
  36. }
  37.  
  38. function transferOnWinLoad(){
  39.   fileXferSession.SetFileXferSessionCallback(fileXferSessionCallback);
  40.   dump ("Loaded transfer window\n");
  41.   if(inviteMode && inviteMode=="incomingfile"){
  42.     document.getElementById("IncomingFileTransfer").setAttribute("title", aimString("file.incomingtitle"));
  43.     dump ("Receiving file\n");
  44.     try {
  45.       fileXferSession.AcceptSend(filepath);
  46.     } catch (e) {
  47.       aimErrorBox(aimString('file.error.error') + " " + aimString('file.pickdirectory'));
  48.       window.close();
  49.     }
  50.   }
  51.   if(inviteMode && inviteMode=="outgoingfile"){
  52.     document.getElementById("IncomingFileTransfer").setAttribute("title", aimString("file.outgoingtitle").replace(/%ScreenName%/, fileProposalScreenName));
  53.     fileXferSession.SetScreenName(fileProposalScreenName);
  54.     fileXferSession.SetInviteMode(1);
  55.     dump ("Sending file\n");
  56.   }
  57. }
  58.  
  59. function transferOnWinUnLoad(){
  60.   if(remoteError != true)
  61.   {
  62.     try {
  63.       fileXferSession.Cancel();
  64.     } catch (e){}
  65.   }
  66.   window.close();
  67. }
  68.