ctkPluginPrivate_p.h 4.6 KB

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