ctkPluginPrivate_p.h 4.6 KB

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