/***************************************************************************
 *   Copyright (C) 2008 by Jakub Stachowski <qbast@go2.pl>                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#include "mainwindow.h"
#include <kapplication.h>
#include <kaboutdata.h>
#include <kdebug.h>
#include <kcmdlineargs.h>
#include <KDE/KLocale>

static const char description[] =
    I18N_NOOP("SSH frontend for Konsole");

static const char version[] = "0.1";

QVector<char*> convert(const QList<QByteArray>& args) {
  QVector<char*> ret;
  Q_FOREACH(const QByteArray& a , args) 
    ret.append( const_cast<char*>(a.data()) );
  ret.append( 0 );
  return ret;
}

int main(int argc, char **argv)
{
    KAboutData about("kssh4", 0, ki18n("kssh4"), version, ki18n(description),
                     KAboutData::License_GPL, ki18n("(C) 2008-2009 Jakub Stachowski"), KLocalizedString(), 0, "qbast@go2.pl");
    about.addAuthor( ki18n("Jakub Stachowski"), KLocalizedString(), "qbast@go2.pl" );
    about.addCredit( ki18n("Andrea Rizzi"), ki18n("Author of KSSH"), "rizzi@kde.org" );
    KCmdLineArgs::init(argc, argv, &about);

//    KCmdLineOptions options;
//    options.add("+[URL]", ki18n( "Document to open" ));
//    KCmdLineArgs::addCmdLineOptions(options);
    KApplication app;

    MainWindow *widget = new MainWindow;
//    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    widget->show();

    app.exec();
    if (widget->result()==QDialog::Accepted) {
      QList<QByteArray> a=widget->arguments();
      kDebug() << a;
      QVector<char*> args=convert( a );
      execvp("ssh", args.data());
    }
}
