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