/*
   
        (c) 2006 by Thomas Michel <tom.michel@arcor.de>

        Kwlan is free software; you can redistribute it and/or modify
        it under the terms of the GNU Library General Public License as
        published by the Free Software Foundation; either version 2 of
        the License, or (at your option) any later version.

        Kwlan is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU Library General Public License for more details.

        You should have received a copy of the GNU Library General Public License
        along with this library; see the file COPYING.LIB.  If not, write to
        the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
        Boston, MA 02110-1301, USA.
*/

#include <stdlib.h>

#include "kwlanmainwin.h"
#include <kuniqueapplication.h>
//#include <dcopclient.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <qsocketnotifier.h>
#include <kmessagebox.h>
#include <kcmdlineargs.h>

#include "wlanlib.h"
#include "kwlanapplication.h"

static const char description[] =
    I18N_NOOP("Network manager for KDE");

static const char version[] = "0.6.2";


bool debugOutput;
KAboutData about("kwlan", 0, ki18n("Kwlan"), version, ki18n(description), KAboutData::License_GPL_V2, ki18n("(C) 2006 Thomas Michel"), KLocalizedString(), 0, "tom.michel@arcor.de");

int main(int argc, char **argv)
{
    
    about.addAuthor( ki18n("Thomas Michel"), KLocalizedString(), "tom.michel@arcor.de" );
    about.addAuthor( ki18n("Jouni Malinen"), ki18n("Original wpa_gui version"), "jkmaline@cc.hut.fi");
    about.addAuthor( ki18n("Valentine Sinitsyn"), ki18n("Misc patches and improvements"), "e_val@inbox.ru");
    about.addAuthor(ki18n("Laurens Vanhove"),ki18n("New icons, improved tooltip design and bugfixes"),"laurens@nature-helps.com");
    about.addCredit( ki18n("Andrew Barr"), ki18n("Kwlan icons"), "andrew.james.barr@gmail.com");
    about.addCredit(ki18n("Percy Leonhard"),ki18n("Source code for interface statistics from knemo"),"percy@eris23.de");
    about.addCredit(ki18n("Jocke Andersson"),ki18n("Bugfixing for connection strength in systray"),"ajocke@gmail.com");
    about.addCredit(ki18n("Hugo Parente Lima"),ki18n("Source code for icons showing I/O and interface statistics using /sys/class"),"hugo_pl@users.sourceforge.net ");
     
    about.setOtherText( ki18n("This product uses wpa_supplicant to configure wireless networks\n"
                        "wpa_supplicant includes software developed\n"
                        "by the OpenSSL Project for use in the\n"
                        "OpenSSL Toolkit (http://www.openssl.org/)\n" ));
    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    options.add("debug", ki18n("print out lots of debug information"));
    options.add("startminimized", ki18n("sets kwlan to start minimized"));
    options.add("startnormal", ki18n("sets kwlan to start with main window displayed"));
    KCmdLineArgs::addCmdLineOptions(options);
    KUniqueApplication::addCmdLineOptions();    
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if (args->isSet("debug"))
    {
            ::debugOutput = TRUE;
    }
    else ::debugOutput = FALSE;
    if (args->isSet("startminimized"))
    {
        mainConfiguration().writeStartMinimized(TRUE);
    }
    if (args->isSet("startnormal"))
    {
        mainConfiguration().writeStartMinimized(FALSE);
    }
    if (!KwlanApplication::start()) {
        fprintf(stderr, "Kwlan is already running!\n");
        exit(-1);
    }
    if (!KwlanApplication::start()) {
        fprintf(stderr, "Kwlan is already running!\n");
        exit(-1);
    }
    KwlanApplication app;
    app.init();
    return app.exec();
    
}
