ctkPluginArchive_p.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 CTKPLUGINARCHIVE_P_H
  16. #define CTKPLUGINARCHIVE_P_H
  17. #include <QString>
  18. #include <QHash>
  19. #include <QUrl>
  20. #include <QDateTime>
  21. #include "ctkPluginManifest_p.h"
  22. // Qt forward declarations
  23. class QIODevice;
  24. // CTK foraward declarations
  25. class ctkPluginStorage;
  26. /**
  27. * \ingroup PluginFramework
  28. *
  29. * Class for managing plugin data.
  30. *
  31. */
  32. class ctkPluginArchive
  33. {
  34. public:
  35. /**
  36. * Autostart setting stopped.
  37. * @see PluginArchiveInterface#setAutostartSetting(const QString&)
  38. */
  39. static const QString AUTOSTART_SETTING_STOPPED; // = "stopped"
  40. /**
  41. * Autostart setting eager.
  42. * @see PluginArchiveInterface#setAutostartSetting(const QString&)
  43. */
  44. static const QString AUTOSTART_SETTING_EAGER; // = "eager"
  45. /**
  46. * Autostart setting declared activation policy.
  47. * @see PluginArchiveInterface#setAutostartSetting(const QString&)
  48. */
  49. static const QString AUTOSTART_SETTING_ACTIVATION_POLICY; // = "activation_policy"
  50. private:
  51. int autostartSetting;
  52. int id;
  53. int startLevel;
  54. QDateTime lastModified;
  55. QUrl location;
  56. QString localPluginPath;
  57. ctkPluginManifest manifest;
  58. ctkPluginStorage* storage;
  59. public:
  60. /**
  61. * Construct new plugin archive.
  62. *
  63. */
  64. ctkPluginArchive(ctkPluginStorage* pluginStorage, const QUrl& pluginLocation,
  65. const QString& localPluginPath, int pluginId,
  66. int startLevel = -1, const QDateTime& lastModified = QDateTime(),
  67. int autostartSetting = -1);
  68. /**
  69. * Get an attribute from the manifest of a plugin.
  70. *
  71. * Not localized
  72. *
  73. * @param key Name of attribute to get.
  74. * @return A string with result or null if the entry doesn't exists.
  75. */
  76. QString getAttribute(const QString& key) const;
  77. /**
  78. * @returns the (raw/unlocalized) attributes
  79. */
  80. QHash<QString,QString> getUnlocalizedAttributes() const;
  81. /**
  82. * Get plugin identifier for this plugin archive.
  83. *
  84. * @return ctkPlugin identifier.
  85. */
  86. int getPluginId() const;
  87. /**
  88. * Get plugin location for this plugin archive.
  89. *
  90. * @return Bundle location.
  91. */
  92. QUrl getPluginLocation() const;
  93. /**
  94. * Get the path to the plugin library on the local
  95. * file system
  96. *
  97. * @return Path to the plugin library
  98. */
  99. QString getLibLocation() const;
  100. /**
  101. * Get a Qt resource as a byte array from a plugin. The resource
  102. * is cached and may be aquired even if the plugin is not active.
  103. *
  104. * @param component Resource to get the byte array from.
  105. * @return QByteArray to the entry (empty if it doesn't exist).
  106. */
  107. QByteArray getPluginResource(const QString& component) const;
  108. /**
  109. * Returns a QStringList of all the paths
  110. * to entries within the plugin whose longest sub-path matches the supplied
  111. * path argument.
  112. *
  113. * @param name
  114. * @return
  115. */
  116. QStringList findResourcesPath(const QString& path) const;
  117. /**
  118. * Get stored plugin start level.
  119. */
  120. int getStartLevel() const;
  121. /**
  122. * Set stored plugin start level.
  123. */
  124. void setStartLevel(int level);
  125. /**
  126. * Get last modified timestamp.
  127. */
  128. QDateTime getLastModified() const;
  129. /**
  130. * Set stored last modified timestamp.
  131. */
  132. void setLastModified(const QDateTime& timemillisecs);
  133. /**
  134. * Get auto-start setting.
  135. *
  136. * @return the autostart setting. "-1" if the plugin is not started.
  137. */
  138. int getAutostartSetting() const;
  139. /**
  140. * Set the auto-start setting.
  141. *
  142. * @param setting the autostart setting to use.
  143. */
  144. void setAutostartSetting(int setting);
  145. /**
  146. * Get certificate chains associated with a plugin.
  147. *
  148. * @param onlyTrusted Only return trusted certificates.
  149. * @return All certificates or null if bundle is unsigned.
  150. */
  151. //QList<> getCertificateChains(bool onlyTrusted) const;
  152. /**
  153. * Mark certificate associated with the plugin as trusted.
  154. *
  155. */
  156. //void trustCertificateChain(QList<> trustedChain);
  157. /**
  158. * Remove plugin from persistent storage.
  159. * This will delete the current ctkPluginArchive instance.
  160. */
  161. void purge();
  162. };
  163. #endif // CTKPLUGINARCHIVE_P_H