2008-02-28 02:34:43 +01:00
|
|
|
/*
|
|
|
|
* wpa_gui - Application startup
|
|
|
|
* Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
|
|
|
|
*
|
2012-02-11 15:46:35 +01:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2008-02-28 02:34:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NATIVE_WINDOWS
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif /* CONFIG_NATIVE_WINDOWS */
|
|
|
|
#include <QApplication>
|
2010-04-11 21:58:08 +02:00
|
|
|
#include <QtCore/QLibraryInfo>
|
|
|
|
#include <QtCore/QTranslator>
|
2008-02-28 02:34:43 +01:00
|
|
|
#include "wpagui.h"
|
|
|
|
|
2009-01-17 12:45:05 +01:00
|
|
|
|
|
|
|
class WpaGuiApp : public QApplication
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WpaGuiApp(int &argc, char **argv);
|
|
|
|
|
2009-11-16 12:20:53 +01:00
|
|
|
#ifndef QT_NO_SESSIONMANAGER
|
2009-01-17 12:45:05 +01:00
|
|
|
virtual void saveState(QSessionManager &manager);
|
2009-11-16 12:20:53 +01:00
|
|
|
#endif
|
2009-01-17 12:45:05 +01:00
|
|
|
|
|
|
|
WpaGui *w;
|
|
|
|
};
|
|
|
|
|
|
|
|
WpaGuiApp::WpaGuiApp(int &argc, char **argv) : QApplication(argc, argv)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-11-16 12:20:53 +01:00
|
|
|
#ifndef QT_NO_SESSIONMANAGER
|
2009-01-17 12:45:05 +01:00
|
|
|
void WpaGuiApp::saveState(QSessionManager &manager)
|
|
|
|
{
|
|
|
|
QApplication::saveState(manager);
|
|
|
|
w->saveState();
|
|
|
|
}
|
2009-11-16 12:20:53 +01:00
|
|
|
#endif
|
2009-01-17 12:45:05 +01:00
|
|
|
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2009-01-17 12:45:05 +01:00
|
|
|
WpaGuiApp app(argc, argv);
|
2010-04-11 21:58:08 +02:00
|
|
|
QTranslator translator;
|
|
|
|
QString locale;
|
|
|
|
QString resourceDir;
|
2008-02-28 02:34:43 +01:00
|
|
|
int ret;
|
|
|
|
|
2010-04-11 21:58:08 +02:00
|
|
|
locale = QLocale::system().name();
|
|
|
|
resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
|
|
|
if (!translator.load("wpa_gui_" + locale, resourceDir))
|
|
|
|
translator.load("wpa_gui_" + locale, "lang");
|
|
|
|
app.installTranslator(&translator);
|
|
|
|
|
|
|
|
WpaGui w(&app);
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
#ifdef CONFIG_NATIVE_WINDOWS
|
|
|
|
WSADATA wsaData;
|
|
|
|
if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
|
2008-11-21 13:05:37 +01:00
|
|
|
/* printf("Could not find a usable WinSock.dll\n"); */
|
2008-02-28 02:34:43 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_NATIVE_WINDOWS */
|
|
|
|
|
2009-01-17 12:45:05 +01:00
|
|
|
app.w = &w;
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
ret = app.exec();
|
|
|
|
|
|
|
|
#ifdef CONFIG_NATIVE_WINDOWS
|
|
|
|
WSACleanup();
|
|
|
|
#endif /* CONFIG_NATIVE_WINDOWS */
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|