Code Viewer

./ftp.js File Size: 6.91 KB

  1. /*
  2. * -----
  3. * Screenshot Sender - ftp.js
  4. * -----
  5. * Ftp upload functionality for Screenshot Sender
  6. * -----
  7. */
  8.  
  9. var bIsFtpTesting = false;
  10. var bFtpSuccess = false;
  11. var oFilesToFtp = [];
  12. var tWndFtp;
  13. var oFtpChatWnd = {};
  14.  
  15. function Ftp_Test(tFtpServer, tFtpLogin, tFtpPassword, tFtpPort, pPlusWndFtp) {
  16.         _debug.getfuncname(arguments);
  17.         bIsFtpTesting = true, tWndFtp = pPlusWndFtp;
  18.         MsgPlus.UploadFileFTP('', tFtpServer, tFtpLogin, tFtpPassword, '', true, parseInt(tFtpPort));
  19. }
  20.        
  21. function Ftp_UploadFile(sFile, bForce, pChatWnd, bUseCurrentFilename) {
  22.         _debug.getfuncname(arguments);
  23.         if (typeof bForce === TYPE_UNDEFINED) bForce = false;
  24.         if (typeof bSendUrl === TYPE_UNDEFINED) bSendUrl = false;
  25.         if (typeof bUseCurrentFilename === TYPE_UNDEFINED) bUseCurrentFilename = false;
  26.         if (bForce === true || objPreferences['cUploadFilesWhenIdle'] === 0) {
  27.                 bIsFtpTesting = false;
  28.                 var sFilename = (bUseCurrentFilename?
  29.                                                         SessionImages.GetFilename(sFile) :
  30.                                                         SessionImages.FilenameQuickTexts(objPreferences['tFilename'])+SessionImages.AppendExt()
  31.                                                 );
  32.                 oFtpChatWnd[SessionImages.GetFilename(sFile)] = {
  33.                         'pChatWnd' : pChatWnd,
  34.                         'sFilename' : sFilename
  35.                 };
  36.        
  37.                 MsgPlus.UploadFileFTP(sFile,
  38.                                                           objPreferences['tFtpServer'],
  39.                                                           objPreferences['tFtpLogin'],
  40.                                                           objPreferences['tFtpPassword'],
  41.                                                           objPreferences['tFtpDirectory']+ '/' + sFilename,
  42.                                                           true,
  43.                                                           parseInt(objPreferences['tFtpPort']));
  44.                                                           
  45.         } else if (objPreferences['cUploadFilesWhenIdle'] === 1){
  46.                 oFilesToFtp.push(sFile);
  47.         }
  48. }
  49.        
  50. function OnEvent_UploadFileComplete(Server, Destination, Source, Success) {
  51.         _debug.getfuncname(arguments);
  52.         Source ?
  53.                 Ftp_UploadFileComplete(Success, SessionImages.GetFilename(Source)) :
  54.                 Ftp_TestComplete(Success, Server);
  55. }
  56.  
  57. function Ftp_TestComplete(bSuccess, sServer) {
  58.         _debug.getfuncname(arguments);
  59.         bIsFtpTesting = false;
  60.         Preferences_ShowChild('PrefFtp');
  61.        
  62.         /* Start : Enabling Close menu */
  63.                 var hSysMenu = _win32.GetSystemMenu(objWindows['Preferences'].Handle, false);
  64.                 _win32.EnableMenuItem(hSysMenu, _win32._const._SC_CLOSE, _win32._const._MF_BYCOMMAND | _win32._const._MF_ENABLED);
  65.                 _win32.ShowWindow(objWindows['Preferences'].GetControlHandle('BaseBtnCancel'), _win32._const._SW_SHOW);
  66.         /* End : Enabling Close menu */
  67.        
  68.         if (bSuccess == true) {
  69.                 _win32.MessageBoxW(tWndFtp.Handle, sReplace(
  70.                                 _lang.text['MsgBoxFtpSuccess'],
  71.                                 [sServer, tWndFtp.GetControlText('tFtpPort'), tWndFtp.GetControlText('tFtpLogin')]
  72.                         ), _lang.text['MsgBoxFtpSuccess_Title'], 32);
  73.         } else {
  74.                 _win32.MessageBoxW(tWndFtp.Handle, sReplace(
  75.                                 _lang.text['MsgBoxFtpFailed'],
  76.                                 [sServer, tWndFtp.GetControlText('tFtpPort'), tWndFtp.GetControlText('tFtpLogin')]
  77.                         ), _lang.text['MsgBoxFtpFailed_Title'], 32);
  78.         }
  79. }
  80.  
  81. function Ftp_UploadFileComplete(bSuccess, sSource) {
  82.         _debug.getfuncname(arguments);
  83.         sSource = SessionImages.GetFilename(sSource);
  84.         Ftp_SendLink(oFtpChatWnd[sSource].pChatWnd, oFtpChatWnd[sSource].sFilename);
  85. }
  86.  
  87. function Ftp_InitiateFileTransferOnIdle() {
  88.         _debug.getfuncname(arguments);
  89.         if (objPreferences['cUploadFilesWhenIdle']) {
  90.                 for (var i in oFilesToFtp) {
  91.                         Ftp_UploadFile(oFilesToFtp[0]);
  92.                         oFilesToFtp.shift();
  93.                 }
  94.         }
  95. }
  96.  
  97. function Ftp_SendLink(pChatWnd, sFile) {
  98.         _debug.getfuncname(arguments);
  99.         if (objPreferences['cSendUploadLink'] == false || !pChatWnd.EditChangeAllowed) return;
  100.  
  101.         pChatWnd.SendMessage(objPreferences['tSendLink']+sFile);
  102. }

Version

  • 5.0.0070_20100325_publicbeta1

Developers

Project Details

  • Folders8
  • Files122
  • Total Lines11,867
  • Repository Version70

User Count

  • 162