akregator/src

main.cpp
1/*
2 This file is part of Akregator.
3
4 Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of TQt, and distribute the resulting executable,
22 without including the source code for TQt in the source distribution.
23*/
24
25#include <tqstringlist.h>
26
27#include <dcopref.h>
28#include <tdecmdlineargs.h>
29#include <tdelocale.h>
30#include <knotifyclient.h>
31#include <tdeuniqueapplication.h>
32
33#include "aboutdata.h"
34#include "mainwindow.h"
35#include "akregator_options.h"
36
37namespace Akregator {
38
39class Application : public TDEUniqueApplication {
40 public:
41 Application() : mMainWindow( ) {}
42 ~Application() {}
43
44 int newInstance();
45
46 private:
47 Akregator::MainWindow *mMainWindow;
48};
49
50int Application::newInstance()
51{
52 if (!isRestored())
53 {
54 DCOPRef akr("akregator", "AkregatorIface");
55
56 TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
57
58 if ( !mMainWindow ) {
59 mMainWindow = new Akregator::MainWindow();
60 setMainWidget( mMainWindow );
61 mMainWindow->loadPart();
62 mMainWindow->setupProgressWidgets();
63 if (!args->isSet("hide-mainwindow"))
64 mMainWindow->show();
65 akr.send("openStandardFeedList");
66 }
67
68 TQString addFeedGroup = !args->getOption("group").isEmpty()
69 ? TQString::fromLocal8Bit(args->getOption("group"))
70 : i18n("Imported Folder");
71
72 QCStringList feeds = args->getOptionList("addfeed");
73 TQStringList feedsToAdd;
74 QCStringList::ConstIterator end( feeds.end() );
75 for (QCStringList::ConstIterator it = feeds.begin(); it != end; ++it)
76 feedsToAdd.append(*it);
77
78 if (!feedsToAdd.isEmpty())
79 akr.send("addFeedsToGroup", feedsToAdd, addFeedGroup );
80
81 args->clear();
82 }
83 return TDEUniqueApplication::newInstance();
84}
85
86} // namespace Akregator
87
88int main(int argc, char **argv)
89{
91 TDECmdLineArgs::init(argc, argv, &about);
92 TDECmdLineArgs::addCmdLineOptions( Akregator::akregator_options );
93 TDEUniqueApplication::addCmdLineOptions();
94
95 Akregator::Application app;
96
97 // start knotifyclient if not already started. makes it work for people who doesn't use full kde, according to kmail devels
98 KNotifyClient::startDaemon();
99
100 // see if we are starting with session management
101 if (app.isRestored())
102 {
103#undef RESTORE
104#define RESTORE(type) { int n = 1;\
105 while (TDEMainWindow::canBeRestored(n)){\
106 (new type)->restore(n, false);\
107 n++;}}
108
109 RESTORE(Akregator::MainWindow);
110 }
111
112 return app.exec();
113}
114
115
This is the application "Shell".
Definition: mainwindow.h:74