TDE core libraries
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.

kdcopcheck.cpp 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #include <kuserprofile.h>
  2. #include <ktrader.h>
  3. #include <kservice.h>
  4. #include <kmimetype.h>
  5. #include <assert.h>
  6. #include <kstandarddirs.h>
  7. #include <kservicegroup.h>
  8. #include <kimageio.h>
  9. #include <kprotocolinfo.h>
  10. #include <kprocess.h>
  11. #include <tqtimer.h>
  12. #include "kdcopcheck.h"
  13. #include <dcopclient.h>
  14. #include <tdeapplication.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. void debug(TQString txt)
  18. {
  19. fprintf(stderr, "%s\n", txt.ascii());
  20. }
  21. void debug(const char *txt)
  22. {
  23. fprintf(stderr, "%s\n", txt);
  24. }
  25. void debug(const char *format, const char *txt)
  26. {
  27. fprintf(stderr, format, txt);
  28. fprintf(stderr, "\n");
  29. }
  30. TestService::TestService(const TQString &exec)
  31. {
  32. m_exec = exec;
  33. proc << exec;
  34. proc.start();
  35. connect(kapp->dcopClient(), TQT_SIGNAL( applicationRegistered(const TQCString&)),
  36. this, TQT_SLOT(newApp(const TQCString&)));
  37. connect(kapp->dcopClient(), TQT_SIGNAL( applicationRemoved(const TQCString&)),
  38. this, TQT_SLOT(endApp(const TQCString&)));
  39. connect(&proc, TQT_SIGNAL(processExited(TDEProcess *)),
  40. this, TQT_SLOT(appExit()));
  41. TQTimer::singleShot(20*1000, this, TQT_SLOT(stop()));
  42. result = KService::DCOP_None;
  43. }
  44. void TestService::newApp(const TQCString &appId)
  45. {
  46. TQString id = appId;
  47. if (id == m_exec)
  48. {
  49. result = KService::DCOP_Unique;
  50. stop();
  51. }
  52. else if (id.startsWith(m_exec))
  53. {
  54. result = KService::DCOP_Multi;
  55. stop();
  56. }
  57. tqWarning("Register %s", appId.data());
  58. }
  59. void TestService::endApp(const TQCString &appId)
  60. {
  61. tqWarning("Unegister %s", appId.data());
  62. }
  63. void TestService::appExit()
  64. {
  65. tqWarning("Exit");
  66. }
  67. void TestService::stop()
  68. {
  69. kapp->exit_loop();
  70. }
  71. int TestService::exec()
  72. {
  73. kapp->enter_loop();
  74. return result;
  75. }
  76. int main(int argc, char *argv[])
  77. {
  78. setenv("IGNORE_SYCOCA_VERSION", "true", true);
  79. TDEApplication k(argc,argv,"whatever",false/*nostyle*/,false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
  80. k.dcopClient()->setNotifications(true);
  81. KService::List list = KService::allServices();
  82. tqWarning("I found %ld services.", list.count());
  83. int i = 0;
  84. for(KService::List::ConstIterator it = list.begin(); it != list.end(); ++it)
  85. {
  86. if (((*it)->DCOPServiceType() == KService::DCOP_None) &&
  87. !(*it)->desktopEntryPath().startsWith("SuSE") &&
  88. (*it)->hasServiceType("Application"))
  89. {
  90. if ((*it)->exec().startsWith((*it)->desktopEntryName()))
  91. {
  92. i++;
  93. TestService *test = new TestService((*it)->desktopEntryName());
  94. int n = test->exec();
  95. delete test;
  96. TQString result;
  97. if (n == KService::DCOP_None)
  98. result = "None";
  99. else if (n == KService::DCOP_Unique)
  100. result = "Unique";
  101. else if (n == KService::DCOP_Multi)
  102. result = "Multi";
  103. tqWarning("%s %s", (*it)->desktopEntryPath().latin1(),
  104. result.latin1());
  105. }
  106. }
  107. }
  108. tqWarning("%d left after filtering.", i);
  109. }
  110. #include "kdcopcheck.moc"