pbx_kdeconsole_main.cc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Asterisk -- A telephony toolkit for Linux.
  3. *
  4. * KDE Console monitor -- Mostly glue code
  5. *
  6. * Copyright (C) 1999, Mark Spencer
  7. *
  8. * Mark Spencer <markster@linux-support.net>
  9. *
  10. * This program is free software, distributed under the terms of
  11. * the GNU General Public License
  12. */
  13. #include <asterisk/module.h>
  14. #include <asterisk/channel.h>
  15. #include <asterisk/logger.h>
  16. #include <asterisk/lock.h>
  17. #include "pbx_kdeconsole.h"
  18. static char *dtext = "KDE Console Monitor";
  19. static int inuse = 0;
  20. static KAsteriskConsole *w;
  21. static void verboser(char *stuff, int opos, int replacelast, int complete)
  22. {
  23. const char *s2[2];
  24. s2[0] = stuff;
  25. s2[1] = NULL;
  26. if (replacelast) {
  27. printf("Removing %d\n", w->verbose->count());
  28. w->verbose->removeItem(w->verbose->count());
  29. }
  30. w->verbose->insertStrList(s2, 1, -1);
  31. w->verbose->setBottomItem(w->verbose->count());
  32. }
  33. static int kde_main(int argc, char *argv[])
  34. {
  35. KApplication a ( argc, argv );
  36. w = new KAsteriskConsole();
  37. a.setMainWidget(w);
  38. w->show();
  39. ast_register_verbose(verboser);
  40. return a.exec();
  41. }
  42. static void *kdemain(void *data)
  43. {
  44. /* It would appear kde really wants to be main */;
  45. char *argv[1] = { "asteriskconsole" };
  46. kde_main(1, argv);
  47. return NULL;
  48. }
  49. extern "C" {
  50. int unload_module(void)
  51. {
  52. return inuse;
  53. }
  54. int load_module(void)
  55. {
  56. pthread_t t;
  57. pthread_create(&t, NULL, kdemain, NULL);
  58. return 0;
  59. }
  60. int usecount(void)
  61. {
  62. return inuse;
  63. }
  64. char *description(void)
  65. {
  66. return dtext;
  67. }
  68. }