main.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifdef CONFIG_NATIVE_WINDOWS
  15. #include <winsock.h>
  16. #endif /* CONFIG_NATIVE_WINDOWS */
  17. #include <QApplication>
  18. #include "wpagui.h"
  19. class WpaGuiApp : public QApplication
  20. {
  21. public:
  22. WpaGuiApp(int &argc, char **argv);
  23. virtual void saveState(QSessionManager &manager);
  24. WpaGui *w;
  25. };
  26. WpaGuiApp::WpaGuiApp(int &argc, char **argv) : QApplication(argc, argv)
  27. {
  28. }
  29. void WpaGuiApp::saveState(QSessionManager &manager)
  30. {
  31. QApplication::saveState(manager);
  32. w->saveState();
  33. }
  34. int main(int argc, char *argv[])
  35. {
  36. WpaGuiApp app(argc, argv);
  37. WpaGui w(&app);
  38. int ret;
  39. #ifdef CONFIG_NATIVE_WINDOWS
  40. WSADATA wsaData;
  41. if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
  42. /* printf("Could not find a usable WinSock.dll\n"); */
  43. return -1;
  44. }
  45. #endif /* CONFIG_NATIVE_WINDOWS */
  46. app.w = &w;
  47. ret = app.exec();
  48. #ifdef CONFIG_NATIVE_WINDOWS
  49. WSACleanup();
  50. #endif /* CONFIG_NATIVE_WINDOWS */
  51. return ret;
  52. }