main.cpp 1.4 KB

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