qca_export,tools,qpipe.h,support,provider,core,qca.h,textfilter and

private headers have been de-indented 1 tab and their documentation 
formatting have been made consistent

svn path=/trunk/kdesupport/qca/; revision=670321
This commit is contained in:
Justin Karneges 2007-06-01 03:00:13 +00:00
parent 24c38e3217
commit ff8b982fb6
6 changed files with 2305 additions and 2312 deletions

File diff suppressed because it is too large Load Diff

View File

@ -47,448 +47,447 @@
#include "qca_export.h" #include "qca_export.h"
#include "qca_tools.h" #include "qca_tools.h"
namespace QCA namespace QCA {
QCA_EXPORT QByteArray methodReturnType(const QMetaObject *obj, const QByteArray &method, const QList<QByteArray> argTypes);
QCA_EXPORT bool invokeMethodWithVariants(QObject *obj, const QByteArray &method, const QVariantList &args, QVariant *ret, Qt::ConnectionType type = Qt::AutoConnection);
class QCA_EXPORT SyncThread : public QThread
{ {
QCA_EXPORT QByteArray methodReturnType(const QMetaObject *obj, const QByteArray &method, const QList<QByteArray> argTypes); Q_OBJECT
QCA_EXPORT bool invokeMethodWithVariants(QObject *obj, const QByteArray &method, const QVariantList &args, QVariant *ret, Qt::ConnectionType type = Qt::AutoConnection); public:
SyncThread(QObject *parent = 0);
~SyncThread();
class QCA_EXPORT SyncThread : public QThread void start();
void stop();
QVariant call(QObject *obj, const QByteArray &method, const QVariantList &args = QVariantList(), bool *ok = 0);
protected:
virtual void atStart() = 0;
virtual void atEnd() = 0;
// reimplemented
virtual void run();
private:
Q_DISABLE_COPY(SyncThread)
class Private;
friend class Private;
Private *d;
};
class QCA_EXPORT Synchronizer : public QObject
{
Q_OBJECT
public:
Synchronizer(QObject *parent);
~Synchronizer();
bool waitForCondition(int msecs = -1);
void conditionMet();
private:
Q_DISABLE_COPY(Synchronizer)
class Private;
Private *d;
};
class QCA_EXPORT DirWatch : public QObject
{
Q_OBJECT
public:
explicit DirWatch(const QString &dir = QString(), QObject *parent = 0);
~DirWatch();
QString dirName() const;
void setDirName(const QString &dir);
Q_SIGNALS:
void changed();
private:
Q_DISABLE_COPY(DirWatch)
class Private;
friend class Private;
Private *d;
};
/**
Support class to monitor a file for activity
%FileWatch monitors a specified file for any changes. When
the file changes, the changed() signal is emitted.
*/
class QCA_EXPORT FileWatch : public QObject
{
Q_OBJECT
public:
/**
Standard constructor
\param file the name of the file to watch. If not
in this object, you can set it using setFileName()
\param parent the parent object for this object
*/
explicit FileWatch(const QString &file = QString(), QObject *parent = 0);
~FileWatch();
/**
The name of the file that is being monitored
*/
QString fileName() const;
/**
Change the file being monitored
\param file the name of the file to monitor
*/
void setFileName(const QString &file);
Q_SIGNALS:
/**
The changed signal is emitted when the file is
changed (e.g. modified, deleted)
*/
void changed();
private:
Q_DISABLE_COPY(FileWatch)
class Private;
friend class Private;
Private *d;
};
class ConsolePrivate;
class ConsoleReferencePrivate;
class ConsoleReference;
// QCA Console system
//
// QCA provides an API for asynchronous, event-based access to
// the console and stdin/stdout, as these facilities are
// otherwise not portable. The primary use of this system within
// QCA is for passphrase prompting in command-line applications,
// using the tty console type.
//
// How it works: Create a Console object for the type of console
// desired, and then use ConsoleReference to act on the console.
// Only one ConsoleReference may operate on a Console at a time.
//
// A Console object overtakes either the physical console (tty
// type) or stdin/stdout (stdio type). Only one of each type
// may be created at a time.
//
// Whenever code is written that needs a tty or stdio object, the
// code should first call one of the static methods (ttyInstance
// or stdioInstance) to see if a console object for the desired
// type exists already. If the object exists, use it. If it does
// not exist, the rule is that the relevant code should create the
// object, use the object, and then destroy the object when the
// operation is completed.
//
// By following the above rule, you can write code that utilizes
// a console without the application having to create some master
// console object for you. Of course, if the application has
// created a console then it will be used.
//
// Why make a master console object? The primary reason is that it
// is not guaranteed that all I/O will survive creation and
// destruction of a console object. If you are using the stdio
// type, then you probably want a long-lived console object. It
// is possible to capture unprocessed I/O by calling
// bytesLeftToRead or bytesLeftToWrite. However, it is not
// expected that general console-needing code will call these
// functions when utilizing a temporary console. Thus, an
// application developer would need to create his own console
// object, invoke the console-needing code, and then do his own
// extraction of the unprocessed I/O if necessary. Another reason
// to extract unprocessed I/O is if you need to switch from
// QCA::Console back to standard functions (e.g. fgets).
//
class QCA_EXPORT Console : public QObject
{
Q_OBJECT
public:
enum Type
{ {
Q_OBJECT Tty, // physical console
public: Stdio // stdin/stdout
SyncThread(QObject *parent = 0);
~SyncThread();
void start();
void stop();
QVariant call(QObject *obj, const QByteArray &method, const QVariantList &args = QVariantList(), bool *ok = 0);
protected:
virtual void atStart() = 0;
virtual void atEnd() = 0;
// reimplemented
virtual void run();
private:
Q_DISABLE_COPY(SyncThread)
class Private;
friend class Private;
Private *d;
}; };
class QCA_EXPORT Synchronizer : public QObject enum ChannelMode
{ {
Q_OBJECT Read, // stdin
public: ReadWrite // stdin + stdout
Synchronizer(QObject *parent);
~Synchronizer();
bool waitForCondition(int msecs = -1);
void conditionMet();
private:
Q_DISABLE_COPY(Synchronizer)
class Private;
Private *d;
}; };
class QCA_EXPORT DirWatch : public QObject enum TerminalMode
{ {
Q_OBJECT Default, // use default terminal settings
public: Interactive // char-by-char input, no echo
explicit DirWatch(const QString &dir = QString(), QObject *parent = 0); };
~DirWatch();
QString dirName() const; Console(Type type, ChannelMode cmode, TerminalMode tmode, QObject *parent = 0);
void setDirName(const QString &dir); ~Console();
Q_SIGNALS: static bool isStdinRedirected();
void changed(); static bool isStdoutRedirected();
private: static Console *ttyInstance();
Q_DISABLE_COPY(DirWatch) static Console *stdioInstance();
class Private; // call release() to get access to unempty buffers
friend class Private; void release();
Private *d; QByteArray bytesLeftToRead();
QByteArray bytesLeftToWrite();
private:
Q_DISABLE_COPY(Console)
friend class ConsolePrivate;
ConsolePrivate *d;
friend class ConsoleReference;
};
// note: only one ConsoleReference object can be active at a time
class QCA_EXPORT ConsoleReference : public QObject
{
Q_OBJECT
public:
enum SecurityMode
{
SecurityDisabled,
SecurityEnabled
};
ConsoleReference(QObject *parent = 0);
~ConsoleReference();
bool start(Console *console, SecurityMode mode = SecurityDisabled);
void stop();
// normal i/o
QByteArray read(int bytes = -1);
void write(const QByteArray &a);
// secure i/o
SecureArray readSecure(int bytes = -1);
void writeSecure(const SecureArray &a);
// close write channel (only if writing enabled)
void closeOutput();
int bytesAvailable() const;
int bytesToWrite() const;
Q_SIGNALS:
void readyRead();
void bytesWritten(int bytes);
void inputClosed();
void outputClosed();
private:
Q_DISABLE_COPY(ConsoleReference)
friend class ConsoleReferencePrivate;
ConsoleReferencePrivate *d;
friend class Console;
};
class QCA_EXPORT ConsolePrompt : public QObject
{
Q_OBJECT
public:
ConsolePrompt(QObject *parent = 0);
~ConsolePrompt();
void getHidden(const QString &promptStr);
void getEnter();
void waitForFinished();
SecureArray result() const;
signals:
void finished();
private:
Q_DISABLE_COPY(ConsolePrompt)
class Private;
friend class Private;
Private *d;
};
class AbstractLogDevice;
/**
A simple logging system
This class provides a simple but flexible approach to logging information that
may be used for debugging or system operation diagnostics.
There is a single %Logger for each application that uses %QCA. You do not need
to create this %Logger yourself - %QCA automatically creates it on startup. You
can get access to the %Logger using the global QCA::logger() method.
By default the Logger just accepts all messages (binary and text). If you want to
get access to those messages, you need to subclass AbstractLogDevice, and register
your subclass (using registerLogDevice()). You can then take whatever action is
appropriate (e.g. show to the user using the GUI, log to a file or send to standard
error).
*/
class QCA_EXPORT Logger : public QObject
{
Q_OBJECT
public:
/**
The severity of the message
This information may be used by the log device to determine
what the appropriate action is.
*/
enum Severity
{
Quiet = 0, ///< Quiet: turn of logging
Emergency = 1, ///< Emergency: system is unusable
Alert = 2, ///< Alert: action must be taken immediately
Critical = 3, ///< Critical: critical conditions
Error = 4, ///< Error: error conditions
Warning = 5, ///< Warning: warning conditions
Notice = 6, ///< Notice: normal but significant condition
Information = 7, ///< Informational: informational messages
Debug = 8 ///< Debug: debug-level messages
}; };
/** /**
Support class to monitor a file for activity Get the current logging level
%FileWatch monitors a specified file for any changes. When \return Current level
the file changes, the changed() signal is emitted.
*/ */
class QCA_EXPORT FileWatch : public QObject inline Logger::Severity level () const { return m_logLevel; }
{
Q_OBJECT
public:
/**
Standard constructor
\param file the name of the file to watch. If not /**
in this object, you can set it using setFileName() Set the current logging level
\param parent the parent object for this object
*/
explicit FileWatch(const QString &file = QString(), QObject *parent = 0);
~FileWatch();
/** \param level new logging level
The name of the file that is being monitored
*/
QString fileName() const;
/** Only severities less or equal than the log level one will be logged
Change the file being monitored */
void setLevel (Logger::Severity level);
\param file the name of the file to monitor /**
*/ Log a message to all available log devices
void setFileName(const QString &file);
Q_SIGNALS: \param message the text to log
/** */
The changed signal is emitted when the file is void logTextMessage(const QString &message, Severity = Information);
changed (e.g. modified, deleted)
*/
void changed();
private: /**
Q_DISABLE_COPY(FileWatch) Log a binary blob to all available log devices
class Private; \param blob the information to log
friend class Private;
Private *d;
};
class ConsolePrivate; \note how this is handled is quite logger specific. For
class ConsoleReferencePrivate; example, it might be logged as a binary, or it might be
class ConsoleReference; encoded in some way
*/
void logBinaryMessage(const QByteArray &blob, Severity = Information);
// QCA Console system /**
// Add an AbstractLogDevice subclass to the existing list of loggers
// QCA provides an API for asynchronous, event-based access to
// the console and stdin/stdout, as these facilities are
// otherwise not portable. The primary use of this system within
// QCA is for passphrase prompting in command-line applications,
// using the tty console type.
//
// How it works: Create a Console object for the type of console
// desired, and then use ConsoleReference to act on the console.
// Only one ConsoleReference may operate on a Console at a time.
//
// A Console object overtakes either the physical console (tty
// type) or stdin/stdout (stdio type). Only one of each type
// may be created at a time.
//
// Whenever code is written that needs a tty or stdio object, the
// code should first call one of the static methods (ttyInstance
// or stdioInstance) to see if a console object for the desired
// type exists already. If the object exists, use it. If it does
// not exist, the rule is that the relevant code should create the
// object, use the object, and then destroy the object when the
// operation is completed.
//
// By following the above rule, you can write code that utilizes
// a console without the application having to create some master
// console object for you. Of course, if the application has
// created a console then it will be used.
//
// Why make a master console object? The primary reason is that it
// is not guaranteed that all I/O will survive creation and
// destruction of a console object. If you are using the stdio
// type, then you probably want a long-lived console object. It
// is possible to capture unprocessed I/O by calling
// bytesLeftToRead or bytesLeftToWrite. However, it is not
// expected that general console-needing code will call these
// functions when utilizing a temporary console. Thus, an
// application developer would need to create his own console
// object, invoke the console-needing code, and then do his own
// extraction of the unprocessed I/O if necessary. Another reason
// to extract unprocessed I/O is if you need to switch from
// QCA::Console back to standard functions (e.g. fgets).
//
class QCA_EXPORT Console : public QObject
{
Q_OBJECT
public:
enum Type
{
Tty, // physical console
Stdio // stdin/stdout
};
enum ChannelMode \param logger the LogDevice to add
{ */
Read, // stdin void registerLogDevice(AbstractLogDevice *logger);
ReadWrite // stdin + stdout
};
enum TerminalMode /**
{ Remove an AbstractLogDevice subclass from the existing list of loggers
Default, // use default terminal settings
Interactive // char-by-char input, no echo
};
Console(Type type, ChannelMode cmode, TerminalMode tmode, QObject *parent = 0); \param loggerName the name of the LogDevice to remove
~Console();
static bool isStdinRedirected(); \note If there are several log devices with the same name, all will be removed.
static bool isStdoutRedirected(); */
void unregisterLogDevice(const QString &loggerName);
static Console *ttyInstance(); /**
static Console *stdioInstance(); Get a list of the names of all registered log devices
*/
QStringList currentLogDevices() const;
// call release() to get access to unempty buffers private:
void release(); Q_DISABLE_COPY(Logger)
QByteArray bytesLeftToRead();
QByteArray bytesLeftToWrite();
private: friend class Global;
Q_DISABLE_COPY(Console)
friend class ConsolePrivate; /**
ConsolePrivate *d; Create a new message logger
*/
Logger();
friend class ConsoleReference; ~Logger();
};
// note: only one ConsoleReference object can be active at a time QStringList m_loggerNames;
class QCA_EXPORT ConsoleReference : public QObject QList<AbstractLogDevice*> m_loggers;
{ Severity m_logLevel;
Q_OBJECT };
public:
enum SecurityMode
{
SecurityDisabled,
SecurityEnabled
};
ConsoleReference(QObject *parent = 0); /**
~ConsoleReference(); An abstract log device
*/
class QCA_EXPORT AbstractLogDevice : public QObject
{
Q_OBJECT
public:
/**
The name of this log device
*/
QString name() const;
bool start(Console *console, SecurityMode mode = SecurityDisabled); /**
void stop(); Log a message
// normal i/o The default implementation does nothing - you should
QByteArray read(int bytes = -1); override this method in your subclass to do whatever
void write(const QByteArray &a); logging is required
*/
virtual void logTextMessage( const QString &message, enum Logger::Severity severity );
// secure i/o /**
SecureArray readSecure(int bytes = -1); Log a binary blob
void writeSecure(const SecureArray &a);
// close write channel (only if writing enabled) The default implementation does nothing - you should
void closeOutput(); override this method in your subclass to do whatever
logging is required
*/
virtual void logBinaryMessage( const QByteArray &blob, Logger::Severity severity );
int bytesAvailable() const; protected:
int bytesToWrite() const; /**
Create a new message logger
Q_SIGNALS: \param name the name of this log device
void readyRead(); \param parent the parent for this logger
void bytesWritten(int bytes); */
void inputClosed(); explicit AbstractLogDevice(const QString &name, QObject *parent = 0);
void outputClosed();
private: virtual ~AbstractLogDevice() = 0;
Q_DISABLE_COPY(ConsoleReference)
friend class ConsoleReferencePrivate; private:
ConsoleReferencePrivate *d; Q_DISABLE_COPY(AbstractLogDevice)
friend class Console; class Private;
}; Private *d;
class QCA_EXPORT ConsolePrompt : public QObject QString m_name;
{ };
Q_OBJECT
public:
ConsolePrompt(QObject *parent = 0);
~ConsolePrompt();
void getHidden(const QString &promptStr);
void getEnter();
void waitForFinished();
SecureArray result() const;
signals:
void finished();
private:
Q_DISABLE_COPY(ConsolePrompt)
class Private;
friend class Private;
Private *d;
};
class AbstractLogDevice;
/**
A simple logging system
This class provides a simple but flexible approach to logging information that
may be used for debugging or system operation diagnostics.
There is a single %Logger for each application that uses %QCA. You do not need
to create this %Logger yourself - %QCA automatically creates it on startup. You
can get access to the %Logger using the global QCA::logger() method.
By default the Logger just accepts all messages (binary and text). If you want to
get access to those messages, you need to subclass AbstractLogDevice, and register
your subclass (using registerLogDevice()). You can then take whatever action is
appropriate (e.g. show to the user using the GUI, log to a file or send to standard
error).
*/
class QCA_EXPORT Logger : public QObject
{
Q_OBJECT
public:
/**
The severity of the message
This information may be used by the log device to determine
what the appropriate action is.
*/
enum Severity
{
Quiet = 0, ///< Quiet: turn of logging
Emergency = 1, ///< Emergency: system is unusable
Alert = 2, ///< Alert: action must be taken immediately
Critical = 3, ///< Critical: critical conditions
Error = 4, ///< Error: error conditions
Warning = 5, ///< Warning: warning conditions
Notice = 6, ///< Notice: normal but significant condition
Information = 7, ///< Informational: informational messages
Debug = 8 ///< Debug: debug-level messages
};
/**
Get the current logging level
\return Current level
*/
inline Logger::Severity level () const {
return m_logLevel;
}
/**
Set the current logging level
\param level new logging level
Only severities less or equal than the log level one will be logged
*/
void setLevel (Logger::Severity level);
/**
Log a message to all available log devices
\param message the text to log
*/
void logTextMessage(const QString &message, Severity = Information);
/**
Log a binary blob to all available log devices
\param blob the information to log
\note how this is handled is quite logger specific. For
example, it might be logged as a binary, or it might be
encoded in some way
*/
void logBinaryMessage(const QByteArray &blob, Severity = Information);
/**
Add an AbstractLogDevice subclass to the existing list of loggers
\param logger the LogDevice to add
*/
void registerLogDevice(AbstractLogDevice *logger);
/**
Remove an AbstractLogDevice subclass from the existing list of loggers
\param loggerName the name of the LogDevice to remove
\note If there are several log devices with the same name, all will be removed.
*/
void unregisterLogDevice(const QString &loggerName);
/**
Get a list of the names of all registered log devices
*/
QStringList currentLogDevices() const;
private:
Q_DISABLE_COPY(Logger)
friend class Global;
/**
Create a new message logger
*/
Logger();
~Logger();
QStringList m_loggerNames;
QList<AbstractLogDevice*> m_loggers;
Severity m_logLevel;
};
/**
An abstract log device
*/
class QCA_EXPORT AbstractLogDevice : public QObject
{
Q_OBJECT
public:
/**
The name of this log device
*/
QString name() const;
/**
Log a message
The default implementation does nothing - you should
override this method in your subclass to do whatever
logging is required
*/
virtual void logTextMessage( const QString &message, enum Logger::Severity severity );
/**
Log a binary blob
The default implementation does nothing - you should
override this method in your subclass to do whatever
logging is required
*/
virtual void logBinaryMessage( const QByteArray &blob, Logger::Severity severity );
protected:
/**
Create a new message logger
\param name the name of this log device
\param parent the parent for this logger
*/
explicit AbstractLogDevice(const QString &name, QObject *parent = 0);
virtual ~AbstractLogDevice() = 0;
private:
Q_DISABLE_COPY(AbstractLogDevice)
class Private;
Private *d;
QString m_name;
};
} }
#endif #endif

View File

@ -34,260 +34,261 @@
#include "qca_core.h" #include "qca_core.h"
namespace QCA namespace QCA {
/**
\class TextFilter qca_textfilter.h QtCrypto
Superclass for text based filtering algorithms
This differs from Filter in that it has the concept
of an algorithm that works in two directions, and
supports operations on QString arguments.
*/
class QCA_EXPORT TextFilter : public Filter
{ {
public:
/** /**
\class TextFilter qca_textfilter.h QtCrypto Standard constructor
Superclass for text based filtering algorithms \param dir the Direction that this TextFilter
should use.
This differs from Filter in that it has the concept
of an algorithm that works in two directions, and
supports operations on QString arguments.
*/ */
class QCA_EXPORT TextFilter : public Filter TextFilter(Direction dir);
{
public:
/**
Standard constructor
\param dir the Direction that this TextFilter
should use.
*/
TextFilter(Direction dir);
/**
Reset the TextFilter
\param dir the Direction that this TextFilter
should use.
*/
void setup(Direction dir);
/**
Process an array in the "forward" direction,
returning an array
This method runs in the forward direction, so
for something like a Base64 encoding, it takes
the "native" array, and returns that array
encoded in base64.
\param a the array to encode
*/
SecureArray encode(const SecureArray &a);
/**
Process an array in the "reverse" direction,
returning an array
This method runs in the reverse direction, so
for something like a Base64 encoding, it takes
a Base64 encoded array, and returns the "native"
representation..
\param a the array to decode
*/
SecureArray decode(const SecureArray &a);
/**
Process an array in the "forward" direction,
returning a QString
This is equivalent to encode(), except
that it returns a QString, rather than a
byte array.
\param a the array to encode
*/
QString arrayToString(const SecureArray &a);
/**
Process an string in the "reverse" direction,
returning a byte array
This is equivalent to decode(), except
that it takes a QString, rather than a
byte array.
\param s the array to decode
*/
SecureArray stringToArray(const QString &s);
/**
Process a string in the "forward" direction,
returning a string
This is equivalent to encode(), except
that it takes and returns a QString, rather than
byte arrays.
\param s the string to encode
*/
QString encodeString(const QString &s);
/**
Process a string in the "reverse" direction,
returning a string
This is equivalent to decode(), except
that it takes and returns a QString, rather than
byte arrays.
\param s the string to decode
*/
QString decodeString(const QString &s);
protected:
/**
Internal state variable for the Direction
that the filter operates in
*/
Direction _dir;
};
/** /**
\class Hex qca_textfilter.h QtCrypto Reset the TextFilter
Hexadecimal encoding / decoding \param dir the Direction that this TextFilter
should use.
*/ */
class QCA_EXPORT Hex : public TextFilter void setup(Direction dir);
{
public:
/**
Standard constructor
\param dir the Direction that should be used.
\note The direction can be changed using
the setup() call.
*/
Hex(Direction dir = Encode);
/**
Reset the internal state.
This is useful to reuse an existing Hex object
*/
virtual void clear();
/**
Process more data, returning the corresponding
encoded or decoded (depending on the Direction
set in the constructor or setup() call) representation.
If you find yourself with code that only calls
this method once, you might be better off using
encode() or decode(). Similarly, if the data is
really a string, you might be better off using
arrayToString(), encodeString(), stringToArray()
or decodeString().
\param a the array containing data to process
*/
virtual SecureArray update(const SecureArray &a);
/**
Complete the algorithm
\return any remaining output. Because of the way
hexadecimal encoding works, this will return a
zero length array - any output will have been returned
from the update() call.
*/
virtual SecureArray final();
/**
Test if an update() or final() call succeeded.
\return true if the previous call succeeded
*/
virtual bool ok() const;
private:
uchar val;
bool partial;
bool _ok;
};
/** /**
\class Base64 qca_textfilter.h QtCrypto Process an array in the "forward" direction,
returning an array
%Base64 encoding / decoding This method runs in the forward direction, so
for something like a Base64 encoding, it takes
the "native" array, and returns that array
encoded in base64.
\param a the array to encode
*/ */
class QCA_EXPORT Base64 : public TextFilter SecureArray encode(const SecureArray &a);
{
public:
/**
Standard constructor
\param dir the Direction that should be used. /**
Process an array in the "reverse" direction,
returning an array
\note The direction can be changed using This method runs in the reverse direction, so
the setup() call. for something like a Base64 encoding, it takes
*/ a Base64 encoded array, and returns the "native"
Base64(Direction dir = Encode); representation..
/** \param a the array to decode
Sets line break mode. If enabled, linebreaks will be */
added to encoded output or accepted in encoded input. SecureArray decode(const SecureArray &a);
If disabled, linebreaks in encoded input will cause
a failure to decode. The default is disabled.
*/
void setLineBreaksEnabled(bool b);
/** /**
Sets the column that linebreaks should be inserted at Process an array in the "forward" direction,
when encoding. returning a QString
*/
void setLineBreaksColumn(int column);
/** This is equivalent to encode(), except
Reset the internal state. This is useful to that it returns a QString, rather than a
reuse an existing Base64 object byte array.
*/
virtual void clear();
/** \param a the array to encode
Process more data, returning the corresponding */
encoded or decoded (depending on the Direction QString arrayToString(const SecureArray &a);
set in the constructor or setup() call) representation.
If you find yourself with code that only calls /**
this method once, you might be better off using Process an string in the "reverse" direction,
encode() or decode(). Similarly, if the data is returning a byte array
really a string, you might be better off using
arrayToString(), encodeString(), stringToArray()
or decodeString().
\param a the array containing data to process This is equivalent to decode(), except
*/ that it takes a QString, rather than a
virtual SecureArray update(const SecureArray &a); byte array.
/** \param s the array to decode
Complete the algorithm */
SecureArray stringToArray(const QString &s);
\return any remaining output. Because of the way /**
Base64 encoding works, you will get either an Process a string in the "forward" direction,
empty array, or an array containing one or two returning a string
"=" (equals, 0x3D) characters.
*/
virtual SecureArray final();
/** This is equivalent to encode(), except
Test if an update() or final() call succeeded. that it takes and returns a QString, rather than
byte arrays.
\return true if the previous call succeeded \param s the string to encode
*/ */
virtual bool ok() const; QString encodeString(const QString &s);
/**
Process a string in the "reverse" direction,
returning a string
This is equivalent to decode(), except
that it takes and returns a QString, rather than
byte arrays.
\param s the string to decode
*/
QString decodeString(const QString &s);
protected:
/**
Internal state variable for the Direction
that the filter operates in
*/
Direction _dir;
};
/**
\class Hex qca_textfilter.h QtCrypto
Hexadecimal encoding / decoding
*/
class QCA_EXPORT Hex : public TextFilter
{
public:
/**
Standard constructor
\param dir the Direction that should be used.
\note The direction can be changed using
the setup() call.
*/
Hex(Direction dir = Encode);
/**
Reset the internal state.
This is useful to reuse an existing Hex object
*/
virtual void clear();
/**
Process more data, returning the corresponding
encoded or decoded (depending on the Direction
set in the constructor or setup() call) representation.
If you find yourself with code that only calls
this method once, you might be better off using
encode() or decode(). Similarly, if the data is
really a string, you might be better off using
arrayToString(), encodeString(), stringToArray()
or decodeString().
\param a the array containing data to process
*/
virtual SecureArray update(const SecureArray &a);
/**
Complete the algorithm
\return any remaining output. Because of the way
hexadecimal encoding works, this will return a
zero length array - any output will have been returned
from the update() call.
*/
virtual SecureArray final();
/**
Test if an update() or final() call succeeded.
\return true if the previous call succeeded
*/
virtual bool ok() const;
private:
uchar val;
bool partial;
bool _ok;
};
/**
\class Base64 qca_textfilter.h QtCrypto
%Base64 encoding / decoding
*/
class QCA_EXPORT Base64 : public TextFilter
{
public:
/**
Standard constructor
\param dir the Direction that should be used.
\note The direction can be changed using
the setup() call.
*/
Base64(Direction dir = Encode);
/**
Sets line break mode. If enabled, linebreaks will be
added to encoded output or accepted in encoded input.
If disabled, linebreaks in encoded input will cause
a failure to decode. The default is disabled.
*/
void setLineBreaksEnabled(bool b);
/**
Sets the column that linebreaks should be inserted at
when encoding.
*/
void setLineBreaksColumn(int column);
/**
Reset the internal state. This is useful to
reuse an existing Base64 object
*/
virtual void clear();
/**
Process more data, returning the corresponding
encoded or decoded (depending on the Direction
set in the constructor or setup() call) representation.
If you find yourself with code that only calls
this method once, you might be better off using
encode() or decode(). Similarly, if the data is
really a string, you might be better off using
arrayToString(), encodeString(), stringToArray()
or decodeString().
\param a the array containing data to process
*/
virtual SecureArray update(const SecureArray &a);
/**
Complete the algorithm
\return any remaining output. Because of the way
Base64 encoding works, you will get either an
empty array, or an array containing one or two
"=" (equals, 0x3D) characters.
*/
virtual SecureArray final();
/**
Test if an update() or final() call succeeded.
\return true if the previous call succeeded
*/
virtual bool ok() const;
private:
SecureArray partial;
bool _ok;
int col;
bool _lb_enabled;
int _lb_column;
};
private:
SecureArray partial;
bool _ok;
int col;
bool _lb_enabled;
int _lb_column;
};
} }
#endif #endif

View File

@ -75,212 +75,206 @@ QCA_EXPORT void *qca_secure_realloc(void *p, int bytes);
namespace QCA { namespace QCA {
/** /**
\class SecureArray qca_tools.h QtCrypto \class SecureArray qca_tools.h QtCrypto
Secure array of bytes Secure array of bytes
The %SecureArray provides an array of memory from a pool that is, The %SecureArray provides an array of memory from a pool that is,
at least partly, secure. In this sense, secure means that the contents at least partly, secure. In this sense, secure means that the contents
of the memory should not be made available to other applications. By of the memory should not be made available to other applications. By
comparison, a QMemArray (or subclass such as QCString or QByteArray) may comparison, a QMemArray (or subclass such as QCString or QByteArray) may
be held in pages that might be swapped to disk or free'd without being be held in pages that might be swapped to disk or free'd without being
cleared first. cleared first.
Note that this class is implicitly shared (that is, copy on write). Note that this class is implicitly shared (that is, copy on write).
**/ */
class QCA_EXPORT SecureArray class QCA_EXPORT SecureArray
{ {
public: public:
/** /**
* Construct a secure byte array, zero length Construct a secure byte array, zero length
*/ */
SecureArray(); SecureArray();
/** /**
* Construct a secure byte array of the specified length Construct a secure byte array of the specified length
*
* \param size the number of bytes in the array \param size the number of bytes in the array
* \param ch the value every byte should be set to \param ch the value every byte should be set to
*/ */
explicit SecureArray(int size, char ch = 0); explicit SecureArray(int size, char ch = 0);
/** /**
* Construct a secure byte array from a string Construct a secure byte array from a string
*
* Note that this copies, rather than references the source array Note that this copies, rather than references the source array
*/ */
SecureArray(const char *str); SecureArray(const char *str);
/** /**
* Construct a secure byte array from a QByteArray Construct a secure byte array from a QByteArray
*
* Note that this copies, rather than references the source array Note that this copies, rather than references the source array
*
* \sa operator=() \sa operator=()
*/ */
SecureArray(const QByteArray &a); SecureArray(const QByteArray &a);
/** /**
* Construct a (shallow) copy of another secure byte array Construct a (shallow) copy of another secure byte array
*
* \param from the source of the data and length. \param from the source of the data and length.
*/ */
SecureArray(const SecureArray &from); SecureArray(const SecureArray &from);
~SecureArray(); ~SecureArray();
/** /**
* Creates a reference, rather than a deep copy. Creates a reference, rather than a deep copy.
* if you want a deep copy then you should use copy() */
* instead, or use operator=(), then call detach() when required.
*/
SecureArray & operator=(const SecureArray &from); SecureArray & operator=(const SecureArray &from);
/** /**
* Creates a copy, rather than references Creates a copy, rather than references
*
* \param a the array to copy from \param a the array to copy from
*/ */
SecureArray & operator=(const QByteArray &a); SecureArray & operator=(const QByteArray &a);
/** /**
* Clears the contents of the array and makes it empty Clears the contents of the array and makes it empty
*/ */
void clear(); void clear();
/** /**
* Returns a reference to the byte at the index position Returns a reference to the byte at the index position
*
* \param index the zero-based offset to obtain \param index the zero-based offset to obtain
*/ */
char & operator[](int index); char & operator[](int index);
/** /**
* Returns a reference to the byte at the index position Returns a reference to the byte at the index position
*
* \param index the zero-based offset to obtain \param index the zero-based offset to obtain
*/ */
const char & operator[](int index) const; const char & operator[](int index) const;
/** /**
* Pointer to the data in the secure array Pointer to the data in the secure array
*
* You can use this for memcpy and similar functions. If you are trying You can use this for memcpy and similar functions. If you are trying
* to obtain data at a particular offset, you might be better off using to obtain data at a particular offset, you might be better off using
* at() or operator[] at() or operator[]
* */
*/
char *data(); char *data();
/** /**
* Pointer to the data in the secure array Pointer to the data in the secure array
*
* You can use this for memcpy and similar functions. If you are trying You can use this for memcpy and similar functions. If you are trying
* to obtain data at a particular offset, you might be better off using to obtain data at a particular offset, you might be better off using
* at() or operator[] at() or operator[]
* */
*/
const char *data() const; const char *data() const;
/** /**
* Pointer to the data in the secure array Pointer to the data in the secure array
*
* You can use this for memcpy and similar functions. If you are trying You can use this for memcpy and similar functions. If you are trying
* to obtain data at a particular offset, you might be better off using to obtain data at a particular offset, you might be better off using
* at() or operator[] at() or operator[]
* */
*/
const char *constData() const; const char *constData() const;
/** /**
* Returns a reference to the byte at the index position Returns a reference to the byte at the index position
*
* \param index the zero-based offset to obtain \param index the zero-based offset to obtain
*/ */
char & at(int index); char & at(int index);
/** /**
* Returns a reference to the byte at the index position Returns a reference to the byte at the index position
*
* \param index the zero-based offset to obtain \param index the zero-based offset to obtain
*/ */
const char & at(int index) const; const char & at(int index) const;
/** /**
* Returns the number of bytes in the array Returns the number of bytes in the array
*/ */
int size() const; int size() const;
/** /**
* Test if the array contains any bytes. Test if the array contains any bytes.
*
* This is equivalent to testing (size() != 0). Note that if This is equivalent to testing (size() != 0). Note that if
* the array is allocated, isEmpty() is false (even if no data the array is allocated, isEmpty() is false (even if no data
* has been added) has been added)
*
* \return true if the array has zero length, otherwise false \return true if the array has zero length, otherwise false
*/ */
bool isEmpty() const; bool isEmpty() const;
/** /**
* Change the length of this array Change the length of this array
* If the new length is less than the old length, the extra information If the new length is less than the old length, the extra information
* is (safely) discarded. If the new length is equal to or greater than is (safely) discarded. If the new length is equal to or greater than
* the old length, the existing data is copied into the array. the old length, the existing data is copied into the array.
*
* \param size the new length \param size the new length
*/ */
bool resize(int size); bool resize(int size);
/** /**
* Fill the data array with a specified character Fill the data array with a specified character
*
* \param fillChar the character to use as the fill \param fillChar the character to use as the fill
* \param fillToPosition the number of characters to fill \param fillToPosition the number of characters to fill
* to. If not specified (or -1), fills array to to. If not specified (or -1), fills array to
* current length. current length.
*
* \note This function does not extend the array - if \note This function does not extend the array - if
* you ask for fill beyond the current length, only you ask for fill beyond the current length, only
* the current length will be used. the current length will be used.
* \note The number of characters is 1 based, so if \note The number of characters is 1 based, so if
* you ask for fill('x', 10), it will fill from you ask for fill('x', 10), it will fill from
* */
*/
void fill(char fillChar, int fillToPosition = -1); void fill(char fillChar, int fillToPosition = -1);
/** /**
* Copy the contents of the secure array out to a Copy the contents of the secure array out to a
* standard QByteArray. Note that this performs a deep copy standard QByteArray. Note that this performs a deep copy
* of the data. of the data.
*/ */
QByteArray toByteArray() const; QByteArray toByteArray() const;
/** /**
* Append a secure byte array to the end of this array Append a secure byte array to the end of this array
*/ */
SecureArray & append(const SecureArray &a); SecureArray & append(const SecureArray &a);
/** /**
* Append a secure byte array to the end of this array Append a secure byte array to the end of this array
*/ */
SecureArray & operator+=(const SecureArray &a); SecureArray & operator+=(const SecureArray &a);
protected: protected:
/** /**
* Assign the contents of a provided byte array to this Assign the contents of a provided byte array to this
* object. object.
*
* \param from the byte array to copy \param from the byte array to copy
*/ */
void set(const SecureArray &from); void set(const SecureArray &from);
/** /**
* Assign the contents of a provided byte array to this Assign the contents of a provided byte array to this
* object. object.
*
* \param from the byte array to copy \param from the byte array to copy
*/ */
void set(const QByteArray &from); void set(const QByteArray &from);
private: private:
@ -289,27 +283,27 @@ private:
}; };
/** /**
* Equality operator. Returns true if the two SecureArray Equality operator. Returns true if the two SecureArray
* arguments have the same data (and the same length, of course). arguments have the same data (and the same length, of course).
*
* \relates SecureArray \relates SecureArray
**/ */
QCA_EXPORT bool operator==(const SecureArray &a, const SecureArray &b); QCA_EXPORT bool operator==(const SecureArray &a, const SecureArray &b);
/** /**
* Inequality operator. Returns true if the two SecureArray Inequality operator. Returns true if the two SecureArray
* arguments have different length, or the same length but arguments have different length, or the same length but
* different data different data
*
* \relates SecureArray \relates SecureArray
**/ */
QCA_EXPORT bool operator!=(const SecureArray &a, const SecureArray &b); QCA_EXPORT bool operator!=(const SecureArray &a, const SecureArray &b);
/** /**
* Returns an array that is the result of concatenating a and b Returns an array that is the result of concatenating a and b
*
* \relates SecureArray \relates SecureArray
**/ */
QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &b); QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &b);
/** /**
@ -319,184 +313,183 @@ QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &
BigInteger provides arbitrary precision integers. BigInteger provides arbitrary precision integers.
\code \code
if ( BigInteger("3499543804349") == if ( BigInteger("3499543804349") ==
BigInteger("38493290803248") + BigInteger( 343 ) ) BigInteger("38493290803248") + BigInteger( 343 ) )
{ {
// do something // do something
} }
\endcode \endcode
**/ */
class QCA_EXPORT BigInteger class QCA_EXPORT BigInteger
{ {
public: public:
/** /**
* Constructor. Creates a new BigInteger, initialised to zero. Constructor. Creates a new BigInteger, initialised to zero.
*/ */
BigInteger(); BigInteger();
/** /**
* \overload \overload
*
* \param n an alternative integer initialisation value. \param n an alternative integer initialisation value.
*/ */
BigInteger(int n); BigInteger(int n);
/** /**
* \overload \overload
*
* \param c an alternative initialisation value, encoded as a character array \param c an alternative initialisation value, encoded as a character array
*
* \code \code
* BigInteger b ( "9890343" ); BigInteger b ( "9890343" );
* \endcode \endcode
*/ */
BigInteger(const char *c); BigInteger(const char *c);
/** /**
* \overload \overload
*
* \param s an alternative initialisation value, encoded as a string \param s an alternative initialisation value, encoded as a string
*/ */
BigInteger(const QString &s); BigInteger(const QString &s);
/** /**
* \overload \overload
*
* \param a an alternative initialisation value, encoded as SecureArray \param a an alternative initialisation value, encoded as SecureArray
*/ */
BigInteger(const QCA::SecureArray &a); BigInteger(const QCA::SecureArray &a);
/** /**
* \overload \overload
*
* \param from an alternative initialisation value, encoded as a %BigInteger \param from an alternative initialisation value, encoded as a %BigInteger
*/ */
BigInteger(const BigInteger &from); BigInteger(const BigInteger &from);
~BigInteger(); ~BigInteger();
/** /**
* Assignment operator Assignment operator
*
* \param from the BigInteger to copy from \param from the BigInteger to copy from
*
* \code \code
* BigInteger a; // a is zero BigInteger a; // a is zero
* BigInteger b( 500 ); BigInteger b( 500 );
* a = b; // a is now 500 a = b; // a is now 500
* \endcode \endcode
*/ */
BigInteger & operator=(const BigInteger &from); BigInteger & operator=(const BigInteger &from);
/** /**
* \overload \overload
*
* \param s the QString containing an integer representation \param s the QString containing an integer representation
*
* \sa bool fromString(const QString &s) \sa bool fromString(const QString &s)
*
* \note it is the application's responsibility to make sure \note it is the application's responsibility to make sure
* that the QString represents a valid integer (ie it only that the QString represents a valid integer (ie it only
* contains numbers and an optional minus sign at the start) contains numbers and an optional minus sign at the start)
* */
**/
BigInteger & operator=(const QString &s); BigInteger & operator=(const QString &s);
/** /**
* Increment in place operator Increment in place operator
*
* \param b the amount to increment by \param b the amount to increment by
*
* \code \code
* BigInteger a; // a is zero BigInteger a; // a is zero
* BigInteger b( 500 ); BigInteger b( 500 );
* a += b; // a is now 500 a += b; // a is now 500
* a += b; // a is now 1000 a += b; // a is now 1000
* \endcode \endcode
**/ */
BigInteger & operator+=(const BigInteger &b); BigInteger & operator+=(const BigInteger &b);
/** /**
* Decrement in place operator Decrement in place operator
*
* \param b the amount to decrement by \param b the amount to decrement by
*
* \code \code
* BigInteger a; // a is zero BigInteger a; // a is zero
* BigInteger b( 500 ); BigInteger b( 500 );
* a -= b; // a is now -500 a -= b; // a is now -500
* a -= b; // a is now -1000 a -= b; // a is now -1000
* \endcode \endcode
**/ */
BigInteger & operator-=(const BigInteger &b); BigInteger & operator-=(const BigInteger &b);
/** /**
* Output %BigInteger as a byte array, useful for storage or Output %BigInteger as a byte array, useful for storage or
* transmission. The format is a binary integer in sign-extended transmission. The format is a binary integer in sign-extended
* network-byte-order. network-byte-order.
*
* \sa void fromArray(const SecureArray &a); \sa void fromArray(const SecureArray &a);
*/ */
QCA::SecureArray toArray() const; QCA::SecureArray toArray() const;
/** /**
* Assign from an array. The input is expected to be a binary integer Assign from an array. The input is expected to be a binary integer
* in sign-extended network-byte-order. in sign-extended network-byte-order.
*
* \param a a SecureArray that represents an integer \param a a SecureArray that represents an integer
*
* \sa BigInteger(const SecureArray &a); \sa BigInteger(const SecureArray &a);
* \sa SecureArray toArray() const; \sa SecureArray toArray() const;
*/ */
void fromArray(const QCA::SecureArray &a); void fromArray(const QCA::SecureArray &a);
/** /**
* Convert %BigInteger to a QString Convert %BigInteger to a QString
*
* \code \code
* QString aString; QString aString;
* BigInteger aBiggishInteger( 5878990 ); BigInteger aBiggishInteger( 5878990 );
* aString = aBiggishInteger.toString(); // aString is now "5878990" aString = aBiggishInteger.toString(); // aString is now "5878990"
* \endcode \endcode
*/ */
QString toString() const; QString toString() const;
/** /**
* Assign from a QString Assign from a QString
*
* \param s a QString that represents an integer \param s a QString that represents an integer
*
* \note it is the application's responsibility to make sure \note it is the application's responsibility to make sure
* that the QString represents a valid integer (ie it only that the QString represents a valid integer (ie it only
* contains numbers and an optional minus sign at the start) contains numbers and an optional minus sign at the start)
*
* \sa BigInteger(const QString &s) \sa BigInteger(const QString &s)
* \sa BigInteger & operator=(const QString &s) \sa BigInteger & operator=(const QString &s)
*/ */
bool fromString(const QString &s); bool fromString(const QString &s);
/** /**
* Compare this value with another %BigInteger Compare this value with another %BigInteger
*
* Normally it is more readable to use one of the operator overloads, Normally it is more readable to use one of the operator overloads,
* so you don't need to use this method directly. so you don't need to use this method directly.
*
* \param n the BigInteger to compare with \param n the BigInteger to compare with
*
* \return zero if the values are the same, negative if the argument \return zero if the values are the same, negative if the argument
* is less than the value of this BigInteger, and positive if the argument is less than the value of this BigInteger, and positive if the argument
* value is greater than this BigInteger value is greater than this BigInteger
*
* \code \code
* BigInteger a( "400" ); BigInteger a( "400" );
* BigInteger b( "-400" ); BigInteger b( "-400" );
* BigInteger c( " 200 " ); BigInteger c( " 200 " );
* int result; int result;
* result = a.compare( b ); // return positive 400 > -400 result = a.compare( b ); // return positive 400 > -400
* result = a.compare( c ); // return positive, 400 > 200 result = a.compare( c ); // return positive, 400 > 200
* result = b.compare( c ); // return negative, -400 < 200 result = b.compare( c ); // return negative, -400 < 200
* \endcode \endcode
**/ */
int compare(const BigInteger &n) const; int compare(const BigInteger &n) const;
private: private:
@ -505,80 +498,80 @@ private:
}; };
/** /**
* Equality operator. Returns true if the two BigInteger values Equality operator. Returns true if the two BigInteger values
* are the same, including having the same sign. are the same, including having the same sign
*
* \relates BigInteger \relates BigInteger
**/ */
inline bool operator==(const BigInteger &a, const BigInteger &b) inline bool operator==(const BigInteger &a, const BigInteger &b)
{ {
return (0 == a.compare( b ) ); return (0 == a.compare( b ) );
} }
/** /**
* Inequality operator. Returns true if the two BigInteger values Inequality operator. Returns true if the two BigInteger values
* are different in magnitude, sign or both are different in magnitude, sign or both
*
* \relates BigInteger \relates BigInteger
**/ */
inline bool operator!=(const BigInteger &a, const BigInteger &b) inline bool operator!=(const BigInteger &a, const BigInteger &b)
{ {
return (0 != a.compare( b ) ); return (0 != a.compare( b ) );
} }
/** /**
* Less than or equal operator. Returns true if the BigInteger value Less than or equal operator. Returns true if the BigInteger value
* on the left hand side is equal to or less than the BigInteger value on the left hand side is equal to or less than the BigInteger value
* on the right hand side. on the right hand side.
*
* \relates BigInteger \relates BigInteger
**/ */
inline bool operator<=(const BigInteger &a, const BigInteger &b) inline bool operator<=(const BigInteger &a, const BigInteger &b)
{ {
return (a.compare( b ) <= 0 ); return (a.compare( b ) <= 0 );
} }
/** /**
* Greater than or equal operator. Returns true if the BigInteger value Greater than or equal operator. Returns true if the BigInteger value
* on the left hand side is equal to or greater than the BigInteger value on the left hand side is equal to or greater than the BigInteger value
* on the right hand side. on the right hand side.
*
* \relates BigInteger \relates BigInteger
**/ */
inline bool operator>=(const BigInteger &a, const BigInteger &b) inline bool operator>=(const BigInteger &a, const BigInteger &b)
{ {
return (a.compare( b ) >= 0 ); return (a.compare( b ) >= 0 );
} }
/** /**
* Less than operator. Returns true if the BigInteger value Less than operator. Returns true if the BigInteger value
* on the left hand side is less than the BigInteger value on the left hand side is less than the BigInteger value
* on the right hand side. on the right hand side.
*
* \relates BigInteger \relates BigInteger
**/ */
inline bool operator<(const BigInteger &a, const BigInteger &b) inline bool operator<(const BigInteger &a, const BigInteger &b)
{ {
return (a.compare( b ) < 0 ); return (a.compare( b ) < 0 );
} }
/** /**
* Greater than operator. Returns true if the BigInteger value Greater than operator. Returns true if the BigInteger value
* on the left hand side is greater than the BigInteger value on the left hand side is greater than the BigInteger value
* on the right hand side. on the right hand side.
*
* \relates BigInteger \relates BigInteger
**/ */
inline bool operator>(const BigInteger &a, const BigInteger &b) inline bool operator>(const BigInteger &a, const BigInteger &b)
{ {
return (a.compare( b ) > 0 ); return (a.compare( b ) > 0 );
} }
/** /**
* Stream operator. Stream operator
*
* \relates BigInteger \relates BigInteger
**/ */
QCA_EXPORT QTextStream &operator<<(QTextStream &stream, const BigInteger &b); QCA_EXPORT QTextStream &operator<<(QTextStream &stream, const BigInteger &b);
} }

View File

@ -27,45 +27,46 @@
#include "qca_core.h" #include "qca_core.h"
#include <QMutex> #include <QMutex>
namespace QCA namespace QCA {
class ProviderItem;
class ProviderManager
{ {
class ProviderItem; public:
ProviderManager();
~ProviderManager();
class ProviderManager void scan();
{ bool add(Provider *p, int priority);
public: void unload(const QString &name);
ProviderManager(); void unloadAll();
~ProviderManager(); void setDefault(Provider *p);
Provider *find(Provider *p) const;
Provider *find(const QString &name) const;
Provider *findFor(const QString &name, const QString &type) const;
void changePriority(const QString &name, int priority);
int getPriority(const QString &name);
QStringList allFeatures() const;
ProviderList providers() const;
void scan(); static void mergeFeatures(QStringList *a, const QStringList &b);
bool add(Provider *p, int priority);
void unload(const QString &name);
void unloadAll();
void setDefault(Provider *p);
Provider *find(Provider *p) const;
Provider *find(const QString &name) const;
Provider *findFor(const QString &name, const QString &type) const;
void changePriority(const QString &name, int priority);
int getPriority(const QString &name);
QStringList allFeatures() const;
ProviderList providers() const;
static void mergeFeatures(QStringList *a, const QStringList &b); QString diagnosticText() const;
void appendDiagnosticText(const QString &str);
void clearDiagnosticText();
QString diagnosticText() const; private:
void appendDiagnosticText(const QString &str); mutable QMutex logMutex, providerMutex;
void clearDiagnosticText(); QString dtext;
QList<ProviderItem*> providerItemList;
ProviderList providerList;
Provider *def;
bool scanned_static;
void addItem(ProviderItem *i, int priority);
bool haveAlready(const QString &name) const;
};
private:
mutable QMutex logMutex, providerMutex;
QString dtext;
QList<ProviderItem*> providerItemList;
ProviderList providerList;
Provider *def;
bool scanned_static;
void addItem(ProviderItem *i, int priority);
bool haveAlready(const QString &name) const;
};
} }
#endif #endif

View File

@ -25,10 +25,11 @@
#include "qca_cert.h" #include "qca_cert.h"
namespace QCA namespace QCA {
{
bool qca_have_systemstore(); bool qca_have_systemstore();
CertificateCollection qca_get_systemstore(const QString &provider); CertificateCollection qca_get_systemstore(const QString &provider);
} }
#endif #endif