Home | History | Annotate | Line # | Download | only in wpa_gui-qt4
      1      1.1  christos /*
      2      1.1  christos  * wpa_gui - Application startup
      3      1.1  christos  * Copyright (c) 2005-2006, Jouni Malinen <j (at) w1.fi>
      4      1.1  christos  *
      5  1.1.1.2  christos  * This software may be distributed under the terms of the BSD license.
      6  1.1.1.2  christos  * See README for more details.
      7      1.1  christos  */
      8      1.1  christos 
      9      1.1  christos #ifdef CONFIG_NATIVE_WINDOWS
     10      1.1  christos #include <winsock.h>
     11      1.1  christos #endif /* CONFIG_NATIVE_WINDOWS */
     12      1.1  christos #include <QApplication>
     13      1.1  christos #include <QtCore/QLibraryInfo>
     14      1.1  christos #include <QtCore/QTranslator>
     15      1.1  christos #include "wpagui.h"
     16      1.1  christos 
     17  1.1.1.3  christos WpaGuiApp::WpaGuiApp(int &argc, char **argv) :
     18  1.1.1.3  christos 	QApplication(argc, argv),
     19  1.1.1.3  christos 	argc(argc),
     20  1.1.1.3  christos 	argv(argv)
     21      1.1  christos {
     22  1.1.1.3  christos 	w = NULL;
     23      1.1  christos }
     24      1.1  christos 
     25  1.1.1.3  christos #if !defined(QT_NO_SESSIONMANAGER) && QT_VERSION < 0x050000
     26      1.1  christos void WpaGuiApp::saveState(QSessionManager &manager)
     27      1.1  christos {
     28      1.1  christos 	QApplication::saveState(manager);
     29      1.1  christos 	w->saveState();
     30      1.1  christos }
     31      1.1  christos #endif
     32      1.1  christos 
     33      1.1  christos 
     34      1.1  christos int main(int argc, char *argv[])
     35      1.1  christos {
     36      1.1  christos 	WpaGuiApp app(argc, argv);
     37      1.1  christos 	QTranslator translator;
     38      1.1  christos 	QString locale;
     39      1.1  christos 	QString resourceDir;
     40      1.1  christos 	int ret;
     41      1.1  christos 
     42      1.1  christos 	locale = QLocale::system().name();
     43      1.1  christos 	resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
     44      1.1  christos 	if (!translator.load("wpa_gui_" + locale, resourceDir))
     45      1.1  christos 		translator.load("wpa_gui_" + locale, "lang");
     46      1.1  christos 	app.installTranslator(&translator);
     47      1.1  christos 
     48      1.1  christos 	WpaGui w(&app);
     49      1.1  christos 
     50      1.1  christos #ifdef CONFIG_NATIVE_WINDOWS
     51      1.1  christos 	WSADATA wsaData;
     52      1.1  christos 	if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
     53      1.1  christos 		/* printf("Could not find a usable WinSock.dll\n"); */
     54      1.1  christos 		return -1;
     55      1.1  christos 	}
     56      1.1  christos #endif /* CONFIG_NATIVE_WINDOWS */
     57      1.1  christos 
     58      1.1  christos 	app.w = &w;
     59      1.1  christos 
     60      1.1  christos 	ret = app.exec();
     61      1.1  christos 
     62      1.1  christos #ifdef CONFIG_NATIVE_WINDOWS
     63      1.1  christos 	WSACleanup();
     64      1.1  christos #endif /* CONFIG_NATIVE_WINDOWS */
     65      1.1  christos 
     66      1.1  christos 	return ret;
     67      1.1  christos }
     68