| Summary: | open url's with "kftpgrabber ftp://someFTP/" | ||
|---|---|---|---|
| Product: | [Unmaintained] kftpgrabber | Reporter: | Yaroslav Sidlovsky <zawertun> |
| Component: | general | Assignee: | Jernej Kos <kostko> |
| Status: | RESOLVED FIXED | ||
| Severity: | wishlist | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Compiled Sources | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Yaroslav Sidlovsky
2005-10-21 22:16:03 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();
}
|