9585e1ef0b6443a0a91ff16f97c15a22f76dfbed
[libeap.git] / wpa_supplicant / wpa_gui-qt4 / main.cpp
1 /*
2  * wpa_gui - Application startup
3  * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifdef CONFIG_NATIVE_WINDOWS
16 #include <winsock.h>
17 #endif /* CONFIG_NATIVE_WINDOWS */
18 #include <QApplication>
19 #include "wpagui.h"
20
21
22 class WpaGuiApp : public QApplication
23 {
24 public:
25         WpaGuiApp(int &argc, char **argv);
26
27         virtual void saveState(QSessionManager &manager);
28
29         WpaGui *w;
30 };
31
32 WpaGuiApp::WpaGuiApp(int &argc, char **argv) : QApplication(argc, argv)
33 {
34 }
35
36 void WpaGuiApp::saveState(QSessionManager &manager)
37 {
38         QApplication::saveState(manager);
39         w->saveState();
40 }
41
42
43 int main(int argc, char *argv[])
44 {
45         WpaGuiApp app(argc, argv);
46         WpaGui w(&app);
47         int ret;
48
49 #ifdef CONFIG_NATIVE_WINDOWS
50         WSADATA wsaData;
51         if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
52                 /* printf("Could not find a usable WinSock.dll\n"); */
53                 return -1;
54         }
55 #endif /* CONFIG_NATIVE_WINDOWS */
56
57         app.w = &w;
58
59         ret = app.exec();
60
61 #ifdef CONFIG_NATIVE_WINDOWS
62         WSACleanup();
63 #endif /* CONFIG_NATIVE_WINDOWS */
64
65         return ret;
66 }