#include "dolphinapplication.h"
#include "dolphinmainwindow.h"
-#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include <krun.h>
+#include <QDBusInterface>
+#include <QDBusReply>
static KCmdLineOptions options[] =
{
KCmdLineLastOption
};
+void openWindow(DolphinApplication* app, const QString& url = QString())
+{
+ if (app != 0) {
+ app->openWindow(url);
+ return;
+ }
+
+ static QDBusInterface dbusIface("org.kde.dolphin", "/dolphin/Application", "",
+ QDBusConnection::connectToBus(QDBusConnection::SessionBus, "session_bus"));
+ QDBusReply<int> reply = dbusIface.call("openWindow", url);
+}
+
int main(int argc, char **argv)
{
KAboutData about("dolphin",
KCmdLineArgs::init(argc, argv, &about);
KCmdLineArgs::addCmdLineOptions(options);
-
- DolphinApplication app;
+ DolphinApplication *app = 0;
+ if (DolphinApplication::start()) {
+ app = new DolphinApplication();
+ }
#warning TODO, SessionManagement
} else {
#endif
- KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
- if (args->count() > 0) {
- for (int i = 0; i < args->count(); ++i) {
- DolphinMainWindow *win = app.createMainWindow();
- win->activeView()->setUrl(args->url(i));
- win->show();
- }
- } else {
- DolphinMainWindow* mainWin = app.createMainWindow();
- mainWin->show();
+ KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
+ if (args->count() > 0) {
+ for (int i = 0; i < args->count(); ++i) {
+ openWindow(app, args->arg(i));
}
- args->clear();
-
- return app.exec();
+ }
+ else {
+ openWindow(app);
+ }
+ args->clear();
+ if (app != 0) {
+ return app->exec();
+ }
}