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.

kdedmodule.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. This file is part of the KDE libraries
  3. Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef __KDEDMODULE_H__
  18. #define __KDEDMODULE_H__
  19. #include <tqobject.h>
  20. #include <dcopobject.h>
  21. #include <ksharedptr.h>
  22. class KDEDModulePrivate;
  23. class Kded;
  24. /**
  25. * The base class for KDED modules.
  26. *
  27. * In KDE 2 and KDE 3, KDED modules are realized as shared
  28. * libraries that are loaded on-demand into kded at runtime.
  29. *
  30. * To write a config module, you have to create a library
  31. * that contains at least one factory function like this:
  32. *
  33. * \code
  34. * extern "C" {
  35. * KDE_EXPORT KDEDModule *create_xyz(TQCString *name)
  36. * {
  37. * return new XYZ(name);
  38. * }
  39. * }
  40. * \endcode
  41. *
  42. * See tdelibs/kded/HOWTO for more detailed documentation.
  43. *
  44. * @author Waldo Bastian <bastian@kde.org>
  45. */
  46. class KDE_EXPORT KDEDModule : public TQObject, public DCOPObject
  47. {
  48. Q_OBJECT
  49. // For inclusion in KDE4 (since it's BIC) long-needed fix for allowing
  50. // DCOP-based kdedmodules -- Gav <gav@kde.org>.
  51. // K_DCOP
  52. friend class Kded;
  53. public:
  54. /**
  55. * Create a DCOPObject named @p name
  56. */
  57. KDEDModule(const TQCString &name);
  58. virtual ~KDEDModule();
  59. /**
  60. * Specifies the idle timeout in seconds. The default is 0.
  61. *
  62. * This will call the idle slot @p secs seconds after the last
  63. * reference was removed.
  64. */
  65. void setIdleTimeout(int secs);
  66. /**
  67. * Reset the idle timeout counter.
  68. *
  69. * (re)starts the timeout counter if no objects are being referenced.
  70. */
  71. void resetIdle();
  72. /**
  73. * Insert @p obj indexed with @p app and @p key. The
  74. * object will be automatically deleted when the application
  75. * @p app unregisters with DCOP.
  76. *
  77. * Any previous object inserted with the same values for @p app
  78. * and @p key will be removed.
  79. */
  80. void insert(const TQCString &app, const TQCString &key, TDEShared *obj);
  81. /**
  82. * Lookup object indexed with @p app and @p key
  83. */
  84. TDEShared *find(const TQCString &app, const TQCString &key);
  85. /**
  86. * remove object indexed with @p app and @p key.
  87. * The object will be deleted when it is no more referenced.
  88. */
  89. void remove(const TQCString &app, const TQCString &key);
  90. /**
  91. * remove all objects indexed with @p app.
  92. * The objects will be deleted when they are no more referenced.
  93. */
  94. void removeAll(const TQCString &app);
  95. /**
  96. * Returns whether a certain mainwindow has registered itself with KDED
  97. */
  98. bool isWindowRegistered(long windowId);
  99. public slots:
  100. /**
  101. * Called whenever the last referenced object gets dereferenced.
  102. *
  103. * See also setIdleTimeout()
  104. *
  105. * You may delete the module from this slot.
  106. */
  107. virtual void idle() { };
  108. signals:
  109. /**
  110. * Emitted when the module is being deleted.
  111. */
  112. void moduleDeleted(KDEDModule *);
  113. /**
  114. * Emitted when a mainwindow registers itself.
  115. */
  116. void windowRegistered(long windowId);
  117. /**
  118. * Emitted when a mainwindow unregisters itself.
  119. */
  120. void windowUnregistered(long windowId);
  121. private:
  122. KDEDModulePrivate *d;
  123. };
  124. #endif