ctkPluginArchiveSQL_p.h 4.6 KB

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