akregator/src
main.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <qstringlist.h>
00026
00027 #include <dcopref.h>
00028 #include <kcmdlineargs.h>
00029 #include <klocale.h>
00030 #include <knotifyclient.h>
00031 #include <kuniqueapplication.h>
00032
00033 #include "aboutdata.h"
00034 #include "mainwindow.h"
00035 #include "akregator_options.h"
00036
00037 namespace Akregator {
00038
00039 class Application : public KUniqueApplication {
00040 public:
00041 Application() : mMainWindow( ) {}
00042 ~Application() {}
00043
00044 int newInstance();
00045
00046 private:
00047 Akregator::MainWindow *mMainWindow;
00048 };
00049
00050 int Application::newInstance()
00051 {
00052 if (!isRestored())
00053 {
00054 DCOPRef akr("akregator", "AkregatorIface");
00055
00056 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00057
00058 if ( !mMainWindow ) {
00059 mMainWindow = new Akregator::MainWindow();
00060 setMainWidget( mMainWindow );
00061 mMainWindow->loadPart();
00062 mMainWindow->setupProgressWidgets();
00063 if (!args->isSet("hide-mainwindow"))
00064 mMainWindow->show();
00065 akr.send("openStandardFeedList");
00066 }
00067
00068 QString addFeedGroup = !args->getOption("group").isEmpty()
00069 ? QString::fromLocal8Bit(args->getOption("group"))
00070 : i18n("Imported Folder");
00071
00072 QCStringList feeds = args->getOptionList("addfeed");
00073 QStringList feedsToAdd;
00074 QCStringList::ConstIterator end( feeds.end() );
00075 for (QCStringList::ConstIterator it = feeds.begin(); it != end; ++it)
00076 feedsToAdd.append(*it);
00077
00078 if (!feedsToAdd.isEmpty())
00079 akr.send("addFeedsToGroup", feedsToAdd, addFeedGroup );
00080
00081 args->clear();
00082 }
00083 return KUniqueApplication::newInstance();
00084 }
00085
00086 }
00087
00088 int main(int argc, char **argv)
00089 {
00090 Akregator::AboutData about;
00091 KCmdLineArgs::init(argc, argv, &about);
00092 KCmdLineArgs::addCmdLineOptions( Akregator::akregator_options );
00093 KUniqueApplication::addCmdLineOptions();
00094
00095 Akregator::Application app;
00096
00097
00098 KNotifyClient::startDaemon();
00099
00100
00101 if (app.isRestored())
00102 {
00103 #undef RESTORE
00104 #define RESTORE(type) { int n = 1;\
00105 while (KMainWindow::canBeRestored(n)){\
00106 (new type)->restore(n, false);\
00107 n++;}}
00108
00109 RESTORE(Akregator::MainWindow);
00110 }
00111
00112 return app.exec();
00113 }
00114
00115
|