You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

noui.cpp 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2016 The Starwels developers
  3. // Distributed under the MIT software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #include "noui.h"
  6. #include "ui_interface.h"
  7. #include "util.h"
  8. #include <cstdio>
  9. #include <stdint.h>
  10. #include <string>
  11. static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
  12. {
  13. bool fSecure = style & CClientUIInterface::SECURE;
  14. style &= ~CClientUIInterface::SECURE;
  15. std::string strCaption;
  16. // Check for usage of predefined caption
  17. switch (style) {
  18. case CClientUIInterface::MSG_ERROR:
  19. strCaption += _("Error");
  20. break;
  21. case CClientUIInterface::MSG_WARNING:
  22. strCaption += _("Warning");
  23. break;
  24. case CClientUIInterface::MSG_INFORMATION:
  25. strCaption += _("Information");
  26. break;
  27. default:
  28. strCaption += caption; // Use supplied caption (can be empty)
  29. }
  30. if (!fSecure)
  31. LogPrintf("%s: %s\n", strCaption, message);
  32. fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
  33. return false;
  34. }
  35. static bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
  36. {
  37. return noui_ThreadSafeMessageBox(message, caption, style);
  38. }
  39. static void noui_InitMessage(const std::string& message)
  40. {
  41. LogPrintf("init message: %s\n", message);
  42. }
  43. void noui_connect()
  44. {
  45. // Connect starwelsd signal handlers
  46. uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
  47. uiInterface.ThreadSafeQuestion.connect(noui_ThreadSafeQuestion);
  48. uiInterface.InitMessage.connect(noui_InitMessage);
  49. }