ctkPluginPrivate_p.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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. namespace ctk {
  23. class PluginActivator;
  24. class PluginArchive;
  25. class PluginFrameworkContext;
  26. class PluginPrivate {
  27. protected:
  28. Plugin * const q_ptr;
  29. public:
  30. Q_DECLARE_PUBLIC(Plugin)
  31. /**
  32. * Construct a new plugin based on a PluginArchive.
  33. *
  34. * @param fw PluginFrameworkContext for this plugin.
  35. * @param ba Plugin 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. PluginPrivate(Plugin& qq, PluginFrameworkContext* fw,
  40. PluginArchive* pa /*, Object checkContext*/);
  41. /**
  42. * Construct a new empty Plugin.
  43. *
  44. * Only called for the system plugin
  45. *
  46. * @param fw Framework for this plugin.
  47. */
  48. PluginPrivate(Plugin& qq,
  49. PluginFrameworkContext* fw,
  50. long id,
  51. const QString& loc,
  52. const QString& sym,
  53. const Version& ver);
  54. virtual ~PluginPrivate();
  55. /**
  56. * Get updated plugin state. That means check if an installed
  57. * plugin has been resolved.
  58. *
  59. * @return Plugin state
  60. */
  61. Plugin::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 Plugin::StartOptions& setting);
  68. /**
  69. * Performs the actual activation.
  70. */
  71. void finalizeActivation();
  72. /**
  73. * Union of flags allowing plugin class access
  74. */
  75. static const Plugin::States RESOLVED_FLAGS;
  76. PluginFrameworkContext * const fwCtx;
  77. /**
  78. * Plugin identifier
  79. */
  80. const long id;
  81. /**
  82. * Plugin location identifier
  83. */
  84. const QString location;
  85. /**
  86. * Plugin symbolic name
  87. */
  88. QString symbolicName;
  89. /**
  90. * Plugin version
  91. */
  92. Version version;
  93. /**
  94. * State of the plugin
  95. */
  96. Plugin::State state;
  97. /**
  98. * Plugin archive
  99. */
  100. PluginArchive* archive;
  101. /**
  102. * PluginContext for the plugin
  103. */
  104. PluginContext* pluginContext;
  105. /**
  106. * PluginActivator for the plugin
  107. */
  108. PluginActivator* pluginActivator;
  109. /**
  110. * The Qt plugin loader for the plugin
  111. */
  112. QPluginLoader pluginLoader;
  113. /**
  114. * Time when the plugin was last modified
  115. */
  116. long lastModified;
  117. /**
  118. * Stores the default locale entries when uninstalled
  119. */
  120. QHash<QString, QString> cachedHeaders;
  121. /**
  122. * Stores the raw manifest headers
  123. */
  124. QHash<QString, QString> cachedRawHeaders;
  125. /**
  126. * True when this plugin has its activation policy
  127. * set to "eager"
  128. */
  129. bool eagerActivation;
  130. /** True during the finalization of an activation. */
  131. bool activating;
  132. /** True during the state change from active to resolved. */
  133. bool deactivating;
  134. /** Saved exception of resolve failure */
  135. //PluginException resolveFailException;
  136. /** List of RequirePlugin entries. */
  137. QList<RequirePlugin*> require;
  138. private:
  139. /**
  140. * Check manifest and cache certain manifest headers as variables.
  141. */
  142. void checkManifestHeaders();
  143. // This could potentially be run in its own thread,
  144. // parallelizing plugin activations
  145. void start0();
  146. /**
  147. * Remove a plugins registered listeners, registered services and
  148. * used services.
  149. *
  150. */
  151. void removePluginResources();
  152. };
  153. }
  154. #endif // CTKPLUGINPRIVATE_P_H