main.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifdef CONFIG_NATIVE_WINDOWS
  9. #include <winsock.h>
  10. #endif /* CONFIG_NATIVE_WINDOWS */
  11. #include <QApplication>
  12. #include <QtCore/QLibraryInfo>
  13. #include <QtCore/QTranslator>
  14. #include "wpagui.h"
  15. class WpaGuiApp : public QApplication
  16. {
  17. public:
  18. WpaGuiApp(int &argc, char **argv);
  19. #ifndef QT_NO_SESSIONMANAGER
  20. virtual void saveState(QSessionManager &manager);
  21. #endif
  22. WpaGui *w;
  23. };
  24. WpaGuiApp::WpaGuiApp(int &argc, char **argv) : QApplication(argc, argv)
  25. {
  26. }
  27. #ifndef QT_NO_SESSIONMANAGER
  28. void WpaGuiApp::saveState(QSessionManager &manager)
  29. {
  30. QApplication::saveState(manager);
  31. w->saveState();
  32. }
  33. #endif
  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. locale = QLocale::system().name();
  42. resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
  43. if (!translator.load("wpa_gui_" + locale, resourceDir))
  44. translator.load("wpa_gui_" + locale, "lang");
  45. app.installTranslator(&translator);
  46. WpaGui w(&app);
  47. #ifdef CONFIG_NATIVE_WINDOWS
  48. WSADATA wsaData;
  49. if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
  50. /* printf("Could not find a usable WinSock.dll\n"); */
  51. return -1;
  52. }
  53. #endif /* CONFIG_NATIVE_WINDOWS */
  54. app.w = &w;
  55. ret = app.exec();
  56. #ifdef CONFIG_NATIVE_WINDOWS
  57. WSACleanup();
  58. #endif /* CONFIG_NATIVE_WINDOWS */
  59. return ret;
  60. }