• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * wpa_gui - Application startup
3  * Copyright (c) 2005-2006, Jouni Malinen <j@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 
18 class WpaGuiApp : public QApplication
19 {
20 public:
21 	WpaGuiApp(int &argc, char **argv);
22 
23 #ifndef QT_NO_SESSIONMANAGER
24 	virtual void saveState(QSessionManager &manager);
25 #endif
26 
27 	WpaGui *w;
28 };
29 
WpaGuiApp(int & argc,char ** argv)30 WpaGuiApp::WpaGuiApp(int &argc, char **argv) : QApplication(argc, argv)
31 {
32 }
33 
34 #ifndef QT_NO_SESSIONMANAGER
saveState(QSessionManager & manager)35 void WpaGuiApp::saveState(QSessionManager &manager)
36 {
37 	QApplication::saveState(manager);
38 	w->saveState();
39 }
40 #endif
41 
42 
main(int argc,char * argv[])43 int main(int argc, char *argv[])
44 {
45 	WpaGuiApp app(argc, argv);
46 	QTranslator translator;
47 	QString locale;
48 	QString resourceDir;
49 	int ret;
50 
51 	locale = QLocale::system().name();
52 	resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
53 	if (!translator.load("wpa_gui_" + locale, resourceDir))
54 		translator.load("wpa_gui_" + locale, "lang");
55 	app.installTranslator(&translator);
56 
57 	WpaGui w(&app);
58 
59 #ifdef CONFIG_NATIVE_WINDOWS
60 	WSADATA wsaData;
61 	if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
62 		/* printf("Could not find a usable WinSock.dll\n"); */
63 		return -1;
64 	}
65 #endif /* CONFIG_NATIVE_WINDOWS */
66 
67 	app.w = &w;
68 
69 	ret = app.exec();
70 
71 #ifdef CONFIG_NATIVE_WINDOWS
72 	WSACleanup();
73 #endif /* CONFIG_NATIVE_WINDOWS */
74 
75 	return ret;
76 }
77