OSDN Git Service

7c0e5e62970d466e6b30ac05bc974fbbfe01b7c7
[kita/kita.git] / kita / src / main.cpp
1 /***************************************************************************
2 *   Copyright (C) 2003 by Hideki Ikemoto                                  *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 ***************************************************************************/
10
11 #include "mainwindow.h"
12
13 #include <cstdlib> // setenv()
14
15 #include <kaboutdata.h>
16 #include <kcmdlineargs.h>
17 #include <kuniqueapplication.h>
18
19 #include "libkita/config.h"
20 #include "libkita/globalconfig.h"
21
22 static const char *description =
23     I18N_NOOP("Kita - 2ch client for KDE");
24
25 using namespace Kita;
26
27 int main(int argc, char **argv)
28 {
29     // for code page 932 with NEC special characters
30     setenv("UNICODEMAP_JP", "cp932,nec-vdc", 1);
31     KAboutData about("kita", "kita", ki18n("Kita"), VERSION, ki18n(description),
32         KAboutData::License_GPL, ki18n("(C) 2003-2010 Kita Developers"),
33         KLocalizedString(), QByteArray(), "ikemo@users.sourceforge.jp");
34     about.addAuthor(ki18n("Hideki Ikemoto"), ki18n("maintainer, initial code"),
35         "ikemo@users.sourceforge.jp");
36     about.addAuthor(ki18n("konqueror plugin no hito"),
37         ki18n("konqueror plugin, KDE part"), "ogirin@users.sourceforge.jp");
38     about.addAuthor(ki18n("421"), ki18n("kitanavi, threadview's improvement"));
39     about.addAuthor(ki18n("Toshihiko Okada"), ki18n("improvements"),
40         "tossi@users.sourceforge.jp");
41     about.addAuthor(ki18n("75"), ki18n("stylesheet support"));
42     KCmdLineArgs::init(argc, argv, &about);
43     KCmdLineOptions options;
44     options.add("+[URL]", ki18n("Document to open."));
45     options.add("boardlist <boardlist>", ki18n("board list's URL."),
46         "http://menu.2ch.net/bbsmenu.html");
47     KCmdLineArgs::addCmdLineOptions(options);
48     KUniqueApplication app;
49
50     // register ourselves as a dcop client
51 //    app.dcopClient() ->registerAs(app.name(), FALSE);
52
53     KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
54     GlobalConfig::setBoardListUrl(QString(args->getOption("boardlist")));
55
56     // see if we are starting with session management
57     if (app.isSessionRestored()) {
58         kRestoreMainWindows<MainWindow>();
59     } else {
60             // no session.. just start up normally
61             KCmdLineArgs * args = KCmdLineArgs::parsedArgs();
62             if (args->count() == 0) {
63                 MainWindow * widget = new MainWindow;
64                 widget->show();
65             } else {
66                 int i = 0;
67                 for (; i < args->count(); i++) {
68                     MainWindow *widget = new MainWindow;
69                     widget->show();
70                     widget->load(args->url(i));
71                 }
72             }
73             args->clear();
74     }
75
76     return app.exec();
77 }