Bug 122476

Summary: When uploading existing files, "auto skip" and "overwrite all" should be possible
Product: [Applications] kftpgrabber Reporter: Christoph Tavan <chefturner>
Component: generalAssignee: Jernej Kos <kostko>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Christoph Tavan 2006-02-22 12:02:10 UTC
Version:           0.6.0 (using KDE KDE 3.5.0KDE 3.4.2)
Installed from:    Gentoo PackagesGentoo Packages
OS:                Linux

The Dialog that appears, when an existing File is uploaded, should be extended to meet the Konqueror-style and -functionality:
1.) The Resume-button should be named "Skip" just like in Konqueror.
2.) Buttons should be re-ordered: Rename, Skip, Overwrite and NOT Rename, Overwrite, Resume
3.) Two additional buttons should be provided: "Auto Skip" and "Overwrite All"
4.) The dialog's title should read "File Already Exists" and NOT "File Exists"

--> Simply make the dialog completely look like in konqueror to unify kde look&feel.
Comment 1 Jernej Kos 2006-02-22 12:56:55 UTC
KFTPGrabber is using the "file exists" dialog from kdelibs (KIO::RenameDlg), so it should be up to standards :)
Comment 2 Jernej Kos 2006-02-22 12:58:57 UTC
Also, resume is not skip. Resume will continue transfering a file (if previous transfer was interrupted somewhere in the middle), while skip (or cancel in this case) will go on to the next file and not download the file at all.
Comment 3 Christoph Tavan 2006-02-23 20:08:24 UTC
Ah OK, I got the difference between "Resume" and "Skip", thanks. For the other point I probably got to be more precise:

When I put let's say 5 files into KFTPGrabber's queue and then start the transfer, every file in the queue is treated as a single file and accordingly there are no options like "Overwrite all" in the RenameDlg.
So what KFTPGrabber does, is as if I would select and copy any of my 5 files in Konqueror one by one.

Now IMHO it would be great, if KFTPGrabber would treat the queue as a whole. That would be just like selecting ALL 5 files in Konqueror and copying them at a time. So in this case "Skip", "Auto skip" and "Overwrite all"-Buttons would really make sense!
Because when I upload a new version of my website it's really an annoying task, to click "Overwrite" for every single file. And deleting all existing files beforehand is no satisfying solution neither...

I hope you got my point, sorry for my horrible English!
Comment 4 Jernej Kos 2006-02-23 20:22:36 UTC
Well, you can set global queue actions in the configuration (look under Actions in 0.7.0-beta1). However I see your point and these additional buttons will be added in the next release (that is when i have some time to implement it).
Comment 5 Jernej Kos 2006-08-23 20:27:46 UTC
SVN commit 576297 by kostko:

Added "Resume all", "Overwrite all" and "Skip all" options to the "on file exists" dialog.

FEATURE: 122476

 M  +1 -0      kftpfileexistsactions.h  
 M  +52 -41    kftpqueue.cpp  
 M  +22 -3     kftpqueue.h  
 M  +3 -0      widgets/queueview/queueview.cpp  


--- trunk/extragear/network/kftpgrabber/src/kftpfileexistsactions.h #576296:576297
@@ -48,6 +48,7 @@
 namespace KFTPQueue {
 
 enum FEAction {
+  FE_DISABLE_ACT = -1,
   FE_SKIP_ACT = 0,
   FE_OVERWRITE_ACT = 1,
   FE_RESUME_ACT = 2,
--- trunk/extragear/network/kftpgrabber/src/kftpqueue.cpp #576296:576297
@@ -200,7 +200,8 @@
 
 Manager::Manager()
   : m_topLevel(new QueueObject(this, QueueObject::Toplevel)),
-    m_processingQueue(false)
+    m_processingQueue(false),
+    m_defaultFeAction(FE_DISABLE_ACT)
 {
   m_topLevel->setId(0);
   
@@ -350,6 +351,9 @@
   if (KFTPCore::Config::lowercaseDownload() && t_type == Download) {
     dstURL.setPath(dstURL.directory() + "/" + dstURL.fileName().lower());
   }
+  
+  // Reset a possible preconfigured default action
+  setDefaultFileExistsAction();
 
   if (!parent)
     parent = this;
@@ -631,66 +635,70 @@
 {
   FileExistsWakeupEvent *event = new FileExistsWakeupEvent();
   FileExistsActions *fa = NULL;
+  FEAction action;
   
-  // File infos
   filesize_t srcSize = 0;
   time_t srcTime = 0;
   
   filesize_t dstSize = 0;
   time_t dstTime = 0;
   
-  switch (transfer->getTransferType()) {
-    case KFTPQueue::Download: {
-      KFileItem info(KFileItem::Unknown, KFileItem::Unknown, transfer->getDestUrl());
-      dstSize = info.size();
-      dstTime = info.time(KIO::UDS_MODIFICATION_TIME);
-      
-      srcSize = stat[0].size();
-      srcTime = stat[0].time();
-      
-      fa = KFTPCore::Config::self()->dActions();
-      break;
+  // Check if there is a default action set
+  action = Manager::self()->getDefaultFileExistsAction();
+  
+  if (action == FE_DISABLE_ACT) {
+    switch (transfer->getTransferType()) {
+      case KFTPQueue::Download: {
+        KFileItem info(KFileItem::Unknown, KFileItem::Unknown, transfer->getDestUrl());
+        dstSize = info.size();
+        dstTime = info.time(KIO::UDS_MODIFICATION_TIME);
+        
+        srcSize = stat[0].size();
+        srcTime = stat[0].time();
+        
+        fa = KFTPCore::Config::self()->dActions();
+        break;
+      }
+      case KFTPQueue::Upload: {
+        KFileItem info(KFileItem::Unknown, KFileItem::Unknown, transfer->getSourceUrl());
+        srcSize = info.size();
+        srcTime = info.time(KIO::UDS_MODIFICATION_TIME);
+        
+        dstSize = stat[0].size();
+        dstTime = stat[0].time();
+        
+        fa = KFTPCore::Config::self()->uActions();
+        break;
+      }
+      case KFTPQueue::FXP: {
+        srcSize = stat[0].size();
+        srcTime = stat[0].time();
+        
+        dstSize = stat[1].size();
+        dstTime = stat[1].time();
+        
+        fa = KFTPCore::Config::self()->fActions();
+        break;
+      }
     }
-    case KFTPQueue::Upload: {
-      KFileItem info(KFileItem::Unknown, KFileItem::Unknown, transfer->getSourceUrl());
-      srcSize = info.size();
-      srcTime = info.time(KIO::UDS_MODIFICATION_TIME);
-      
-      dstSize = stat[0].size();
-      dstTime = stat[0].time();
-      
-      fa = KFTPCore::Config::self()->uActions();
-      break;
-    }
-    case KFTPQueue::FXP: {
-      srcSize = stat[0].size();
-      srcTime = stat[0].time();
-      
-      dstSize = stat[1].size();
-      dstTime = stat[1].time();
-      
-      fa = KFTPCore::Config::self()->fActions();
-      break;
-    }
+    
+    // Now that we have all data, get the action and do it
+    action = fa->getActionForSituation(srcSize, srcTime, dstSize, dstTime);
   }
   
-  // Now that we have all data, get the action and do it
-  FEAction action = fa->getActionForSituation(srcSize, srcTime, dstSize, dstTime);
-  
   switch (action) {
+    default:
     case FE_SKIP_ACT: event->action = FileExistsWakeupEvent::Skip; break;
     case FE_OVERWRITE_ACT: event->action =  FileExistsWakeupEvent::Overwrite; break;
     case FE_RESUME_ACT: event->action =  FileExistsWakeupEvent::Resume; break;
-    case FE_RENAME_ACT: {
-      // TODO implement auto rename action
-    }
+    case FE_RENAME_ACT:
     case FE_USER_ACT: {
       QString newDestPath;
       KIO::RenameDlg_Result r = KIO::open_RenameDlg(
         i18n("File Exists"),
         transfer->getSourceUrl().prettyURL(),
         transfer->getDestUrl().prettyURL(),
-        (KIO::RenameDlg_Mode) (KIO::M_OVERWRITE | KIO::M_RESUME | KIO::M_SKIP),
+        (KIO::RenameDlg_Mode) (KIO::M_OVERWRITE | KIO::M_RESUME | KIO::M_SKIP | KIO::M_MULTI),
         newDestPath,
         srcSize,
         dstSize,
@@ -708,9 +716,12 @@
           event->newFileName = newDestPath;
           break;
         }
+        case KIO::R_AUTO_SKIP: Manager::self()->setDefaultFileExistsAction(FE_SKIP_ACT);
         case KIO::R_SKIP:
         case KIO::R_CANCEL: event->action = FileExistsWakeupEvent::Skip; break;
+        case KIO::R_RESUME_ALL: Manager::self()->setDefaultFileExistsAction(FE_RESUME_ACT);
         case KIO::R_RESUME: event->action = FileExistsWakeupEvent::Resume; break;
+        case KIO::R_OVERWRITE_ALL: Manager::self()->setDefaultFileExistsAction(FE_OVERWRITE_ACT);
         default: event->action = FileExistsWakeupEvent::Overwrite; break;
       }
     }
--- trunk/extragear/network/kftpgrabber/src/kftpqueue.h #576296:576297
@@ -49,6 +49,7 @@
 
 #include "kftpqueueprocessor.h"
 #include "kftpqueueconverter.h"
+#include "kftpfileexistsactions.h"
 #include "misc.h"
 
 #include "engine/directorylisting.h"
@@ -350,9 +351,25 @@
     long nextTransferId() { return m_lastQID++; }
     
     /**
-     * Decides what to do with the existing file. It will return a valid KIO action to
-     * take. It will first consider the pre-configured "on file exists" action matrix.
+     * Set a default action to take when encountering an existing file situation. Note that
+     * the action set here will override any preconfigured user actions unless set to the
+     * value of FE_DISABLE_ACT.
      *
+     * @param action The action to take
+     */
+    void setDefaultFileExistsAction(FEAction action = FE_DISABLE_ACT) { m_defaultFeAction = action; }
+    
+    /**
+     * Get the default action preset for situations where a file already exists.
+     *
+     * @return A valid FEAction
+     */
+    FEAction getDefaultFileExistsAction() { return m_defaultFeAction; }
+    
+    /**
+     * Decides what to do with the existing file. It will return a valid wakeup event to
+     * dispatch. It will first consider the pre-configured "on file exists" action matrix.
+     *
      * @param transfer The transfer object
      * @param srcStat Source file information (if remote)
      * @param dstStat Destination file information (if remote)
@@ -360,7 +377,7 @@
      */
     static KFTPEngine::FileExistsWakeupEvent *fileExistsAction(KFTPQueue::TransferFile *transfer,
                                                                QValueList<KFTPEngine::DirectoryEntry> stat);
-                                
+    
     KFTPQueue::Transfer *spawnTransfer(KURL srcURL, KURL dstURL, filesize_t size, bool dir, KFTPQueue::TransferType t_type, 
                                        bool ignoreSkip = false, bool insertToQueue = true, QObject *parent = 0L, bool noScan = false);
 protected:
@@ -381,6 +398,8 @@
 
     filesize_t m_curDownSpeed;
     filesize_t m_curUpSpeed;
+    
+    FEAction m_defaultFeAction;
 private slots:
     void slotQueueProcessingComplete();
     void slotQueueProcessingAborted();
--- trunk/extragear/network/kftpgrabber/src/widgets/queueview/queueview.cpp #576296:576297
@@ -551,6 +551,9 @@
 
 void QueueView::slotLaunch()
 {
+  // Reset a possible preconfigured default action
+  KFTPQueue::Manager::self()->setDefaultFileExistsAction();
+  
   static_cast<QueueViewItem*>(m_queue->selectedItems().first())->getObject()->execute();
 }