ctkPluginArchive.cpp

Go to the documentation of this file.
00001 /*=============================================================================
00002 
00003   Library: CTK
00004 
00005   Copyright (c) 2010 German Cancer Research Center,
00006     Division of Medical and Biological Informatics
00007 
00008   Licensed under the Apache License, Version 2.0 (the "License");
00009   you may not use this file except in compliance with the License.
00010   You may obtain a copy of the License at
00011 
00012     http://www.apache.org/licenses/LICENSE-2.0
00013 
00014   Unless required by applicable law or agreed to in writing, software
00015   distributed under the License is distributed on an "AS IS" BASIS,
00016   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017   See the License for the specific language governing permissions and
00018   limitations under the License.
00019 
00020 =============================================================================*/
00021 
00022 #include "ctkPluginArchive_p.h"
00023 
00024 #include "ctkPluginException.h"
00025 #include "ctkPluginStorage_p.h"
00026 
00027 #include <QStringList>
00028 #include <QFile>
00029 
00030 
00031   const QString ctkPluginArchive::AUTOSTART_SETTING_STOPPED("stopped");
00032   const QString ctkPluginArchive::AUTOSTART_SETTING_EAGER("eager");
00033   const QString ctkPluginArchive::AUTOSTART_SETTING_ACTIVATION_POLICY("activation_policy");
00034 
00035   ctkPluginArchive::ctkPluginArchive(ctkPluginStorage* pluginStorage,
00036                 const QUrl& pluginLocation, const QString& localPluginPath,
00037                 int pluginId)
00038                   : autostartSetting(-1), id(pluginId), lastModified(0),
00039                   location(pluginLocation), localPluginPath(localPluginPath),
00040                   storage(pluginStorage)
00041   {
00042     QByteArray manifestResource = this->getPluginResource("META-INF/MANIFEST.MF");
00043     if (manifestResource.isEmpty())
00044     {
00045       throw ctkPluginException(QString("ctkPlugin has no MANIFEST.MF resource, location=") + pluginLocation.toString());
00046     }
00047     manifest.read(manifestResource);
00048   }
00049 
00050   QString ctkPluginArchive::getAttribute(const QString& key) const
00051   {
00052     return manifest.getAttribute(key);
00053   }
00054 
00055   QHash<QString,QString> ctkPluginArchive::getUnlocalizedAttributes() const
00056   {
00057     return manifest.getMainAttributes();
00058   }
00059 
00060   int ctkPluginArchive::getPluginId() const
00061   {
00062     return id;
00063   }
00064 
00065   QUrl ctkPluginArchive::getPluginLocation() const
00066   {
00067     return location;
00068   }
00069 
00070   QString ctkPluginArchive::getLibLocation() const
00071   {
00072     return localPluginPath;
00073   }
00074 
00075   QByteArray ctkPluginArchive::getPluginResource(const QString& component) const
00076   {
00077     return storage->getPluginResource(getPluginId(), component);
00078   }
00079 
00080   QStringList ctkPluginArchive::findResourcesPath(const QString& path) const
00081   {
00082     return storage->findResourcesPath(getPluginId(), path);
00083   }
00084 
00085   int ctkPluginArchive::getStartLevel() const
00086   {
00087     //TODO
00088     return 0;
00089   }
00090 
00091   void ctkPluginArchive::setStartLevel(int level)
00092   {
00093     //TODO
00094 //    if (startLevel != level)
00095 //    {
00096 //      startLevel = level;
00097 //      putContent(...);
00098 //    }
00099   }
00100 
00101   qtimestamp ctkPluginArchive::getLastModified() const
00102   {
00103     return lastModified;
00104   }
00105 
00106   void ctkPluginArchive::setLastModified(qtimestamp clockticks)
00107   {
00108     lastModified = clockticks;
00109     //TDOO
00110     //putContent(...)
00111   }
00112 
00113   int ctkPluginArchive::getAutostartSetting() const
00114   {
00115     return autostartSetting;
00116   }
00117 
00118   void ctkPluginArchive::setAutostartSetting(int setting)
00119   {
00120     if (autostartSetting != setting)
00121     {
00122       autostartSetting = setting;
00123       //TODO
00124       //putContent(...)
00125     }
00126   }
00127 
00128   void ctkPluginArchive::purge()
00129   {
00130     storage->removeArchive(this);
00131 
00132 
00133 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated on 21 May 2010 for CTK by  doxygen 1.6.1