Qt Cryptographic Architecture: qca_support.h Source File

Qt Cryptographic Architecture

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

qca_support.h
Go to the documentation of this file.
1 /*
2 * qca_support.h - Qt Cryptographic Architecture
3 * Copyright (C) 2003-2005 Justin Karneges <justin@affinix.com>
4 * Copyright (C) 2004,2005, 2007 Brad Hards <bradh@frogmouth.net>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 */
22
36 #ifndef QCA_SUPPORT_H
37 #define QCA_SUPPORT_H
38
39 #include <QByteArray>
40 #include <QString>
41 #include <QObject>
42 #include <QVariant>
43 #include <QVariantList>
44 #include <QStringList>
45 #include <QList>
46 #include <QMetaObject>
47 #include <QThread>
48 #include "qca_export.h"
49 #include "qca_tools.h"
50
51 namespace QCA {
52
101 QCA_EXPORT QByteArray methodReturnType(const QMetaObject *obj, const QByteArray &method, const QList<QByteArray> argTypes);
102
144 QCA_EXPORT bool invokeMethodWithVariants(QObject *obj, const QByteArray &method, const QVariantList &args, QVariant *ret, Qt::ConnectionType type = Qt::AutoConnection);
145
272 class QCA_EXPORT SyncThread : public QThread
273 {
274 Q_OBJECT
275 public:
281 SyncThread(QObject *parent = 0);
282
288 ~SyncThread();
289
295 void start();
296
302 void stop();
303
322 QVariant call(QObject *obj, const QByteArray &method, const QVariantList &args = QVariantList(), bool *ok = 0);
323
324 protected:
328 virtual void atStart() = 0;
329
333 virtual void atEnd() = 0;
334
338 virtual void run();
339
340 private:
341 Q_DISABLE_COPY(SyncThread)
342
343 class Private;
344 friend class Private;
345 Private *d;
346 };
347
353 class QCA_EXPORT Synchronizer : public QObject
354 {
355 Q_OBJECT
356 public:
362 Synchronizer(QObject *parent);
363 ~Synchronizer();
364
372 bool waitForCondition(int msecs = -1);
373
377 void conditionMet();
378
379 private:
380 Q_DISABLE_COPY(Synchronizer)
381
382 class Private;
383 Private *d;
384 };
385
401 class QCA_EXPORT DirWatch : public QObject
402 {
403 Q_OBJECT
404 public:
412 explicit DirWatch(const QString &dir = QString(), QObject *parent = 0);
413 ~DirWatch();
414
418 QString dirName() const;
419
425 void setDirName(const QString &dir);
426
427 Q_SIGNALS:
434 void changed();
435
436 private:
437 Q_DISABLE_COPY(DirWatch)
438
439 class Private;
440 friend class Private;
441 Private *d;
442 };
443
459 class QCA_EXPORT FileWatch : public QObject
460 {
461 Q_OBJECT
462 public:
470 explicit FileWatch(const QString &file = QString(), QObject *parent = 0);
471 ~FileWatch();
472
476 QString fileName() const;
477
483 void setFileName(const QString &file);
484
485 Q_SIGNALS:
490 void changed();
491
492 private:
493 Q_DISABLE_COPY(FileWatch)
494
495 class Private;
496 friend class Private;
497 Private *d;
498 };
499
500 class ConsolePrivate;
501 class ConsoleReferencePrivate;
502 class ConsoleReference;
503
552 class QCA_EXPORT Console : public QObject
553 {
554 Q_OBJECT
555 public:
559 enum Type
560 {
561 Tty,
562 Stdio
563 };
567 enum ChannelMode
568 {
569 Read,
570 ReadWrite
571 };
572
576 enum TerminalMode
577 {
578 Default,
579 Interactive
580 };
581
599 Console(Type type, ChannelMode cmode, TerminalMode tmode, QObject *parent = 0);
600 ~Console();
601
605 Type type() const;
606
610 ChannelMode channelMode() const;
611
615 TerminalMode terminalMode() const;
616
622 static bool isStdinRedirected();
623
629 static bool isStdoutRedirected();
630
637 static Console *ttyInstance();
638
645 static Console *stdioInstance();
646
652 void release();
653
658 QByteArray bytesLeftToRead();
659
664 QByteArray bytesLeftToWrite();
665
666 private:
667 Q_DISABLE_COPY(Console)
668
669 friend class ConsolePrivate;
670 ConsolePrivate *d;
671
672 friend class ConsoleReference;
673 };
674
684 class QCA_EXPORT ConsoleReference : public QObject
685 {
686 Q_OBJECT
687 public:
691 enum SecurityMode
692 {
693 SecurityDisabled,
694 SecurityEnabled
695 };
696
702 ConsoleReference(QObject *parent = 0);
703 ~ConsoleReference();
704
718 bool start(Console *console, SecurityMode mode = SecurityDisabled);
719
723 void stop();
724
730 Console *console() const;
731
738 SecurityMode securityMode() const;
739
749 QByteArray read(int bytes = -1);
750
759 void write(const QByteArray &a);
760
769 SecureArray readSecure(int bytes = -1);
770
778 void writeSecure(const SecureArray &a);
779
786 void closeOutput();
787
792 int bytesAvailable() const;
793
798 int bytesToWrite() const;
799
800 Q_SIGNALS:
805 void readyRead();
806
814 void bytesWritten(int bytes);
815
819 void inputClosed();
820
824 void outputClosed();
825
826 private:
827 Q_DISABLE_COPY(ConsoleReference)
828
829 friend class ConsoleReferencePrivate;
830 ConsoleReferencePrivate *d;
831
832 friend class Console;
833 };
834
855 class QCA_EXPORT ConsolePrompt : public QObject
856 {
857 Q_OBJECT
858 public:
864 ConsolePrompt(QObject *parent = 0);
865 ~ConsolePrompt();
866
876 void getHidden(const QString &promptStr);
877
883 void getChar();
884
891 void waitForFinished();
892
900 SecureArray result() const;
901
909 QChar resultChar() const;
910
911 Q_SIGNALS:
921 void finished();
922
923 private:
924 Q_DISABLE_COPY(ConsolePrompt)
925
926 class Private;
927 friend class Private;
928 Private *d;
929 };
930
931 class AbstractLogDevice;
932
954 class QCA_EXPORT Logger : public QObject
955 {
956 Q_OBJECT
957 public:
964 enum Severity
965 {
966 Quiet = 0,
967 Emergency = 1,
968 Alert = 2,
969 Critical = 3,
970 Error = 4,
971 Warning = 5,
972 Notice = 6,
973 Information = 7,
974 Debug = 8
975 };
976
982 inline Severity level() const { return m_logLevel; }
983
991 void setLevel(Severity level);
992
998 void logTextMessage(const QString &message, Severity = Information);
999
1009 void logBinaryMessage(const QByteArray &blob, Severity = Information);
1010
1016 void registerLogDevice(AbstractLogDevice *logger);
1017
1025 void unregisterLogDevice(const QString &loggerName);
1026
1030 QStringList currentLogDevices() const;
1031
1032 private:
1033 Q_DISABLE_COPY(Logger)
1034
1035 friend class Global;
1036
1040 Logger();
1041
1042 ~Logger();
1043
1044 QStringList m_loggerNames;
1045 QList<AbstractLogDevice*> m_loggers;
1046 Severity m_logLevel;
1047 };
1048
1056 class QCA_EXPORT AbstractLogDevice : public QObject
1057 {
1058 Q_OBJECT
1059 public:
1063 QString name() const;
1064
1075 virtual void logTextMessage(const QString &message, Logger::Severity severity);
1076
1087 virtual void logBinaryMessage(const QByteArray &blob, Logger::Severity severity);
1088
1089 protected:
1096 explicit AbstractLogDevice(const QString &name, QObject *parent = 0);
1097
1098 virtual ~AbstractLogDevice() = 0;
1099
1100 private:
1101 Q_DISABLE_COPY(AbstractLogDevice)
1102
1103 class Private;
1104 Private *d;
1105
1106 QString m_name;
1107 };
1108
1109 }
1110
1111 #endif
QCA::logger
QCA_EXPORT Logger * logger()
Return a reference to the QCA Logger, which is used for diagnostics and error recording.
QCA::ConsolePrompt
Console prompt handler.
Definition: qca_support.h:855
QCA::SyncThread
Convenience class to run a thread and interact with it synchronously.
Definition: qca_support.h:272
QCA::Logger
A simple logging system.
Definition: qca_support.h:954
QCA::Console::TerminalMode
TerminalMode
The nature of the console operation.
Definition: qca_support.h:576
QCA::Console::Type
Type
The type of console object.
Definition: qca_support.h:559
QCA::Console
QCA Console system
Definition: qca_support.h:552
QObject
QCA::FileWatch
Support class to monitor a file for activity.
Definition: qca_support.h:459
QCA::Console::Tty
physical console
Definition: qca_support.h:561
QCA::DirWatch
Support class to monitor a directory for activity.
Definition: qca_support.h:401
qca_export.h
Preprocessor magic to allow export of library symbols.
QCA::Console::Read
Read only (equivalent to stdin)
Definition: qca_support.h:569
QCA::ConsoleReference
Manager for a Console.
Definition: qca_support.h:684
QCA::Console::Default
use default terminal settings
Definition: qca_support.h:578
QCA
QCA - the Qt Cryptographic Architecture.
Definition: qca_basic.h:47
QCA::Synchronizer
Enable synchronization between two threads.
Definition: qca_support.h:353
QCA::AbstractLogDevice
An abstract log device.
Definition: qca_support.h:1056
QCA::SecureArray
Secure array of bytes.
Definition: qca_tools.h:316
QCA::Console::ChannelMode
ChannelMode
The type of I/O to use with the console object.
Definition: qca_support.h:567
QCA::Logger::Severity
Severity
The severity of the message.
Definition: qca_support.h:964
qca_tools.h
Header file for "tool" classes used in QCA.
QCA::ConsoleReference::SecurityMode
SecurityMode
The security setting to use for the Console being managed.
Definition: qca_support.h:691
QThread
QCA::Logger::level
Severity level() const
Get the current logging level.
Definition: qca_support.h:982
QList