Bug 114840 - open url's with "kftpgrabber ftp://someFTP/"
Summary: open url's with "kftpgrabber ftp://someFTP/"
Status: RESOLVED FIXED
Alias: None
Product: kftpgrabber
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Jernej Kos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-21 22:16 UTC by Yaroslav Sidlovsky
Modified: 2006-08-24 15:40 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yaroslav Sidlovsky 2005-10-21 22:16:03 UTC
Version:           0.7.0-beta1 (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources

it will be useful kftpgrabber to open url's
with command "kftpgrabber ftp://someFTP/"
(to open ftp servers with kftpgrabber from firefox/mozilla/konqueror)
Comment 1 Jernej Kos 2006-08-24 15:40:23 UTC
SVN commit 576644 by kostko:

Added support for passing an URL via the command line.

FEATURE: 114840

 M  +8 -4      kftpsession.cpp  
 M  +30 -7     main.cpp  


--- trunk/extragear/network/kftpgrabber/src/kftpsession.cpp #576643:576644
@@ -703,11 +703,15 @@
     return spawnLocalSession(side);
 
   if ((session = find(remoteUrl, mustUnlock)) == 0L || (session->m_side != side && side != IGNORE_SIDE)) {
-    // Try to find the session that was last connected to this URL and
-    // if that fails, spawn a new one.
+    // Try to find the session that was last connected to this URL
     if ((session = findLast(remoteUrl, side)) == 0L) {
-      side = side == IGNORE_SIDE ? RIGHT_SIDE : side;
-      session = new KFTPSession(side);
+      // Attempt to reuse a local session if one exists one the right side
+      session = getActive(RIGHT_SIDE);
+      
+      if (session->isRemote()) {
+        side = side == IGNORE_SIDE ? RIGHT_SIDE : side;
+        session = new KFTPSession(side);
+      }
     }
   
     // Try to find the site by url if it is not set
--- trunk/extragear/network/kftpgrabber/src/main.cpp #576643:576644
@@ -48,6 +48,8 @@
 #include <dcopclient.h>
 #include "kftpgrabberiface.h"
 
+#include "kftpsession.h"
+
 static const char description[] =
     I18N_NOOP("KFTPGrabber - an FTP client for KDE");
 
@@ -55,6 +57,7 @@
 
 static KCmdLineOptions options[] =
 {
+    { "+[url]", I18N_NOOP("An optional URL to connect to"), 0},
     KCmdLineLastOption
 };
 
@@ -79,7 +82,6 @@
     KCmdLineArgs::init(argc, argv, &about);
     KCmdLineArgs::addCmdLineOptions(options);
     KApplication app;
-    KFTPGrabber *mainWin = 0;
 
     // Create our DCOP client
     kapp->dcopClient()->setDefaultObject((new KFTPGrabberIface())->objId());
@@ -87,7 +89,7 @@
     if (app.isRestored()) {
       RESTORE(KFTPGrabber);
     } else {
-      // no session.. just start up normally
+      KFTPGrabber *mainWindow = 0;
       KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
       KSplashScreen *splash = 0L;
@@ -102,21 +104,42 @@
         }
       }
       
-      mainWin = new KFTPGrabber();
-      app.setMainWidget( mainWin );
+      mainWindow = new KFTPGrabber();
+      app.setMainWidget(mainWindow);
       
       if (!KFTPCore::Config::startMinimized())
-        mainWin->show();
+        mainWindow->show();
         
+      // Check if an URL was passed as a command line argument
+      if (args->count() == 1) {
+        KURL remoteUrl = args->url(0);
+        
+        if (!remoteUrl.isLocalFile()) {
+          if (!remoteUrl.port())
+            remoteUrl.setPort(21);
+            
+          if (!remoteUrl.hasUser())
+            remoteUrl.setUser("anonymous");
+            
+          if (!remoteUrl.hasPass()) {
+            if (!KFTPCore::Config::anonMail().isEmpty())
+              remoteUrl.setPass(KFTPCore::Config::anonMail());
+            else
+              remoteUrl.setPass("userlogin@anonymo.us");
+          }
+
+          FTPSessionManager->spawnRemoteSession(IGNORE_SIDE, remoteUrl);
+        }
+      }
+        
       if (splash != 0L) {
-        splash->finish(mainWin);
+        splash->finish(mainWindow);
         delete splash;
       }
       
       args->clear();
     }
     
-    // mainWin has WDestructiveClose flag by default, so it will delete itself.
     return app.exec();
 }