Bug 107243

Summary: aKregator -a command doesn't work with an existing aKregator session
Product: [Applications] akregator Reporter: Mamading Ceesay <mamading>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Mamading Ceesay 2005-06-12 02:57:48 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    Debian testing/unstable Packages
Compiler:          gcc (GCC) 3.3.6 (Debian 1:3.3.6-5) 
OS:                Linux

Quit akregator then run akregator -a <url> where url is a valid feed.  Akregator will be started and the new feed will be added successfully.

Leave akregator running, and run akregator -a <newurl> where newurl is a valid feed. Akregator will flash, come to foreground but the second new feed will not be added.
Comment 1 Eckhart Wörner 2005-06-12 10:27:21 UTC
Confirmed.

A simple workaround until this bug has been fixed would be a DCOP call:

akregator && dcop akregator AkregatorIface addFeed "<newurl>"
Comment 2 Eckhart Wörner 2005-06-12 14:25:51 UTC
The above mentioned DCOP call is only present in SVN (thanks to randomaccess for pointing out).
Comment 3 Eckhart Wörner 2005-06-12 15:08:21 UTC
Well, forget everything about this workaround - it simply cannot work, but is totally crap. Thanks to myself for pointing this out ;-)
Comment 4 Mamading Ceesay 2005-06-12 16:10:39 UTC
A workaround that I've tested as working is as follows:

dcop akregator AkregatorIface addFeedsToGroup [ "<newurl" ] Imported

I generally have akregator running, so I don't bother with the "akregator &&" bit.
Comment 5 Heinrich Wendel 2005-06-23 23:35:19 UTC
i vote for removing the commandline argument, and adding a defaultgroup to addFeedsToGroup
Comment 6 Heinrich Wendel 2005-06-23 23:49:26 UTC
this should fix it, not tested though

--- main.cpp.orig  2005-06-19 22:33:13.000000000 +0200
+++ main.cpp    2005-06-23 23:44:21.000000000 +0200
@@ -69,6 +69,7 @@
             return 1;
         mainwin->setupProgressWidgets();
         mainwin->show();
+    }


         DCOPRef akr("akregator", "AkregatorIface");
@@ -86,7 +87,6 @@
             akr.send("addFeedsToGroup", feedsToAdd, addFeedGroup );

         args->clear();
-    }

     return app.exec();
 }
Comment 7 Heinrich Wendel 2005-06-27 19:14:12 UTC
SVN commit 429428 by lanius:

cleanup main.cpp, make it look like e.g. kaddressbook/kontact
BUG: 107243

 M  +58 -43    main.cpp  


--- trunk/KDE/kdepim/akregator/src/main.cpp #429427:429428
@@ -27,7 +27,6 @@
 #include <dcopref.h>
 #include <kcmdlineargs.h>
 #include <klocale.h>
-#include <kdebug.h>
 #include <knotifyclient.h>
 #include <kuniqueapplication.h>
 
@@ -35,58 +34,74 @@
 #include "mainwindow.h"
 #include "akregator_options.h"
 
+class AkregatorApp : public KUniqueApplication {
+  public:
+    AkregatorApp() : mMainWindow( 0 ) {}
+    ~AkregatorApp() {}
 
+    int newInstance();
+
+  private:
+    Akregator::MainWindow *mMainWindow;
+};
+
+int AkregatorApp::newInstance()
+{
+  DCOPRef akr("akregator", "AkregatorIface");
+
+  if ( isRestored() ) {
+    if ( KMainWindow::canBeRestored( 1 ) ) {
+      mMainWindow = new Akregator::MainWindow();
+      setMainWidget( mMainWindow );
+      mMainWindow->show();
+      mMainWindow->restore( 1 );
+    }
+  } else {
+    if ( !mMainWindow ) {
+      mMainWindow = new Akregator::MainWindow();
+      setMainWidget( mMainWindow );
+      mMainWindow->loadPart();
+      mMainWindow->setupProgressWidgets();
+      mMainWindow->show();
+      akr.send("openStandardFeedList");
+    }
+
+    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+    QString addFeedGroup = !args->getOption("group").isEmpty() ? args->getOption("group") : i18n("Imported Folder");
+
+    QCStringList feeds = args->getOptionList("addfeed");
+    QStringList feedsToAdd;
+    for (QCStringList::ConstIterator it = feeds.begin(); it != feeds.end(); ++it)
+        feedsToAdd.append(*it);
+
+    if (!feedsToAdd.isEmpty())
+        akr.send("addFeedsToGroup", feedsToAdd, addFeedGroup );
+
+    args->clear();
+  }
+
+  return KUniqueApplication::newInstance();
+} 
+
 int main(int argc, char **argv)
 {
     Akregator::AboutData about;
     KCmdLineArgs::init(argc, argv, &about);
     KCmdLineArgs::addCmdLineOptions( Akregator::akregator_options );
-    KUniqueApplication app;
-    
+    KUniqueApplication::addCmdLineOptions();
+
     // start knotifyclient if not already started. makes it work for people who doesn't use full kde, according to kmail devels
     KNotifyClient::startDaemon();
 
-    // see if we are starting with session management
-    if (app.isRestored())
-    {
-#undef RESTORE
-#define RESTORE(type) { int n = 1;\
-    while (KMainWindow::canBeRestored(n)){\
-        (new type)->restore(n, false);\
-            n++;}}
+    if(!AkregatorApp::start())
+      return 0;
 
-        RESTORE(Akregator::MainWindow);
-    }
-    else
-    {
-        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+    AkregatorApp app;
 
-        Akregator::MainWindow* mainwin = new Akregator::MainWindow();
+    bool ret = app.exec();
+    while ( KMainWindow::memberList->first() )
+        delete KMainWindow::memberList->first();
 
-        app.setMainWidget(mainwin);
-
-        if (mainwin->loadPart() == false)
-            return 1;
-        mainwin->setupProgressWidgets();
-        mainwin->show();  
-
-    
-        DCOPRef akr("akregator", "AkregatorIface");
-        
-        akr.send("openStandardFeedList");
-     
-        QString addFeedGroup = !args->getOption("group").isEmpty() ? args->getOption("group") : i18n("Imported Folder");
-        
-        QCStringList feeds = args->getOptionList("addfeed");
-        QStringList feedsToAdd;
-        for (QCStringList::ConstIterator it = feeds.begin(); it != feeds.end(); ++it)
-            feedsToAdd.append(*it);
-        
-        if (!feedsToAdd.isEmpty())
-            akr.send("addFeedsToGroup", feedsToAdd, addFeedGroup );
-
-        args->clear();
-    }
-
-    return app.exec();
+    return ret;
 }