mirror of
https://github.com/QuasarApp/qca.git
synced 2025-05-06 07:49:34 +00:00
provider versioning, also added qcaVersion for runtime version check
svn path=/trunk/kdesupport/qca/; revision=604475
This commit is contained in:
parent
3abc066bbc
commit
498fe8fff4
examples/aes-cmac
include/QtCrypto
plugins/qca-openssl
src
unittest/clientplugin
@ -195,6 +195,11 @@ protected:
|
||||
class ClientSideProvider : public QCA::Provider
|
||||
{
|
||||
public:
|
||||
int version() const
|
||||
{
|
||||
return QCA_VERSION;
|
||||
}
|
||||
|
||||
QString name() const
|
||||
{
|
||||
return "exampleClientSideProvider";
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "qca_support.h"
|
||||
#include "qca_tools.h"
|
||||
|
||||
QCA_EXPORT int qcaVersion();
|
||||
|
||||
/**
|
||||
* QCA - the Qt Cryptographic Architecture
|
||||
*/
|
||||
@ -605,6 +607,19 @@ namespace QCA
|
||||
*/
|
||||
virtual void init();
|
||||
|
||||
/**
|
||||
* Target QCA version for the provider.
|
||||
*
|
||||
* This is used to verify compatibility between the
|
||||
* provider and QCA. For a provider to be used, it
|
||||
* must have major and minor version numbers that are
|
||||
* less-than or equal to the QCA version (the patch
|
||||
* version number is ignored). This means an older
|
||||
* provider may be used with a newer QCA, but a newer
|
||||
* provider cannot be used with an older QCA.
|
||||
*/
|
||||
virtual int version() const = 0;
|
||||
|
||||
/**
|
||||
* The name of the provider.
|
||||
*
|
||||
|
@ -5882,6 +5882,11 @@ public:
|
||||
// todo: any shutdown?
|
||||
}
|
||||
|
||||
int version() const
|
||||
{
|
||||
return QCA_VERSION;
|
||||
}
|
||||
|
||||
QString name() const
|
||||
{
|
||||
return "qca-openssl";
|
||||
|
@ -31,6 +31,11 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
int qcaVersion()
|
||||
{
|
||||
return QCA_VERSION;
|
||||
}
|
||||
|
||||
namespace QCA {
|
||||
|
||||
// from qca_tools
|
||||
|
@ -900,6 +900,11 @@ public:
|
||||
srand(t);
|
||||
}
|
||||
|
||||
int version() const
|
||||
{
|
||||
return QCA_VERSION;
|
||||
}
|
||||
|
||||
QString name() const
|
||||
{
|
||||
return "default";
|
||||
|
@ -34,6 +34,14 @@ static void logDebug(const QString &str)
|
||||
g_pluginman->appendDiagnosticText(str + '\n');
|
||||
}
|
||||
|
||||
static bool validVersion(int ver)
|
||||
{
|
||||
// make sure the provider isn't newer than qca
|
||||
if((ver & 0xffff00) <= (QCA_VERSION & 0xffff00))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
class PluginInstance
|
||||
{
|
||||
private:
|
||||
@ -263,6 +271,14 @@ void ProviderManager::scan()
|
||||
continue;
|
||||
}
|
||||
|
||||
int ver = i->p->version();
|
||||
if(!validVersion(ver))
|
||||
{
|
||||
logDebug(QString().sprintf("plugin version 0x%06x is in the future", ver));
|
||||
delete i;
|
||||
continue;
|
||||
}
|
||||
|
||||
addItem(i, -1);
|
||||
}
|
||||
scanned_static = true;
|
||||
@ -322,6 +338,14 @@ void ProviderManager::scan()
|
||||
continue;
|
||||
}
|
||||
|
||||
int ver = i->p->version();
|
||||
if(!validVersion(ver))
|
||||
{
|
||||
logDebug(QString().sprintf("plugin version 0x%06x is in the future", ver));
|
||||
delete i;
|
||||
continue;
|
||||
}
|
||||
|
||||
addItem(i, -1);
|
||||
}
|
||||
}
|
||||
@ -336,6 +360,13 @@ bool ProviderManager::add(Provider *p, int priority)
|
||||
return false;
|
||||
}
|
||||
|
||||
int ver = p->version();
|
||||
if(!validVersion(ver))
|
||||
{
|
||||
logDebug(QString().sprintf("plugin version 0x%06x is in the future", ver));
|
||||
return false;
|
||||
}
|
||||
|
||||
ProviderItem *i = ProviderItem::fromClass(p);
|
||||
addItem(i, priority);
|
||||
return true;
|
||||
|
@ -54,6 +54,11 @@ void ClientPlugin::cleanupTestCase()
|
||||
class TestClientProvider : public QCA::Provider
|
||||
{
|
||||
public:
|
||||
int version() const
|
||||
{
|
||||
return QCA_VERSION;
|
||||
}
|
||||
|
||||
QString name() const
|
||||
{
|
||||
return "testClientSideProvider";
|
||||
|
Loading…
x
Reference in New Issue
Block a user