ctkPluginArchive_p.h 4.4 KB

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