main.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. WpaGuiApp::WpaGuiApp(int &argc, char **argv) :
  16. QApplication(argc, argv),
  17. argc(argc),
  18. argv(argv)
  19. {
  20. w = NULL;
  21. }
  22. #if !defined(QT_NO_SESSIONMANAGER) && QT_VERSION < 0x050000
  23. void WpaGuiApp::saveState(QSessionManager &manager)
  24. {
  25. QApplication::saveState(manager);
  26. w->saveState();
  27. }
  28. #endif
  29. int main(int argc, char *argv[])
  30. {
  31. WpaGuiApp app(argc, argv);
  32. QTranslator translator;
  33. QString locale;
  34. QString resourceDir;
  35. int ret;
  36. locale = QLocale::system().name();
  37. resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
  38. if (!translator.load("wpa_gui_" + locale, resourceDir))
  39. translator.load("wpa_gui_" + locale, "lang");
  40. app.installTranslator(&translator);
  41. WpaGui w(&app);
  42. #ifdef CONFIG_NATIVE_WINDOWS
  43. WSADATA wsaData;
  44. if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
  45. /* printf("Could not find a usable WinSock.dll\n"); */
  46. return -1;
  47. }
  48. #endif /* CONFIG_NATIVE_WINDOWS */
  49. app.w = &w;
  50. ret = app.exec();
  51. #ifdef CONFIG_NATIVE_WINDOWS
  52. WSACleanup();
  53. #endif /* CONFIG_NATIVE_WINDOWS */
  54. return ret;
  55. }