ctkPluginPrivate_p.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKPLUGINPRIVATE_P_H
  16. #define CTKPLUGINPRIVATE_P_H
  17. #include "ctkPlugin.h"
  18. #include "ctkPluginException.h"
  19. #include "ctkRequirePlugin_p.h"
  20. #include <QHash>
  21. #include <QPluginLoader>
  22. #include <QDateTime>
  23. class ctkPluginActivator;
  24. class ctkPluginArchive;
  25. class ctkPluginFrameworkContext;
  26. class ctkPluginPrivate {
  27. protected:
  28. ctkPlugin * const q_ptr;
  29. public:
  30. Q_DECLARE_PUBLIC(ctkPlugin)
  31. /**
  32. * Construct a new plugin based on a ctkPluginArchive.
  33. *
  34. * @param fw ctkPluginFrameworkContext for this plugin.
  35. * @param ba ctkPlugin archive representing the shared library and cached data
  36. * @param checkContext AccessConrolContext to do permission checks against.
  37. * @exception std::invalid_argument Faulty manifest for bundle
  38. */
  39. ctkPluginPrivate(ctkPlugin& qq, ctkPluginFrameworkContext* fw,
  40. ctkPluginArchive* pa /*, Object checkContext*/);
  41. /**
  42. * Construct a new empty ctkPlugin.
  43. *
  44. * Only called for the system plugin
  45. *
  46. * @param fw Framework for this plugin.
  47. */
  48. ctkPluginPrivate(ctkPlugin& qq,
  49. ctkPluginFrameworkContext* fw,
  50. long id,
  51. const QString& loc,
  52. const QString& sym,
  53. const ctkVersion& ver);
  54. virtual ~ctkPluginPrivate();
  55. /**
  56. * Get updated plugin state. That means check if an installed
  57. * plugin has been resolved.
  58. *
  59. * @return ctkPlugin state
  60. */
  61. ctkPlugin::State getUpdatedState();
  62. /**
  63. * Save the autostart setting to the persistent plugin storage.
  64. *
  65. * @param setting The autostart options to save.
  66. */
  67. void setAutostartSetting(const ctkPlugin::StartOptions& setting);
  68. void ignoreAutostartSetting();
  69. void modified();
  70. /**
  71. * Performs the actual activation.
  72. */
  73. void finalizeActivation();
  74. /**
  75. * Performs the actual stopping.
  76. */
  77. void stop0(bool wasStarted);
  78. /**
  79. * Union of flags allowing plugin class access
  80. */
  81. static const ctkPlugin::States RESOLVED_FLAGS;
  82. ctkPluginFrameworkContext * const fwCtx;
  83. /**
  84. * ctkPlugin identifier
  85. */
  86. const long id;
  87. /**
  88. * ctkPlugin location identifier
  89. */
  90. const QString location;
  91. /**
  92. * ctkPlugin symbolic name
  93. */
  94. QString symbolicName;
  95. /**
  96. * ctkPlugin version
  97. */
  98. ctkVersion version;
  99. /**
  100. * State of the plugin
  101. */
  102. ctkPlugin::State state;
  103. /**
  104. * ctkPlugin archive
  105. */
  106. ctkPluginArchive* archive;
  107. /**
  108. * ctkPluginContext for the plugin
  109. */
  110. QScopedPointer<ctkPluginContext> pluginContext;
  111. /**
  112. * ctkPluginActivator for the plugin
  113. */
  114. ctkPluginActivator* pluginActivator;
  115. /**
  116. * The Qt plugin loader for the plugin
  117. */
  118. QPluginLoader pluginLoader;
  119. /**
  120. * Time when the plugin was last modified
  121. */
  122. QDateTime lastModified;
  123. /**
  124. * Stores the default locale entries when uninstalled
  125. */
  126. QHash<QString, QString> cachedHeaders;
  127. /**
  128. * Stores the raw manifest headers
  129. */
  130. QHash<QString, QString> cachedRawHeaders;
  131. /**
  132. * True when this plugin has its activation policy
  133. * set to "eager"
  134. */
  135. bool eagerActivation;
  136. /** True during the finalization of an activation. */
  137. bool activating;
  138. /** True during the state change from active to resolved. */
  139. bool deactivating;
  140. /** Saved exception of resolve failure */
  141. //ctkPluginException resolveFailException;
  142. /** List of ctkRequirePlugin entries. */
  143. QList<ctkRequirePlugin*> require;
  144. private:
  145. /**
  146. * Check manifest and cache certain manifest headers as variables.
  147. */
  148. void checkManifestHeaders();
  149. // This could potentially be run in its own thread,
  150. // parallelizing plugin activations
  151. void start0();
  152. void startDependencies();
  153. /**
  154. * Remove a plugins registered listeners, registered services and
  155. * used services.
  156. *
  157. */
  158. void removePluginResources();
  159. };
  160. #endif // CTKPLUGINPRIVATE_P_H