[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [PATCH] khtml/konqueror download manager integration
From:       Rainer Wirtz <rainer.wirtz () gmx ! de>
Date:       2005-01-29 22:13:27
Message-ID: 200501292313.27321.rainer.wirtz () gmx ! de
[Download RAW message or body]

This patch makes konqueror behave consistent with respect to download 
manager integration. ATM when using RMB->save link as; RMB->save image 
as or <shift>+LMB then konquerors file dialog is opened and the chosen 
filename is handed to the download manager. Using LMB->save as (in the 
open with|save as|cancel dialog) opens the DLMs file dialog directly.
IMO in all those cases the DLMs file dialog should be used to make use 
of features like default folders etc.
This patch accomplishes this. Apply from within kdelibs/khtml

Rainer

["khtml_DLM_integration.diff" (text/x-diff)]

diff -U 3 -H -d -r -N -x .libs -x .deps -x '*.a' -x '*.o' -x '*.moc' -x '*.lo' -x \
                '*~' -- khtml.orig/khtml_ext.cpp khtml/khtml_ext.cpp
--- khtml.orig/khtml_ext.cpp	2005-01-29 05:30:21.000000000 +0100
+++ khtml/khtml_ext.cpp	2005-01-29 05:32:38.000000000 +0100
@@ -575,7 +575,7 @@
 {
   KIO::MetaData metaData;
   metaData["referrer"] = d->m_khtml->referrer();
-  saveURL( d->m_khtml->widget(), i18n( "Save Link As" ), d->m_url, metaData );
+  saveURLbyDLM( d->m_khtml->widget(), i18n( "Save Link As" ), d->m_url, metaData );
 }
 
 void KHTMLPopupGUIClient::slotSendImage()
@@ -595,7 +595,7 @@
 {
   KIO::MetaData metaData;
   metaData["referrer"] = d->m_khtml->referrer();
-  saveURL( d->m_khtml->widget(), i18n( "Save Image As" ), d->m_imageURL, metaData, \
QString::null, 0, d->m_suggestedFilename ); +  saveURLbyDLM( d->m_khtml->widget(), \
i18n( "Save Image As" ), d->m_imageURL, metaData, QString::null, 0, \
d->m_suggestedFilename );  }
 
 void KHTMLPopupGUIClient::slotCopyLinkLocation()
@@ -694,6 +694,56 @@
   emit d->m_khtml->browserExtension()->createNewWindow( d->m_khtml->url(), args );
 }
 
+void KHTMLPopupGUIClient::saveURLbyDLM( QWidget *parent, const QString &caption,
+                                   const KURL &url,
+                                   const QMap<QString, QString> &metadata,
+                                   const QString &filter, long cacheId,
+                                   const QString & suggestedFilename )
+{
+        // DownloadManager <-> konqueror integration
+        // find if the integration is enabled
+        // the empty key  means no integration
+        // only use download manager for non-local urls!
+
+    if ( !url.isLocalFile() )
+    {
+        KConfig cfg("konquerorrc", false, false);
+        cfg.setGroup("HTML Settings");
+        QString downloadManger = cfg.readPathEntry("DownloadManager");
+        if (!downloadManger.isEmpty())
+        {
+                // then find the download manager location
+            kdDebug(1000) << "Using: "<<downloadManger <<" as Download Manager" \
<<endl; +            QString cmd = KStandardDirs::findExe(downloadManger);
+            if (cmd.isEmpty())
+            {
+                QString errMsg=i18n("The Download Manager (%1) could not be found in \
your $PATH ").arg(downloadManger); +                QString errMsgEx= i18n("Try to \
reinstall it  \n\nThe integration with Konqueror will be disabled!"); +               \
KMessageBox::detailedSorry(0,errMsg,errMsgEx); +                \
cfg.writePathEntry("DownloadManager",QString::null); +                cfg.sync ();
+            }
+            else
+            {
+                KURL _url = url;
+                if ( url.fileName( false ).isEmpty() )
+                {
+                    _url.addPath ("index.html");
+                    QString d_url=_url.prettyURL();
+                    kdDebug()<<"saveURLbyDLM URL = "<<d_url<<endl;
+
+                }
+                cmd += " " + KProcess::quote(_url.url());
+                kdDebug(1000) << "Calling command  "<<cmd<<endl;
+                KRun::runCommand(cmd);
+                return;
+            }
+        }
+    } //end if ( !url.isLocalFile() )
+
+    saveURL ( parent, caption, url, metadata, filter, cacheId, suggestedFilename);
+}
+
 void KHTMLPopupGUIClient::saveURL( QWidget *parent, const QString &caption,
                                    const KURL &url,
                                    const QMap<QString, QString> &metadata,
@@ -760,50 +810,11 @@
         }
         if(!saved)
         {
-          // DownloadManager <-> konqueror integration
-          // find if the integration is enabled
-          // the empty key  means no integration
-          // only use download manager for non-local urls!
-          bool downloadViaKIO = true;
-          if ( !url.isLocalFile() )
-          {
-            KConfig cfg("konquerorrc", false, false);
-            cfg.setGroup("HTML Settings");
-            QString downloadManger = cfg.readPathEntry("DownloadManager");
-            if (!downloadManger.isEmpty())
-            {
-                // then find the download manager location
-                kdDebug(1000) << "Using: "<<downloadManger <<" as Download Manager" \
                <<endl;
-                QString cmd = KStandardDirs::findExe(downloadManger);
-                if (cmd.isEmpty())
-                {
-                    QString errMsg=i18n("The Download Manager (%1) could not be \
                found in your $PATH ").arg(downloadManger);
-                    QString errMsgEx= i18n("Try to reinstall it  \n\nThe integration \
                with Konqueror will be disabled!");
-                    KMessageBox::detailedSorry(0,errMsg,errMsgEx);
-                    cfg.writePathEntry("DownloadManager",QString::null);
-                    cfg.sync ();
-                }
-                else
-                {
-                    downloadViaKIO = false;
-                    KURL cleanDest = destURL;
-                    cleanDest.setPass( QString::null ); // don't put password into \
                commandline
-                    cmd += " " + KProcess::quote(url.url()) + " " +
-                           KProcess::quote(cleanDest.url());
-                    kdDebug(1000) << "Calling command  "<<cmd<<endl;
-                    KRun::runCommand(cmd);
-                }
-            }
-          }
-
-          if ( downloadViaKIO )
-          {
-              KIO::Job *job = KIO::file_copy( url, destURL, -1, true /*overwrite*/ \
                );
-              job->setMetaData(metadata);
-              job->addMetaData("MaxCacheSize", "0"); // Don't store in http cache.
-              job->addMetaData("cache", "cache"); // Use entry from cache if \
                available.
-              job->setAutoErrorHandlingEnabled( true );
-          }
+            KIO::Job *job = KIO::file_copy( url, destURL, -1, true /*overwrite*/ );
+            job->setMetaData(metadata);
+            job->addMetaData("MaxCacheSize", "0"); // Don't store in http cache.
+            job->addMetaData("cache", "cache"); // Use entry from cache if \
available. +            job->setAutoErrorHandlingEnabled( true );
         } //end if(!saved)
     }
 }
diff -U 3 -H -d -r -N -x .libs -x .deps -x '*.a' -x '*.o' -x '*.moc' -x '*.lo' -x \
                '*~' -- khtml.orig/khtml_ext.h khtml/khtml_ext.h
--- khtml.orig/khtml_ext.h	2005-01-28 03:36:11.000000000 +0100
+++ khtml/khtml_ext.h	2005-01-29 03:06:02.000000000 +0100
@@ -123,6 +123,12 @@
                        const QString &filter = QString::null, long cacheId = 0,
                        const QString &suggestedFilename = QString::null );
 
+  // To save via Downloadmanager
+  static void saveURLbyDLM( QWidget *parent, const QString &caption, const KURL \
&url, +                       const QMap<QString, QString> &metaData = \
KIO::MetaData(), +                       const QString &filter = QString::null, long \
cacheId = 0, +                       const QString &suggestedFilename = QString::null \
); +
   static void saveURL( const KURL &url, const KURL &destination,
                        const QMap<QString, QString> &metaData = KIO::MetaData(),
                        long cacheId = 0 );
diff -U 3 -H -d -r -N -x .libs -x .deps -x '*.a' -x '*.o' -x '*.moc' -x '*.lo' -x \
                '*~' -- khtml.orig/khtml_part.cpp khtml/khtml_part.cpp
--- khtml.orig/khtml_part.cpp	2005-01-28 03:36:22.000000000 +0100
+++ khtml/khtml_part.cpp	2005-01-29 03:06:02.000000000 +0100
@@ -3666,7 +3666,7 @@
   {
     KIO::MetaData metaData;
     metaData["referrer"] = d->m_referrer;
-    KHTMLPopupGUIClient::saveURL( d->m_view, i18n( "Save As" ), cURL, metaData );
+    KHTMLPopupGUIClient::saveURLbyDLM( d->m_view, i18n( "Save As" ), cURL, metaData \
);  return;
   }
 
@@ -4173,7 +4173,7 @@
         url, mimetype, suggestedFilename  );
       switch( res ) {
       case KParts::BrowserRun::Save:
-        KHTMLPopupGUIClient::saveURL( widget(), i18n( "Save As" ), url, \
child->m_args.metaData(), QString::null, 0, suggestedFilename); +        \
KHTMLPopupGUIClient::saveURLbyDLM( widget(), i18n( "Save As" ), url, \
child->m_args.metaData(), QString::null, 0, suggestedFilename);  // fall-through
       case KParts::BrowserRun::Cancel:
         child->m_bCompleted = true;



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic