[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [KSecretService] 5f895fa: Force kdelibs style using the parameters
From: Michael Leupold <lemma () confuego ! org>
Date: 2010-11-09 19:14:33
Message-ID: 20101109191433.A06F9A6104 () git ! kde ! org
[Download RAW message or body]
commit 5f895fa76ea49dc3d752d12a7635c6d6256f1da7
branch master
Author: Michael Leupold <lemma@confuego.org>
Date: Sat Oct 30 08:32:08 2010 +0000
Force kdelibs style using the parameters from kdesdk and astyle.
CCMAIL: ksecretservice-devel@kde.org
svn path=/trunk/playground/base/ksecretservice/; revision=1191239
diff --git a/backend/backendcollection.cpp b/backend/backendcollection.cpp
index 5691277..16478d4 100644
--- a/backend/backendcollection.cpp
+++ b/backend/backendcollection.cpp
@@ -23,7 +23,7 @@
#include "backendcollectionmanager.h"
BackendCollection::BackendCollection(BackendCollectionManager *manager)
- : QObject(manager)
+ : QObject(manager)
{
}
@@ -31,15 +31,15 @@ BackendCollection::~BackendCollection()
{
}
-bool BackendCollection::isPeerAclAllowed( const Peer* peer ) const
+bool BackendCollection::isPeerAclAllowed(const Peer* peer) const
{
- bool accessAllowed = false;
- return accessAllowed;
+ bool accessAllowed = false;
+ return accessAllowed;
}
bool BackendCollection::askPeerAclAllowed(const Peer* peer) const
{
- return false;
+ return false;
}
#include "backendcollection.moc"
diff --git a/backend/backendcollection.h b/backend/backendcollection.h
index 85a7fba..a6ed7b8 100644
--- a/backend/backendcollection.h
+++ b/backend/backendcollection.h
@@ -36,7 +36,7 @@
class BackendCollectionManager;
class BackendItem;
-
+
/**
* Abstract base class for backend collections.
*
@@ -47,192 +47,192 @@ class BackendItem;
*/
class BackendCollection : public QObject, public JobQueue
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Application permissions stored inside the backend file
- */
- enum ApplicationPermission {
- PermissionAsk = 0, /// ask every time
- PermissionDeny = 1, /// deny every time
- PermissionAllow = 2 /// always allow
- };
-
- /**
- * Constructor
- */
- BackendCollection(BackendCollectionManager *manager = 0);
-
- /**
- * Destructor
- */
- virtual ~BackendCollection();
-
- /**
- * The unique identifier for this collection.
- */
- virtual QString id() const = 0;
-
- /**
- * The human-readable label for this collection.
- */
- virtual BackendReturn<QString> label() const = 0;
-
- /**
- * Set this collection's label human-readable label.
- *
- * @param label the new label for this collection
- */
- virtual BackendReturn<void> setLabel(const QString &label) = 0;
-
- /**
- * The time this collection was created.
- */
- virtual QDateTime created() const = 0;
-
- /**
- * The time this collection was last modified.
- */
- virtual QDateTime modified() const = 0;
-
- /**
- * Check whether this collection is locked.
- *
- * @return true if the collection is locked, false if the collection is
- * unlocked.
- */
- virtual bool isLocked() const = 0;
-
- /**
- * List all items inside this backend.
- *
- * @return a list containing all items inside this backend.
- */
- virtual BackendReturn<QList<BackendItem*> > items() const = 0;
-
- /**
- * Return all items whose attributes match the search terms.
- *
- * @param attributes attributes against which the items should be matched
- * @return a list of items matching the attributes. An empty list either means \
that
- * no items were found or that an error occurred (eg. collection needs
- * unlocking before listing the items).
- */
- virtual BackendReturn<QList<BackendItem*> > searchItems(
- const QMap<QString, QString> &attributes) const = 0;
-
- /**
- * Create a job for unlocking this collection.
- */
- virtual UnlockCollectionJob *createUnlockJob( const CollectionUnlockInfo \
&unlockInfo ) = 0;
-
- /**
- * Create a job for locking this collection.
- */
- virtual LockCollectionJob *createLockJob() = 0;
-
- /**
- * Create a job for deleting this collection.
- */
- virtual DeleteCollectionJob *createDeleteJob( const CollectionDeleteInfo& \
deleteJobInfo ) = 0;
-
- /**
- * Create a job for creating an item.
- *
- * @param label label to assign to the new item
- * @param attributes attributes to store for the new item
- * @param secret the secret to store
- * @param replace if true, an existing item with the same attributes
- * will be replaced, if false no item will be created
- * if one with the same attributes already exists
- * @param locked if true, the item will be locked after creation
- */
- virtual CreateItemJob *createCreateItemJob(const ItemCreateInfo& createInfo) = 0;
-
- /**
- * Create a job for changing this collection's authentication.
- */
- virtual ChangeAuthenticationCollectionJob *createChangeAuthenticationJob() = 0;
-
- /**
- * Check if the given DBus peer has access to this collection
- * Inheritors may want to implement doCheckPeerAclAllowed.
- * Depending on the ApplicationPermission stored for the given peer, his
- * method may pop-up a dialog box asking user for permission.
- * NOTE This method is not virtual to prevent accidental or incorrect \
overloading.
- * @param Peer the peer information or NULL if not called over DBus
- * @return true if the given peer has access or if peer == NULL
- */
- bool isPeerAclAllowed(const Peer* peer) const;
-
- /**
- * Get the permission an executable file has for this collection
- * @param path Path to the executable file
- * @return one of the ApplicationPermission enumeration values
- */
- virtual ApplicationPermission applicationPermission( const QString& path ) const \
=0;
-
- /**
- * Sets the permission an executable application has for this collection.
- * Note that the permissions are stored as per executable path to prevent \
application
- * identify spoofing. User should always carefully read the path to the \
executable when
- * giving access to this collection
- * @param path the complete path to the exectuable
- * @param perm one of the values from the ApplicationPermission enumeration
- * @return true if the permission have been retained. The return value is false \
if
- * the givent executable file does not exist on disc.
- */
- virtual bool setApplicationPermission( const QString& path, ApplicationPermission \
perm ) =0; + /**
+ * Application permissions stored inside the backend file
+ */
+ enum ApplicationPermission {
+ PermissionAsk = 0, /// ask every time
+ PermissionDeny = 1, /// deny every time
+ PermissionAllow = 2 /// always allow
+ };
+
+ /**
+ * Constructor
+ */
+ BackendCollection(BackendCollectionManager *manager = 0);
+
+ /**
+ * Destructor
+ */
+ virtual ~BackendCollection();
+
+ /**
+ * The unique identifier for this collection.
+ */
+ virtual QString id() const = 0;
+
+ /**
+ * The human-readable label for this collection.
+ */
+ virtual BackendReturn<QString> label() const = 0;
+
+ /**
+ * Set this collection's label human-readable label.
+ *
+ * @param label the new label for this collection
+ */
+ virtual BackendReturn<void> setLabel(const QString &label) = 0;
+
+ /**
+ * The time this collection was created.
+ */
+ virtual QDateTime created() const = 0;
+
+ /**
+ * The time this collection was last modified.
+ */
+ virtual QDateTime modified() const = 0;
+
+ /**
+ * Check whether this collection is locked.
+ *
+ * @return true if the collection is locked, false if the collection is
+ * unlocked.
+ */
+ virtual bool isLocked() const = 0;
+
+ /**
+ * List all items inside this backend.
+ *
+ * @return a list containing all items inside this backend.
+ */
+ virtual BackendReturn<QList<BackendItem*> > items() const = 0;
+
+ /**
+ * Return all items whose attributes match the search terms.
+ *
+ * @param attributes attributes against which the items should be matched
+ * @return a list of items matching the attributes. An empty list either means \
that + * no items were found or that an error occurred (eg. collection \
needs + * unlocking before listing the items).
+ */
+ virtual BackendReturn<QList<BackendItem*> > searchItems(
+ const QMap<QString, QString> &attributes) const = 0;
+
+ /**
+ * Create a job for unlocking this collection.
+ */
+ virtual UnlockCollectionJob *createUnlockJob(const CollectionUnlockInfo \
&unlockInfo) = 0; +
+ /**
+ * Create a job for locking this collection.
+ */
+ virtual LockCollectionJob *createLockJob() = 0;
+
+ /**
+ * Create a job for deleting this collection.
+ */
+ virtual DeleteCollectionJob *createDeleteJob(const CollectionDeleteInfo& \
deleteJobInfo) = 0; +
+ /**
+ * Create a job for creating an item.
+ *
+ * @param label label to assign to the new item
+ * @param attributes attributes to store for the new item
+ * @param secret the secret to store
+ * @param replace if true, an existing item with the same attributes
+ * will be replaced, if false no item will be created
+ * if one with the same attributes already exists
+ * @param locked if true, the item will be locked after creation
+ */
+ virtual CreateItemJob *createCreateItemJob(const ItemCreateInfo& createInfo) = \
0; +
+ /**
+ * Create a job for changing this collection's authentication.
+ */
+ virtual ChangeAuthenticationCollectionJob *createChangeAuthenticationJob() = 0;
+
+ /**
+ * Check if the given DBus peer has access to this collection
+ * Inheritors may want to implement doCheckPeerAclAllowed.
+ * Depending on the ApplicationPermission stored for the given peer, his
+ * method may pop-up a dialog box asking user for permission.
+ * NOTE This method is not virtual to prevent accidental or incorrect \
overloading. + * @param Peer the peer information or NULL if not called over DBus
+ * @return true if the given peer has access or if peer == NULL
+ */
+ bool isPeerAclAllowed(const Peer* peer) const;
+
+ /**
+ * Get the permission an executable file has for this collection
+ * @param path Path to the executable file
+ * @return one of the ApplicationPermission enumeration values
+ */
+ virtual ApplicationPermission applicationPermission(const QString& path) const = \
0; +
+ /**
+ * Sets the permission an executable application has for this collection.
+ * Note that the permissions are stored as per executable path to prevent \
application + * identify spoofing. User should always carefully read the path to \
the executable when + * giving access to this collection
+ * @param path the complete path to the exectuable
+ * @param perm one of the values from the ApplicationPermission enumeration
+ * @return true if the permission have been retained. The return value is false \
if + * the givent executable file does not exist on disc.
+ */
+ virtual bool setApplicationPermission(const QString& path, ApplicationPermission \
perm) = 0;
protected:
- /**
- * This member is called by isPeerAclAllowed when peer != NULL and when
- * the application permission for this peer is set to PermissionAsk. An
- * UI job is used to get ask the user if access is to be allowed or not.
- * @param peer the dbus peer information
- * @return always true, allowing access to this collection
- */
- bool askPeerAclAllowed(const Peer*) const;
-
+ /**
+ * This member is called by isPeerAclAllowed when peer != NULL and when
+ * the application permission for this peer is set to PermissionAsk. An
+ * UI job is used to get ask the user if access is to be allowed or not.
+ * @param peer the dbus peer information
+ * @return always true, allowing access to this collection
+ */
+ bool askPeerAclAllowed(const Peer*) const;
+
Q_SIGNALS:
- /**
- * Emitted when a new item within this collection has been created.
- *
- * @param item item that has been created
- */
- void itemCreated(BackendItem *item);
-
- /**
- * Emitted when an item within this collection has been deleted.
- *
- * @param item item that is being deleted
- * @remarks The slot connected to this signal is the last place to safely
- * access the item before it is actually removed.
- */
- void itemDeleted(BackendItem *item);
-
- /**
- * Emitted when an item within this collection has been changed.
- *
- * @param item item that has been changed
- */
- void itemChanged(BackendItem *item);
-
- /**
- * Emitted right before a collection is being deleted in response to a \
deleteCollection
- * call.
- *
- * @param collection the collection being deleted
- */
- void collectionDeleted(BackendCollection *collection);
-
- /**
- * Emitted when the collection has been changed.
- *
- * @param collection the collection that changed
- */
- void collectionChanged(BackendCollection *collection);
+ /**
+ * Emitted when a new item within this collection has been created.
+ *
+ * @param item item that has been created
+ */
+ void itemCreated(BackendItem *item);
+
+ /**
+ * Emitted when an item within this collection has been deleted.
+ *
+ * @param item item that is being deleted
+ * @remarks The slot connected to this signal is the last place to safely
+ * access the item before it is actually removed.
+ */
+ void itemDeleted(BackendItem *item);
+
+ /**
+ * Emitted when an item within this collection has been changed.
+ *
+ * @param item item that has been changed
+ */
+ void itemChanged(BackendItem *item);
+
+ /**
+ * Emitted right before a collection is being deleted in response to a \
deleteCollection + * call.
+ *
+ * @param collection the collection being deleted
+ */
+ void collectionDeleted(BackendCollection *collection);
+
+ /**
+ * Emitted when the collection has been changed.
+ *
+ * @param collection the collection that changed
+ */
+ void collectionChanged(BackendCollection *collection);
};
#endif
diff --git a/backend/backendcollectionmanager.cpp \
b/backend/backendcollectionmanager.cpp index 73ded02..f53bbd6 100644
--- a/backend/backendcollectionmanager.cpp
+++ b/backend/backendcollectionmanager.cpp
@@ -22,7 +22,7 @@
#include "backendcollection.h"
BackendCollectionManager::BackendCollectionManager(QObject *parent)
- : QObject(parent)
+ : QObject(parent)
{
}
diff --git a/backend/backendcollectionmanager.h b/backend/backendcollectionmanager.h
index bd45984..058adec 100644
--- a/backend/backendcollectionmanager.h
+++ b/backend/backendcollectionmanager.h
@@ -30,7 +30,7 @@
class CreateCollectionJob;
class BackendCollection;
class CollectionCreateInfo;
-
+
/**
* Abstract base class for collection managers.
*
@@ -44,55 +44,55 @@ class CollectionCreateInfo;
*/
class BackendCollectionManager : public QObject, public JobQueue
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor
- *
- * @param parent parent object
- */
- BackendCollectionManager(QObject *parent = 0);
-
- /**
- * Destructor
- */
- virtual ~BackendCollectionManager();
+ /**
+ * Constructor
+ *
+ * @param parent parent object
+ */
+ BackendCollectionManager(QObject *parent = 0);
+
+ /**
+ * Destructor
+ */
+ virtual ~BackendCollectionManager();
+
+ /**
+ * Create a job for creating a new collection.
+ *
+ * @param label the label of the new collection
+ * @param lock if true the collection should be locked after creation,
+ * if false it should be unlocked
+ */
+ virtual CreateCollectionJob *createCreateCollectionJob(const \
CollectionCreateInfo& createCollectionInfo) = 0;
- /**
- * Create a job for creating a new collection.
- *
- * @param label the label of the new collection
- * @param lock if true the collection should be locked after creation,
- * if false it should be unlocked
- */
- virtual CreateCollectionJob *createCreateCollectionJob(const \
CollectionCreateInfo& createCollectionInfo) = 0;
-
Q_SIGNALS:
- /**
- * Issued by the manager when a new collection is created or an existing
- * collection is discovered.
- *
- * @param collection collection created or discovered
- */
- void collectionCreated(BackendCollection *collection);
-
- /**
- * Issued by the manager when a collection is removed from
- * the list of known collections.
- *
- * @param collection collection removed
- * @remarks the slot called is the last place a collection
- * can be safely accessed.
- */
- void collectionDeleted(BackendCollection *collection);
+ /**
+ * Issued by the manager when a new collection is created or an existing
+ * collection is discovered.
+ *
+ * @param collection collection created or discovered
+ */
+ void collectionCreated(BackendCollection *collection);
+
+ /**
+ * Issued by the manager when a collection is removed from
+ * the list of known collections.
+ *
+ * @param collection collection removed
+ * @remarks the slot called is the last place a collection
+ * can be safely accessed.
+ */
+ void collectionDeleted(BackendCollection *collection);
- /**
- * Issued by the manager when a collection is changed.
- *
- * @param collection collection that changed
- */
- void collectionChanged(BackendCollection *collection);
+ /**
+ * Issued by the manager when a collection is changed.
+ *
+ * @param collection collection that changed
+ */
+ void collectionChanged(BackendCollection *collection);
};
#endif
diff --git a/backend/backenditem.cpp b/backend/backenditem.cpp
index cb26632..471909c 100644
--- a/backend/backenditem.cpp
+++ b/backend/backenditem.cpp
@@ -22,7 +22,7 @@
#include "backendcollection.h"
BackendItem::BackendItem(BackendCollection *collection) : QObject(collection),
- m_collection(collection)
+ m_collection(collection)
{
}
diff --git a/backend/backenditem.h b/backend/backenditem.h
index d48a81d..adc74cd 100644
--- a/backend/backenditem.h
+++ b/backend/backenditem.h
@@ -42,131 +42,133 @@ class BackendCollection;
*/
class BackendItem : public QObject, public JobQueue
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructor
- */
- BackendItem(BackendCollection *collection = 0);
-
- /**
- * Destructor
- */
- virtual ~BackendItem();
-
- /**
- * The unique identifer for this item.
- */
- virtual QString id() const = 0;
-
- /**
- * The human-readable label for this item.
- */
- virtual BackendReturn<QString> label() const = 0;
-
- /**
- * Set the human-readable label for this item.
- *
- * @param label the new label for this item
- */
- virtual BackendReturn<void> setLabel(const QString &label) = 0;
-
- /**
- * Get the secret stored inside this item.
- *
- * @return the secret
- * @todo this will most likely become non-const as that might make sense
- * with certain backends me reckons.
- */
- virtual BackendReturn<QCA::SecureArray> secret() const = 0;
-
- /**
- * Set the secret stored inside this item.
- *
- * @param secret the secret to store
- */
- virtual BackendReturn<void> setSecret(const QCA::SecureArray &secret) = 0;
-
- /**
- * The attributes of the item.
- *
- * @return the item's attributes
- */
- virtual BackendReturn<QMap<QString, QString> > attributes() const = 0;
-
- /**
- * Set the attributes of this item.
- *
- * @param attributes attributes to assign to this item
- */
- virtual BackendReturn<void> setAttributes(const QMap<QString, QString> \
&attributes) = 0;
-
- /**
- * The time this item was created.
- */
- virtual QDateTime created() const = 0;
-
- /**
- * The time this item was last modified.
- */
- virtual QDateTime modified() const = 0;
-
- /**
- * Check whether this item is locked.
- *
- * @return true if the item is locked, false if the item is
- * unlocked.
- */
- virtual bool isLocked() const = 0;
-
- /**
- * Create a call for unlocking this item.
- */
- virtual UnlockItemJob *createUnlockJob(const ItemUnlockInfo& unlockInfo) = 0;
-
- /**
- * Create a call for locking this item.
- */
- virtual LockItemJob *createLockJob() = 0;
-
- /**
- * Create a call for deleting this item.
- */
- virtual DeleteItemJob *createDeleteJob(const ItemDeleteInfo& deleteJobInfo) = 0;
-
- /**
- * Create a job for changing this item's authentication.
- */
- virtual ChangeAuthenticationItemJob *createChangeAuthenticationJob() = 0;
-
- /**
- * Returns the collection wich holds this item or NULL if this item is not (yet)
- * contained in a collection
- */
- BackendCollection *collection() const { return m_collection; }
-
+ /**
+ * Constructor
+ */
+ BackendItem(BackendCollection *collection = 0);
+
+ /**
+ * Destructor
+ */
+ virtual ~BackendItem();
+
+ /**
+ * The unique identifer for this item.
+ */
+ virtual QString id() const = 0;
+
+ /**
+ * The human-readable label for this item.
+ */
+ virtual BackendReturn<QString> label() const = 0;
+
+ /**
+ * Set the human-readable label for this item.
+ *
+ * @param label the new label for this item
+ */
+ virtual BackendReturn<void> setLabel(const QString &label) = 0;
+
+ /**
+ * Get the secret stored inside this item.
+ *
+ * @return the secret
+ * @todo this will most likely become non-const as that might make sense
+ * with certain backends me reckons.
+ */
+ virtual BackendReturn<QCA::SecureArray> secret() const = 0;
+
+ /**
+ * Set the secret stored inside this item.
+ *
+ * @param secret the secret to store
+ */
+ virtual BackendReturn<void> setSecret(const QCA::SecureArray &secret) = 0;
+
+ /**
+ * The attributes of the item.
+ *
+ * @return the item's attributes
+ */
+ virtual BackendReturn<QMap<QString, QString> > attributes() const = 0;
+
+ /**
+ * Set the attributes of this item.
+ *
+ * @param attributes attributes to assign to this item
+ */
+ virtual BackendReturn<void> setAttributes(const QMap<QString, QString> \
&attributes) = 0; +
+ /**
+ * The time this item was created.
+ */
+ virtual QDateTime created() const = 0;
+
+ /**
+ * The time this item was last modified.
+ */
+ virtual QDateTime modified() const = 0;
+
+ /**
+ * Check whether this item is locked.
+ *
+ * @return true if the item is locked, false if the item is
+ * unlocked.
+ */
+ virtual bool isLocked() const = 0;
+
+ /**
+ * Create a call for unlocking this item.
+ */
+ virtual UnlockItemJob *createUnlockJob(const ItemUnlockInfo& unlockInfo) = 0;
+
+ /**
+ * Create a call for locking this item.
+ */
+ virtual LockItemJob *createLockJob() = 0;
+
+ /**
+ * Create a call for deleting this item.
+ */
+ virtual DeleteItemJob *createDeleteJob(const ItemDeleteInfo& deleteJobInfo) = 0;
+
+ /**
+ * Create a job for changing this item's authentication.
+ */
+ virtual ChangeAuthenticationItemJob *createChangeAuthenticationJob() = 0;
+
+ /**
+ * Returns the collection wich holds this item or NULL if this item is not (yet)
+ * contained in a collection
+ */
+ BackendCollection *collection() const {
+ return m_collection;
+ }
+
Q_SIGNALS:
- /**
- * Emitted right before the item is about to be deleted.
- *
- * @param item the item being deleted
- * @remarks this is only used internally and connected to collection's \
itemDeleted
- * signal.
- */
- void itemDeleted(BackendItem *item);
-
- /**
- * This signal must be emitted whenever the item changes.
- *
- * @param item the item that changed
- * @remarks this is only used internally and connected to collection's \
itemChanged
- * signal.
- */
- void itemChanged(BackendItem *item);
-
+ /**
+ * Emitted right before the item is about to be deleted.
+ *
+ * @param item the item being deleted
+ * @remarks this is only used internally and connected to collection's \
itemDeleted + * signal.
+ */
+ void itemDeleted(BackendItem *item);
+
+ /**
+ * This signal must be emitted whenever the item changes.
+ *
+ * @param item the item that changed
+ * @remarks this is only used internally and connected to collection's \
itemChanged + * signal.
+ */
+ void itemChanged(BackendItem *item);
+
private:
- BackendCollection *m_collection;
+ BackendCollection *m_collection;
};
#endif
diff --git a/backend/backendjob.cpp b/backend/backendjob.cpp
index 7761ce8..6b30ee5 100644
--- a/backend/backendjob.cpp
+++ b/backend/backendjob.cpp
@@ -27,306 +27,306 @@
#include <klocalizedstring.h>
BackendJob::BackendJob(JobType type, JobQueue *queue)
- : QueuedJob(queue), m_type(type), m_dismissed(false), m_error(NoError)
+ : QueuedJob(queue), m_type(type), m_dismissed(false), m_error(NoError)
{
}
bool BackendJob::isImmediate() const
{
- return true;
+ return true;
}
BackendJob::JobType BackendJob::type() const
{
- return m_type;
+ return m_type;
}
bool BackendJob::isDismissed() const
{
- return m_dismissed;
+ return m_dismissed;
}
void BackendJob::dismiss()
{
- m_dismissed = true;
- deleteLater();
- emitResult();
+ m_dismissed = true;
+ deleteLater();
+ emitResult();
}
ErrorType BackendJob::error() const
{
- return m_error;
+ return m_error;
}
const QString &BackendJob::errorMessage() const
{
- return m_errorMessage;
+ return m_errorMessage;
}
void BackendJob::start()
{
- exec();
+ exec();
}
void BackendJob::setError(ErrorType error, const QString &errorMessage)
{
- m_error = error;
- m_errorMessage = errorMessage;
+ m_error = error;
+ m_errorMessage = errorMessage;
}
CreateCollectionJob::CreateCollectionJob(const CollectionCreateInfo \
&createCollectionInfo,
- BackendCollectionManager *manager)
- : BackendJob(BackendJob::TypeCreateCollection, manager),
- m_createCollectionInfo(createCollectionInfo),
- m_manager(manager), m_collection(0)
+ BackendCollectionManager *manager)
+ : BackendJob(BackendJob::TypeCreateCollection, manager),
+ m_createCollectionInfo(createCollectionInfo),
+ m_manager(manager), m_collection(0)
{
}
BackendCollection *CreateCollectionJob::collection()
{
- return m_collection;
+ return m_collection;
}
const QString &CreateCollectionJob::label() const
{
- return m_createCollectionInfo.m_label;
+ return m_createCollectionInfo.m_label;
}
bool CreateCollectionJob::locked() const
{
- return m_createCollectionInfo.m_locked;
+ return m_createCollectionInfo.m_locked;
}
BackendCollectionManager *CreateCollectionJob::manager() const
{
- return m_manager;
+ return m_manager;
}
void CreateCollectionJob::setCollection(BackendCollection *collection)
{
- m_collection = collection;
+ m_collection = collection;
}
CreateCollectionMasterJob::CreateCollectionMasterJob(const CollectionCreateInfo& \
createCollectionInfo,
- BackendMaster *master)
- : BackendJob(BackendJob::TypeCreateCollectionMaster, master),
- m_createCollectionInfo( createCollectionInfo ),
- m_master(master), m_subJob(0), m_collection(0)
+ BackendMaster *master)
+ : BackendJob(BackendJob::TypeCreateCollectionMaster, master),
+ m_createCollectionInfo(createCollectionInfo),
+ m_master(master), m_subJob(0), m_collection(0)
{
}
CreateCollectionMasterJob::~CreateCollectionMasterJob()
{
- // FIXME: do something about a possible subJob!
+ // FIXME: do something about a possible subJob!
}
bool CreateCollectionMasterJob::isImmediate() const
{
- if (m_master->managers().count() == 0) {
- // no manager => job fails
- return true;
- } else {
- // It's safe to assume that the call is not immediate if there are backends
- // available, as only the most basic ones are synchronous.
- return false;
- }
+ if(m_master->managers().count() == 0) {
+ // no manager => job fails
+ return true;
+ } else {
+ // It's safe to assume that the call is not immediate if there are backends
+ // available, as only the most basic ones are synchronous.
+ return false;
+ }
}
void CreateCollectionMasterJob::exec()
{
- if (m_master->managers().count() == 0) {
- setError(ErrorOther, i18n("No backend to create the collection was found."));
- emitResult();
- } else {
- // can't call synchronous if there's a backend.
- Q_ASSERT(false);
- }
+ if(m_master->managers().count() == 0) {
+ setError(ErrorOther, i18n("No backend to create the collection was \
found.")); + emitResult();
+ } else {
+ // can't call synchronous if there's a backend.
+ Q_ASSERT(false);
+ }
}
void CreateCollectionMasterJob::start()
{
- if (m_master->managers().count() == 0) {
- setError(ErrorOther, i18n("No backend to create the collection was found."));
- emitResult();
- } else if (m_master->managers().count() == 1) {
- createSubJob(m_master->managers().first());
- connect(m_subJob, SIGNAL(result(QueuedJob*)),
- SLOT(createCollectionJobFinished(QueuedJob*)));
- m_subJob->enqueue();
- } else {
- setError(ErrorOther, i18n("Not implemented."));
- emitResult();
- }
+ if(m_master->managers().count() == 0) {
+ setError(ErrorOther, i18n("No backend to create the collection was \
found.")); + emitResult();
+ } else if(m_master->managers().count() == 1) {
+ createSubJob(m_master->managers().first());
+ connect(m_subJob, SIGNAL(result(QueuedJob*)),
+ SLOT(createCollectionJobFinished(QueuedJob*)));
+ m_subJob->enqueue();
+ } else {
+ setError(ErrorOther, i18n("Not implemented."));
+ emitResult();
+ }
}
BackendCollection *CreateCollectionMasterJob::collection() const
{
- return m_collection;
+ return m_collection;
}
void CreateCollectionMasterJob::createCollectionJobFinished(QueuedJob *subJob)
{
- // copy the subjob's result
- Q_ASSERT(m_subJob == subJob);
- CreateCollectionJob *ccj = qobject_cast<CreateCollectionJob*>(subJob);
- Q_ASSERT(ccj);
- if (ccj->error() != NoError) {
- setError(ccj->error(), ccj->errorMessage());
- } else {
- m_collection = ccj->collection();
- }
- emitResult();
+ // copy the subjob's result
+ Q_ASSERT(m_subJob == subJob);
+ CreateCollectionJob *ccj = qobject_cast<CreateCollectionJob*>(subJob);
+ Q_ASSERT(ccj);
+ if(ccj->error() != NoError) {
+ setError(ccj->error(), ccj->errorMessage());
+ } else {
+ m_collection = ccj->collection();
+ }
+ emitResult();
}
void CreateCollectionMasterJob::createSubJob(BackendCollectionManager *manager)
{
- Q_ASSERT(!m_subJob);
- m_subJob = manager->createCreateCollectionJob(m_createCollectionInfo);
+ Q_ASSERT(!m_subJob);
+ m_subJob = manager->createCreateCollectionJob(m_createCollectionInfo);
}
BooleanResultJob::BooleanResultJob(BackendJob::JobType type, JobQueue* queue)
- : BackendJob(type, queue)
+ : BackendJob(type, queue)
{
}
bool BooleanResultJob::result() const
{
- return m_result;
+ return m_result;
}
void BooleanResultJob::setResult(bool result)
{
- m_result = result;
+ m_result = result;
}
LockCollectionJob::LockCollectionJob(BackendCollection *collection)
- : BooleanResultJob(BackendJob::TypeLockCollection, collection),
- m_collection(collection)
+ : BooleanResultJob(BackendJob::TypeLockCollection, collection),
+ m_collection(collection)
{
}
BackendCollection *LockCollectionJob::collection()
{
- return m_collection;
+ return m_collection;
}
LockItemJob::LockItemJob(BackendItem *item)
- : BooleanResultJob(BackendJob::TypeLockItem, item), m_item(item)
+ : BooleanResultJob(BackendJob::TypeLockItem, item), m_item(item)
{
}
BackendItem *LockItemJob::item()
{
- return m_item;
+ return m_item;
}
UnlockCollectionJob::UnlockCollectionJob(const CollectionUnlockInfo &unlockInfo, \
BackendCollection *collection)
- : BooleanResultJob(BackendJob::TypeUnlockCollection, collection),
- m_collection(collection), m_unlockInfo(unlockInfo)
+ : BooleanResultJob(BackendJob::TypeUnlockCollection, collection),
+ m_collection(collection), m_unlockInfo(unlockInfo)
{
}
BackendCollection *UnlockCollectionJob::collection()
{
- return m_collection;
+ return m_collection;
}
UnlockItemJob::UnlockItemJob(const ItemUnlockInfo& unlockInfo)
- : BooleanResultJob(BackendJob::TypeUnlockItem, unlockInfo.m_item), m_unlockInfo( \
unlockInfo ) + : BooleanResultJob(BackendJob::TypeUnlockItem, unlockInfo.m_item), \
m_unlockInfo(unlockInfo) {
}
BackendItem *UnlockItemJob::item()
{
- return m_unlockInfo.m_item;
+ return m_unlockInfo.m_item;
}
-DeleteCollectionJob::DeleteCollectionJob( const CollectionDeleteInfo& deleteInfo )
- : BooleanResultJob(BackendJob::TypeDeleteCollection, deleteInfo.m_collection),
- m_deleteInfo(deleteInfo)
+DeleteCollectionJob::DeleteCollectionJob(const CollectionDeleteInfo& deleteInfo)
+ : BooleanResultJob(BackendJob::TypeDeleteCollection, deleteInfo.m_collection),
+ m_deleteInfo(deleteInfo)
{
}
BackendCollection *DeleteCollectionJob::collection()
{
- return m_deleteInfo.m_collection;
+ return m_deleteInfo.m_collection;
}
DeleteItemJob::DeleteItemJob(const ItemDeleteInfo& deleteInfo)
- : BooleanResultJob(BackendJob::TypeDeleteItem, deleteInfo.m_item), \
m_deleteInfo(deleteInfo) + : BooleanResultJob(BackendJob::TypeDeleteItem, \
deleteInfo.m_item), m_deleteInfo(deleteInfo) {
}
BackendItem *DeleteItemJob::item()
{
- return m_deleteInfo.m_item;
+ return m_deleteInfo.m_item;
}
ChangeAuthenticationCollectionJob::ChangeAuthenticationCollectionJob(BackendCollection* \
collection)
- : BooleanResultJob(BackendJob::TypeChangeAuthenticationCollection, collection),
- m_collection(collection)
+ : BooleanResultJob(BackendJob::TypeChangeAuthenticationCollection, collection),
+ m_collection(collection)
{
}
BackendCollection *ChangeAuthenticationCollectionJob::collection()
{
- return m_collection;
+ return m_collection;
}
ChangeAuthenticationItemJob::ChangeAuthenticationItemJob(BackendItem *item)
- : BooleanResultJob(BackendJob::TypeChangeAuthenticationItem, item), m_item(item)
+ : BooleanResultJob(BackendJob::TypeChangeAuthenticationItem, item), m_item(item)
{
}
BackendItem *ChangeAuthenticationItemJob::item()
{
- return m_item;
+ return m_item;
}
CreateItemJob::CreateItemJob(const ItemCreateInfo& createInfo, BackendCollection \
*collection)
- : BackendJob(BackendJob::TypeCreateItem, collection), m_collection(collection),
- m_createInfo(createInfo), m_item(0)
+ : BackendJob(BackendJob::TypeCreateItem, collection), m_collection(collection),
+ m_createInfo(createInfo), m_item(0)
{
}
BackendItem *CreateItemJob::item() const
{
- return m_item;
+ return m_item;
}
const QString &CreateItemJob::label() const
{
- return m_createInfo.m_label;
+ return m_createInfo.m_label;
}
const QMap<QString, QString> &CreateItemJob::attributes() const
{
- return m_createInfo.m_attributes;
+ return m_createInfo.m_attributes;
}
const QCA::SecureArray &CreateItemJob::secret() const
{
- return m_createInfo.m_secret;
+ return m_createInfo.m_secret;
}
bool CreateItemJob::locked() const
{
- return m_createInfo.m_locked;
+ return m_createInfo.m_locked;
}
bool CreateItemJob::replace() const
{
- return m_createInfo.m_replace;
+ return m_createInfo.m_replace;
}
BackendCollection *CreateItemJob::collection()
{
- return m_collection;
+ return m_collection;
}
void CreateItemJob::setItem(BackendItem *item)
{
- m_item = item;
+ m_item = item;
}
#include "backendjob.moc"
diff --git a/backend/backendjob.h b/backend/backendjob.h
index 64f526f..e980af1 100644
--- a/backend/backendjob.h
+++ b/backend/backendjob.h
@@ -33,102 +33,102 @@
*/
class BackendJob : public QueuedJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Types of jobs.
- */
- enum JobType {
- TypeCreateCollectionMaster,
- TypeCreateCollection,
- TypeUnlockCollection,
- TypeLockCollection,
- TypeDeleteCollection,
- TypeChangeAuthenticationCollection,
- TypeCreateItem,
- TypeDeleteItem,
- TypeLockItem,
- TypeUnlockItem,
- TypeChangeAuthenticationItem
- };
-
- /**
- * Constructor.
- *
- * @param type the type of job
- * @param queue the queue object this call will be enqueued to
- * @todo add WId parameter in a way that makes sense (!)
- */
- BackendJob(JobType type, JobQueue *queue);
-
- /**
- * Default implementation for isImmediate() which unconditionally returns
- * true. This is for convenience reasons are many of the inheriting classes
- * implement jobs immediately.
- *
- * @warning this MUST be reimplemented if the job being implemented is not
- * always immediate or needs special handling.
- */
- virtual bool isImmediate() const;
-
- /**
- * Get the job's type.
- *
- * @return the job's type
- */
- JobType type() const;
-
- /**
- * Check if this call has been dismissed.
- *
- * @return true if this call has been dismissed, false else
- */
- bool isDismissed() const;
-
- /**
- * Dismiss this job.
- */
- void dismiss();
-
- /**
- * Check if the job had an error.
- *
- * @return the error or NoError if there was no error
- */
- ErrorType error() const;
-
- /**
- * Get the error message if there is any.
- *
- * @return the error message or an empty string if there is none
- */
- const QString &errorMessage() const;
-
+ /**
+ * Types of jobs.
+ */
+ enum JobType {
+ TypeCreateCollectionMaster,
+ TypeCreateCollection,
+ TypeUnlockCollection,
+ TypeLockCollection,
+ TypeDeleteCollection,
+ TypeChangeAuthenticationCollection,
+ TypeCreateItem,
+ TypeDeleteItem,
+ TypeLockItem,
+ TypeUnlockItem,
+ TypeChangeAuthenticationItem
+ };
+
+ /**
+ * Constructor.
+ *
+ * @param type the type of job
+ * @param queue the queue object this call will be enqueued to
+ * @todo add WId parameter in a way that makes sense (!)
+ */
+ BackendJob(JobType type, JobQueue *queue);
+
+ /**
+ * Default implementation for isImmediate() which unconditionally returns
+ * true. This is for convenience reasons are many of the inheriting classes
+ * implement jobs immediately.
+ *
+ * @warning this MUST be reimplemented if the job being implemented is not
+ * always immediate or needs special handling.
+ */
+ virtual bool isImmediate() const;
+
+ /**
+ * Get the job's type.
+ *
+ * @return the job's type
+ */
+ JobType type() const;
+
+ /**
+ * Check if this call has been dismissed.
+ *
+ * @return true if this call has been dismissed, false else
+ */
+ bool isDismissed() const;
+
+ /**
+ * Dismiss this job.
+ */
+ void dismiss();
+
+ /**
+ * Check if the job had an error.
+ *
+ * @return the error or NoError if there was no error
+ */
+ ErrorType error() const;
+
+ /**
+ * Get the error message if there is any.
+ *
+ * @return the error message or an empty string if there is none
+ */
+ const QString &errorMessage() const;
+
protected:
- /**
- * Default implementation for start() which just calls exec. This is
- * implemented for convenience reasons as it eases the implementation of
- * jobs which can be called immediately.
- *
- * @warning this MUST be reimplemented if the job being implemented is not
- * always immediate or needs special handling.
- */
- virtual void start();
-
- /**
- * Set the job result to be an error.
- *
- * @param error error code
- * @param errorMessage error message
- */
- void setError(ErrorType error, const QString &errorMessage = QString());
-
+ /**
+ * Default implementation for start() which just calls exec. This is
+ * implemented for convenience reasons as it eases the implementation of
+ * jobs which can be called immediately.
+ *
+ * @warning this MUST be reimplemented if the job being implemented is not
+ * always immediate or needs special handling.
+ */
+ virtual void start();
+
+ /**
+ * Set the job result to be an error.
+ *
+ * @param error error code
+ * @param errorMessage error message
+ */
+ void setError(ErrorType error, const QString &errorMessage = QString());
+
private:
- JobType m_type;
- bool m_dismissed;
- ErrorType m_error;
- QString m_errorMessage;
+ JobType m_type;
+ bool m_dismissed;
+ ErrorType m_error;
+ QString m_errorMessage;
};
class BackendMaster;
@@ -143,59 +143,61 @@ class BackendItem;
*/
class CreateCollectionJob : public BackendJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param label human-readable label for the new collection
- * @param locked true if the collection should be locked after creation,
- * false else
- * @param manager the collection manager that should create the collection
- */
- CreateCollectionJob(const CollectionCreateInfo &createCollectionInfo,
- BackendCollectionManager *manager);
-
- /**
- * The collection that was created.
- *
- * @return the collection created or 0 in case of an error
- */
- BackendCollection *collection();
-
+ /**
+ * Constructor.
+ *
+ * @param label human-readable label for the new collection
+ * @param locked true if the collection should be locked after creation,
+ * false else
+ * @param manager the collection manager that should create the collection
+ */
+ CreateCollectionJob(const CollectionCreateInfo &createCollectionInfo,
+ BackendCollectionManager *manager);
+
+ /**
+ * The collection that was created.
+ *
+ * @return the collection created or 0 in case of an error
+ */
+ BackendCollection *collection();
+
protected:
- /**
- * Get the label for the new collection.
- */
- const QString &label() const;
-
- /**
- * Check whether the new collection should be created locked.
- */
- bool locked() const;
-
- /**
- * The manager to call for creating the collection.
- */
- BackendCollectionManager *manager() const;
-
- /**
- * Set the collection created of the job.
- */
- void setCollection(BackendCollection *collection);
-
- /**
- * Get the create collection information structure
- */
- const CollectionCreateInfo &createCollectionInfo() const { return \
m_createCollectionInfo; }
-
+ /**
+ * Get the label for the new collection.
+ */
+ const QString &label() const;
+
+ /**
+ * Check whether the new collection should be created locked.
+ */
+ bool locked() const;
+
+ /**
+ * The manager to call for creating the collection.
+ */
+ BackendCollectionManager *manager() const;
+
+ /**
+ * Set the collection created of the job.
+ */
+ void setCollection(BackendCollection *collection);
+
+ /**
+ * Get the create collection information structure
+ */
+ const CollectionCreateInfo &createCollectionInfo() const {
+ return m_createCollectionInfo;
+ }
+
private:
- CollectionCreateInfo m_createCollectionInfo; // let child classes access this \
member + CollectionCreateInfo m_createCollectionInfo; // let child classes access \
this member +
+ BackendCollectionManager *m_manager;
- BackendCollectionManager *m_manager;
-
- BackendCollection *m_collection;
+ BackendCollection *m_collection;
};
/**
@@ -207,69 +209,69 @@ private:
*/
class CreateCollectionMasterJob : public BackendJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param label human-readable label for the new collection
- * @param locked true if the collection should be locked after creation,
- * false else
- * @param master the master used to create the collection
- */
- CreateCollectionMasterJob(const CollectionCreateInfo& createCollectionInfo,
- BackendMaster *master);
-
- /**
- * Destructor.
- */
- virtual ~CreateCollectionMasterJob();
-
- /**
- * Checks if this call can be made immediately/synchronously.
- *
- * @return true if the call can be made immediately, false if it needs to
- * be queued
- */
- virtual bool isImmediate() const;
-
- /**
- * Execute the job synchronously.
- */
- virtual void exec();
-
- /**
- * Get the collection created by the job.
- *
- * @return the BackendCollection which was created or 0 on failure.
- */
- BackendCollection *collection() const;
+ /**
+ * Constructor.
+ *
+ * @param label human-readable label for the new collection
+ * @param locked true if the collection should be locked after creation,
+ * false else
+ * @param master the master used to create the collection
+ */
+ CreateCollectionMasterJob(const CollectionCreateInfo& createCollectionInfo,
+ BackendMaster *master);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CreateCollectionMasterJob();
+
+ /**
+ * Checks if this call can be made immediately/synchronously.
+ *
+ * @return true if the call can be made immediately, false if it needs to
+ * be queued
+ */
+ virtual bool isImmediate() const;
+
+ /**
+ * Execute the job synchronously.
+ */
+ virtual void exec();
+
+ /**
+ * Get the collection created by the job.
+ *
+ * @return the BackendCollection which was created or 0 on failure.
+ */
+ BackendCollection *collection() const;
protected:
- /**
- * Start the job asynchronously.
- */
- virtual void start();
-
+ /**
+ * Start the job asynchronously.
+ */
+ virtual void start();
+
private Q_SLOTS:
- /**
- * Called when the CreateCollectionJob sent to the collection manager
- * is finished.
- *
- * @param subJob the sub job that finished
- */
- void createCollectionJobFinished(QueuedJob *subJob);
-
+ /**
+ * Called when the CreateCollectionJob sent to the collection manager
+ * is finished.
+ *
+ * @param subJob the sub job that finished
+ */
+ void createCollectionJobFinished(QueuedJob *subJob);
+
private:
- CollectionCreateInfo m_createCollectionInfo;
- BackendMaster *m_master;
- QueuedJob *m_subJob;
-
- // create a subjob enqueued at the given manager
- void createSubJob(BackendCollectionManager *manager);
-
- BackendCollection *m_collection;
+ CollectionCreateInfo m_createCollectionInfo;
+ BackendMaster *m_master;
+ QueuedJob *m_subJob;
+
+ // create a subjob enqueued at the given manager
+ void createSubJob(BackendCollectionManager *manager);
+
+ BackendCollection *m_collection;
};
/**
@@ -278,35 +280,35 @@ private:
*/
class BooleanResultJob : public BackendJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param type concrete type of the job
- * @param queue JobQueue to perform the action on
- */
- BooleanResultJob(BackendJob::JobType type, JobQueue *queue);
-
- /**
- * Get the boolean result of the job.
- *
- * @return the result of the job
- */
- bool result() const;
-
+ /**
+ * Constructor.
+ *
+ * @param type concrete type of the job
+ * @param queue JobQueue to perform the action on
+ */
+ BooleanResultJob(BackendJob::JobType type, JobQueue *queue);
+
+ /**
+ * Get the boolean result of the job.
+ *
+ * @return the result of the job
+ */
+ bool result() const;
+
protected:
- /**
- * Set the result of the job.
- *
- * @param result the job's result
- * @remarks this is called by classes implementing the jobs
- */
- void setResult(bool result);
-
+ /**
+ * Set the result of the job.
+ *
+ * @param result the job's result
+ * @remarks this is called by classes implementing the jobs
+ */
+ void setResult(bool result);
+
private:
- bool m_result;
+ bool m_result;
};
/**
@@ -316,25 +318,25 @@ private:
*/
class LockCollectionJob : public BooleanResultJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor for a job that locks a collection.
- */
- explicit LockCollectionJob(BackendCollection *collection);
-
- /**
- * Get the collection to lock.
- *
- * @remarks public as needed by ServiceMultiPrompt
- */
- BackendCollection *collection();
-
+ /**
+ * Constructor for a job that locks a collection.
+ */
+ explicit LockCollectionJob(BackendCollection *collection);
+
+ /**
+ * Get the collection to lock.
+ *
+ * @remarks public as needed by ServiceMultiPrompt
+ */
+ BackendCollection *collection();
+
private:
- BackendCollection *m_collection;
+ BackendCollection *m_collection;
};
-
+
/**
* Base class for jobs locking an item.
*
@@ -342,23 +344,23 @@ private:
*/
class LockItemJob : public BooleanResultJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor for a job that locks an item.
- */
- explicit LockItemJob(BackendItem *item);
-
- /**
- * Get the item to lock.
- *
- * @remarks public as needed by ServiceMultiPrompt
- */
- BackendItem *item();
-
+ /**
+ * Constructor for a job that locks an item.
+ */
+ explicit LockItemJob(BackendItem *item);
+
+ /**
+ * Get the item to lock.
+ *
+ * @remarks public as needed by ServiceMultiPrompt
+ */
+ BackendItem *item();
+
private:
- BackendItem *m_item;
+ BackendItem *m_item;
};
/**
@@ -368,29 +370,31 @@ private:
*/
class UnlockCollectionJob : public BooleanResultJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- */
- UnlockCollectionJob(const CollectionUnlockInfo &unlockInfo, BackendCollection \
*collection);
-
- /**
- * Get the collection to unlock.
- *
- * @remarks public as needed by ServiceMultiPrompt
- */
- BackendCollection *collection();
-
- /**
- * Get the collection unlock info
- */
- const CollectionUnlockInfo& unlockInfo() const { return m_unlockInfo; }
-
+ /**
+ * Constructor.
+ */
+ UnlockCollectionJob(const CollectionUnlockInfo &unlockInfo, BackendCollection \
*collection); +
+ /**
+ * Get the collection to unlock.
+ *
+ * @remarks public as needed by ServiceMultiPrompt
+ */
+ BackendCollection *collection();
+
+ /**
+ * Get the collection unlock info
+ */
+ const CollectionUnlockInfo& unlockInfo() const {
+ return m_unlockInfo;
+ }
+
private:
- BackendCollection *m_collection;
- CollectionUnlockInfo m_unlockInfo;
+ BackendCollection *m_collection;
+ CollectionUnlockInfo m_unlockInfo;
};
/**
@@ -400,23 +404,23 @@ private:
*/
class UnlockItemJob : public BooleanResultJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- */
- explicit UnlockItemJob( const ItemUnlockInfo& unlockInfo );
-
- /**
- * Get the item to unlock.
- *
- * @remarks public as needed by ServiceMultiPrompt
- */
- BackendItem *item();
-
+ /**
+ * Constructor.
+ */
+ explicit UnlockItemJob(const ItemUnlockInfo& unlockInfo);
+
+ /**
+ * Get the item to unlock.
+ *
+ * @remarks public as needed by ServiceMultiPrompt
+ */
+ BackendItem *item();
+
private:
- ItemUnlockInfo m_unlockInfo;
+ ItemUnlockInfo m_unlockInfo;
};
/**
@@ -424,27 +428,29 @@ private:
*/
class DeleteCollectionJob : public BooleanResultJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- */
- explicit DeleteCollectionJob(const CollectionDeleteInfo& deleteInfo);
-
+ /**
+ * Constructor.
+ */
+ explicit DeleteCollectionJob(const CollectionDeleteInfo& deleteInfo);
+
protected:
- /**
- * Get the collection to delete.
- */
- BackendCollection *collection();
-
- /**
- * Get the collection delete information
- */
- const CollectionDeleteInfo& collectionDeleteInfo() const { return m_deleteInfo; }
-
+ /**
+ * Get the collection to delete.
+ */
+ BackendCollection *collection();
+
+ /**
+ * Get the collection delete information
+ */
+ const CollectionDeleteInfo& collectionDeleteInfo() const {
+ return m_deleteInfo;
+ }
+
private:
- CollectionDeleteInfo m_deleteInfo;
+ CollectionDeleteInfo m_deleteInfo;
};
/**
@@ -452,22 +458,22 @@ private:
*/
class DeleteItemJob : public BooleanResultJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- */
- explicit DeleteItemJob(const ItemDeleteInfo& deleteInfo);
-
+ /**
+ * Constructor.
+ */
+ explicit DeleteItemJob(const ItemDeleteInfo& deleteInfo);
+
protected:
- /**
- * Get the item to delete.
- */
- BackendItem *item();
-
+ /**
+ * Get the item to delete.
+ */
+ BackendItem *item();
+
private:
- ItemDeleteInfo m_deleteInfo;
+ ItemDeleteInfo m_deleteInfo;
};
/**
@@ -475,22 +481,22 @@ private:
*/
class ChangeAuthenticationCollectionJob : public BooleanResultJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- */
- explicit ChangeAuthenticationCollectionJob(BackendCollection *collection);
-
+ /**
+ * Constructor.
+ */
+ explicit ChangeAuthenticationCollectionJob(BackendCollection *collection);
+
protected:
- /**
- * Get the collection to change the authentication for.
- */
- BackendCollection *collection();
-
+ /**
+ * Get the collection to change the authentication for.
+ */
+ BackendCollection *collection();
+
private:
- BackendCollection *m_collection;
+ BackendCollection *m_collection;
};
/**
@@ -498,22 +504,22 @@ private:
*/
class ChangeAuthenticationItemJob : public BooleanResultJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- */
- explicit ChangeAuthenticationItemJob(BackendItem *item);
-
+ /**
+ * Constructor.
+ */
+ explicit ChangeAuthenticationItemJob(BackendItem *item);
+
protected:
- /**
- * Get the collection to change the authentication for.
- */
- BackendItem *item();
-
+ /**
+ * Get the collection to change the authentication for.
+ */
+ BackendItem *item();
+
private:
- BackendItem *m_item;
+ BackendItem *m_item;
};
/**
@@ -521,76 +527,76 @@ private:
*/
class CreateItemJob : public BackendJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param createInfo Item creation contextual information
- * @param collection Collection to create the item in
- */
- CreateItemJob(const ItemCreateInfo& createInfo,
- BackendCollection *collection);
-
- /**
- * The item that was created or 0 if creating the item failed.
- */
- BackendItem *item() const;
-
- /**
- * The collection inside which the item should be created.
- *
- * @remarks this is public because retrieving the collection is needed
- * by PromptSingleJob objects.
- */
- BackendCollection *collection();
-
+ /**
+ * Constructor.
+ *
+ * @param createInfo Item creation contextual information
+ * @param collection Collection to create the item in
+ */
+ CreateItemJob(const ItemCreateInfo& createInfo,
+ BackendCollection *collection);
+
+ /**
+ * The item that was created or 0 if creating the item failed.
+ */
+ BackendItem *item() const;
+
+ /**
+ * The collection inside which the item should be created.
+ *
+ * @remarks this is public because retrieving the collection is needed
+ * by PromptSingleJob objects.
+ */
+ BackendCollection *collection();
+
protected:
- /**
- * The label to assign to the new item.
- */
- const QString &label() const;
-
- /**
- * The attributes to assign to the new item.
- */
- const QMap<QString, QString> &attributes() const;
-
- /**
- * The secret that should be stored.
- *
- * @todo make secure
- */
- const QCA::SecureArray &secret() const;
-
- /**
- * If true, the new item should be created locked, if false it should be unlocked
- * after creation.
- */
- bool locked() const;
-
- /**
- * If true, an existing item with the same attributes should be replaced by the \
new item,
- * if false creating an item with the same attributes as an existing item will \
fail.
- *
- * @todo or will it create a second item?
- */
- bool replace() const;
-
- /**
- * Set the item created.
- *
- * @param item the item which was created.
- * @remarks this is called by inheriting classes
- */
- void setItem(BackendItem *item);
-
+ /**
+ * The label to assign to the new item.
+ */
+ const QString &label() const;
+
+ /**
+ * The attributes to assign to the new item.
+ */
+ const QMap<QString, QString> &attributes() const;
+
+ /**
+ * The secret that should be stored.
+ *
+ * @todo make secure
+ */
+ const QCA::SecureArray &secret() const;
+
+ /**
+ * If true, the new item should be created locked, if false it should be \
unlocked + * after creation.
+ */
+ bool locked() const;
+
+ /**
+ * If true, an existing item with the same attributes should be replaced by the \
new item, + * if false creating an item with the same attributes as an existing \
item will fail. + *
+ * @todo or will it create a second item?
+ */
+ bool replace() const;
+
+ /**
+ * Set the item created.
+ *
+ * @param item the item which was created.
+ * @remarks this is called by inheriting classes
+ */
+ void setItem(BackendItem *item);
+
private:
- BackendCollection *m_collection;
- ItemCreateInfo m_createInfo;
-
- BackendItem *m_item;
+ BackendCollection *m_collection;
+ ItemCreateInfo m_createInfo;
+
+ BackendItem *m_item;
};
#endif // BACKENDJOB_H
diff --git a/backend/backendmaster.cpp b/backend/backendmaster.cpp
index cab1bb8..01e0097 100644
--- a/backend/backendmaster.cpp
+++ b/backend/backendmaster.cpp
@@ -31,86 +31,86 @@ K_GLOBAL_STATIC(BackendMaster, s_backendMaster)
bool BackendMaster::s_initialized = false;
BackendMaster::BackendMaster()
- : m_uiManager(0)
+ : m_uiManager(0)
{
}
BackendMaster::~BackendMaster()
{
- qRemovePostRoutine(s_backendMaster.destroy);
- delete m_uiManager;
+ qRemovePostRoutine(s_backendMaster.destroy);
+ delete m_uiManager;
}
BackendMaster *BackendMaster::instance()
{
- if (!s_initialized) {
- s_initialized = true;
- qAddPostRoutine(s_backendMaster.destroy);
- }
- return s_backendMaster;
+ if(!s_initialized) {
+ s_initialized = true;
+ qAddPostRoutine(s_backendMaster.destroy);
+ }
+ return s_backendMaster;
}
void BackendMaster::addManager(BackendCollectionManager *manager)
{
- Q_ASSERT(manager);
- connect(manager, SIGNAL(collectionCreated(BackendCollection*)),
- SLOT(slotCollectionCreated(BackendCollection*)));
- connect(manager, SIGNAL(collectionDeleted(BackendCollection*)),
- SLOT(slotCollectionDeleted(BackendCollection*)));
- m_collectionManagers.append(manager);
+ Q_ASSERT(manager);
+ connect(manager, SIGNAL(collectionCreated(BackendCollection*)),
+ SLOT(slotCollectionCreated(BackendCollection*)));
+ connect(manager, SIGNAL(collectionDeleted(BackendCollection*)),
+ SLOT(slotCollectionDeleted(BackendCollection*)));
+ m_collectionManagers.append(manager);
}
void BackendMaster::removeManager(BackendCollectionManager *manager)
{
- manager->disconnect(SIGNAL(collectionCreated(BackendCollection*)), this,
- SLOT(slotCollectionCreated(BackendCollection*)));
- manager->disconnect(SIGNAL(collectionDeleted(BackendCollection*)), this,
- SLOT(slotCollectionDeleted(BackendCollection*)));
- m_collectionManagers.removeAll(manager);
+ manager->disconnect(SIGNAL(collectionCreated(BackendCollection*)), this,
+ SLOT(slotCollectionCreated(BackendCollection*)));
+ manager->disconnect(SIGNAL(collectionDeleted(BackendCollection*)), this,
+ SLOT(slotCollectionDeleted(BackendCollection*)));
+ m_collectionManagers.removeAll(manager);
}
const QList<BackendCollection*> &BackendMaster::collections() const
{
- return m_collections;
+ return m_collections;
}
QList<BackendCollectionManager*> &BackendMaster::managers()
{
- return m_collectionManagers;
+ return m_collectionManagers;
}
void BackendMaster::setUiManager(AbstractUiManager *uiManager)
{
- delete m_uiManager;
- m_uiManager = uiManager;
+ delete m_uiManager;
+ m_uiManager = uiManager;
}
AbstractUiManager *BackendMaster::uiManager()
{
- Q_ASSERT(m_uiManager);
- return m_uiManager;
+ Q_ASSERT(m_uiManager);
+ return m_uiManager;
}
CreateCollectionMasterJob *BackendMaster::createCreateCollectionMasterJob(
- const CollectionCreateInfo& createCollectionInfo)
+ const CollectionCreateInfo& createCollectionInfo)
{
- return new CreateCollectionMasterJob(createCollectionInfo, this);
+ return new CreateCollectionMasterJob(createCollectionInfo, this);
}
void BackendMaster::slotCollectionCreated(BackendCollection *collection)
{
- Q_ASSERT(collection);
- m_collections.append(collection);
- connect(collection, SIGNAL(collectionChanged(BackendCollection*)),
- SIGNAL(collectionChanged(BackendCollection*)));
- emit collectionCreated(collection);
+ Q_ASSERT(collection);
+ m_collections.append(collection);
+ connect(collection, SIGNAL(collectionChanged(BackendCollection*)),
+ SIGNAL(collectionChanged(BackendCollection*)));
+ emit collectionCreated(collection);
}
void BackendMaster::slotCollectionDeleted(BackendCollection *collection)
{
- Q_ASSERT(collection);
- m_collections.removeAll(collection);
- emit collectionDeleted(collection);
+ Q_ASSERT(collection);
+ m_collections.removeAll(collection);
+ emit collectionDeleted(collection);
}
#include "backendmaster.moc"
diff --git a/backend/backendmaster.h b/backend/backendmaster.h
index 601a99a..89f5afb 100644
--- a/backend/backendmaster.h
+++ b/backend/backendmaster.h
@@ -45,121 +45,121 @@ class AbstractUiManager;
*/
class BackendMaster : public QObject, public JobQueue
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructor.
- *
- * @remarks only called by K_GLOBAL_STATIC
- */
- BackendMaster();
-
- /**
- * Destructor
- */
- virtual ~BackendMaster();
-
- /**
- * Get the singleton BackendMaster instance.
- */
- static BackendMaster *instance();
-
- /**
- * Adds a new collection manager to the list of known managers.
- *
- * @param manager New collection manager to add
- */
- void addManager(BackendCollectionManager *manager);
-
- /**
- * Remove a collection manager from the list of known managers.
- *
- * @param manager collection manager to remove
- */
- void removeManager(BackendCollectionManager *manager);
-
- /**
- * Get the list of registered collection managers
- *
- * @return the list of registered collection managers
- */
- QList<BackendCollectionManager*> &managers();
-
- /**
- * Get the list of known collections.
- *
- * @return The list of known collections
- */
- const QList<BackendCollection*> &collections() const;
-
- /**
- * Create a job for creating a new collection. The job decides which manager
- * to use for creation (usually based on user input).
- *
- * @param label the label of the new collection
- * @param lock if true, the collection should be locked after creation,
- * if false it should be unlocked
- * @return the collection creation job
- */
- CreateCollectionMasterJob *createCreateCollectionMasterJob(const \
CollectionCreateInfo& createCollectionInfo);
-
- /**
- * Set the user interface manager to use.
- *
- * @remarks Any previously set user interface manager will be deleted.
- * This MUST be set before using any of the backend methods.
- */
- void setUiManager(AbstractUiManager *manager);
-
- /**
- * Get the user interface manager to use.
- */
- AbstractUiManager *uiManager();
+ /**
+ * Constructor.
+ *
+ * @remarks only called by K_GLOBAL_STATIC
+ */
+ BackendMaster();
+
+ /**
+ * Destructor
+ */
+ virtual ~BackendMaster();
+
+ /**
+ * Get the singleton BackendMaster instance.
+ */
+ static BackendMaster *instance();
+
+ /**
+ * Adds a new collection manager to the list of known managers.
+ *
+ * @param manager New collection manager to add
+ */
+ void addManager(BackendCollectionManager *manager);
+
+ /**
+ * Remove a collection manager from the list of known managers.
+ *
+ * @param manager collection manager to remove
+ */
+ void removeManager(BackendCollectionManager *manager);
+
+ /**
+ * Get the list of registered collection managers
+ *
+ * @return the list of registered collection managers
+ */
+ QList<BackendCollectionManager*> &managers();
+
+ /**
+ * Get the list of known collections.
+ *
+ * @return The list of known collections
+ */
+ const QList<BackendCollection*> &collections() const;
+
+ /**
+ * Create a job for creating a new collection. The job decides which manager
+ * to use for creation (usually based on user input).
+ *
+ * @param label the label of the new collection
+ * @param lock if true, the collection should be locked after creation,
+ * if false it should be unlocked
+ * @return the collection creation job
+ */
+ CreateCollectionMasterJob *createCreateCollectionMasterJob(const \
CollectionCreateInfo& createCollectionInfo); +
+ /**
+ * Set the user interface manager to use.
+ *
+ * @remarks Any previously set user interface manager will be deleted.
+ * This MUST be set before using any of the backend methods.
+ */
+ void setUiManager(AbstractUiManager *manager);
+
+ /**
+ * Get the user interface manager to use.
+ */
+ AbstractUiManager *uiManager();
private Q_SLOTS:
- /**
- * Notify the Master about a new collection being available.
- *
- * @param collection New collection to add to the list of known collections
- */
- void slotCollectionCreated(BackendCollection *collection);
-
- /**
- * Notify the Master about a collection getting unavailable.
- *
- * @param collection Collection to remove from the list of known collections
- */
- void slotCollectionDeleted(BackendCollection *collection);
+ /**
+ * Notify the Master about a new collection being available.
+ *
+ * @param collection New collection to add to the list of known collections
+ */
+ void slotCollectionCreated(BackendCollection *collection);
+
+ /**
+ * Notify the Master about a collection getting unavailable.
+ *
+ * @param collection Collection to remove from the list of known collections
+ */
+ void slotCollectionDeleted(BackendCollection *collection);
Q_SIGNALS:
- /**
- * Notify a listening service about creation of a collection.
- *
- * @param collection New collection that is now available
- */
- void collectionCreated(BackendCollection *collection);
-
- /**
- * Notify a listening service about deletion of a collection.
- *
- * @param collection Existing collection that will be removed
- */
- void collectionDeleted(BackendCollection *collection);
-
- /**
- * Notify a listening service about a collection that changed
- *
- * @param collection Collection that changed
- */
- void collectionChanged(BackendCollection *collection);
-
+ /**
+ * Notify a listening service about creation of a collection.
+ *
+ * @param collection New collection that is now available
+ */
+ void collectionCreated(BackendCollection *collection);
+
+ /**
+ * Notify a listening service about deletion of a collection.
+ *
+ * @param collection Existing collection that will be removed
+ */
+ void collectionDeleted(BackendCollection *collection);
+
+ /**
+ * Notify a listening service about a collection that changed
+ *
+ * @param collection Collection that changed
+ */
+ void collectionChanged(BackendCollection *collection);
+
private:
- QList<BackendCollection*> m_collections;
- QList<BackendCollectionManager*> m_collectionManagers;
-
- AbstractUiManager *m_uiManager;
- static bool s_initialized;
+ QList<BackendCollection*> m_collections;
+ QList<BackendCollectionManager*> m_collectionManagers;
+
+ AbstractUiManager *m_uiManager;
+ static bool s_initialized;
};
#endif
diff --git a/backend/backendreturn.h b/backend/backendreturn.h
index 76e917b..e365718 100644
--- a/backend/backendreturn.h
+++ b/backend/backendreturn.h
@@ -27,16 +27,16 @@
* Error codes for backend calls.
*/
enum ErrorType {
- NoError, /// no error
- ErrorOther, /// an unspecified error
- ErrorAlreadyExists, /// a collection could not be created because one with
- /// the same name already exists
- ErrorIsLocked, /// the object (item/collection) must be unlocked before \
this
- /// call can be made
- ErrorNotSupported, /// the backend doesn't support calling this method
+ NoError, /// no error
+ ErrorOther, /// an unspecified error
+ ErrorAlreadyExists, /// a collection could not be created because one with
+ /// the same name already exists
+ ErrorIsLocked, /// the object (item/collection) must be unlocked before \
this + /// call can be made
+ ErrorNotSupported, /// the backend doesn't support calling this method
};
-
+
/**
* Possible Erroneous Return encapsulates return values and an error code/message
* as a method's return value.
@@ -48,58 +48,56 @@ template <typename T>
class BackendReturn
{
public:
- /**
- * Constructor.
- */
- BackendReturn(const T &value, ErrorType error = NoError,
- const QString &errorMessage = QString())
- : m_value(value), m_error(error), m_errorMessage(errorMessage)
- {
- }
-
- /**
- * Copy constructor.
- */
- BackendReturn(const BackendReturn<T> &other)
- : m_value(other.m_value), m_error(other.m_error), \
m_errorMessage(other.m_errorMessage)
- {
- }
-
- /**
- * Get the enclosed value of the object
- */
- const T &value() const {
- return m_value;
- }
-
- /**
- * Check if this return object contains an error.
- *
- * @return true if this return object contains an error, false if it doesn't \
contain
- * an error
- */
- bool isError() const {
- return m_error != NoError;
- }
-
- /**
- * Get the error enclosed in the object
- */
- ErrorType error() const {
- return m_error;
- }
-
- /**
- * Get the error message enclosed in the object
- */
- const QString &errorMessage() const {
- return m_errorMessage;
- }
+ /**
+ * Constructor.
+ */
+ BackendReturn(const T &value, ErrorType error = NoError,
+ const QString &errorMessage = QString())
+ : m_value(value), m_error(error), m_errorMessage(errorMessage) {
+ }
+
+ /**
+ * Copy constructor.
+ */
+ BackendReturn(const BackendReturn<T> &other)
+ : m_value(other.m_value), m_error(other.m_error), \
m_errorMessage(other.m_errorMessage) { + }
+
+ /**
+ * Get the enclosed value of the object
+ */
+ const T &value() const {
+ return m_value;
+ }
+
+ /**
+ * Check if this return object contains an error.
+ *
+ * @return true if this return object contains an error, false if it doesn't \
contain + * an error
+ */
+ bool isError() const {
+ return m_error != NoError;
+ }
+
+ /**
+ * Get the error enclosed in the object
+ */
+ ErrorType error() const {
+ return m_error;
+ }
+
+ /**
+ * Get the error message enclosed in the object
+ */
+ const QString &errorMessage() const {
+ return m_errorMessage;
+ }
private:
- T m_value;
- ErrorType m_error;
- QString m_errorMessage;
+ T m_value;
+ ErrorType m_error;
+ QString m_errorMessage;
};
/**
@@ -109,41 +107,40 @@ template <>
class BackendReturn<void>
{
public:
- /**
- * Constructor.
- */
- BackendReturn(ErrorType error = NoError, const QString &errorMessage = QString())
- : m_error(error), m_errorMessage(errorMessage)
- {
- }
-
- /**
- * Check if this return object contains an error.
- *
- * @return true if this return object contains an error, false if it doesn't \
contain
- * an error
- */
- bool isError() const {
- return m_error != NoError;
- }
-
- /**
- * Get the error enclosed in the object
- */
- ErrorType error() const {
- return m_error;
- }
-
- /**
- * Get the error message enclosed in the object
- */
- const QString &errorMessage() const {
- return m_errorMessage;
- }
+ /**
+ * Constructor.
+ */
+ BackendReturn(ErrorType error = NoError, const QString &errorMessage = \
QString()) + : m_error(error), m_errorMessage(errorMessage) {
+ }
+
+ /**
+ * Check if this return object contains an error.
+ *
+ * @return true if this return object contains an error, false if it doesn't \
contain + * an error
+ */
+ bool isError() const {
+ return m_error != NoError;
+ }
+
+ /**
+ * Get the error enclosed in the object
+ */
+ ErrorType error() const {
+ return m_error;
+ }
+
+ /**
+ * Get the error message enclosed in the object
+ */
+ const QString &errorMessage() const {
+ return m_errorMessage;
+ }
private:
- ErrorType m_error;
- QString m_errorMessage;
+ ErrorType m_error;
+ QString m_errorMessage;
};
#endif
diff --git a/backend/ksecret/ksecretcollection.cpp \
b/backend/ksecret/ksecretcollection.cpp index 4eb2d04..4303d96 100644
--- a/backend/ksecret/ksecretcollection.cpp
+++ b/backend/ksecret/ksecretcollection.cpp
@@ -38,1266 +38,1266 @@
static const QString genericLoadingErrorMessage()
{
- return i18nc("Error message: Generic error loading the ksecret file",
- "There was an error reading the ksecret file.");
+ return i18nc("Error message: Generic error loading the ksecret file",
+ "There was an error reading the ksecret file.");
}
static const QString genericSavingErrorMessage()
{
- return i18nc("Error message: Generic error saving the ksecret file",
- "There was an error writing the ksecret file.");
+ return i18nc("Error message: Generic error saving the ksecret file",
+ "There was an error writing the ksecret file.");
}
// create a symmetric encryption key from a user-supplied password using
// PBKDF2.
// Returns a zero-length key if creating the key failed.
static QCA::SymmetricKey createKeyFromPassword(const QCA::SecureArray &password,
- int keyLength)
+ int keyLength)
{
- if (!QCA::isSupported("sha1")) {
- return QCA::SymmetricKey();
- }
-
- QCA::PBKDF2 deriv("sha1");
- return deriv.makeKey(password, QCA::InitializationVector(), keyLength, 10000);
+ if(!QCA::isSupported("sha1")) {
+ return QCA::SymmetricKey();
+ }
+
+ QCA::PBKDF2 deriv("sha1");
+ return deriv.makeKey(password, QCA::InitializationVector(), keyLength, 10000);
}
KSecretCollection *KSecretCollection::create(const QString &id, const \
QCA::SecureArray &password,
- BackendCollectionManager *parent, \
QString &errorMessage) + BackendCollectionManager *parent, QString \
&errorMessage) {
- KSecretCollection *coll = new KSecretCollection(parent);
- coll->m_id = id;
- coll->m_algoHash = KSecretFile::SHA256;
- coll->m_algoCipher = KSecretFile::AES256;
-
- // initialize default encryption algorithms
- if (!coll->setupAlgorithms(errorMessage)) {
- delete coll;
- return 0;
- }
-
- // create a new symmetric key
- // TODO: is minimum() right in all cases?
- coll->m_symmetricKey = new \
QCA::SymmetricKey(coll->m_cipher->keyLength().minimum());
- QCA::Cipher *keyCipher = coll->m_cipher;
- int keyLength = keyCipher->keyLength().minimum();
- QCA::SymmetricKey keyUnlockKey = createKeyFromPassword(password, keyLength);
- if (keyUnlockKey.isEmpty()) {
- delete coll;
- return 0;
- }
-
- QCA::InitializationVector iv = QCA::InitializationVector(keyLength);
- EncryptedKey *key = new EncryptedKey;
- key->m_type = KSecretFile::KeyPassword;
- key->m_iv = iv.toByteArray();
- keyCipher->setup(QCA::Encode, keyUnlockKey, iv);
- key->m_key.append(keyCipher->update(*coll->m_symmetricKey).toByteArray());
- key->m_key.append(keyCipher->final().toByteArray());
- coll->m_encryptedSymKeys.append(key);
-
- // build the verifier
- coll->m_verInitVector = QCA::InitializationVector(coll->m_cipher->blockSize());
- // get random data and compute its hash
- QCA::SecureArray randomData = QCA::Random::randomArray(VERIFIER_LENGTH);
- coll->m_hash->clear();
- coll->m_hash->update(randomData);
- randomData.append(coll->m_hash->final());
- // now encrypt randomData
- coll->m_cipher->setup(QCA::Encode, *coll->m_symmetricKey, coll->m_verInitVector);
- coll->m_verEncryptedRandom = coll->m_cipher->update(randomData);
- coll->m_verEncryptedRandom.append(coll->m_cipher->final());
-
- return coll;
+ KSecretCollection *coll = new KSecretCollection(parent);
+ coll->m_id = id;
+ coll->m_algoHash = KSecretFile::SHA256;
+ coll->m_algoCipher = KSecretFile::AES256;
+
+ // initialize default encryption algorithms
+ if(!coll->setupAlgorithms(errorMessage)) {
+ delete coll;
+ return 0;
+ }
+
+ // create a new symmetric key
+ // TODO: is minimum() right in all cases?
+ coll->m_symmetricKey = new \
QCA::SymmetricKey(coll->m_cipher->keyLength().minimum()); + QCA::Cipher *keyCipher \
= coll->m_cipher; + int keyLength = keyCipher->keyLength().minimum();
+ QCA::SymmetricKey keyUnlockKey = createKeyFromPassword(password, keyLength);
+ if(keyUnlockKey.isEmpty()) {
+ delete coll;
+ return 0;
+ }
+
+ QCA::InitializationVector iv = QCA::InitializationVector(keyLength);
+ EncryptedKey *key = new EncryptedKey;
+ key->m_type = KSecretFile::KeyPassword;
+ key->m_iv = iv.toByteArray();
+ keyCipher->setup(QCA::Encode, keyUnlockKey, iv);
+ key->m_key.append(keyCipher->update(*coll->m_symmetricKey).toByteArray());
+ key->m_key.append(keyCipher->final().toByteArray());
+ coll->m_encryptedSymKeys.append(key);
+
+ // build the verifier
+ coll->m_verInitVector = QCA::InitializationVector(coll->m_cipher->blockSize());
+ // get random data and compute its hash
+ QCA::SecureArray randomData = QCA::Random::randomArray(VERIFIER_LENGTH);
+ coll->m_hash->clear();
+ coll->m_hash->update(randomData);
+ randomData.append(coll->m_hash->final());
+ // now encrypt randomData
+ coll->m_cipher->setup(QCA::Encode, *coll->m_symmetricKey, \
coll->m_verInitVector); + coll->m_verEncryptedRandom = \
coll->m_cipher->update(randomData); + \
coll->m_verEncryptedRandom.append(coll->m_cipher->final()); +
+ return coll;
}
KSecretCollection::KSecretCollection(BackendCollectionManager *parent)
- : BackendCollection(parent), m_hash(0),
- m_mac(0), m_cipher(0), m_symmetricKey(0)
+ : BackendCollection(parent), m_hash(0),
+ m_mac(0), m_cipher(0), m_symmetricKey(0)
{
}
KSecretCollection::~KSecretCollection()
{
- // TODO: delete items?
- delete m_hash;
- delete m_cipher;
- delete m_mac;
- delete m_symmetricKey;
- qDeleteAll(m_unknownParts);
- qDeleteAll(m_encryptedSymKeys);
- // TODO: make sure there's nothing else to delete
+ // TODO: delete items?
+ delete m_hash;
+ delete m_cipher;
+ delete m_mac;
+ delete m_symmetricKey;
+ qDeleteAll(m_unknownParts);
+ qDeleteAll(m_encryptedSymKeys);
+ // TODO: make sure there's nothing else to delete
}
QString KSecretCollection::id() const
{
- return m_id;
+ return m_id;
}
BackendReturn<QString> KSecretCollection::label() const
{
- return m_label;
+ return m_label;
}
BackendReturn<void> KSecretCollection::setLabel(const QString &label)
{
- // label can only be set if the collection is unlocked
- if (isLocked()) {
- return ErrorIsLocked;
- }
-
- m_label = label;
- emit collectionChanged(this);
- return NoError;
+ // label can only be set if the collection is unlocked
+ if(isLocked()) {
+ return ErrorIsLocked;
+ }
+
+ m_label = label;
+ emit collectionChanged(this);
+ return NoError;
}
QDateTime KSecretCollection::created() const
{
- return m_created;
+ return m_created;
}
QDateTime KSecretCollection::modified() const
{
- return m_modified;
+ return m_modified;
}
bool KSecretCollection::isLocked() const
{
- // a collection is unlocked if m_cipher is initialized
- return (m_symmetricKey == 0);
+ // a collection is unlocked if m_cipher is initialized
+ return (m_symmetricKey == 0);
}
BackendReturn<QList<BackendItem*> > KSecretCollection::items() const
{
- QList<BackendItem*> itemList;
- QHash<QString, KSecretItem*>::const_iterator it = m_items.constBegin();
- QHash<QString, KSecretItem*>::const_iterator end = m_items.constEnd();
- for ( ; it != end; ++it) {
- itemList.append(it.value());
- }
-
- return itemList;
+ QList<BackendItem*> itemList;
+ QHash<QString, KSecretItem*>::const_iterator it = m_items.constBegin();
+ QHash<QString, KSecretItem*>::const_iterator end = m_items.constEnd();
+ for(; it != end; ++it) {
+ itemList.append(it.value());
+ }
+
+ return itemList;
}
BackendReturn<QList<BackendItem*> > KSecretCollection::searchItems(
- const QMap<QString, QString> &attributes) const
+ const QMap<QString, QString> &attributes) const
{
- QList<BackendItem*> itemList;
- // create hashes for each of the attributes queried
- QSet<QByteArray> attributeHashes = KSecretItem::createHashes(attributes, m_hash);
- if (attributeHashes.isEmpty()) {
- return items();
- } else {
- // use the first attribute hash to build an initial list of items matching
- QHash<QByteArray, KSecretItem*>::const_iterator resit =
- m_itemHashes.constFind(*attributeHashes.constBegin());
- QHash<QByteArray, KSecretItem*>::const_iterator resend = \
m_itemHashes.constEnd();
- // now check which of the items in resit match the remainder of the attributes
- // to do this the actual attributes are used instead of the hashes
- for ( ; resit != resend; ++resit) {
- if (resit.value()->matches(attributes)) {
- itemList.append(resit.value());
- }
- }
- return itemList;
- }
+ QList<BackendItem*> itemList;
+ // create hashes for each of the attributes queried
+ QSet<QByteArray> attributeHashes = KSecretItem::createHashes(attributes, \
m_hash); + if(attributeHashes.isEmpty()) {
+ return items();
+ } else {
+ // use the first attribute hash to build an initial list of items matching
+ QHash<QByteArray, KSecretItem*>::const_iterator resit =
+ m_itemHashes.constFind(*attributeHashes.constBegin());
+ QHash<QByteArray, KSecretItem*>::const_iterator resend = \
m_itemHashes.constEnd(); + // now check which of the items in resit match the \
remainder of the attributes + // to do this the actual attributes are used \
instead of the hashes + for(; resit != resend; ++resit) {
+ if(resit.value()->matches(attributes)) {
+ itemList.append(resit.value());
+ }
+ }
+ return itemList;
+ }
}
-UnlockCollectionJob *KSecretCollection::createUnlockJob( const CollectionUnlockInfo \
&unlockInfo ) +UnlockCollectionJob *KSecretCollection::createUnlockJob(const \
CollectionUnlockInfo &unlockInfo) {
- UnlockCollectionJob *job = new KSecretUnlockCollectionJob(unlockInfo, this);
- return job;
+ UnlockCollectionJob *job = new KSecretUnlockCollectionJob(unlockInfo, this);
+ return job;
}
LockCollectionJob *KSecretCollection::createLockJob()
{
- return new KSecretLockCollectionJob(this);
+ return new KSecretLockCollectionJob(this);
}
DeleteCollectionJob *KSecretCollection::createDeleteJob(const CollectionDeleteInfo& \
deleteJobInfo) {
- deleteJobInfo.m_collection = this;
- return new KSecretDeleteCollectionJob(deleteJobInfo);
+ deleteJobInfo.m_collection = this;
+ return new KSecretDeleteCollectionJob(deleteJobInfo);
}
BackendReturn<bool> KSecretCollection::deleteCollection()
{
- // remove the ksecret file
- if (!QFile::remove(m_path)) {
- return false;
- }
-
- // emit signals and actually delete
- emit collectionDeleted(this);
- deleteLater();
- return true;
+ // remove the ksecret file
+ if(!QFile::remove(m_path)) {
+ return false;
+ }
+
+ // emit signals and actually delete
+ emit collectionDeleted(this);
+ deleteLater();
+ return true;
}
CreateItemJob *KSecretCollection::createCreateItemJob(const ItemCreateInfo& \
createInfo) {
- return new KSecretCreateItemJob(createInfo, this);
+ return new KSecretCreateItemJob(createInfo, this);
}
-
+
ChangeAuthenticationCollectionJob \
*KSecretCollection::createChangeAuthenticationJob() {
- return new KSecretChangeAuthenticationCollectionJob(this);
+ return new KSecretChangeAuthenticationCollectionJob(this);
}
BackendReturn<BackendItem*> KSecretCollection::createItem(const QString &label,
- const QMap<QString, \
QString> &attributes,
- const QCA::SecureArray \
&secret,
- bool locked, bool replace)
+ const QMap<QString, QString> &attributes,
+ const QCA::SecureArray &secret,
+ bool locked, bool replace)
{
- // TODO: use locked argument
- Q_UNUSED(locked);
-
- // only works if unlocked
- if (isLocked()) {
- return BackendReturn<BackendItem*>(0, ErrorIsLocked);
- } else {
- KSecretItem *item = 0;
- bool replacing = false;
-
- // check for duplicates
- BackendReturn<QList<BackendItem*> > foundItems = searchItems(attributes);
- if (!foundItems.isError() && foundItems.value().size() > 0) {
- QList<BackendItem*> oldlist = foundItems.value();
- Q_FOREACH(BackendItem *olditem, oldlist) {
- if (olditem->attributes().value() == attributes) {
- if (replace) {
- // replace an existing item
- item = qobject_cast<KSecretItem*>(olditem);
- replacing = true;
- } else {
- // item existing but should not be replaced
- return BackendReturn<BackendItem*>(0, ErrorAlreadyExists);
- }
- break;
+ // TODO: use locked argument
+ Q_UNUSED(locked);
+
+ // only works if unlocked
+ if(isLocked()) {
+ return BackendReturn<BackendItem*>(0, ErrorIsLocked);
+ } else {
+ KSecretItem *item = 0;
+ bool replacing = false;
+
+ // check for duplicates
+ BackendReturn<QList<BackendItem*> > foundItems = searchItems(attributes);
+ if(!foundItems.isError() && foundItems.value().size() > 0) {
+ QList<BackendItem*> oldlist = foundItems.value();
+ Q_FOREACH(BackendItem * olditem, oldlist) {
+ if(olditem->attributes().value() == attributes) {
+ if(replace) {
+ // replace an existing item
+ item = qobject_cast<KSecretItem*>(olditem);
+ replacing = true;
+ } else {
+ // item existing but should not be replaced
+ return BackendReturn<BackendItem*>(0, ErrorAlreadyExists);
+ }
+ break;
+ }
}
- }
- }
-
- if (!item) {
- item = new KSecretItem(createId(), this);
- connect(item, SIGNAL(attributesChanged(KSecretItem*)),
- SLOT(changeAttributeHashes(KSecretItem*)));
- }
- item->m_label = label;
- item->m_attributes = attributes;
- item->m_secret = secret;
-
- // insert new item's hashes
- changeAttributeHashes(item);
-
- if (replacing) {
- emit itemChanged(item);
- } else {
- m_items.insert(item->id(), item);
- // new item, signals need to be wired
- connect(item, SIGNAL(itemDeleted(BackendItem*)), \
SLOT(slotItemDeleted(BackendItem*)));
- connect(item, SIGNAL(itemChanged(BackendItem*)), \
SIGNAL(itemChanged(BackendItem*)));
- emit itemCreated(item);
- }
-
- return item;
- }
+ }
+
+ if(!item) {
+ item = new KSecretItem(createId(), this);
+ connect(item, SIGNAL(attributesChanged(KSecretItem*)),
+ SLOT(changeAttributeHashes(KSecretItem*)));
+ }
+ item->m_label = label;
+ item->m_attributes = attributes;
+ item->m_secret = secret;
+
+ // insert new item's hashes
+ changeAttributeHashes(item);
+
+ if(replacing) {
+ emit itemChanged(item);
+ } else {
+ m_items.insert(item->id(), item);
+ // new item, signals need to be wired
+ connect(item, SIGNAL(itemDeleted(BackendItem*)), \
SLOT(slotItemDeleted(BackendItem*))); + connect(item, \
SIGNAL(itemChanged(BackendItem*)), SIGNAL(itemChanged(BackendItem*))); + \
emit itemCreated(item); + }
+
+ return item;
+ }
}
const QString &KSecretCollection::path() const
{
- return m_path;
+ return m_path;
}
void KSecretCollection::slotItemDeleted(BackendItem *item)
{
- KSecretItem *kitem = qobject_cast<KSecretItem*>(item);
- Q_ASSERT(kitem);
-
- // remove the item as well as item hashes
- if (m_reverseItemHashes.contains(kitem)) {
- Q_FOREACH(const QByteArray &hash, m_reverseItemHashes.value(kitem)) {
- m_itemHashes.remove(hash);
- }
- m_reverseItemHashes.remove(kitem);
- }
- m_items.remove(kitem->id());
-
- emit itemDeleted(item);
+ KSecretItem *kitem = qobject_cast<KSecretItem*>(item);
+ Q_ASSERT(kitem);
+
+ // remove the item as well as item hashes
+ if(m_reverseItemHashes.contains(kitem)) {
+ Q_FOREACH(const QByteArray & hash, m_reverseItemHashes.value(kitem)) {
+ m_itemHashes.remove(hash);
+ }
+ m_reverseItemHashes.remove(kitem);
+ }
+ m_items.remove(kitem->id());
+
+ emit itemDeleted(item);
}
void KSecretCollection::changeAttributeHashes(KSecretItem *item)
{
- Q_ASSERT(item);
-
- // remove previous item hashes
- if (m_reverseItemHashes.contains(item)) {
- QSet<QByteArray> oldHashes = m_reverseItemHashes.value(item);
- Q_FOREACH(const QByteArray &hash, oldHashes) {
- m_itemHashes.remove(hash, item);
- }
- }
-
- // insert new hashes
- QSet<QByteArray> attributeHashes = item->createAttributeHashes(m_hash);
- Q_FOREACH(const QByteArray &hash, attributeHashes) {
- m_itemHashes.insert(hash, item);
- }
- m_reverseItemHashes.insert(item, attributeHashes);
+ Q_ASSERT(item);
+
+ // remove previous item hashes
+ if(m_reverseItemHashes.contains(item)) {
+ QSet<QByteArray> oldHashes = m_reverseItemHashes.value(item);
+ Q_FOREACH(const QByteArray & hash, oldHashes) {
+ m_itemHashes.remove(hash, item);
+ }
+ }
+
+ // insert new hashes
+ QSet<QByteArray> attributeHashes = item->createAttributeHashes(m_hash);
+ Q_FOREACH(const QByteArray & hash, attributeHashes) {
+ m_itemHashes.insert(hash, item);
+ }
+ m_reverseItemHashes.insert(item, attributeHashes);
}
KSecretCollection *KSecretCollection::deserialize(const QString &path,
- KSecretCollectionManager *parent,
- QString &errorMessage)
+ KSecretCollectionManager *parent,
+ QString &errorMessage)
{
- QFile device(path);
- KSecretFile file(&device, KSecretFile::Read);
- if (!file.isValid()) {
- errorMessage = i18nc("Error message: collection file to be opened doesn't \
exist",
- "Collection does not exist.");
- return 0;
- }
-
- KSecretCollection *coll = new KSecretCollection(parent);
- coll->m_path = path;
-
- if (!coll->deserializeHeader(file, errorMessage) ||
- !coll->deserializeParts(file, errorMessage)) {
- delete coll;
- return 0;
- }
-
- return coll;
+ QFile device(path);
+ KSecretFile file(&device, KSecretFile::Read);
+ if(!file.isValid()) {
+ errorMessage = i18nc("Error message: collection file to be opened doesn't \
exist", + "Collection does not exist.");
+ return 0;
+ }
+
+ KSecretCollection *coll = new KSecretCollection(parent);
+ coll->m_path = path;
+
+ if(!coll->deserializeHeader(file, errorMessage) ||
+ !coll->deserializeParts(file, errorMessage)) {
+ delete coll;
+ return 0;
+ }
+
+ return coll;
}
bool KSecretCollection::tryUnlock()
{
- // TODO: after unlocking, check integrity by verifying the MACs.
-
- // before actually trying to unlock, check if the key matches by decrypting
- // the verifier.
- m_cipher->setup(QCA::Decode, *m_symmetricKey, m_verInitVector);
- QCA::SecureArray verifier = m_cipher->update(m_verEncryptedRandom);
- verifier.append(m_cipher->final());
- QCA::SecureArray randomData(VERIFIER_LENGTH);
- QCA::SecureArray verifierHash(verifier.size() - VERIFIER_LENGTH);
- int i = 0;
- for ( ; i < VERIFIER_LENGTH; ++i) {
- randomData[i] = verifier[i];
- }
- for ( ; i < verifier.size(); ++i) {
- verifierHash[i - VERIFIER_LENGTH] = verifier[i];
- }
- // rebuild the hash and compare to the decrypted one
- m_hash->clear();
- m_hash->update(randomData);
- if (verifierHash != m_hash->final()) {
- // hashes don't match, the master key is wrong.
- return false;
- }
-
- QCA::SecureArray decryptedPart;
- Q_FOREACH(const QByteArray &partContents, m_encryptedItemParts) {
- if (!deserializePartEncrypted(partContents, decryptedPart)) {
- return false;
- }
-
- // deserialize the items inside the decrypted part
- SecureBuffer device(&decryptedPart);
- KSecretFile itemFile(&device, KSecretFile::Read);
- if (!deserializeItemsUnlocked(itemFile)) {
- return false;
- }
- }
-
- emit collectionChanged(this);
-
- return true;
+ // TODO: after unlocking, check integrity by verifying the MACs.
+
+ // before actually trying to unlock, check if the key matches by decrypting
+ // the verifier.
+ m_cipher->setup(QCA::Decode, *m_symmetricKey, m_verInitVector);
+ QCA::SecureArray verifier = m_cipher->update(m_verEncryptedRandom);
+ verifier.append(m_cipher->final());
+ QCA::SecureArray randomData(VERIFIER_LENGTH);
+ QCA::SecureArray verifierHash(verifier.size() - VERIFIER_LENGTH);
+ int i = 0;
+ for(; i < VERIFIER_LENGTH; ++i) {
+ randomData[i] = verifier[i];
+ }
+ for(; i < verifier.size(); ++i) {
+ verifierHash[i - VERIFIER_LENGTH] = verifier[i];
+ }
+ // rebuild the hash and compare to the decrypted one
+ m_hash->clear();
+ m_hash->update(randomData);
+ if(verifierHash != m_hash->final()) {
+ // hashes don't match, the master key is wrong.
+ return false;
+ }
+
+ QCA::SecureArray decryptedPart;
+ Q_FOREACH(const QByteArray & partContents, m_encryptedItemParts) {
+ if(!deserializePartEncrypted(partContents, decryptedPart)) {
+ return false;
+ }
+
+ // deserialize the items inside the decrypted part
+ SecureBuffer device(&decryptedPart);
+ KSecretFile itemFile(&device, KSecretFile::Read);
+ if(!deserializeItemsUnlocked(itemFile)) {
+ return false;
+ }
+ }
+
+ emit collectionChanged(this);
+
+ return true;
}
BackendReturn<bool> KSecretCollection::tryUnlockPassword(const QCA::SecureArray \
&password) {
- // TODO: reference/open counting?
-
- bool unlocked = false;
-
- QCA::Cipher *keyCipher = m_cipher;
- int keyLength = keyCipher->keyLength().minimum();
- QCA::SymmetricKey keyUnlockKey = createKeyFromPassword(password, keyLength);
- // try decrypting any of the symmetric keys using the keyUnlockKey
- Q_FOREACH(EncryptedKey *key, m_encryptedSymKeys) {
- if (key->m_type == KSecretFile::KeyPassword) {
- keyCipher->setup(QCA::Decode, keyUnlockKey, key->m_iv);
- QCA::SecureArray unlockedKey = keyCipher->update(key->m_key);
- unlockedKey.append(keyCipher->final());
- m_symmetricKey = new QCA::SymmetricKey(unlockedKey);
-
- unlocked = tryUnlock();
- if (unlocked) {
- break;
- }
- }
- }
-
- return unlocked;
+ // TODO: reference/open counting?
+
+ bool unlocked = false;
+
+ QCA::Cipher *keyCipher = m_cipher;
+ int keyLength = keyCipher->keyLength().minimum();
+ QCA::SymmetricKey keyUnlockKey = createKeyFromPassword(password, keyLength);
+ // try decrypting any of the symmetric keys using the keyUnlockKey
+ Q_FOREACH(EncryptedKey * key, m_encryptedSymKeys) {
+ if(key->m_type == KSecretFile::KeyPassword) {
+ keyCipher->setup(QCA::Decode, keyUnlockKey, key->m_iv);
+ QCA::SecureArray unlockedKey = keyCipher->update(key->m_key);
+ unlockedKey.append(keyCipher->final());
+ m_symmetricKey = new QCA::SymmetricKey(unlockedKey);
+
+ unlocked = tryUnlock();
+ if(unlocked) {
+ break;
+ }
+ }
+ }
+
+ return unlocked;
}
BackendReturn<bool> KSecretCollection::lock()
{
- // TODO: reference/open counting?
-
- // TODO: emit signals?
-
- if (isLocked()) {
- return true;
- } else {
- // TODO: only serialize if dirty
- QString errorMessage;
- if (!serialize(errorMessage)) {
- return BackendReturn<bool>(false, ErrorOther, errorMessage);
- }
-
- // remove individual item secrets
- QHash<QString, KSecretItem*>::iterator it = m_items.begin();
- QHash<QString, KSecretItem*>::iterator end = m_items.end();
- for ( ; it != end; ++it) {
- // FIXME: it.value()->removeSecrets();
- }
-
- // remove symmetric key
- delete m_symmetricKey;
- m_symmetricKey = 0;
-
- emit collectionChanged(this);
-
- return true;
- }
+ // TODO: reference/open counting?
+
+ // TODO: emit signals?
+
+ if(isLocked()) {
+ return true;
+ } else {
+ // TODO: only serialize if dirty
+ QString errorMessage;
+ if(!serialize(errorMessage)) {
+ return BackendReturn<bool>(false, ErrorOther, errorMessage);
+ }
+
+ // remove individual item secrets
+ QHash<QString, KSecretItem*>::iterator it = m_items.begin();
+ QHash<QString, KSecretItem*>::iterator end = m_items.end();
+ for(; it != end; ++it) {
+ // FIXME: it.value()->removeSecrets();
+ }
+
+ // remove symmetric key
+ delete m_symmetricKey;
+ m_symmetricKey = 0;
+
+ emit collectionChanged(this);
+
+ return true;
+ }
}
bool KSecretCollection::setupAlgorithms(QString &errorMessage)
{
- // figure out algorithms to use
- switch (m_algoHash) {
-
- case KSecretFile::SHA256:
- if (!QCA::isSupported("sha256") || !QCA::isSupported("hmac(sha256)")) {
- errorMessage = i18nc("Error message: unsupported hashing algorithm SHA256 \
used",
- "The hashing algorithm SHA256 is not supported by your \
installation.");
- return false;
- }
- m_hash = new QCA::Hash("sha256");
- m_mac = new QCA::MessageAuthenticationCode("hmac(sha256)", \
QCA::SymmetricKey());
- break;
-
- default:
- errorMessage = i18nc("Error message: unknown hashing algorithm used",
- "The file uses an unknown hashing algorithm.");
- return false;
- }
-
- switch (m_algoCipher) {
-
- case KSecretFile::AES256:
- if (!QCA::isSupported("aes256-cbc-pkcs7")) {
- errorMessage = i18nc("Error message: unsupported encryption algorithm \
AES256 used",
- "The encryption algorithm AES256 is not suppored by \
your installation.");
- return false;
- }
- m_cipher = new QCA::Cipher("aes256", QCA::Cipher::CBC, QCA::Cipher::PKCS7);
- break;
-
- default:
- errorMessage = i18nc("Error message: unknown encryption algorithm used",
- "The file uses an unknown encryption algorithm.");
- return false;
- }
-
- return true;
+ // figure out algorithms to use
+ switch(m_algoHash) {
+
+ case KSecretFile::SHA256:
+ if(!QCA::isSupported("sha256") || !QCA::isSupported("hmac(sha256)")) {
+ errorMessage = i18nc("Error message: unsupported hashing algorithm \
SHA256 used", + "The hashing algorithm SHA256 is not \
supported by your installation."); + return false;
+ }
+ m_hash = new QCA::Hash("sha256");
+ m_mac = new QCA::MessageAuthenticationCode("hmac(sha256)", \
QCA::SymmetricKey()); + break;
+
+ default:
+ errorMessage = i18nc("Error message: unknown hashing algorithm used",
+ "The file uses an unknown hashing algorithm.");
+ return false;
+ }
+
+ switch(m_algoCipher) {
+
+ case KSecretFile::AES256:
+ if(!QCA::isSupported("aes256-cbc-pkcs7")) {
+ errorMessage = i18nc("Error message: unsupported encryption algorithm \
AES256 used", + "The encryption algorithm AES256 is \
not suppored by your installation."); + return false;
+ }
+ m_cipher = new QCA::Cipher("aes256", QCA::Cipher::CBC, QCA::Cipher::PKCS7);
+ break;
+
+ default:
+ errorMessage = i18nc("Error message: unknown encryption algorithm used",
+ "The file uses an unknown encryption algorithm.");
+ return false;
+ }
+
+ return true;
}
bool KSecretCollection::deserializeHeader(KSecretFile &file, QString &errorMessage)
{
- // magic, version numbers
- quint32 versionMajor;
- quint32 versionMinor;
- if (!file.readMagic() || !file.readUint(&versionMajor) || \
!file.readUint(&versionMinor)) {
- errorMessage = i18nc("Error message: collection has wrong file format or is \
corrupted",
- "Collection is not a ksecret file or is corrupted.");
- return false;
- }
-
- // check if version number matches something we understand
- if (versionMajor > VERSION_MAJOR) {
- errorMessage = i18nc("Error message: collection's file format is too recent",
- "The file format used is too recent.");
- return false;
- }
-
- // algorithms
- if (!file.readUint(&m_algoHash) || !file.readUint(&m_algoCipher)) {
- errorMessage = genericLoadingErrorMessage();
- return false;
- }
- if (!setupAlgorithms(errorMessage)) {
- // TODO: error message
- return false;
- }
-
- // verifier
- if (!file.readSecret(&m_verInitVector) || \
!file.readSecret(&m_verEncryptedRandom)) {
- errorMessage = genericLoadingErrorMessage();
- return false;
- }
-
- return true;
+ // magic, version numbers
+ quint32 versionMajor;
+ quint32 versionMinor;
+ if(!file.readMagic() || !file.readUint(&versionMajor) || \
!file.readUint(&versionMinor)) { + errorMessage = i18nc("Error message: \
collection has wrong file format or is corrupted", + \
"Collection is not a ksecret file or is corrupted."); + return false;
+ }
+
+ // check if version number matches something we understand
+ if(versionMajor > VERSION_MAJOR) {
+ errorMessage = i18nc("Error message: collection's file format is too \
recent", + "The file format used is too recent.");
+ return false;
+ }
+
+ // algorithms
+ if(!file.readUint(&m_algoHash) || !file.readUint(&m_algoCipher)) {
+ errorMessage = genericLoadingErrorMessage();
+ return false;
+ }
+ if(!setupAlgorithms(errorMessage)) {
+ // TODO: error message
+ return false;
+ }
+
+ // verifier
+ if(!file.readSecret(&m_verInitVector) || \
!file.readSecret(&m_verEncryptedRandom)) { + errorMessage = \
genericLoadingErrorMessage(); + return false;
+ }
+
+ return true;
}
bool KSecretCollection::deserializeParts(KSecretFile &file, QString &errorMessage)
{
- // parts table
- quint32 numParts;
- if (!file.readUint(&numParts)) {
- errorMessage = genericLoadingErrorMessage();
- return false;
- }
- QList<FilePartEntry> filePartEntries;
- quint32 partType;
- quint32 partPos;
- quint32 partLength;
- for (quint32 i = 0; i < numParts; ++i) {
- if (!file.readUint(&partType) || !file.readUint(&partPos) || \
!file.readUint(&partLength)) {
- errorMessage = genericLoadingErrorMessage();
- return false;
- }
-
- FilePartEntry part;
- part.m_type = partType;
- part.m_position = partPos;
- part.m_length = partLength;
- filePartEntries.append(part);
- }
-
- // read parts
- Q_FOREACH(const FilePartEntry &filePartEntry, filePartEntries) {
- // read the contents into a bytearray
- QByteArray contents;
- if (!file.readPart(&contents, filePartEntry.m_position, \
filePartEntry.m_length)) {
- errorMessage = genericLoadingErrorMessage();
- return false;
- }
-
- bool rc;
- switch (filePartEntry.m_type) {
-
- case KSecretFile::PartItemHashes:
- rc = deserializePartItemHashes(contents);
- break;
-
- case KSecretFile::PartSymKey:
- rc = deserializePartSymKey(contents);
- break;
-
- case KSecretFile::PartItems:
- m_encryptedItemParts.append(contents);
- rc = true;
- break;
-
- case KSecretFile::PartAcls:
- rc = deserializePartAcls(contents);
- break;
-
- case KSecretFile::PartConfig:
- rc = deserializePartConfig(contents);
- break;
-
- case KSecretFile::PartCollProps:
- rc = deserializePartCollProps(contents);
- break;
-
- default: // unknown part type
- UnknownFilePart *ufp = new UnknownFilePart;
- ufp->m_type = filePartEntry.m_type;
- ufp->m_contents = contents;
- m_unknownParts.append(ufp);
- rc = true;
- break;
- }
-
- if (!rc) {
- errorMessage = genericLoadingErrorMessage();
- return false;
- }
- }
-
- return true;
+ // parts table
+ quint32 numParts;
+ if(!file.readUint(&numParts)) {
+ errorMessage = genericLoadingErrorMessage();
+ return false;
+ }
+ QList<FilePartEntry> filePartEntries;
+ quint32 partType;
+ quint32 partPos;
+ quint32 partLength;
+ for(quint32 i = 0; i < numParts; ++i) {
+ if(!file.readUint(&partType) || !file.readUint(&partPos) || \
!file.readUint(&partLength)) { + errorMessage = \
genericLoadingErrorMessage(); + return false;
+ }
+
+ FilePartEntry part;
+ part.m_type = partType;
+ part.m_position = partPos;
+ part.m_length = partLength;
+ filePartEntries.append(part);
+ }
+
+ // read parts
+ Q_FOREACH(const FilePartEntry & filePartEntry, filePartEntries) {
+ // read the contents into a bytearray
+ QByteArray contents;
+ if(!file.readPart(&contents, filePartEntry.m_position, \
filePartEntry.m_length)) { + errorMessage = genericLoadingErrorMessage();
+ return false;
+ }
+
+ bool rc;
+ switch(filePartEntry.m_type) {
+
+ case KSecretFile::PartItemHashes:
+ rc = deserializePartItemHashes(contents);
+ break;
+
+ case KSecretFile::PartSymKey:
+ rc = deserializePartSymKey(contents);
+ break;
+
+ case KSecretFile::PartItems:
+ m_encryptedItemParts.append(contents);
+ rc = true;
+ break;
+
+ case KSecretFile::PartAcls:
+ rc = deserializePartAcls(contents);
+ break;
+
+ case KSecretFile::PartConfig:
+ rc = deserializePartConfig(contents);
+ break;
+
+ case KSecretFile::PartCollProps:
+ rc = deserializePartCollProps(contents);
+ break;
+
+ default: // unknown part type
+ UnknownFilePart *ufp = new UnknownFilePart;
+ ufp->m_type = filePartEntry.m_type;
+ ufp->m_contents = contents;
+ m_unknownParts.append(ufp);
+ rc = true;
+ break;
+ }
+
+ if(!rc) {
+ errorMessage = genericLoadingErrorMessage();
+ return false;
+ }
+ }
+
+ return true;
}
bool KSecretCollection::deserializePartCollProps(const QByteArray &partContents)
{
- QBuffer buffer;
- buffer.setData(partContents);
- KSecretFile file(&buffer, KSecretFile::Read);
- if (!file.isValid()) {
- return false;
- }
-
- QByteArray partProps;
- if (!file.readBytearray(&partProps) || !file.readBytearray(&m_propertiesMac)) {
- return false;
- }
-
- QBuffer propsBuffer(&partProps);
- KSecretFile propsFile(&propsBuffer, KSecretFile::Read);
- if (!propsFile.isValid()) {
- return false;
- }
-
- if (!propsFile.readString(&m_id) || !propsFile.readString(&m_label) ||
- !propsFile.readDatetime(&m_created) || !propsFile.readDatetime(&m_modified)) \
{
- return false;
- }
-
- return true;
+ QBuffer buffer;
+ buffer.setData(partContents);
+ KSecretFile file(&buffer, KSecretFile::Read);
+ if(!file.isValid()) {
+ return false;
+ }
+
+ QByteArray partProps;
+ if(!file.readBytearray(&partProps) || !file.readBytearray(&m_propertiesMac)) {
+ return false;
+ }
+
+ QBuffer propsBuffer(&partProps);
+ KSecretFile propsFile(&propsBuffer, KSecretFile::Read);
+ if(!propsFile.isValid()) {
+ return false;
+ }
+
+ if(!propsFile.readString(&m_id) || !propsFile.readString(&m_label) ||
+ !propsFile.readDatetime(&m_created) || \
!propsFile.readDatetime(&m_modified)) { + return false;
+ }
+
+ return true;
}
bool KSecretCollection::deserializePartItemHashes(const QByteArray &partContents)
{
- QBuffer buffer;
- buffer.setData(partContents);
- KSecretFile file(&buffer, KSecretFile::Read);
- quint32 numItems;
- if (!file.isValid() || !file.readUint(&numItems)) {
- return false;
- }
-
- // read each item hash
- KSecretItem *item;
- for (quint32 i = 0; i < numItems; ++i) {
- QString itemId;
- quint32 numAttribs;
- if (!file.readString(&itemId) || !file.readUint(&numAttribs)) {
- return false;
- }
-
- // read each attribute
- QSet<QByteArray> attributeHashes;
- for (quint32 j = 0; j < numAttribs; ++j) {
- QByteArray attributeHash;
- if (!file.readBytearray(&attributeHash)) {
+ QBuffer buffer;
+ buffer.setData(partContents);
+ KSecretFile file(&buffer, KSecretFile::Read);
+ quint32 numItems;
+ if(!file.isValid() || !file.readUint(&numItems)) {
+ return false;
+ }
+
+ // read each item hash
+ KSecretItem *item;
+ for(quint32 i = 0; i < numItems; ++i) {
+ QString itemId;
+ quint32 numAttribs;
+ if(!file.readString(&itemId) || !file.readUint(&numAttribs)) {
return false;
- }
- attributeHashes.insert(attributeHash);
- }
+ }
+
+ // read each attribute
+ QSet<QByteArray> attributeHashes;
+ for(quint32 j = 0; j < numAttribs; ++j) {
+ QByteArray attributeHash;
+ if(!file.readBytearray(&attributeHash)) {
+ return false;
+ }
+ attributeHashes.insert(attributeHash);
+ }
- item = new KSecretItem(itemId, this);
- connect(item, SIGNAL(attributesChanged(KSecretItem*)),
- SLOT(changeAttributeHashes(KSecretItem*)));
- Q_FOREACH(const QByteArray &hash, attributeHashes) {
- m_itemHashes.insert(hash, item);
- }
-
- // append hashes to the list of reverse hashes
- m_reverseItemHashes.insert(item, attributeHashes);
- }
-
- return true;
+ item = new KSecretItem(itemId, this);
+ connect(item, SIGNAL(attributesChanged(KSecretItem*)),
+ SLOT(changeAttributeHashes(KSecretItem*)));
+ Q_FOREACH(const QByteArray & hash, attributeHashes) {
+ m_itemHashes.insert(hash, item);
+ }
+
+ // append hashes to the list of reverse hashes
+ m_reverseItemHashes.insert(item, attributeHashes);
+ }
+
+ return true;
}
bool KSecretCollection::deserializePartSymKey(const QByteArray &partContents)
{
- QBuffer buffer;
- buffer.setData(partContents);
- KSecretFile file(&buffer, KSecretFile::Read);
- quint32 keyType;
- QByteArray keyData;
- if (!file.isValid() || !file.readUint(&keyType) || !file.readBytearray(&keyData)) \
{
- return false;
- }
- EncryptedKey *key = new EncryptedKey;
- key->m_type = keyType;
- key->m_key = keyData;
- m_encryptedSymKeys.append(key);
- return true;
+ QBuffer buffer;
+ buffer.setData(partContents);
+ KSecretFile file(&buffer, KSecretFile::Read);
+ quint32 keyType;
+ QByteArray keyData;
+ if(!file.isValid() || !file.readUint(&keyType) || !file.readBytearray(&keyData)) \
{ + return false;
+ }
+ EncryptedKey *key = new EncryptedKey;
+ key->m_type = keyType;
+ key->m_key = keyData;
+ m_encryptedSymKeys.append(key);
+ return true;
}
bool KSecretCollection::deserializePartAcls(const QByteArray &partContents)
{
- QBuffer buffer;
- buffer.setData(partContents);
- KSecretFile file(&buffer, KSecretFile::Read);
- if (!file.isValid()) {
- return false;
- }
-
- QByteArray partAcls;
- if (!file.readBytearray(&partAcls) || !file.readBytearray(&m_aclsMac)) {
- return false;
- }
-
- QBuffer aclsBuffer(&partAcls);
- KSecretFile aclsFile(&aclsBuffer, KSecretFile::Read);
- quint32 numAcls;
- if (!aclsFile.isValid() || !aclsFile.readUint(&numAcls)) {
- return false;
- }
-
- QString path;
- quint32 value;
- ApplicationPermission perm;
- for (quint32 i = 0; i < numAcls; ++i) {
- if (!aclsFile.readString(&path) || !file.readUint(&value)) {
- return false;
- }
-
- switch (value) {
-
- case PermissionAsk:
- perm = PermissionAsk;
- break;
-
- case PermissionDeny:
- perm = PermissionDeny;
- break;
-
- case PermissionAllow:
- perm = PermissionAllow;
- break;
-
- default:
- // unknown acl rule
- m_unknownAcls.insert(path, value);
- continue;
- }
-
- m_acls.insert(path, perm);
- }
-
- return true;
+ QBuffer buffer;
+ buffer.setData(partContents);
+ KSecretFile file(&buffer, KSecretFile::Read);
+ if(!file.isValid()) {
+ return false;
+ }
+
+ QByteArray partAcls;
+ if(!file.readBytearray(&partAcls) || !file.readBytearray(&m_aclsMac)) {
+ return false;
+ }
+
+ QBuffer aclsBuffer(&partAcls);
+ KSecretFile aclsFile(&aclsBuffer, KSecretFile::Read);
+ quint32 numAcls;
+ if(!aclsFile.isValid() || !aclsFile.readUint(&numAcls)) {
+ return false;
+ }
+
+ QString path;
+ quint32 value;
+ ApplicationPermission perm;
+ for(quint32 i = 0; i < numAcls; ++i) {
+ if(!aclsFile.readString(&path) || !file.readUint(&value)) {
+ return false;
+ }
+
+ switch(value) {
+
+ case PermissionAsk:
+ perm = PermissionAsk;
+ break;
+
+ case PermissionDeny:
+ perm = PermissionDeny;
+ break;
+
+ case PermissionAllow:
+ perm = PermissionAllow;
+ break;
+
+ default:
+ // unknown acl rule
+ m_unknownAcls.insert(path, value);
+ continue;
+ }
+
+ m_acls.insert(path, perm);
+ }
+
+ return true;
}
bool KSecretCollection::deserializePartConfig(const QByteArray &partContents)
{
- QBuffer buffer;
- buffer.setData(partContents);
- KSecretFile file(&buffer, KSecretFile::Read);
- if (!file.isValid()) {
- return false;
- }
-
- QByteArray partConfig;
- if (!file.readBytearray(&partConfig) || !file.readBytearray(&m_configValuesMac)) \
{
- return false;
- }
-
- QBuffer configBuffer(&partConfig);
- KSecretFile configFile(&configBuffer, KSecretFile::Read);
- quint32 numConfigValues;
- if (!configFile.isValid() || !configFile.readUint(&numConfigValues)) {
- return false;
- }
-
- QString configKey;
- QByteArray configValue;
- for (quint32 i = 0; i < numConfigValues; ++i) {
- if (!configFile.readString(&configKey) || \
!configFile.readBytearray(&configValue)) {
- return false;
- }
-
- if (configKey == QLatin1String("CloseScreensaver")) {
- if (configValue.size() == 1 && configValue[0] == '0') {
- m_cfgCloseScreensaver = false;
- }
- } else if (configKey == QLatin1String("CloseIfUnused")) {
- if (configValue.size() == 1 && configValue[0] == '0') {
- m_cfgCloseIfUnused = false;
- }
- } else if (configKey == QLatin1String("CloseUnusedTimeout")) {
- bool ok;
- m_cfgCloseUnusedTimeout = configValue.toUInt(&ok);
- if (!ok) {
- m_cfgCloseUnusedTimeout = 30;
- }
- } else {
- m_cfgUnknownKeys.insert(configKey, configValue);
- }
- }
-
- return true;
+ QBuffer buffer;
+ buffer.setData(partContents);
+ KSecretFile file(&buffer, KSecretFile::Read);
+ if(!file.isValid()) {
+ return false;
+ }
+
+ QByteArray partConfig;
+ if(!file.readBytearray(&partConfig) || !file.readBytearray(&m_configValuesMac)) \
{ + return false;
+ }
+
+ QBuffer configBuffer(&partConfig);
+ KSecretFile configFile(&configBuffer, KSecretFile::Read);
+ quint32 numConfigValues;
+ if(!configFile.isValid() || !configFile.readUint(&numConfigValues)) {
+ return false;
+ }
+
+ QString configKey;
+ QByteArray configValue;
+ for(quint32 i = 0; i < numConfigValues; ++i) {
+ if(!configFile.readString(&configKey) || \
!configFile.readBytearray(&configValue)) { + return false;
+ }
+
+ if(configKey == QLatin1String("CloseScreensaver")) {
+ if(configValue.size() == 1 && configValue[0] == '0') {
+ m_cfgCloseScreensaver = false;
+ }
+ } else if(configKey == QLatin1String("CloseIfUnused")) {
+ if(configValue.size() == 1 && configValue[0] == '0') {
+ m_cfgCloseIfUnused = false;
+ }
+ } else if(configKey == QLatin1String("CloseUnusedTimeout")) {
+ bool ok;
+ m_cfgCloseUnusedTimeout = configValue.toUInt(&ok);
+ if(!ok) {
+ m_cfgCloseUnusedTimeout = 30;
+ }
+ } else {
+ m_cfgUnknownKeys.insert(configKey, configValue);
+ }
+ }
+
+ return true;
}
bool KSecretCollection::deserializeItemsUnlocked(KSecretFile &file)
{
- Q_ASSERT(file.isValid());
-
- KSecretItem *item;
- quint32 numItems;
- if (!file.readUint(&numItems)) {
- return false;
- }
-
- QString itemId;
- for (quint32 i = 0; i < numItems; ++i) {
- // read the identifier of the item
- if (!file.readString(&itemId)) {
- return false;
- }
-
- // find the item matching the identifier
- bool recreateHashes = false;
- if (!m_items.contains(itemId)) {
- // item without a hash. ignore this inconsistency and simply
- // load the item, creating the hashes on-the-go.
- item = new KSecretItem(itemId, this);
- connect(item, SIGNAL(attributesChanged(KSecretItem*)),
- SLOT(changeAttributeHashes(KSecretItem*)));
- m_items.insert(itemId, item);
- recreateHashes = true;
- } else {
- item = m_items.value(itemId);
- }
-
- QCA::SecureArray itemData;
- if (!file.readSecret(&itemData)) {
- return false;
- }
-
- SecureBuffer device(&itemData);
- KSecretFile itemFile(&device, KSecretFile::Read);
- if (!item->deserializeUnlocked(itemFile)) {
- return false;
- }
-
- if (recreateHashes) {
- changeAttributeHashes(item);
- }
- }
- return true;
+ Q_ASSERT(file.isValid());
+
+ KSecretItem *item;
+ quint32 numItems;
+ if(!file.readUint(&numItems)) {
+ return false;
+ }
+
+ QString itemId;
+ for(quint32 i = 0; i < numItems; ++i) {
+ // read the identifier of the item
+ if(!file.readString(&itemId)) {
+ return false;
+ }
+
+ // find the item matching the identifier
+ bool recreateHashes = false;
+ if(!m_items.contains(itemId)) {
+ // item without a hash. ignore this inconsistency and simply
+ // load the item, creating the hashes on-the-go.
+ item = new KSecretItem(itemId, this);
+ connect(item, SIGNAL(attributesChanged(KSecretItem*)),
+ SLOT(changeAttributeHashes(KSecretItem*)));
+ m_items.insert(itemId, item);
+ recreateHashes = true;
+ } else {
+ item = m_items.value(itemId);
+ }
+
+ QCA::SecureArray itemData;
+ if(!file.readSecret(&itemData)) {
+ return false;
+ }
+
+ SecureBuffer device(&itemData);
+ KSecretFile itemFile(&device, KSecretFile::Read);
+ if(!item->deserializeUnlocked(itemFile)) {
+ return false;
+ }
+
+ if(recreateHashes) {
+ changeAttributeHashes(item);
+ }
+ }
+ return true;
}
bool KSecretCollection::deserializePartEncrypted(const QByteArray &partContents,
- QCA::SecureArray &decryptedPart)
+ QCA::SecureArray &decryptedPart)
{
- Q_ASSERT(m_symmetricKey);
-
- QBuffer buffer;
- buffer.setData(partContents);
- KSecretFile file(&buffer, KSecretFile::Read);
- if (!file.isValid()) {
- return false;
- }
-
- QCA::SecureArray ivdata;
- if (!file.readSecret(&ivdata)) {
- return false;
- }
- QCA::InitializationVector iv(ivdata);
-
- QCA::SecureArray encryptedPart;
- if (!file.readSecret(&encryptedPart)) {
- return false;
- }
-
- // decrypt the data
- m_cipher->setup(QCA::Decode, *m_symmetricKey, iv);
- decryptedPart = m_cipher->update(encryptedPart);
- if (!m_cipher->ok()) {
- return false;
- }
- decryptedPart.append(m_cipher->final());
- if (!m_cipher->ok()) {
- return false;
- }
-
- return true;
+ Q_ASSERT(m_symmetricKey);
+
+ QBuffer buffer;
+ buffer.setData(partContents);
+ KSecretFile file(&buffer, KSecretFile::Read);
+ if(!file.isValid()) {
+ return false;
+ }
+
+ QCA::SecureArray ivdata;
+ if(!file.readSecret(&ivdata)) {
+ return false;
+ }
+ QCA::InitializationVector iv(ivdata);
+
+ QCA::SecureArray encryptedPart;
+ if(!file.readSecret(&encryptedPart)) {
+ return false;
+ }
+
+ // decrypt the data
+ m_cipher->setup(QCA::Decode, *m_symmetricKey, iv);
+ decryptedPart = m_cipher->update(encryptedPart);
+ if(!m_cipher->ok()) {
+ return false;
+ }
+ decryptedPart.append(m_cipher->final());
+ if(!m_cipher->ok()) {
+ return false;
+ }
+
+ return true;
}
bool KSecretCollection::serialize(QString &errorMessage) const
{
- KSaveFile device(m_path);
- KSecretFile file(&device, KSecretFile::Write);
- if (!file.isValid()) {
- errorMessage = i18nc("Error message: collection file couldn't be opened for \
writing",
- "Collection file couldn't be opened for writing");
- return false;
- }
-
- if (!serializeHeader(file)) {
- errorMessage = genericSavingErrorMessage();
- return false;
- }
-
- if (!serializeParts(file)) {
- errorMessage = genericSavingErrorMessage();
- return false;
- }
-
- return true;
+ KSaveFile device(m_path);
+ KSecretFile file(&device, KSecretFile::Write);
+ if(!file.isValid()) {
+ errorMessage = i18nc("Error message: collection file couldn't be opened for \
writing", + "Collection file couldn't be opened for \
writing"); + return false;
+ }
+
+ if(!serializeHeader(file)) {
+ errorMessage = genericSavingErrorMessage();
+ return false;
+ }
+
+ if(!serializeParts(file)) {
+ errorMessage = genericSavingErrorMessage();
+ return false;
+ }
+
+ return true;
}
bool KSecretCollection::serializeHeader(KSecretFile &file) const
{
- // write the ksecret file header
- if (!file.writeMagic() || !file.writeUint(VERSION_MAJOR) || \
!file.writeUint(VERSION_MINOR)) {
- return false;
- }
-
- // algorithms
- if (!file.writeUint(m_algoHash) && !file.writeUint(m_algoCipher)) {
- return false;
- }
-
- // verifier
- if (!file.writeSecret(m_verInitVector) && \
!file.writeSecret(m_verEncryptedRandom)) {
- return false;
- }
-
- return true;
+ // write the ksecret file header
+ if(!file.writeMagic() || !file.writeUint(VERSION_MAJOR) || \
!file.writeUint(VERSION_MINOR)) { + return false;
+ }
+
+ // algorithms
+ if(!file.writeUint(m_algoHash) && !file.writeUint(m_algoCipher)) {
+ return false;
+ }
+
+ // verifier
+ if(!file.writeSecret(m_verInitVector) && \
!file.writeSecret(m_verEncryptedRandom)) { + return false;
+ }
+
+ return true;
}
bool KSecretCollection::serializeParts(KSecretFile &file) const
{
- QString errorMessage;
- // TODO: only save if the collection is open.
-
- // determine the number of parts
- // properties part + item hash part + items part + acls part + config part + \
number of keys +
- // number of unknown parts = 5 + number of keys + number of unknown parts
- int curFilePartEntry = 0;
- quint32 numParts = 5 + m_encryptedSymKeys.size() + m_unknownParts.size();
- quint32 partTableSize = 4 + numParts * 12;
- QList<FilePartEntry> filePartEntries;
- for (quint32 i = 0; i < numParts; ++i) {
- filePartEntries.append(FilePartEntry());
- }
- // remember the part table position and skip the part table so it can be written
- // later.
- quint64 partTablePos = file.pos();
- if (!file.seek(partTablePos + partTableSize)) {
- return false;
- }
-
- // collection properties part
- if (!serializePropertiesPart(file, filePartEntries[curFilePartEntry])) {
- return false;
- }
-
- // config part
- if (!serializeConfigPart(file, filePartEntries[curFilePartEntry])) {
- return false;
- }
- curFilePartEntry++;
-
- // acls part
- filePartEntries[curFilePartEntry].m_type = KSecretFile::PartAcls;
- filePartEntries[curFilePartEntry].m_position = (quint32)file.pos();
- QBuffer buffer;
- KSecretFile device(&buffer, KSecretFile::Write);
- QHash<QString, KSecretCollection::ApplicationPermission>::const_iterator it = \
m_acls.constBegin();
- QHash<QString, KSecretCollection::ApplicationPermission>::const_iterator end = \
m_acls.constEnd();
- for ( ; it != end; ++it) {
- if (!file.writeString(it.key()) || !file.writeUint((quint32)it.value())) {
- return false;
- }
- }
- if (!serializeAuthenticated(buffer.data(), file)) {
- return false;
- }
- filePartEntries[curFilePartEntry].m_length =
- (quint32)file.pos() - filePartEntries[curFilePartEntry].m_position;
- curFilePartEntry++;
-
- // item hash part
- if (!serializeItemHashes(file, filePartEntries[curFilePartEntry])) {
- return false;
- }
- curFilePartEntry++;
-
- // items part
- if (!serializeItems(file, filePartEntries[curFilePartEntry])) {
- return false;
- }
- curFilePartEntry++;
-
- // keys
- Q_FOREACH(EncryptedKey *key, m_encryptedSymKeys) {
- filePartEntries[curFilePartEntry].m_type = KSecretFile::PartSymKey;
- filePartEntries[curFilePartEntry].m_position = (quint32)file.pos();
- if (!file.writeUint(key->m_type) || !file.writeBytearray(key->m_key) ||
- !file.writeBytearray(key->m_iv)) {
- return false;
- }
- filePartEntries[curFilePartEntry].m_length =
- (quint32)file.pos() - filePartEntries[curFilePartEntry].m_position;
- curFilePartEntry++;
- }
-
- // unknown parts
- Q_FOREACH(UnknownFilePart *unknown, m_unknownParts) {
- filePartEntries[curFilePartEntry].m_type = unknown->m_type;
- filePartEntries[curFilePartEntry].m_position = (quint32)file.pos();
- if (!file.writeBytearray(unknown->m_contents)) {
- return false;
- }
- filePartEntries[curFilePartEntry].m_length =
- (quint32)file.pos() - filePartEntries[curFilePartEntry].m_position;
- curFilePartEntry++;
- }
-
- // write part table
- if (!file.seek(partTablePos) || !file.writeUint(numParts)) {
- return false;
- }
-
- Q_FOREACH(const FilePartEntry &part, filePartEntries) {
- if (!file.writeUint(part.m_type) || !file.writeUint(part.m_position) ||
- !file.writeUint(part.m_length)) {
- return false;
- }
- }
-
- file.close();
- return true;
+ QString errorMessage;
+ // TODO: only save if the collection is open.
+
+ // determine the number of parts
+ // properties part + item hash part + items part + acls part + config part + \
number of keys + + // number of unknown parts = 5 + number of keys + number of \
unknown parts + int curFilePartEntry = 0;
+ quint32 numParts = 5 + m_encryptedSymKeys.size() + m_unknownParts.size();
+ quint32 partTableSize = 4 + numParts * 12;
+ QList<FilePartEntry> filePartEntries;
+ for(quint32 i = 0; i < numParts; ++i) {
+ filePartEntries.append(FilePartEntry());
+ }
+ // remember the part table position and skip the part table so it can be written
+ // later.
+ quint64 partTablePos = file.pos();
+ if(!file.seek(partTablePos + partTableSize)) {
+ return false;
+ }
+
+ // collection properties part
+ if(!serializePropertiesPart(file, filePartEntries[curFilePartEntry])) {
+ return false;
+ }
+
+ // config part
+ if(!serializeConfigPart(file, filePartEntries[curFilePartEntry])) {
+ return false;
+ }
+ curFilePartEntry++;
+
+ // acls part
+ filePartEntries[curFilePartEntry].m_type = KSecretFile::PartAcls;
+ filePartEntries[curFilePartEntry].m_position = (quint32)file.pos();
+ QBuffer buffer;
+ KSecretFile device(&buffer, KSecretFile::Write);
+ QHash<QString, KSecretCollection::ApplicationPermission>::const_iterator it = \
m_acls.constBegin(); + QHash<QString, \
KSecretCollection::ApplicationPermission>::const_iterator end = m_acls.constEnd(); + \
for(; it != end; ++it) { + if(!file.writeString(it.key()) || \
!file.writeUint((quint32)it.value())) { + return false;
+ }
+ }
+ if(!serializeAuthenticated(buffer.data(), file)) {
+ return false;
+ }
+ filePartEntries[curFilePartEntry].m_length =
+ (quint32)file.pos() - filePartEntries[curFilePartEntry].m_position;
+ curFilePartEntry++;
+
+ // item hash part
+ if(!serializeItemHashes(file, filePartEntries[curFilePartEntry])) {
+ return false;
+ }
+ curFilePartEntry++;
+
+ // items part
+ if(!serializeItems(file, filePartEntries[curFilePartEntry])) {
+ return false;
+ }
+ curFilePartEntry++;
+
+ // keys
+ Q_FOREACH(EncryptedKey * key, m_encryptedSymKeys) {
+ filePartEntries[curFilePartEntry].m_type = KSecretFile::PartSymKey;
+ filePartEntries[curFilePartEntry].m_position = (quint32)file.pos();
+ if(!file.writeUint(key->m_type) || !file.writeBytearray(key->m_key) ||
+ !file.writeBytearray(key->m_iv)) {
+ return false;
+ }
+ filePartEntries[curFilePartEntry].m_length =
+ (quint32)file.pos() - filePartEntries[curFilePartEntry].m_position;
+ curFilePartEntry++;
+ }
+
+ // unknown parts
+ Q_FOREACH(UnknownFilePart * unknown, m_unknownParts) {
+ filePartEntries[curFilePartEntry].m_type = unknown->m_type;
+ filePartEntries[curFilePartEntry].m_position = (quint32)file.pos();
+ if(!file.writeBytearray(unknown->m_contents)) {
+ return false;
+ }
+ filePartEntries[curFilePartEntry].m_length =
+ (quint32)file.pos() - filePartEntries[curFilePartEntry].m_position;
+ curFilePartEntry++;
+ }
+
+ // write part table
+ if(!file.seek(partTablePos) || !file.writeUint(numParts)) {
+ return false;
+ }
+
+ Q_FOREACH(const FilePartEntry & part, filePartEntries) {
+ if(!file.writeUint(part.m_type) || !file.writeUint(part.m_position) ||
+ !file.writeUint(part.m_length)) {
+ return false;
+ }
+ }
+
+ file.close();
+ return true;
}
bool KSecretCollection::serializeAclsPart(KSecretFile &file, FilePartEntry &entry) \
const {
- entry.m_type = KSecretFile::PartAcls;
- entry.m_position = (quint32)file.pos();
-
- // build temporary buffer containing acls
- QBuffer aclsBuffer;
- KSecretFile tempFile(&aclsBuffer, KSecretFile::Write);
- if (!tempFile.writeUint(m_acls.size())) {
- return false;
- }
-
- QHash<QString, ApplicationPermission>::const_iterator it = m_acls.constBegin();
- QHash<QString, ApplicationPermission>::const_iterator end = m_acls.constEnd();
- for ( ; it != end; ++it) {
- if (!tempFile.writeString(it.key()) || \
!tempFile.writeUint((quint32)it.value())) {
- return false;
- }
- }
-
- QMap<QString, int>::const_iterator it2 = m_unknownAcls.constBegin();
- QMap<QString, int>::const_iterator end2 = m_unknownAcls.constEnd();
- for ( ; it2 != end2; ++it2) {
- if (!tempFile.writeString(it2.key()) || !tempFile.writeUint(it2.value())) {
- return false;
- }
- }
-
- if (!serializeAuthenticated(aclsBuffer.data(), file)) {
- return false;
- }
- entry.m_length = (quint32)file.pos() - entry.m_position;
- return true;
+ entry.m_type = KSecretFile::PartAcls;
+ entry.m_position = (quint32)file.pos();
+
+ // build temporary buffer containing acls
+ QBuffer aclsBuffer;
+ KSecretFile tempFile(&aclsBuffer, KSecretFile::Write);
+ if(!tempFile.writeUint(m_acls.size())) {
+ return false;
+ }
+
+ QHash<QString, ApplicationPermission>::const_iterator it = m_acls.constBegin();
+ QHash<QString, ApplicationPermission>::const_iterator end = m_acls.constEnd();
+ for(; it != end; ++it) {
+ if(!tempFile.writeString(it.key()) || \
!tempFile.writeUint((quint32)it.value())) { + return false;
+ }
+ }
+
+ QMap<QString, int>::const_iterator it2 = m_unknownAcls.constBegin();
+ QMap<QString, int>::const_iterator end2 = m_unknownAcls.constEnd();
+ for(; it2 != end2; ++it2) {
+ if(!tempFile.writeString(it2.key()) || !tempFile.writeUint(it2.value())) {
+ return false;
+ }
+ }
+
+ if(!serializeAuthenticated(aclsBuffer.data(), file)) {
+ return false;
+ }
+ entry.m_length = (quint32)file.pos() - entry.m_position;
+ return true;
}
bool KSecretCollection::serializePropertiesPart(KSecretFile &file, FilePartEntry \
&entry) const {
- entry.m_type = KSecretFile::PartCollProps;
- entry.m_position = (quint32)file.pos();
-
- // build temporary buffer containing properties
- QBuffer propsBuffer;
- KSecretFile tempFile(&propsBuffer, KSecretFile::Write);
-
- if (!tempFile.writeString(m_id) || !tempFile.writeString(m_label) ||
- !tempFile.writeDatetime(m_created) || !tempFile.writeDatetime(m_modified)) {
- return false;
- }
-
- tempFile.close();
- if (!serializeAuthenticated(propsBuffer.data(), file)) {
- return false;
- }
- entry.m_length = (quint32)file.pos() - entry.m_position;
-
- return true;
+ entry.m_type = KSecretFile::PartCollProps;
+ entry.m_position = (quint32)file.pos();
+
+ // build temporary buffer containing properties
+ QBuffer propsBuffer;
+ KSecretFile tempFile(&propsBuffer, KSecretFile::Write);
+
+ if(!tempFile.writeString(m_id) || !tempFile.writeString(m_label) ||
+ !tempFile.writeDatetime(m_created) || \
!tempFile.writeDatetime(m_modified)) { + return false;
+ }
+
+ tempFile.close();
+ if(!serializeAuthenticated(propsBuffer.data(), file)) {
+ return false;
+ }
+ entry.m_length = (quint32)file.pos() - entry.m_position;
+
+ return true;
}
bool KSecretCollection::serializeConfigPart(KSecretFile &file, FilePartEntry &entry) \
const {
- entry.m_type = KSecretFile::PartConfig;
- entry.m_position = (quint32)file.pos();
-
- // build temporary buffer containing config keys and values
- QBuffer configBuffer;
- KSecretFile tempFile(&configBuffer, KSecretFile::Write);
- if (!tempFile.writeUint(3 + m_cfgUnknownKeys.size())) {
- return false;
- }
-
- // save known configuration values
- QByteArray valCloseScreensaver;
- valCloseScreensaver.setNum((int)m_cfgCloseScreensaver);
- QByteArray valCloseIfUnused;
- valCloseIfUnused.setNum((int)m_cfgCloseIfUnused);
- QByteArray valCloseUnusedTimeout;
- valCloseUnusedTimeout.setNum(m_cfgCloseUnusedTimeout);
- if (!tempFile.writeString("CloseScreensaver") ||
- !tempFile.writeBytearray(valCloseScreensaver) ||
- !tempFile.writeString("CloseIfUnused") ||
- !tempFile.writeBytearray(valCloseIfUnused) ||
- !tempFile.writeString("CloseUnusedTimeout") ||
- !tempFile.writeBytearray(valCloseUnusedTimeout)) {
- return false;
- }
-
- // save unknown configuration values
- QMap<QString, QByteArray>::const_iterator it = m_cfgUnknownKeys.constBegin();
- QMap<QString, QByteArray>::const_iterator end = m_cfgUnknownKeys.constEnd();
- for ( ; it != end; ++it) {
- if (!tempFile.writeString(it.key()) || !tempFile.writeBytearray(it.value())) {
- return false;
- }
- }
-
- tempFile.close();
- if (!serializeAuthenticated(configBuffer.data(), file)) {
- return false;
- }
- entry.m_length = (quint32)file.pos() - entry.m_position;
-
- return true;
+ entry.m_type = KSecretFile::PartConfig;
+ entry.m_position = (quint32)file.pos();
+
+ // build temporary buffer containing config keys and values
+ QBuffer configBuffer;
+ KSecretFile tempFile(&configBuffer, KSecretFile::Write);
+ if(!tempFile.writeUint(3 + m_cfgUnknownKeys.size())) {
+ return false;
+ }
+
+ // save known configuration values
+ QByteArray valCloseScreensaver;
+ valCloseScreensaver.setNum((int)m_cfgCloseScreensaver);
+ QByteArray valCloseIfUnused;
+ valCloseIfUnused.setNum((int)m_cfgCloseIfUnused);
+ QByteArray valCloseUnusedTimeout;
+ valCloseUnusedTimeout.setNum(m_cfgCloseUnusedTimeout);
+ if(!tempFile.writeString("CloseScreensaver") ||
+ !tempFile.writeBytearray(valCloseScreensaver) ||
+ !tempFile.writeString("CloseIfUnused") ||
+ !tempFile.writeBytearray(valCloseIfUnused) ||
+ !tempFile.writeString("CloseUnusedTimeout") ||
+ !tempFile.writeBytearray(valCloseUnusedTimeout)) {
+ return false;
+ }
+
+ // save unknown configuration values
+ QMap<QString, QByteArray>::const_iterator it = m_cfgUnknownKeys.constBegin();
+ QMap<QString, QByteArray>::const_iterator end = m_cfgUnknownKeys.constEnd();
+ for(; it != end; ++it) {
+ if(!tempFile.writeString(it.key()) || !tempFile.writeBytearray(it.value())) \
{ + return false;
+ }
+ }
+
+ tempFile.close();
+ if(!serializeAuthenticated(configBuffer.data(), file)) {
+ return false;
+ }
+ entry.m_length = (quint32)file.pos() - entry.m_position;
+
+ return true;
}
bool KSecretCollection::serializeItemHashes(KSecretFile &file, FilePartEntry &entry) \
const {
- entry.m_type = KSecretFile::PartItemHashes;
- entry.m_position = (quint32)file.pos();
-
- // as the hashes are stored as hash-value => item and they have to be written
- // to the file the other way round (item => hash-value, hash-value, ...), we
- // have to manually reverse them.
-
- QHash<KSecretItem*, QList<QByteArray> > hashes;
-
- QMultiHash<QByteArray, KSecretItem*>::const_iterator it = \
m_itemHashes.constBegin();
- const QMultiHash<QByteArray, KSecretItem*>::const_iterator end = \
m_itemHashes.constEnd();
- for ( ; it != end; ++it) {
- hashes[it.value()].append(it.key());
- }
-
- if (!file.writeUint(hashes.size())) {
- return false;
- }
-
- QHash<KSecretItem*, QList<QByteArray> >::const_iterator it2 = \
hashes.constBegin();
- QHash<KSecretItem*, QList<QByteArray> >::const_iterator end2 = hashes.constEnd();
- for ( ; it2 != end2; ++it2) {
- if (!file.writeString(it2.key()->id()) || !file.writeUint(it2.value().size())) \
{
- return false;
- }
- QList<QByteArray> hv = it2.value();
- Q_FOREACH(const QByteArray &hash, hv) {
- if (!file.writeBytearray(hash)) {
+ entry.m_type = KSecretFile::PartItemHashes;
+ entry.m_position = (quint32)file.pos();
+
+ // as the hashes are stored as hash-value => item and they have to be written
+ // to the file the other way round (item => hash-value, hash-value, ...), we
+ // have to manually reverse them.
+
+ QHash<KSecretItem*, QList<QByteArray> > hashes;
+
+ QMultiHash<QByteArray, KSecretItem*>::const_iterator it = \
m_itemHashes.constBegin(); + const QMultiHash<QByteArray, \
KSecretItem*>::const_iterator end = m_itemHashes.constEnd(); + for(; it != end; \
++it) { + hashes[it.value()].append(it.key());
+ }
+
+ if(!file.writeUint(hashes.size())) {
+ return false;
+ }
+
+ QHash<KSecretItem*, QList<QByteArray> >::const_iterator it2 = \
hashes.constBegin(); + QHash<KSecretItem*, QList<QByteArray> >::const_iterator \
end2 = hashes.constEnd(); + for(; it2 != end2; ++it2) {
+ if(!file.writeString(it2.key()->id()) || \
!file.writeUint(it2.value().size())) { return false;
- }
- }
- }
+ }
+ QList<QByteArray> hv = it2.value();
+ Q_FOREACH(const QByteArray & hash, hv) {
+ if(!file.writeBytearray(hash)) {
+ return false;
+ }
+ }
+ }
- entry.m_length = (quint32)file.pos() - entry.m_position;
+ entry.m_length = (quint32)file.pos() - entry.m_position;
- return true;
+ return true;
}
bool KSecretCollection::serializeItems(KSecretFile &file, FilePartEntry &entry) \
const {
- Q_ASSERT(file.isValid());
-
- entry.m_type = KSecretFile::PartItems;
- entry.m_position = (quint32)file.pos();
-
- // construct a file to write the unlocked items to
- SecureBuffer device;
- KSecretFile tempFile(&device, KSecretFile::Write);
-
- if (!tempFile.writeUint(m_items.size())) {
- return false;
- }
-
- QHash<QString, KSecretItem*>::const_iterator it = m_items.constBegin();
- const QHash<QString, KSecretItem*>::const_iterator end = m_items.constEnd();
- for ( ; it != end; ++it) {
- if (!it.value()->serializeUnlocked(tempFile)) {
- return false;
- }
- }
-
- bool rc = serializeEncrypted(device.buffer(), file);
- if (rc) {
- entry.m_length = (quint32)file.pos() - entry.m_position;
- return true;
- } else {
- return false;
- }
+ Q_ASSERT(file.isValid());
+
+ entry.m_type = KSecretFile::PartItems;
+ entry.m_position = (quint32)file.pos();
+
+ // construct a file to write the unlocked items to
+ SecureBuffer device;
+ KSecretFile tempFile(&device, KSecretFile::Write);
+
+ if(!tempFile.writeUint(m_items.size())) {
+ return false;
+ }
+
+ QHash<QString, KSecretItem*>::const_iterator it = m_items.constBegin();
+ const QHash<QString, KSecretItem*>::const_iterator end = m_items.constEnd();
+ for(; it != end; ++it) {
+ if(!it.value()->serializeUnlocked(tempFile)) {
+ return false;
+ }
+ }
+
+ bool rc = serializeEncrypted(device.buffer(), file);
+ if(rc) {
+ entry.m_length = (quint32)file.pos() - entry.m_position;
+ return true;
+ } else {
+ return false;
+ }
}
bool KSecretCollection::serializeEncrypted(const QCA::SecureArray &data, KSecretFile \
&file) const {
- Q_ASSERT(file.isValid());
- // TODO: those errors either have to be caught before calling this method
- // or inside.
- Q_ASSERT(m_symmetricKey);
- Q_ASSERT(m_hash);
- Q_ASSERT(m_cipher);
-
- QCA::InitializationVector iv(m_cipher->blockSize());
- if (!file.writeSecret(iv)) {
- return false;
- }
-
- // TODO: random padding?
-
- // encrypt the data
- m_cipher->setup(QCA::Encode, *m_symmetricKey, iv);
- QCA::SecureArray encryptedPart = m_cipher->update(data);
- if (!m_cipher->ok()) {
- return false;
- }
- encryptedPart.append(m_cipher->final());
- if (!m_cipher->ok()) {
- return false;
- }
-
- // write the encrypted data to file
- if (!file.writeSecret(encryptedPart)) {
- return false;
- }
-
- return true;
+ Q_ASSERT(file.isValid());
+ // TODO: those errors either have to be caught before calling this method
+ // or inside.
+ Q_ASSERT(m_symmetricKey);
+ Q_ASSERT(m_hash);
+ Q_ASSERT(m_cipher);
+
+ QCA::InitializationVector iv(m_cipher->blockSize());
+ if(!file.writeSecret(iv)) {
+ return false;
+ }
+
+ // TODO: random padding?
+
+ // encrypt the data
+ m_cipher->setup(QCA::Encode, *m_symmetricKey, iv);
+ QCA::SecureArray encryptedPart = m_cipher->update(data);
+ if(!m_cipher->ok()) {
+ return false;
+ }
+ encryptedPart.append(m_cipher->final());
+ if(!m_cipher->ok()) {
+ return false;
+ }
+
+ // write the encrypted data to file
+ if(!file.writeSecret(encryptedPart)) {
+ return false;
+ }
+
+ return true;
}
bool KSecretCollection::serializeAuthenticated(const QByteArray &data, KSecretFile \
&file) const {
- Q_ASSERT(m_mac);
-
- // write actual data first
- if (!file.writeUint(data.size()) || !file.writeBytearray(data)) {
- return false;
- }
-
- // compute the HMAC for the data
- m_mac->clear();
- m_mac->update(QCA::SecureArray(data));
- QCA::SecureArray dataHash = m_mac->final();
-
- return file.writeSecret(dataHash);
+ Q_ASSERT(m_mac);
+
+ // write actual data first
+ if(!file.writeUint(data.size()) || !file.writeBytearray(data)) {
+ return false;
+ }
+
+ // compute the HMAC for the data
+ m_mac->clear();
+ m_mac->update(QCA::SecureArray(data));
+ QCA::SecureArray dataHash = m_mac->final();
+
+ return file.writeSecret(dataHash);
}
BackendCollection::ApplicationPermission \
KSecretCollection::applicationPermission(const QString& path) const {
- // TODO: implement
- Q_ASSERT(0);
- return BackendCollection::PermissionAllow;
+ // TODO: implement
+ Q_ASSERT(0);
+ return BackendCollection::PermissionAllow;
}
bool KSecretCollection::setApplicationPermission(const QString& path, \
BackendCollection::ApplicationPermission perm) {
- // TODO: implement
- Q_ASSERT(0);
- return true;
+ // TODO: implement
+ Q_ASSERT(0);
+ return true;
}
diff --git a/backend/ksecret/ksecretcollection.h \
b/backend/ksecret/ksecretcollection.h index 1f2a971..1e2e896 100644
--- a/backend/ksecret/ksecretcollection.h
+++ b/backend/ksecret/ksecretcollection.h
@@ -36,10 +36,9 @@ class KSecretCreateItemJob;
* is stored as unsigned integer as the part is unknown to this version of
* ksecretservice.
*/
-struct UnknownFilePart
-{
- quint32 m_type;
- QByteArray m_contents;
+struct UnknownFilePart {
+ quint32 m_type;
+ QByteArray m_contents;
};
/**
@@ -47,21 +46,19 @@ struct UnknownFilePart
* type is stored as unsigned integer as the key type might not be known
* to this version of ksecretservice.
*/
-struct EncryptedKey
-{
- quint32 m_type;
- QByteArray m_key;
- QByteArray m_iv;
+struct EncryptedKey {
+ quint32 m_type;
+ QByteArray m_key;
+ QByteArray m_iv;
};
/**
* Holds a description of a ksecret file part.
*/
-struct FilePartEntry
-{
- quint32 m_type;
- quint32 m_position;
- quint32 m_length;
+struct FilePartEntry {
+ quint32 m_type;
+ quint32 m_position;
+ quint32 m_length;
};
/**
@@ -69,449 +66,449 @@ struct FilePartEntry
*/
class KSecretCollection : public BackendCollection
{
- Q_OBJECT
+ Q_OBJECT
private:
- /**
- * Constructor for loading an existing collection from a file or creating
- * a new collection using create().
- *
- * @param parent the collection manager that loads this collection
- */
- KSecretCollection(BackendCollectionManager *parent);
+ /**
+ * Constructor for loading an existing collection from a file or creating
+ * a new collection using create().
+ *
+ * @param parent the collection manager that loads this collection
+ */
+ KSecretCollection(BackendCollectionManager *parent);
public:
- /**
- * Create a new collection.
- *
- * @param id id for the new collection
- * @param password password to use for encrypting the collection
- * @param parent parent collection manager
- * @param errorMessage set in case of an error
- * @return the new collection or 0 in case of an error
- */
- static KSecretCollection *create(const QString &id, const QCA::SecureArray \
&password,
- BackendCollectionManager *parent, QString \
&errorMessage);
-
- /**
- * Destructor
- */
- virtual ~KSecretCollection();
-
- /**
- * The unique identifier for this collection
- */
- virtual QString id() const;
-
- /**
- * The human-readable label for this collection.
- * @todo error
- */
- virtual BackendReturn<QString> label() const;
-
- /**
- * Set this collection's label human-readable label.
- *
- * @todo error
- * @param label the new label for this collection
- */
- virtual BackendReturn<void> setLabel(const QString &label);
-
- /**
- * The time this collection was created.
- */
- virtual QDateTime created() const;
-
- /**
- * The time this collection was last modified.
- */
- virtual QDateTime modified() const;
-
- /**
- * Check whether this collection is locked.
- *
- * @return true if the collection is locked, false if the collection
- * is unlocked.
- */
- virtual bool isLocked() const;
-
- /**
- * List all items inside this backend.
- *
- * @return a list containing all items inside this backend. An empty list
- * either means that no items were found or that an error occurred
- * (eg. collection needs unlocking before listing the items).
- * @todo error
- */
- virtual BackendReturn<QList<BackendItem*> > items() const;
-
- /**
- * Return all items whose attributes match the search terms.
- *
- * @param attributes attributes against which the items should be matched
- * @return a list of items matching the attributes. An empty list either means \
that
- * no items were found or that an error occurred (eg. collection needs
- * unlocking before listing the items).
- * @todo error
- */
- virtual BackendReturn<QList<BackendItem*> > searchItems(
- const QMap<QString, QString> &attributes) const;
-
- /**
- * Create a job for unlocking this collection.
- */
- virtual UnlockCollectionJob *createUnlockJob( const CollectionUnlockInfo \
&unlockInfo );
-
- /**
- * Create a job for locking this collection.
- */
- virtual LockCollectionJob *createLockJob();
-
- /**
- * Create a job for deleting this collection.
- */
- virtual DeleteCollectionJob *createDeleteJob(const CollectionDeleteInfo& \
deleteJobInfo);
-
- /**
- * Create a job for creating an item.
- *
- * @param label label to assign to the new item
- * @param attributes attributes to store for the new item
- * @param secret the secret to store
- * @param replace if true, an existing item with the same attributes
- * will be replaced, if false no item will be created
- * if one with the same attributes already exists
- * @param locked if true, the item will be locked after creation
- */
- virtual CreateItemJob *createCreateItemJob(const ItemCreateInfo& createInfo);
-
- /**
- * Create a job for changing this collection's authentication.
- */
+ /**
+ * Create a new collection.
+ *
+ * @param id id for the new collection
+ * @param password password to use for encrypting the collection
+ * @param parent parent collection manager
+ * @param errorMessage set in case of an error
+ * @return the new collection or 0 in case of an error
+ */
+ static KSecretCollection *create(const QString &id, const QCA::SecureArray \
&password, + BackendCollectionManager *parent, \
QString &errorMessage); +
+ /**
+ * Destructor
+ */
+ virtual ~KSecretCollection();
+
+ /**
+ * The unique identifier for this collection
+ */
+ virtual QString id() const;
+
+ /**
+ * The human-readable label for this collection.
+ * @todo error
+ */
+ virtual BackendReturn<QString> label() const;
+
+ /**
+ * Set this collection's label human-readable label.
+ *
+ * @todo error
+ * @param label the new label for this collection
+ */
+ virtual BackendReturn<void> setLabel(const QString &label);
+
+ /**
+ * The time this collection was created.
+ */
+ virtual QDateTime created() const;
+
+ /**
+ * The time this collection was last modified.
+ */
+ virtual QDateTime modified() const;
+
+ /**
+ * Check whether this collection is locked.
+ *
+ * @return true if the collection is locked, false if the collection
+ * is unlocked.
+ */
+ virtual bool isLocked() const;
+
+ /**
+ * List all items inside this backend.
+ *
+ * @return a list containing all items inside this backend. An empty list
+ * either means that no items were found or that an error occurred
+ * (eg. collection needs unlocking before listing the items).
+ * @todo error
+ */
+ virtual BackendReturn<QList<BackendItem*> > items() const;
+
+ /**
+ * Return all items whose attributes match the search terms.
+ *
+ * @param attributes attributes against which the items should be matched
+ * @return a list of items matching the attributes. An empty list either means \
that + * no items were found or that an error occurred (eg. collection \
needs + * unlocking before listing the items).
+ * @todo error
+ */
+ virtual BackendReturn<QList<BackendItem*> > searchItems(
+ const QMap<QString, QString> &attributes) const;
+
+ /**
+ * Create a job for unlocking this collection.
+ */
+ virtual UnlockCollectionJob *createUnlockJob(const CollectionUnlockInfo \
&unlockInfo); +
+ /**
+ * Create a job for locking this collection.
+ */
+ virtual LockCollectionJob *createLockJob();
+
+ /**
+ * Create a job for deleting this collection.
+ */
+ virtual DeleteCollectionJob *createDeleteJob(const CollectionDeleteInfo& \
deleteJobInfo); +
+ /**
+ * Create a job for creating an item.
+ *
+ * @param label label to assign to the new item
+ * @param attributes attributes to store for the new item
+ * @param secret the secret to store
+ * @param replace if true, an existing item with the same attributes
+ * will be replaced, if false no item will be created
+ * if one with the same attributes already exists
+ * @param locked if true, the item will be locked after creation
+ */
+ virtual CreateItemJob *createCreateItemJob(const ItemCreateInfo& createInfo);
+
+ /**
+ * Create a job for changing this collection's authentication.
+ */
virtual ChangeAuthenticationCollectionJob* createChangeAuthenticationJob();
-
- /**
- * Get the path of the ksecret file the collection is stored inside.
- *
- * @return the path of the collection file
- */
- const QString &path() const;
+
+ /**
+ * Get the path of the ksecret file the collection is stored inside.
+ *
+ * @return the path of the collection file
+ */
+ const QString &path() const;
private Q_SLOTS:
- /**
- * Remove an item from our list of known items.
- *
- * @param item Item to remove
- */
- void slotItemDeleted(BackendItem *item);
-
- /**
- * This slot is called whenever an Item's attributes change to rebuild the item \
lookup
- * hashes the collection uses to search items.
- *
- * @param item Item whose attributes changed
- */
- void changeAttributeHashes(KSecretItem *item);
+ /**
+ * Remove an item from our list of known items.
+ *
+ * @param item Item to remove
+ */
+ void slotItemDeleted(BackendItem *item);
+
+ /**
+ * This slot is called whenever an Item's attributes change to rebuild the item \
lookup + * hashes the collection uses to search items.
+ *
+ * @param item Item whose attributes changed
+ */
+ void changeAttributeHashes(KSecretItem *item);
public:
- /**
- * Deserialize a ksecret collection from a KSecretFile.
- *
- * @param path Path to load the collection from
- * @param parent parent collection manager
- * @param errorMessage set if there's an error
- * @return the KSecretCollection on success, 0 in case of an error
- */
- static KSecretCollection *deserialize(const QString &path, \
KSecretCollectionManager *parent,
- QString &errorMessage);
-
- virtual ApplicationPermission applicationPermission(const QString& path) const;
- virtual bool setApplicationPermission(const QString& path, ApplicationPermission \
perm);
-
+ /**
+ * Deserialize a ksecret collection from a KSecretFile.
+ *
+ * @param path Path to load the collection from
+ * @param parent parent collection manager
+ * @param errorMessage set if there's an error
+ * @return the KSecretCollection on success, 0 in case of an error
+ */
+ static KSecretCollection *deserialize(const QString &path, \
KSecretCollectionManager *parent, + QString \
&errorMessage); +
+ virtual ApplicationPermission applicationPermission(const QString& path) const;
+ virtual bool setApplicationPermission(const QString& path, ApplicationPermission \
perm); +
protected:
- /**
- * Try to unlock the collection using the password provided.
- *
- * @return true if unlocking succeeded, false else
- * @remarks this is used by KSecretUnlockCollectionJob
- */
- BackendReturn<bool> tryUnlockPassword(const QCA::SecureArray &password);
-
- /**
- * Lock this collection. This is implemented here for convenience purposes.
- *
- * @remarks this is used by KSecretLockCollectionJob
- */
- BackendReturn<bool> lock();
-
- /**
- * Create a new item inside this collection.
- *
- * @remarks this is used by KSecretCreateItemJob
- */
- BackendReturn<BackendItem*> createItem(const QString &label,
- const QMap<QString, QString> &attributes,
- const QCA::SecureArray &secret, bool \
locked,
- bool replace);
-
- /**
- * Delete this collection and emit the corresponding signals.
- *
- * @remarks this is used by KSecretDeleteCollectionJob
- */
- BackendReturn<bool> deleteCollection();
-
+ /**
+ * Try to unlock the collection using the password provided.
+ *
+ * @return true if unlocking succeeded, false else
+ * @remarks this is used by KSecretUnlockCollectionJob
+ */
+ BackendReturn<bool> tryUnlockPassword(const QCA::SecureArray &password);
+
+ /**
+ * Lock this collection. This is implemented here for convenience purposes.
+ *
+ * @remarks this is used by KSecretLockCollectionJob
+ */
+ BackendReturn<bool> lock();
+
+ /**
+ * Create a new item inside this collection.
+ *
+ * @remarks this is used by KSecretCreateItemJob
+ */
+ BackendReturn<BackendItem*> createItem(const QString &label,
+ const QMap<QString, QString> &attributes,
+ const QCA::SecureArray &secret, bool \
locked, + bool replace);
+
+ /**
+ * Delete this collection and emit the corresponding signals.
+ *
+ * @remarks this is used by KSecretDeleteCollectionJob
+ */
+ BackendReturn<bool> deleteCollection();
+
private:
- friend class KSecretUnlockCollectionJob;
- friend class KSecretLockCollectionJob;
- friend class KSecretDeleteCollectionJob;
- friend class KSecretCreateItemJob;
-
-
- /**
- * Try to unlock using the currently set symmetric key.
- *
- * @return true if unlocking succeeded, false if it failed
- * @remarks this is used by KSecretUnlockCollectionJob
- */
- bool tryUnlock();
-
- /**
- * Set-up the encryption to be used by the secret collection.
- * This creates hash and cipher functors as configured.
- *
- * @param errorMessage set in case of an error
- * @return true if setting up the encryption worked, false if
- * there were errors (ie. unsupported encryption methods.
- */
- bool setupAlgorithms(QString &errorMessage);
-
- /**
- * Deserialize the ksecret file header.
- *
- * @param file ksecret file to read from
- * @param errorMessage set if there's an error
- * @return true on success, false in case of an error
- */
- bool deserializeHeader(KSecretFile &file, QString &errorMessage);
-
- /**
- * Deserialize the algorithms used by a collection and check whether they
- * are supported.
- *
- * @param file ksecret file to read from
- * @param errorMessage set if there's an error
- * @return true on success, false in case of an error
- */
- bool deserializeAlgorithms(KSecretFile &file, QString &errorMessage);
-
- /**
- * Deserialize the parts inside the ksecret file.
- *
- * @param file ksecret file to read from
- * @param errorMessage set if there's an error
- * @return true on success, false in case of an error
- */
- bool deserializeParts(KSecretFile &file, QString &errorMessage);
-
- /**
- * Deserialize the collection property part inside a ksecret file.
- *
- * @param partContents contents of the part to deserialize
- * @return true on success, false in case of an error
- */
- bool deserializePartCollProps(const QByteArray &partContents);
-
- /**
- * Deserialize an item hashes part inside a ksecret file.
- *
- * @param partContents contents of the part to deserialize
- * @return true on success, false in case of an error
- */
- bool deserializePartItemHashes(const QByteArray &partContents);
-
- /**
- * Deserialize a symmetric key part inside a ksecret file.
- *
- * @param partContents contents of the part to deserialize
- * @return true on success, false in case of an error
- */
- bool deserializePartSymKey(const QByteArray &partContents);
-
- /**
- * Deserialize an acl part inside a ksecret file.
- *
- * @param partContents contents of the part to deserialize
- * @return true on success, false in case of an error
- */
- bool deserializePartAcls(const QByteArray &partContents);
-
- /**
- * Deserialize a config part inside a ksecret file.
- *
- * @param partContents contents of the part to deserialize
- * @return true on success, false in case of an error
- */
- bool deserializePartConfig(const QByteArray &partContents);
-
- /**
- * Deserialize the unlocked items part contained in file.
- *
- * @param file File to read the unlocked items from
- * @return true if reading the items was successful, false else
- * @remarks if the return value of this method is false, some of the
- * items might already have been overwritten. So in this case
- * it's wise to clear the items' data and re-lock them.
- */
- bool deserializeItemsUnlocked(KSecretFile &file);
-
- /**
- * Deserialize the contents of an encrypted part.
- *
- * @param partContents the contents of the part
- * @param decryptedPart the decrypted part contents
- * @return true if decrypting and deserializing was successful, false else
- */
- bool deserializePartEncrypted(const QByteArray &partContents, QCA::SecureArray \
&decryptedPart);
-
- /**
- * Serialize this ksecret collection back to a KSecretFile.
- *
- * @param errorMessage set if there's an replaceerror
- * @return true on success, false in case of an error
- */
- bool serialize(QString &errorMessage) const;
-
- /**
- * Serialize a ksecret file's headers.
- *
- * @param file ksecret file to write to
- * @return true if serialization was successful, false else
- */
- bool serializeHeader(KSecretFile &file) const;
-
- /**
- * Serialize a collection's parts to a ksecret file.
- *
- * @param file ksecret file to write to
- * @return true if serialization was successful, false else
- */
- bool serializeParts(KSecretFile &file) const;
-
- /**
- * Serialize a collection's properties to a ksecret file.
- *
- * @param file ksecret file to serialize the properties to
- * @param entry file part descriptor to put part information to
- * @return true if serialization was successful, false else
- */
- bool serializePropertiesPart(KSecretFile &file, FilePartEntry &entry) const;
-
- /**
- * Serialize a collection's configuration to a ksecret file.
- *
- * @param file ksecret file to serialize the configuration values to
- * @param entry file part descriptor to put part information to
- * @return true if serialization was successful, false else
- */
- bool serializeConfigPart(KSecretFile &file, FilePartEntry &entry) const;
-
- /**
- * Serialize a collection's acls to a ksecret file.
- *
- * @param file ksecret file to serialize the acls to
- * @param entry file part descriptor to put part information to
- * @return true if serialization was successful, false else
- */
- bool serializeAclsPart(KSecretFile &file, FilePartEntry &entry) const;
-
- /**
- * Serialize the item hashes of this collection to the ksecret file.
- *
- * @param file ksecret file to write to
- * @return true on success, false in case of an error
- */
- bool serializeItemHashes(KSecretFile &file, FilePartEntry &entry) const;
-
- /**
- * Serialize the unlocked items of this collection to the ksecret file.
- *
- * @param file ksecret file to write to
- * @return true on success, false in case of an error
- */
- bool serializeItems(KSecretFile &file, FilePartEntry &entry) const;
-
- /**
- * Write an encrypted part.
- *
- * @param data data to be encrypted and written
- * @param file ksecret file to write to
- * @param true on success, false in case of an error
- */
- bool serializeEncrypted(const QCA::SecureArray &data, KSecretFile &file) const;
-
- /**
- * Serialize a file part by writing it to the ksecret file and appending a hash \
mac
- * to sign its contents.
- *
- * @param data data to write to the partreplace
- * @param file ksecret file to write the data to
- * @return true if serializing was successful, false else
- */
- bool serializeAuthenticated(const QByteArray &data, KSecretFile &file) const;
-
- QString m_id;
- QString m_label;
- QDateTime m_created;
- QDateTime m_modified;
- QMap<QString, QByteArray> m_propUnknownKeys; // unknown collection properties
-
- QString m_path; // path of the ksecret file on disk
-
- // verifier
- QCA::InitializationVector m_verInitVector; // initialization vector of the \
verifier
- QCA::SecureArray m_verEncryptedRandom; // encrypted random data of the verifier
-
- // configuration values
- bool m_cfgCloseScreensaver; // close when the screensaver starts
- bool m_cfgCloseIfUnused; // close when the last application stops using it
- quint32 m_cfgCloseUnusedTimeout; // timeout the collection will be closed after \
if unused (secs)
- QMap<QString, QByteArray> m_cfgUnknownKeys; // unknown configuration keys
-
- quint32 m_algoHash; // hashing/mac algorithm identifier
- QCA::Hash *m_hash; // hashing algorithm
- QCA::MessageAuthenticationCode *m_mac; // message authentication code algorithm
- quint32 m_algoCipher; // encryption algorithm identifier
- QCA::Cipher *m_cipher; // encryption algorithm
-
- QCA::SymmetricKey *m_symmetricKey; // the symmetric key used for \
encryption/decryption
-
- // the configuration values message authentication code
- QByteArray m_configValuesMac;
- // the properties message authentication code
- QByteArray m_propertiesMac;
-
- // the acls message authentication code
- QHash<QString, BackendCollection::ApplicationPermission> m_acls;
- QMap<QString, int> m_unknownAcls;
- QByteArray m_aclsMac;
-
- // unknown file parts stored as-is
- QList<UnknownFilePart*> m_unknownParts;
-
- // contains the encrypted item parts
- QList<QByteArray> m_encryptedItemParts;
-
- // contains the encrypted symmetric keys
- QList<EncryptedKey*> m_encryptedSymKeys;
-
- // maps lookup attribute hashes to items
- QMultiHash<QByteArray, KSecretItem*> m_itemHashes;
- // maps item ids to their hashes for changing/removal
- QHash<KSecretItem*, QSet<QByteArray> > m_reverseItemHashes;
-
- // maps item identifiers to items
- QHash<QString, KSecretItem*> m_items;
+ friend class KSecretUnlockCollectionJob;
+ friend class KSecretLockCollectionJob;
+ friend class KSecretDeleteCollectionJob;
+ friend class KSecretCreateItemJob;
+
+
+ /**
+ * Try to unlock using the currently set symmetric key.
+ *
+ * @return true if unlocking succeeded, false if it failed
+ * @remarks this is used by KSecretUnlockCollectionJob
+ */
+ bool tryUnlock();
+
+ /**
+ * Set-up the encryption to be used by the secret collection.
+ * This creates hash and cipher functors as configured.
+ *
+ * @param errorMessage set in case of an error
+ * @return true if setting up the encryption worked, false if
+ * there were errors (ie. unsupported encryption methods.
+ */
+ bool setupAlgorithms(QString &errorMessage);
+
+ /**
+ * Deserialize the ksecret file header.
+ *
+ * @param file ksecret file to read from
+ * @param errorMessage set if there's an error
+ * @return true on success, false in case of an error
+ */
+ bool deserializeHeader(KSecretFile &file, QString &errorMessage);
+
+ /**
+ * Deserialize the algorithms used by a collection and check whether they
+ * are supported.
+ *
+ * @param file ksecret file to read from
+ * @param errorMessage set if there's an error
+ * @return true on success, false in case of an error
+ */
+ bool deserializeAlgorithms(KSecretFile &file, QString &errorMessage);
+
+ /**
+ * Deserialize the parts inside the ksecret file.
+ *
+ * @param file ksecret file to read from
+ * @param errorMessage set if there's an error
+ * @return true on success, false in case of an error
+ */
+ bool deserializeParts(KSecretFile &file, QString &errorMessage);
+
+ /**
+ * Deserialize the collection property part inside a ksecret file.
+ *
+ * @param partContents contents of the part to deserialize
+ * @return true on success, false in case of an error
+ */
+ bool deserializePartCollProps(const QByteArray &partContents);
+
+ /**
+ * Deserialize an item hashes part inside a ksecret file.
+ *
+ * @param partContents contents of the part to deserialize
+ * @return true on success, false in case of an error
+ */
+ bool deserializePartItemHashes(const QByteArray &partContents);
+
+ /**
+ * Deserialize a symmetric key part inside a ksecret file.
+ *
+ * @param partContents contents of the part to deserialize
+ * @return true on success, false in case of an error
+ */
+ bool deserializePartSymKey(const QByteArray &partContents);
+
+ /**
+ * Deserialize an acl part inside a ksecret file.
+ *
+ * @param partContents contents of the part to deserialize
+ * @return true on success, false in case of an error
+ */
+ bool deserializePartAcls(const QByteArray &partContents);
+
+ /**
+ * Deserialize a config part inside a ksecret file.
+ *
+ * @param partContents contents of the part to deserialize
+ * @return true on success, false in case of an error
+ */
+ bool deserializePartConfig(const QByteArray &partContents);
+
+ /**
+ * Deserialize the unlocked items part contained in file.
+ *
+ * @param file File to read the unlocked items from
+ * @return true if reading the items was successful, false else
+ * @remarks if the return value of this method is false, some of the
+ * items might already have been overwritten. So in this case
+ * it's wise to clear the items' data and re-lock them.
+ */
+ bool deserializeItemsUnlocked(KSecretFile &file);
+
+ /**
+ * Deserialize the contents of an encrypted part.
+ *
+ * @param partContents the contents of the part
+ * @param decryptedPart the decrypted part contents
+ * @return true if decrypting and deserializing was successful, false else
+ */
+ bool deserializePartEncrypted(const QByteArray &partContents, QCA::SecureArray \
&decryptedPart); +
+ /**
+ * Serialize this ksecret collection back to a KSecretFile.
+ *
+ * @param errorMessage set if there's an replaceerror
+ * @return true on success, false in case of an error
+ */
+ bool serialize(QString &errorMessage) const;
+
+ /**
+ * Serialize a ksecret file's headers.
+ *
+ * @param file ksecret file to write to
+ * @return true if serialization was successful, false else
+ */
+ bool serializeHeader(KSecretFile &file) const;
+
+ /**
+ * Serialize a collection's parts to a ksecret file.
+ *
+ * @param file ksecret file to write to
+ * @return true if serialization was successful, false else
+ */
+ bool serializeParts(KSecretFile &file) const;
+
+ /**
+ * Serialize a collection's properties to a ksecret file.
+ *
+ * @param file ksecret file to serialize the properties to
+ * @param entry file part descriptor to put part information to
+ * @return true if serialization was successful, false else
+ */
+ bool serializePropertiesPart(KSecretFile &file, FilePartEntry &entry) const;
+
+ /**
+ * Serialize a collection's configuration to a ksecret file.
+ *
+ * @param file ksecret file to serialize the configuration values to
+ * @param entry file part descriptor to put part information to
+ * @return true if serialization was successful, false else
+ */
+ bool serializeConfigPart(KSecretFile &file, FilePartEntry &entry) const;
+
+ /**
+ * Serialize a collection's acls to a ksecret file.
+ *
+ * @param file ksecret file to serialize the acls to
+ * @param entry file part descriptor to put part information to
+ * @return true if serialization was successful, false else
+ */
+ bool serializeAclsPart(KSecretFile &file, FilePartEntry &entry) const;
+
+ /**
+ * Serialize the item hashes of this collection to the ksecret file.
+ *
+ * @param file ksecret file to write to
+ * @return true on success, false in case of an error
+ */
+ bool serializeItemHashes(KSecretFile &file, FilePartEntry &entry) const;
+
+ /**
+ * Serialize the unlocked items of this collection to the ksecret file.
+ *
+ * @param file ksecret file to write to
+ * @return true on success, false in case of an error
+ */
+ bool serializeItems(KSecretFile &file, FilePartEntry &entry) const;
+
+ /**
+ * Write an encrypted part.
+ *
+ * @param data data to be encrypted and written
+ * @param file ksecret file to write to
+ * @param true on success, false in case of an error
+ */
+ bool serializeEncrypted(const QCA::SecureArray &data, KSecretFile &file) const;
+
+ /**
+ * Serialize a file part by writing it to the ksecret file and appending a hash \
mac + * to sign its contents.
+ *
+ * @param data data to write to the partreplace
+ * @param file ksecret file to write the data to
+ * @return true if serializing was successful, false else
+ */
+ bool serializeAuthenticated(const QByteArray &data, KSecretFile &file) const;
+
+ QString m_id;
+ QString m_label;
+ QDateTime m_created;
+ QDateTime m_modified;
+ QMap<QString, QByteArray> m_propUnknownKeys; // unknown collection properties
+
+ QString m_path; // path of the ksecret file on disk
+
+ // verifier
+ QCA::InitializationVector m_verInitVector; // initialization vector of the \
verifier + QCA::SecureArray m_verEncryptedRandom; // encrypted random data of the \
verifier +
+ // configuration values
+ bool m_cfgCloseScreensaver; // close when the screensaver starts
+ bool m_cfgCloseIfUnused; // close when the last application stops using \
it + quint32 m_cfgCloseUnusedTimeout; // timeout the collection will be closed \
after if unused (secs) + QMap<QString, QByteArray> m_cfgUnknownKeys; // unknown \
configuration keys +
+ quint32 m_algoHash; // hashing/mac algorithm identifier
+ QCA::Hash *m_hash; // hashing algorithm
+ QCA::MessageAuthenticationCode *m_mac; // message authentication code algorithm
+ quint32 m_algoCipher; // encryption algorithm identifier
+ QCA::Cipher *m_cipher; // encryption algorithm
+
+ QCA::SymmetricKey *m_symmetricKey; // the symmetric key used for \
encryption/decryption +
+ // the configuration values message authentication code
+ QByteArray m_configValuesMac;
+ // the properties message authentication code
+ QByteArray m_propertiesMac;
+
+ // the acls message authentication code
+ QHash<QString, BackendCollection::ApplicationPermission> m_acls;
+ QMap<QString, int> m_unknownAcls;
+ QByteArray m_aclsMac;
+
+ // unknown file parts stored as-is
+ QList<UnknownFilePart*> m_unknownParts;
+
+ // contains the encrypted item parts
+ QList<QByteArray> m_encryptedItemParts;
+
+ // contains the encrypted symmetric keys
+ QList<EncryptedKey*> m_encryptedSymKeys;
+
+ // maps lookup attribute hashes to items
+ QMultiHash<QByteArray, KSecretItem*> m_itemHashes;
+ // maps item ids to their hashes for changing/removal
+ QHash<KSecretItem*, QSet<QByteArray> > m_reverseItemHashes;
+
+ // maps item identifiers to items
+ QHash<QString, KSecretItem*> m_items;
};
#endif
diff --git a/backend/ksecret/ksecretcollectionmanager.cpp \
b/backend/ksecret/ksecretcollectionmanager.cpp index 3d73a6b..ad627a8 100644
--- a/backend/ksecret/ksecretcollectionmanager.cpp
+++ b/backend/ksecret/ksecretcollectionmanager.cpp
@@ -28,64 +28,64 @@
#include <QtCore/QDir>
KSecretCollectionManager::KSecretCollectionManager(const QString &path, QObject \
*parent)
- : BackendCollectionManager(parent), m_watcher(QStringList(path))
+ : BackendCollectionManager(parent), m_watcher(QStringList(path))
{
- connect(&m_watcher, SIGNAL(directoryChanged(QString)), \
SLOT(slotDirectoryChanged(QString)));
- // list directory contents to discover existing collections on startup
- QTimer::singleShot(0, this, SLOT(slotStartupDiscovery()));
+ connect(&m_watcher, SIGNAL(directoryChanged(QString)), \
SLOT(slotDirectoryChanged(QString))); + // list directory contents to discover \
existing collections on startup + QTimer::singleShot(0, this, \
SLOT(slotStartupDiscovery())); }
KSecretCollectionManager::~KSecretCollectionManager()
{
- // TODO: cleanup?
+ // TODO: cleanup?
}
CreateCollectionJob *KSecretCollectionManager::createCreateCollectionJob(const \
CollectionCreateInfo &createCollectionInfo) {
- KSecretCreateCollectionJob *job = new \
KSecretCreateCollectionJob(createCollectionInfo, this);
- connect(job, SIGNAL(result(QueuedJob*)),
- SLOT(createCollectionJobResult(QueuedJob*)));
- return job;
+ KSecretCreateCollectionJob *job = new \
KSecretCreateCollectionJob(createCollectionInfo, this); + connect(job, \
SIGNAL(result(QueuedJob*)), + \
SLOT(createCollectionJobResult(QueuedJob*))); + return job;
}
void KSecretCollectionManager::addCollection(KSecretCollection *collection)
{
- m_collections.insert(collection->path(), collection);
+ m_collections.insert(collection->path(), collection);
}
void KSecretCollectionManager::slotDirectoryChanged(const QString &path)
{
- // list all collections in the directory and check if there's a collection
- // which we don't know yet.
- QDir dir(path);
- QStringList entries = dir.entryList(QStringList("*.ksecret"), QDir::Files);
- Q_FOREACH(const QString &file, entries) {
- if (!m_collections.contains(file)) {
- QString errorMessage;
- KSecretCollection *coll = KSecretCollection::deserialize(file, this, \
errorMessage);
- if (coll) {
- addCollection(coll);
- }
- }
- }
+ // list all collections in the directory and check if there's a collection
+ // which we don't know yet.
+ QDir dir(path);
+ QStringList entries = dir.entryList(QStringList("*.ksecret"), QDir::Files);
+ Q_FOREACH(const QString & file, entries) {
+ if(!m_collections.contains(file)) {
+ QString errorMessage;
+ KSecretCollection *coll = KSecretCollection::deserialize(file, this, \
errorMessage); + if(coll) {
+ addCollection(coll);
+ }
+ }
+ }
}
void KSecretCollectionManager::slotStartupDiscovery()
{
- Q_ASSERT(m_watcher.directories().count() == 1);
- slotDirectoryChanged(m_watcher.directories().at(0));
+ Q_ASSERT(m_watcher.directories().count() == 1);
+ slotDirectoryChanged(m_watcher.directories().at(0));
}
void KSecretCollectionManager::createCollectionJobResult(QueuedJob *job)
{
- KSecretCreateCollectionJob *ccj = qobject_cast<KSecretCreateCollectionJob*>(job);
- Q_ASSERT(ccj);
-
- connect(ccj->collection(), SIGNAL(collectionDeleted(BackendCollection*)),
- SIGNAL(collectionDeleted(BackendCollection*)));
- connect(ccj->collection(), SIGNAL(collectionChanged(BackendCollection*)),
- SIGNAL(collectionChanged(BackendCollection*)));
- emit collectionCreated(ccj->collection());
+ KSecretCreateCollectionJob *ccj = \
qobject_cast<KSecretCreateCollectionJob*>(job); + Q_ASSERT(ccj);
+
+ connect(ccj->collection(), SIGNAL(collectionDeleted(BackendCollection*)),
+ SIGNAL(collectionDeleted(BackendCollection*)));
+ connect(ccj->collection(), SIGNAL(collectionChanged(BackendCollection*)),
+ SIGNAL(collectionChanged(BackendCollection*)));
+ emit collectionCreated(ccj->collection());
}
#include "ksecretcollectionmanager.moc"
diff --git a/backend/ksecret/ksecretcollectionmanager.h \
b/backend/ksecret/ksecretcollectionmanager.h index 6c93e30..4fc55f4 100644
--- a/backend/ksecret/ksecretcollectionmanager.h
+++ b/backend/ksecret/ksecretcollectionmanager.h
@@ -34,68 +34,68 @@ class KSecretCreateCollectionJob;
*/
class KSecretCollectionManager : public BackendCollectionManager
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructor
- *
- * @param path Path to detect ksecret files in
- * @param parent parent object
- */
- KSecretCollectionManager(const QString &path, QObject *parent = 0);
-
- /**
- * Destructor
- */
- virtual ~KSecretCollectionManager();
-
- /**
- * Create a call for creating a new collection.
- *
- * @param label the label of the new collection
- * @param lock if true, the collection should be locked after creation,
- * if false it should stay unlocked
- */
- virtual CreateCollectionJob *createCreateCollectionJob(const CollectionCreateInfo \
&createCollectionInfod); + /**
+ * Constructor
+ *
+ * @param path Path to detect ksecret files in
+ * @param parent parent object
+ */
+ KSecretCollectionManager(const QString &path, QObject *parent = 0);
+
+ /**
+ * Destructor
+ */
+ virtual ~KSecretCollectionManager();
+
+ /**
+ * Create a call for creating a new collection.
+ *
+ * @param label the label of the new collection
+ * @param lock if true, the collection should be locked after creation,
+ * if false it should stay unlocked
+ */
+ virtual CreateCollectionJob *createCreateCollectionJob(const \
CollectionCreateInfo &createCollectionInfod);
protected:
- /**
- * This methods adds a newly created collection to the manager.
- *
- * @param collection collection to add
- */
- void addCollection(KSecretCollection *coll);
-
+ /**
+ * This methods adds a newly created collection to the manager.
+ *
+ * @param collection collection to add
+ */
+ void addCollection(KSecretCollection *coll);
+
private Q_SLOTS:
- /**
- * Connected to a filesystem watcher this slot is called whenever
- * a ksecret file is added or removed.
- *
- * @param path directory that changed
- */
- void slotDirectoryChanged(const QString &path);
-
- /**
- * Collection discovery method which can be called using a single-shot timer.
- */
- void slotStartupDiscovery();
-
- /**
- * Called when a CreateCollectionJob run by this manager finishes.
- *
- * @param job the job that finished
- */
- void createCollectionJobResult(QueuedJob *job);
+ /**
+ * Connected to a filesystem watcher this slot is called whenever
+ * a ksecret file is added or removed.
+ *
+ * @param path directory that changed
+ */
+ void slotDirectoryChanged(const QString &path);
+
+ /**
+ * Collection discovery method which can be called using a single-shot timer.
+ */
+ void slotStartupDiscovery();
+
+ /**
+ * Called when a CreateCollectionJob run by this manager finishes.
+ *
+ * @param job the job that finished
+ */
+ void createCollectionJobResult(QueuedJob *job);
private:
- friend class KSecretCreateCollectionJob;
-
- // filesystem watcher to detect new/removed ksecret files
- QFileSystemWatcher m_watcher;
-
- // map of paths pointing to the respective collection objects
- QMap<QString, KSecretCollection*> m_collections;
+ friend class KSecretCreateCollectionJob;
+
+ // filesystem watcher to detect new/removed ksecret files
+ QFileSystemWatcher m_watcher;
+
+ // map of paths pointing to the respective collection objects
+ QMap<QString, KSecretCollection*> m_collections;
};
#endif
diff --git a/backend/ksecret/ksecretfile.cpp b/backend/ksecret/ksecretfile.cpp
index 8ebad21..7db7ce3 100644
--- a/backend/ksecret/ksecretfile.cpp
+++ b/backend/ksecret/ksecretfile.cpp
@@ -29,258 +29,258 @@
// ksecret file wasting a lot of memory and making the pc unusable.
KSecretFile::KSecretFile(QIODevice *device, OpenMode mode)
- : m_device(device), m_mode(mode)
+ : m_device(device), m_mode(mode)
{
- m_valid = m_device->open((mode == Read) ? QIODevice::ReadOnly : \
QIODevice::WriteOnly); + m_valid = m_device->open((mode == Read) ? \
QIODevice::ReadOnly : QIODevice::WriteOnly); }
KSecretFile::~KSecretFile()
{
- m_device->close();
+ m_device->close();
}
void KSecretFile::close()
{
- m_device->close();
+ m_device->close();
}
bool KSecretFile::isValid() const
{
- return m_valid;
+ return m_valid;
}
qint64 KSecretFile::pos() const
{
- return m_device->pos();
+ return m_device->pos();
}
bool KSecretFile::seek(qint64 pos)
{
- return m_device->seek(pos);
+ return m_device->seek(pos);
}
bool KSecretFile::readMagic()
{
- Q_ASSERT(m_mode == Read);
-
- if (!m_valid) {
- return false;
- }
-
- m_readBuffer.resize(KSECRET_MAGIC_LEN);
- if (m_device->read(m_readBuffer.data(), KSECRET_MAGIC_LEN) != KSECRET_MAGIC_LEN) \
{
- m_valid = false;
- return false;
- }
- return m_readBuffer == KSECRET_MAGIC;
+ Q_ASSERT(m_mode == Read);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ m_readBuffer.resize(KSECRET_MAGIC_LEN);
+ if(m_device->read(m_readBuffer.data(), KSECRET_MAGIC_LEN) != KSECRET_MAGIC_LEN) \
{ + m_valid = false;
+ return false;
+ }
+ return m_readBuffer == KSECRET_MAGIC;
}
bool KSecretFile::writeMagic()
{
- Q_ASSERT(m_mode == Write);
-
- if (!m_valid) {
- return false;
- }
-
- if (m_device->write(KSECRET_MAGIC, KSECRET_MAGIC_LEN) != KSECRET_MAGIC_LEN) {
- m_valid = false;
- }
- return m_valid;
+ Q_ASSERT(m_mode == Write);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ if(m_device->write(KSECRET_MAGIC, KSECRET_MAGIC_LEN) != KSECRET_MAGIC_LEN) {
+ m_valid = false;
+ }
+ return m_valid;
}
bool KSecretFile::readUint(quint32 *value)
{
- Q_ASSERT(value);
- Q_ASSERT(m_mode == Read);
-
- if (!m_valid) {
- return false;
- }
-
- m_readBuffer.resize(4);
- if (m_device->read(m_readBuffer.data(), 4) != 4) {
- m_valid = false;
- return false;
- }
- *value = qFromBigEndian<quint32>((const uchar*)m_readBuffer.constData());
- return true;
+ Q_ASSERT(value);
+ Q_ASSERT(m_mode == Read);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ m_readBuffer.resize(4);
+ if(m_device->read(m_readBuffer.data(), 4) != 4) {
+ m_valid = false;
+ return false;
+ }
+ *value = qFromBigEndian<quint32>((const uchar*)m_readBuffer.constData());
+ return true;
}
bool KSecretFile::writeUint(quint32 value)
{
- Q_ASSERT(m_mode == Write);
-
- if (!m_valid) {
- return false;
- }
-
- uchar outputBuffer[4];
- qToBigEndian<quint32>(value, outputBuffer);
- if (m_device->write((const char*)outputBuffer, 4) != 4) {
- m_valid = false;
- }
- return m_valid;
+ Q_ASSERT(m_mode == Write);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ uchar outputBuffer[4];
+ qToBigEndian<quint32>(value, outputBuffer);
+ if(m_device->write((const char*)outputBuffer, 4) != 4) {
+ m_valid = false;
+ }
+ return m_valid;
}
bool KSecretFile::readDatetime(QDateTime *value)
{
- Q_ASSERT(value);
- Q_ASSERT(m_mode == Read);
-
- if (!m_valid) {
- return false;
- }
-
- m_readBuffer.resize(8);
- if (m_device->read(m_readBuffer.data(), 8) != 8) {
- m_valid = false;
- return false;
- }
- value->setTime_t(qFromBigEndian<quint64>((const \
uchar*)m_readBuffer.constData()));
- return true;
+ Q_ASSERT(value);
+ Q_ASSERT(m_mode == Read);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ m_readBuffer.resize(8);
+ if(m_device->read(m_readBuffer.data(), 8) != 8) {
+ m_valid = false;
+ return false;
+ }
+ value->setTime_t(qFromBigEndian<quint64>((const \
uchar*)m_readBuffer.constData())); + return true;
}
bool KSecretFile::writeDatetime(const QDateTime &value)
{
- Q_ASSERT(m_mode == Write);
-
- if (!m_valid) {
- return false;
- }
-
- uchar outputBuffer[8];
- qToBigEndian<quint64>(value.toTime_t(), outputBuffer);
- if (m_device->write((const char*)outputBuffer, 8) != 8) {
- m_valid = false;
- }
- return m_valid;
+ Q_ASSERT(m_mode == Write);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ uchar outputBuffer[8];
+ qToBigEndian<quint64>(value.toTime_t(), outputBuffer);
+ if(m_device->write((const char*)outputBuffer, 8) != 8) {
+ m_valid = false;
+ }
+ return m_valid;
}
bool KSecretFile::readBytearray(QByteArray *value)
{
- Q_ASSERT(value);
- Q_ASSERT(m_mode == Read);
-
- if (!m_valid) {
- return false;
- }
-
- quint32 length;
- if (!readUint(&length)) {
- m_valid = false;
- return false;
- }
-
- value->resize(length);
- if (m_device->read(value->data(), length) != length) {
- m_valid = false;
- }
- return m_valid;
+ Q_ASSERT(value);
+ Q_ASSERT(m_mode == Read);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ quint32 length;
+ if(!readUint(&length)) {
+ m_valid = false;
+ return false;
+ }
+
+ value->resize(length);
+ if(m_device->read(value->data(), length) != length) {
+ m_valid = false;
+ }
+ return m_valid;
}
bool KSecretFile::writeBytearray(const QByteArray &value)
{
- Q_ASSERT(m_mode == Write);
+ Q_ASSERT(m_mode == Write);
- if (!m_valid) {
- return false;
- }
+ if(!m_valid) {
+ return false;
+ }
- if (!writeUint(value.size()) || m_device->write(value) != value.size()) {
- m_valid = false;
- }
- return m_valid;
+ if(!writeUint(value.size()) || m_device->write(value) != value.size()) {
+ m_valid = false;
+ }
+ return m_valid;
}
bool KSecretFile::readString(QString *value)
{
- Q_ASSERT(value);
- Q_ASSERT(m_mode == Read);
-
- if (!m_valid) {
- return false;
- }
-
- QByteArray bytearray;
- if (!readBytearray(&bytearray)) {
- m_valid = false;
- return false;
- }
-
- // TODO: detect invalid Utf-8 strings!
- *value = QString::fromUtf8(bytearray);
- return true;
+ Q_ASSERT(value);
+ Q_ASSERT(m_mode == Read);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ QByteArray bytearray;
+ if(!readBytearray(&bytearray)) {
+ m_valid = false;
+ return false;
+ }
+
+ // TODO: detect invalid Utf-8 strings!
+ *value = QString::fromUtf8(bytearray);
+ return true;
}
bool KSecretFile::writeString(const QString &value)
{
- return writeBytearray(value.toUtf8());
+ return writeBytearray(value.toUtf8());
}
bool KSecretFile::readSecret(QCA::SecureArray *value)
{
- Q_ASSERT(value);
- Q_ASSERT(m_mode == Read);
-
- if (!m_valid) {
- return false;
- }
-
- quint32 length;
- if (!readUint(&length)) {
- m_valid = false;
- return false;
- }
-
- value->resize(length);
- if (m_device->read(value->data(), length) != length) {
- m_valid = false;
- return false;
- }
- return true;
+ Q_ASSERT(value);
+ Q_ASSERT(m_mode == Read);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ quint32 length;
+ if(!readUint(&length)) {
+ m_valid = false;
+ return false;
+ }
+
+ value->resize(length);
+ if(m_device->read(value->data(), length) != length) {
+ m_valid = false;
+ return false;
+ }
+ return true;
}
bool KSecretFile::writeSecret(const QCA::SecureArray &value)
{
- Q_ASSERT(m_mode == Write);
+ Q_ASSERT(m_mode == Write);
- if (!m_valid) {
- return false;
- }
+ if(!m_valid) {
+ return false;
+ }
- if (!writeUint(value.size()) ||
- m_device->write(value.constData(), value.size()) != value.size()) {
- m_valid = false;
- }
- return m_valid;
+ if(!writeUint(value.size()) ||
+ m_device->write(value.constData(), value.size()) != value.size()) {
+ m_valid = false;
+ }
+ return m_valid;
}
bool KSecretFile::readPart(QByteArray *value, quint32 position, quint32 length)
{
- Q_ASSERT(value);
- Q_ASSERT(m_mode == Read);
-
- if (!m_valid) {
- return false;
- }
-
- // remember current position
- qint64 oldPos = m_device->pos();
-
- bool rc = true;
-
- // seek new position
- if (m_device->seek(position)) {
- value->resize(length);
- if (m_device->read(value->data(), length) != length) {
- rc = false;
- }
- } else {
- rc = false;
- }
-
- m_device->seek(oldPos);
- m_valid = rc;
- return rc;
+ Q_ASSERT(value);
+ Q_ASSERT(m_mode == Read);
+
+ if(!m_valid) {
+ return false;
+ }
+
+ // remember current position
+ qint64 oldPos = m_device->pos();
+
+ bool rc = true;
+
+ // seek new position
+ if(m_device->seek(position)) {
+ value->resize(length);
+ if(m_device->read(value->data(), length) != length) {
+ rc = false;
+ }
+ } else {
+ rc = false;
+ }
+
+ m_device->seek(oldPos);
+ m_valid = rc;
+ return rc;
}
diff --git a/backend/ksecret/ksecretfile.h b/backend/ksecret/ksecretfile.h
index 0b7385c..216735e 100644
--- a/backend/ksecret/ksecretfile.h
+++ b/backend/ksecret/ksecretfile.h
@@ -34,202 +34,202 @@
class KSecretFile
{
public:
- /**
- * Modes for opening the ksecret file.
- */
- enum OpenMode {
- Read, /// Open file for reading
- Write /// Open file for writing
- };
-
- /**
- * Known hashing and MAC algorithms.
- */
- enum AlgorithmHash {
- SHA256 = 0 /// SHA256
- };
-
- /**
- * Known encryption algorithms.
- */
- enum AlgorithmEncryption {
- AES256 = 0 /// AES256 using CBC and default padding
- };
-
- /**
- * Known types of parts in the ksecret file.
- */
- enum PartType {
- PartItemHashes = 0, /// Attribute hashes for item lookup
- PartSymKey = 1, /// Encrypted symmetric master-key
- PartItems = 2, /// Encrypted items
- PartAcls = 3, /// Signed ACLs
- PartConfig = 4, /// Signed collection configuration
- PartCollProps = 5 /// Signed collection properties
- };
-
- /**
- * Known encryption types for the symmetric key.
- */
- enum KeyType {
- KeyPassword = 0, /// Key encrypted using a password
- KeyBogus = 666 /// TODO: remove this once other keys are implemented
- };
-
- /**
- * Constructor.
- *
- * @param device device to read the contents from
- * @param mode set whether to read or to write
- */
- KSecretFile(QIODevice *device, OpenMode mode);
-
- /**
- * Destructor.
- */
- ~KSecretFile();
-
- /**
- * Check if the secret file was constructed validly.
- * This DOES NOT check if the file contents are valid.
- *
- * @return true if the object can be worked with, false if an
- * error occurred during opening or reading/writing data.
- */
- bool isValid() const;
-
- /**
- * Close this ksecret file.
- */
- void close();
-
- /**
- * Get the current position withing the file.
- *
- * @return the current file position
- */
- qint64 pos() const;
-
- /**
- * Set the current position withing the file to pos.
- *
- * @param pos position to seek inside the underlying device
- * @return true on success, false on error
- */
- bool seek(qint64 pos);
-
- /**
- * Read the ksecret file's magic value.
- *
- * @return true if the magic indicates this file is a ksecret file,
- * false else
- */
- bool readMagic();
-
- /**
- * Write the ksecret file's magic value.
- *
- * @return true if the magic was written successfull, false else
- */
- bool writeMagic();
-
- /**
- * Read a UINT from the file.
- *
- * @param value pointer the UINT will be written to
- * @return true if reading was successful, false else
- */
- bool readUint(quint32 *value);
-
- /**
- * Write a UINT to the file.
- *
- * @param value the UINT that should be written
- * @return true if writing was successful, false else
- */
- bool writeUint(quint32 value);
-
- /**
- * Read a DATETIME from the file.
- *
- * @param value pointer the DATETIME will be written to
- * @return true if reading was successful, false else
- */
- bool readDatetime(QDateTime *value);
-
- /**
- * Write a DATETIME to the file.
- *
- * @param value DATETIME to be written
- * @return true if writing was successful, false else
- */
- bool writeDatetime(const QDateTime &value);
-
- /**
- * Read a BYTEARRAY from the file.
- *
- * @param value pointer the BYTEARRAY will be written to
- * @return true if reading was successful, false else
- */
- bool readBytearray(QByteArray *value);
-
- /**
- * Write a BYTEARRAY to the file.
- *
- * @param value BYTEARRAY to be written
- * @return true if writing was successful, false else
- */
- bool writeBytearray(const QByteArray &value);
-
- /**
- * Read a STRING from the file.
- *
- * @param value pointer the STRING will be written to
- * @return true if reading was successful, false else
- */
- bool readString(QString *value);
-
- /**
- * Write a STRING to the file.
- *
- * @param value the STRING to be written
- * @return true if writing was successful, false else
- */
- bool writeString(const QString &value);
-
- /**
- * Read a secret BYTEARRAY/STRING from the file.
- *
- * @param value pointer the secret will be written to
- * @return true if reading was successul, false else
- * @remarks basically the same as \sa readBytearray
- * but writes the results into a SecureArray.
- */
- bool readSecret(QCA::SecureArray *value);
-
- /**
- * Write a secret BYTEARRAY/STRING to the file.
- *
- * @param value the secret to be written
- * @return true if writing was successful, false else
- */
- bool writeSecret(const QCA::SecureArray &value);
-
- /**
- * Read an entire part of the ksecret file.
- *
- * @param value pointer to the bytearray that should be filled
- * @param position position inside the ksecret file
- * @param length length of the part to read
- */
- bool readPart(QByteArray *value, quint32 position, quint32 length);
+ /**
+ * Modes for opening the ksecret file.
+ */
+ enum OpenMode {
+ Read, /// Open file for reading
+ Write /// Open file for writing
+ };
+
+ /**
+ * Known hashing and MAC algorithms.
+ */
+ enum AlgorithmHash {
+ SHA256 = 0 /// SHA256
+ };
+
+ /**
+ * Known encryption algorithms.
+ */
+ enum AlgorithmEncryption {
+ AES256 = 0 /// AES256 using CBC and default padding
+ };
+
+ /**
+ * Known types of parts in the ksecret file.
+ */
+ enum PartType {
+ PartItemHashes = 0, /// Attribute hashes for item lookup
+ PartSymKey = 1, /// Encrypted symmetric master-key
+ PartItems = 2, /// Encrypted items
+ PartAcls = 3, /// Signed ACLs
+ PartConfig = 4, /// Signed collection configuration
+ PartCollProps = 5 /// Signed collection properties
+ };
+
+ /**
+ * Known encryption types for the symmetric key.
+ */
+ enum KeyType {
+ KeyPassword = 0, /// Key encrypted using a password
+ KeyBogus = 666 /// TODO: remove this once other keys are implemented
+ };
+
+ /**
+ * Constructor.
+ *
+ * @param device device to read the contents from
+ * @param mode set whether to read or to write
+ */
+ KSecretFile(QIODevice *device, OpenMode mode);
+
+ /**
+ * Destructor.
+ */
+ ~KSecretFile();
+
+ /**
+ * Check if the secret file was constructed validly.
+ * This DOES NOT check if the file contents are valid.
+ *
+ * @return true if the object can be worked with, false if an
+ * error occurred during opening or reading/writing data.
+ */
+ bool isValid() const;
+
+ /**
+ * Close this ksecret file.
+ */
+ void close();
+
+ /**
+ * Get the current position withing the file.
+ *
+ * @return the current file position
+ */
+ qint64 pos() const;
+
+ /**
+ * Set the current position withing the file to pos.
+ *
+ * @param pos position to seek inside the underlying device
+ * @return true on success, false on error
+ */
+ bool seek(qint64 pos);
+
+ /**
+ * Read the ksecret file's magic value.
+ *
+ * @return true if the magic indicates this file is a ksecret file,
+ * false else
+ */
+ bool readMagic();
+
+ /**
+ * Write the ksecret file's magic value.
+ *
+ * @return true if the magic was written successfull, false else
+ */
+ bool writeMagic();
+
+ /**
+ * Read a UINT from the file.
+ *
+ * @param value pointer the UINT will be written to
+ * @return true if reading was successful, false else
+ */
+ bool readUint(quint32 *value);
+
+ /**
+ * Write a UINT to the file.
+ *
+ * @param value the UINT that should be written
+ * @return true if writing was successful, false else
+ */
+ bool writeUint(quint32 value);
+
+ /**
+ * Read a DATETIME from the file.
+ *
+ * @param value pointer the DATETIME will be written to
+ * @return true if reading was successful, false else
+ */
+ bool readDatetime(QDateTime *value);
+
+ /**
+ * Write a DATETIME to the file.
+ *
+ * @param value DATETIME to be written
+ * @return true if writing was successful, false else
+ */
+ bool writeDatetime(const QDateTime &value);
+
+ /**
+ * Read a BYTEARRAY from the file.
+ *
+ * @param value pointer the BYTEARRAY will be written to
+ * @return true if reading was successful, false else
+ */
+ bool readBytearray(QByteArray *value);
+
+ /**
+ * Write a BYTEARRAY to the file.
+ *
+ * @param value BYTEARRAY to be written
+ * @return true if writing was successful, false else
+ */
+ bool writeBytearray(const QByteArray &value);
+
+ /**
+ * Read a STRING from the file.
+ *
+ * @param value pointer the STRING will be written to
+ * @return true if reading was successful, false else
+ */
+ bool readString(QString *value);
+
+ /**
+ * Write a STRING to the file.
+ *
+ * @param value the STRING to be written
+ * @return true if writing was successful, false else
+ */
+ bool writeString(const QString &value);
+
+ /**
+ * Read a secret BYTEARRAY/STRING from the file.
+ *
+ * @param value pointer the secret will be written to
+ * @return true if reading was successul, false else
+ * @remarks basically the same as \sa readBytearray
+ * but writes the results into a SecureArray.
+ */
+ bool readSecret(QCA::SecureArray *value);
+
+ /**
+ * Write a secret BYTEARRAY/STRING to the file.
+ *
+ * @param value the secret to be written
+ * @return true if writing was successful, false else
+ */
+ bool writeSecret(const QCA::SecureArray &value);
+
+ /**
+ * Read an entire part of the ksecret file.
+ *
+ * @param value pointer to the bytearray that should be filled
+ * @param position position inside the ksecret file
+ * @param length length of the part to read
+ */
+ bool readPart(QByteArray *value, quint32 position, quint32 length);
private:
- QIODevice *m_device;
- OpenMode m_mode;
- bool m_valid;
+ QIODevice *m_device;
+ OpenMode m_mode;
+ bool m_valid;
- QByteArray m_readBuffer;
+ QByteArray m_readBuffer;
};
#endif
diff --git a/backend/ksecret/ksecretitem.cpp b/backend/ksecret/ksecretitem.cpp
index f4fa603..230827f 100644
--- a/backend/ksecret/ksecretitem.cpp
+++ b/backend/ksecret/ksecretitem.cpp
@@ -27,9 +27,9 @@
#include <QtCore/QTimer>
KSecretItem::KSecretItem(const QString &id, KSecretCollection *parent)
- : BackendItem(parent), m_collection(parent), m_id(id)
+ : BackendItem(parent), m_collection(parent), m_id(id)
{
- Q_ASSERT(parent);
+ Q_ASSERT(parent);
}
KSecretItem::~KSecretItem()
@@ -38,253 +38,253 @@ KSecretItem::~KSecretItem()
QString KSecretItem::id() const
{
- return m_id;
+ return m_id;
}
BackendReturn<QString> KSecretItem::label() const
{
- if (isLocked()) {
- return BackendReturn<QString>(QString(), ErrorIsLocked);
- } else {
- markAsUsed();
- return m_label;
- }
+ if(isLocked()) {
+ return BackendReturn<QString>(QString(), ErrorIsLocked);
+ } else {
+ markAsUsed();
+ return m_label;
+ }
}
BackendReturn<void> KSecretItem::setLabel(const QString &label)
{
- if (isLocked()) {
- return BackendReturn<void>(ErrorIsLocked);
- } else {
- m_label = label;
- markAsModified();
- return BackendReturn<void>();
- }
+ if(isLocked()) {
+ return BackendReturn<void>(ErrorIsLocked);
+ } else {
+ m_label = label;
+ markAsModified();
+ return BackendReturn<void>();
+ }
}
BackendReturn<QCA::SecureArray> KSecretItem::secret() const
{
- if (isLocked()) {
- return BackendReturn<QCA::SecureArray>(QCA::SecureArray(), ErrorIsLocked);
- } else {
- markAsUsed();
- return m_secret;
- }
+ if(isLocked()) {
+ return BackendReturn<QCA::SecureArray>(QCA::SecureArray(), ErrorIsLocked);
+ } else {
+ markAsUsed();
+ return m_secret;
+ }
}
BackendReturn<void> KSecretItem::setSecret(const QCA::SecureArray &secret)
{
- if (isLocked()) {
- return BackendReturn<void>(ErrorIsLocked);
- } else {
- m_secret = secret;
- markAsModified();
- return BackendReturn<void>();
- }
+ if(isLocked()) {
+ return BackendReturn<void>(ErrorIsLocked);
+ } else {
+ m_secret = secret;
+ markAsModified();
+ return BackendReturn<void>();
+ }
}
BackendReturn<QMap<QString, QString> > KSecretItem::attributes() const
{
- if (isLocked()) {
- return BackendReturn<QMap<QString, QString> >(QMap<QString, QString>(), \
ErrorIsLocked);
- } else {
- markAsUsed();
- return m_attributes;
- }
+ if(isLocked()) {
+ return BackendReturn<QMap<QString, QString> >(QMap<QString, QString>(), \
ErrorIsLocked); + } else {
+ markAsUsed();
+ return m_attributes;
+ }
}
BackendReturn<void> KSecretItem::setAttributes(const QMap<QString, QString> \
&attributes) {
- if (isLocked()) {
- return BackendReturn<void>(ErrorIsLocked);
- } else {
- m_attributes = attributes;
- markAsModified();
- emit attributesChanged(this);
- return BackendReturn<void>();
- }
+ if(isLocked()) {
+ return BackendReturn<void>(ErrorIsLocked);
+ } else {
+ m_attributes = attributes;
+ markAsModified();
+ emit attributesChanged(this);
+ return BackendReturn<void>();
+ }
}
QDateTime KSecretItem::created() const
{
- markAsUsed();
- return m_created;
+ markAsUsed();
+ return m_created;
}
QDateTime KSecretItem::modified() const
{
- markAsUsed();
- return m_modified;
+ markAsUsed();
+ return m_modified;
}
bool KSecretItem::isLocked() const
{
- return m_collection->isLocked();
+ return m_collection->isLocked();
}
UnlockItemJob *KSecretItem::createUnlockJob(const ItemUnlockInfo& unlockInfo)
{
- Q_ASSERT(m_collection);
- Q_ASSERT(unlockInfo.m_item == 0); // FIXME: what to do when item information is \
already present ?
- unlockInfo.m_item = this;
- return new KSecretUnlockItemJob(unlockInfo, m_collection);
+ Q_ASSERT(m_collection);
+ Q_ASSERT(unlockInfo.m_item == 0); // FIXME: what to do when item information is \
already present ? + unlockInfo.m_item = this;
+ return new KSecretUnlockItemJob(unlockInfo, m_collection);
}
LockItemJob *KSecretItem::createLockJob()
{
- Q_ASSERT(m_collection);
- return new KSecretLockItemJob(this, m_collection);
+ Q_ASSERT(m_collection);
+ return new KSecretLockItemJob(this, m_collection);
}
DeleteItemJob *KSecretItem::createDeleteJob(const ItemDeleteInfo& deleteJobInfo)
{
- deleteJobInfo.m_item = this;
- return new KSecretDeleteItemJob(deleteJobInfo);
+ deleteJobInfo.m_item = this;
+ return new KSecretDeleteItemJob(deleteJobInfo);
}
BackendReturn<bool> KSecretItem::deleteItem()
{
- emit itemDeleted(this);
- deleteLater();
- return true;
+ emit itemDeleted(this);
+ deleteLater();
+ return true;
}
ChangeAuthenticationItemJob *KSecretItem::createChangeAuthenticationJob()
{
- return new KSecretChangeAuthenticationItemJob(this);
+ return new KSecretChangeAuthenticationItemJob(this);
}
bool KSecretItem::matches(const QMap<QString, QString> &attributes)
{
- QMap<QString, QString>::const_iterator it = attributes.constBegin();
- const QMap<QString, QString>::const_iterator end = attributes.constEnd();
- for ( ; it != end; ++it) {
- if (!m_attributes.contains(it.key()) ||
- m_attributes.value(it.key()) != it.value()) {
- return false;
- }
- }
- return true;
+ QMap<QString, QString>::const_iterator it = attributes.constBegin();
+ const QMap<QString, QString>::const_iterator end = attributes.constEnd();
+ for(; it != end; ++it) {
+ if(!m_attributes.contains(it.key()) ||
+ m_attributes.value(it.key()) != it.value()) {
+ return false;
+ }
+ }
+ return true;
}
bool KSecretItem::deserializeUnlocked(KSecretFile &file)
{
- Q_ASSERT(file.isValid());
-
- // deserialize everything to temporary variables/objects and write it
- // into the members in one go once everything could be read successfully.
-
- // file currently points at item-label
- QString itemLabel;
- QDateTime itemCreated;
- QDateTime itemModified;
- quint32 numAttribs;
- if (!file.readString(&itemLabel) || !file.readDatetime(&itemCreated) ||
- !file.readDatetime(&itemModified) || !file.readUint(&numAttribs)) {
- return false;
- }
-
- // read the attributes
- QMap<QString, QString> attributes;
- for (quint32 i = 0; i < numAttribs; ++i) {
- QString attribKey;
- QString attribValue;
- if (!file.readString(&attribKey) || !file.readString(&attribValue)) {
- return false;
- }
- attributes.insert(attribKey, attribValue);
- }
-
- // read the secret
- QCA::SecureArray secret;
- if (!file.readSecret(&secret)) {
- return false;
- }
-
- m_label = itemLabel;
- m_created = itemCreated;
- m_modified = itemModified;
- m_attributes = attributes;
- m_secret = secret;
-
- return true;
+ Q_ASSERT(file.isValid());
+
+ // deserialize everything to temporary variables/objects and write it
+ // into the members in one go once everything could be read successfully.
+
+ // file currently points at item-label
+ QString itemLabel;
+ QDateTime itemCreated;
+ QDateTime itemModified;
+ quint32 numAttribs;
+ if(!file.readString(&itemLabel) || !file.readDatetime(&itemCreated) ||
+ !file.readDatetime(&itemModified) || !file.readUint(&numAttribs)) {
+ return false;
+ }
+
+ // read the attributes
+ QMap<QString, QString> attributes;
+ for(quint32 i = 0; i < numAttribs; ++i) {
+ QString attribKey;
+ QString attribValue;
+ if(!file.readString(&attribKey) || !file.readString(&attribValue)) {
+ return false;
+ }
+ attributes.insert(attribKey, attribValue);
+ }
+
+ // read the secret
+ QCA::SecureArray secret;
+ if(!file.readSecret(&secret)) {
+ return false;
+ }
+
+ m_label = itemLabel;
+ m_created = itemCreated;
+ m_modified = itemModified;
+ m_attributes = attributes;
+ m_secret = secret;
+
+ return true;
}
bool KSecretItem::serializeUnlocked(KSecretFile &file)
{
- Q_ASSERT(file.isValid());
-
- if (!file.writeString(m_id)) {
- return false;
- }
-
- // serialize data to a temporary array
- SecureBuffer device;
- KSecretFile tempFile(&device, KSecretFile::Write);
- if (!tempFile.isValid()) {
- return false;
- }
-
- if (!tempFile.writeString(m_label) || !tempFile.writeDatetime(m_created) ||
- !tempFile.writeDatetime(m_modified) || \
!tempFile.writeUint(m_attributes.size())) {
- return false;
- }
-
- // serialize attributes
- QMap<QString, QString>::const_iterator it = m_attributes.constBegin();
- const QMap<QString, QString>::const_iterator end = m_attributes.constEnd();
- for ( ; it != end; ++it) {
- if (!tempFile.writeString(it.key()) || !tempFile.writeString(it.value())) {
- return false;
- }
- }
-
- // serialize secret
- if (!tempFile.writeSecret(m_secret)) {
- return false;
- }
-
- // now take the tempFile and write its contents to the actual file
- if (!file.writeSecret(device.buffer())) {
- return false;
- }
- return true;
+ Q_ASSERT(file.isValid());
+
+ if(!file.writeString(m_id)) {
+ return false;
+ }
+
+ // serialize data to a temporary array
+ SecureBuffer device;
+ KSecretFile tempFile(&device, KSecretFile::Write);
+ if(!tempFile.isValid()) {
+ return false;
+ }
+
+ if(!tempFile.writeString(m_label) || !tempFile.writeDatetime(m_created) ||
+ !tempFile.writeDatetime(m_modified) || \
!tempFile.writeUint(m_attributes.size())) { + return false;
+ }
+
+ // serialize attributes
+ QMap<QString, QString>::const_iterator it = m_attributes.constBegin();
+ const QMap<QString, QString>::const_iterator end = m_attributes.constEnd();
+ for(; it != end; ++it) {
+ if(!tempFile.writeString(it.key()) || !tempFile.writeString(it.value())) {
+ return false;
+ }
+ }
+
+ // serialize secret
+ if(!tempFile.writeSecret(m_secret)) {
+ return false;
+ }
+
+ // now take the tempFile and write its contents to the actual file
+ if(!file.writeSecret(device.buffer())) {
+ return false;
+ }
+ return true;
}
QSet<QByteArray> KSecretItem::createHashes(const QMap<QString, QString> &attributes,
- QCA::Hash *hash)
+ QCA::Hash *hash)
{
- Q_ASSERT(hash);
-
- QSet<QByteArray> hashSet;
- QMap<QString, QString>::const_iterator it = attributes.constBegin();
- QMap<QString, QString>::const_iterator end = attributes.constEnd();
- for ( ; it != end; ++it) {
- hash->clear();
- hash->update(it.key().toUtf8());
- hash->update(it.value().toUtf8());
- hashSet.insert(hash->final().toByteArray());
- }
-
- return hashSet;
+ Q_ASSERT(hash);
+
+ QSet<QByteArray> hashSet;
+ QMap<QString, QString>::const_iterator it = attributes.constBegin();
+ QMap<QString, QString>::const_iterator end = attributes.constEnd();
+ for(; it != end; ++it) {
+ hash->clear();
+ hash->update(it.key().toUtf8());
+ hash->update(it.value().toUtf8());
+ hashSet.insert(hash->final().toByteArray());
+ }
+
+ return hashSet;
}
QSet<QByteArray> KSecretItem::createAttributeHashes(QCA::Hash *hash) const
{
- return createHashes(m_attributes, hash);
+ return createHashes(m_attributes, hash);
}
void KSecretItem::markAsModified()
{
- m_modified = QDateTime::currentDateTime();
- emit itemUsed(this);
- emit itemChanged(this);
+ m_modified = QDateTime::currentDateTime();
+ emit itemUsed(this);
+ emit itemChanged(this);
}
void KSecretItem::markAsUsed() const
{
- // TODO: figure out what to do. this method exists so a "close-if-unused" timer
- // can be implemented.
+ // TODO: figure out what to do. this method exists so a "close-if-unused" timer
+ // can be implemented.
}
#include "ksecretitem.moc"
diff --git a/backend/ksecret/ksecretitem.h b/backend/ksecret/ksecretitem.h
index 5666d3b..269767e 100644
--- a/backend/ksecret/ksecretitem.h
+++ b/backend/ksecret/ksecretitem.h
@@ -34,202 +34,202 @@ class KSecretDeleteItemJob;
*/
class KSecretItem : public BackendItem
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructor.
- *
- * @param id unique identifier of the new item
- * @param collection collection that created this item
- */
- KSecretItem(const QString &id, KSecretCollection *parent);
-
- /**
- * Destructor.
- */
- ~KSecretItem();
-
- /**
- * The unique identifer for this item.
- */
- virtual QString id() const;
-
- /**
- * The human-readable label for this item.
- * @todo error
- */
- virtual BackendReturn<QString> label() const;
-
- /**
- * Set the human-readable label for this item.
- *
- * @param label the new label for this item
- * @todo error
- */
- virtual BackendReturn<void> setLabel(const QString &label);
-
- /**
- * Get the secret stored inside this item.
- *
- * @return the secret
- * @todo this will most likely become non-const as that might make sense
- * with certain backends me reckons.
- */
- virtual BackendReturn<QCA::SecureArray> secret() const;
-
- /**
- * Set the secret stored inside this item.
- *
- * @param secret the secret to store
- */
- virtual BackendReturn<void> setSecret(const QCA::SecureArray &secret);
-
- /**
- * The attributes of the item.
- *
- * @return the item's attributes
- */
- virtual BackendReturn<QMap<QString, QString> > attributes() const;
-
- /**
- * Set the attributes of this item.
- *
- * @param attributes attributes to assign to this item
- */
- virtual BackendReturn<void> setAttributes(const QMap<QString, QString> \
&attributes);
-
- /**
- * The time this item was created.
- */
- virtual QDateTime created() const;
-
- /**
- * The time this item was last modified.
- */
- virtual QDateTime modified() const;
-
- /**
- * Check whether this item is locked.
- *
- * @return true if the item is locked, false else
- */
- virtual bool isLocked() const;
-
- /**
- * Create a job for unlocking this item.
- */
- virtual UnlockItemJob *createUnlockJob(const ItemUnlockInfo& unlockInfo);
-
- /**
- * Create a job for locking this item.
- */
- virtual LockItemJob *createLockJob();
-
- /**
- * Create a job for deleting this item.
- */
- virtual DeleteItemJob *createDeleteJob(const ItemDeleteInfo& deleteJobInfo);
-
- /**
- * Create a job for changing this item's authentication.
- */
- virtual ChangeAuthenticationItemJob *createChangeAuthenticationJob();
-
- /**
- * Check whether this item matches the attributes given.
- *
- * @param attributes attributes to match against
- * @return true if this item matches the attributes, false
- * if the item doesn't match the attributes.
- */
- bool matches(const QMap<QString, QString> &attributes);
+ /**
+ * Constructor.
+ *
+ * @param id unique identifier of the new item
+ * @param collection collection that created this item
+ */
+ KSecretItem(const QString &id, KSecretCollection *parent);
+
+ /**
+ * Destructor.
+ */
+ ~KSecretItem();
+
+ /**
+ * The unique identifer for this item.
+ */
+ virtual QString id() const;
+
+ /**
+ * The human-readable label for this item.
+ * @todo error
+ */
+ virtual BackendReturn<QString> label() const;
+
+ /**
+ * Set the human-readable label for this item.
+ *
+ * @param label the new label for this item
+ * @todo error
+ */
+ virtual BackendReturn<void> setLabel(const QString &label);
+
+ /**
+ * Get the secret stored inside this item.
+ *
+ * @return the secret
+ * @todo this will most likely become non-const as that might make sense
+ * with certain backends me reckons.
+ */
+ virtual BackendReturn<QCA::SecureArray> secret() const;
+
+ /**
+ * Set the secret stored inside this item.
+ *
+ * @param secret the secret to store
+ */
+ virtual BackendReturn<void> setSecret(const QCA::SecureArray &secret);
+
+ /**
+ * The attributes of the item.
+ *
+ * @return the item's attributes
+ */
+ virtual BackendReturn<QMap<QString, QString> > attributes() const;
+
+ /**
+ * Set the attributes of this item.
+ *
+ * @param attributes attributes to assign to this item
+ */
+ virtual BackendReturn<void> setAttributes(const QMap<QString, QString> \
&attributes); +
+ /**
+ * The time this item was created.
+ */
+ virtual QDateTime created() const;
+
+ /**
+ * The time this item was last modified.
+ */
+ virtual QDateTime modified() const;
+
+ /**
+ * Check whether this item is locked.
+ *
+ * @return true if the item is locked, false else
+ */
+ virtual bool isLocked() const;
+
+ /**
+ * Create a job for unlocking this item.
+ */
+ virtual UnlockItemJob *createUnlockJob(const ItemUnlockInfo& unlockInfo);
+
+ /**
+ * Create a job for locking this item.
+ */
+ virtual LockItemJob *createLockJob();
+
+ /**
+ * Create a job for deleting this item.
+ */
+ virtual DeleteItemJob *createDeleteJob(const ItemDeleteInfo& deleteJobInfo);
+
+ /**
+ * Create a job for changing this item's authentication.
+ */
+ virtual ChangeAuthenticationItemJob *createChangeAuthenticationJob();
+
+ /**
+ * Check whether this item matches the attributes given.
+ *
+ * @param attributes attributes to match against
+ * @return true if this item matches the attributes, false
+ * if the item doesn't match the attributes.
+ */
+ bool matches(const QMap<QString, QString> &attributes);
protected:
- /**
- * Fill this item using the values contained in the unlocked file.
- *
- * @param file the file to read the values from
- * @return true on success, false on error
- */
- bool deserializeUnlocked(KSecretFile &file);
-
- /**
- * Serialize this item's unlocked contents to the file given.
- *
- * @param file the file to write the values to
- * @return true on success, false on error
- */
- bool serializeUnlocked(KSecretFile &file);
-
- /**
- * Create a list of hashes out of this item's attributes.
- *
- * @param hash the hash function to use
- * @return a list of hashes for each of the item's attributes
- * @remarks called by KSecretCollection on-demand
- */
- QSet<QByteArray> createAttributeHashes(QCA::Hash *hash) const;
-
- /**
- * Create a list of hashes out of some attributes.
- *
- * @param attributes the attributes to create the hashes for
- * @param hash the hash function to use
- * @returns a list of hashes for each of the attributes
- */
- static QSet<QByteArray> createHashes(const QMap<QString, QString> &attributes,
- QCA::Hash *hash);
-
- /**
- * Delete the item.
- *
- * @remarks this is called by KSecretDeleteItemJob
- */
- BackendReturn<bool> deleteItem();
+ /**
+ * Fill this item using the values contained in the unlocked file.
+ *
+ * @param file the file to read the values from
+ * @return true on success, false on error
+ */
+ bool deserializeUnlocked(KSecretFile &file);
+
+ /**
+ * Serialize this item's unlocked contents to the file given.
+ *
+ * @param file the file to write the values to
+ * @return true on success, false on error
+ */
+ bool serializeUnlocked(KSecretFile &file);
+
+ /**
+ * Create a list of hashes out of this item's attributes.
+ *
+ * @param hash the hash function to use
+ * @return a list of hashes for each of the item's attributes
+ * @remarks called by KSecretCollection on-demand
+ */
+ QSet<QByteArray> createAttributeHashes(QCA::Hash *hash) const;
+
+ /**
+ * Create a list of hashes out of some attributes.
+ *
+ * @param attributes the attributes to create the hashes for
+ * @param hash the hash function to use
+ * @returns a list of hashes for each of the attributes
+ */
+ static QSet<QByteArray> createHashes(const QMap<QString, QString> &attributes,
+ QCA::Hash *hash);
+
+ /**
+ * Delete the item.
+ *
+ * @remarks this is called by KSecretDeleteItemJob
+ */
+ BackendReturn<bool> deleteItem();
Q_SIGNALS:
- /**
- * Emitted when the item has been "used" ie. one of its values has been
- * read or written.
- *
- * @param item the item that was used
- * @remarks this is used internally to implement the "close-if-unused" timer
- */
- void itemUsed(BackendItem *item);
-
- /**
- * This signal is emitted when an item's attributes change so the
- * collection can rebuild the attribute lookup hashes related to this
- * item.
- *
- * @param item Item whose attributes changed
- */
- void attributesChanged(KSecretItem *item);
-
+ /**
+ * Emitted when the item has been "used" ie. one of its values has been
+ * read or written.
+ *
+ * @param item the item that was used
+ * @remarks this is used internally to implement the "close-if-unused" timer
+ */
+ void itemUsed(BackendItem *item);
+
+ /**
+ * This signal is emitted when an item's attributes change so the
+ * collection can rebuild the attribute lookup hashes related to this
+ * item.
+ *
+ * @param item Item whose attributes changed
+ */
+ void attributesChanged(KSecretItem *item);
+
private:
- friend class KSecretCollection;
- friend class KSecretDeleteItemJob;
-
- /**
- * Mark this item as modified and emit the \sa itemChanged signal.
- */
- void markAsModified();
-
- /**
- * Mark this item as used and emit the \sa itemUsed signal.
- */
- void markAsUsed() const;
-
- KSecretCollection *m_collection;
-
- QString m_id;
- QString m_label;
- QDateTime m_created;
- QDateTime m_modified;
- QMap<QString, QString> m_attributes;
-
- QCA::SecureArray m_secret;
+ friend class KSecretCollection;
+ friend class KSecretDeleteItemJob;
+
+ /**
+ * Mark this item as modified and emit the \sa itemChanged signal.
+ */
+ void markAsModified();
+
+ /**
+ * Mark this item as used and emit the \sa itemUsed signal.
+ */
+ void markAsUsed() const;
+
+ KSecretCollection *m_collection;
+
+ QString m_id;
+ QString m_label;
+ QDateTime m_created;
+ QDateTime m_modified;
+ QMap<QString, QString> m_attributes;
+
+ QCA::SecureArray m_secret;
};
#endif
diff --git a/backend/ksecret/ksecretjobs.cpp b/backend/ksecret/ksecretjobs.cpp
index 44894e0..e041780 100644
--- a/backend/ksecret/ksecretjobs.cpp
+++ b/backend/ksecret/ksecretjobs.cpp
@@ -31,400 +31,399 @@
#include <QtCore/QDebug>
KSecretCreateCollectionJob::KSecretCreateCollectionJob(const CollectionCreateInfo \
&createCollectionInfo,
- KSecretCollectionManager \
*manager)
- : CreateCollectionJob(createCollectionInfo, manager), m_manager(manager)
+ KSecretCollectionManager *manager)
+ : CreateCollectionJob(createCollectionInfo, manager), m_manager(manager)
{
}
bool KSecretCreateCollectionJob::isImmediate() const
{
- // TODO: depending on available authentiation methods this may return
- // true.
- return false;
+ // TODO: depending on available authentiation methods this may return
+ // true.
+ return false;
}
void KSecretCreateCollectionJob::exec()
{
- Q_ASSERT(false);
+ Q_ASSERT(false);
}
void KSecretCreateCollectionJob::start()
{
- // start a job for getting a new password for the collection from the user.
- AbstractUiManager *uiManager = BackendMaster::instance()->uiManager();
- AbstractNewPasswordJob *subJob = uiManager->createNewPasswordJob(label());
- connect(subJob, SIGNAL(result(QueuedJob*)),
- SLOT(newPasswordJobResult(QueuedJob*)));
- subJob->enqueue();
-
- // then create a job asking user preferences for handling application permission
- AbstractAskAclPrefsJob *aclSubjob = uiManager->createAskAclPrefsJob( \
createCollectionInfo() );
- connect( aclSubjob, SIGNAL(result(QueuedJob*)),
- SLOT(askAclPrefsJobResult(QueuedJob*)));
- aclSubjob->enqueue();
+ // start a job for getting a new password for the collection from the user.
+ AbstractUiManager *uiManager = BackendMaster::instance()->uiManager();
+ AbstractNewPasswordJob *subJob = uiManager->createNewPasswordJob(label());
+ connect(subJob, SIGNAL(result(QueuedJob*)),
+ SLOT(newPasswordJobResult(QueuedJob*)));
+ subJob->enqueue();
+
+ // then create a job asking user preferences for handling application permission
+ AbstractAskAclPrefsJob *aclSubjob = \
uiManager->createAskAclPrefsJob(createCollectionInfo()); + connect(aclSubjob, \
SIGNAL(result(QueuedJob*)), + SLOT(askAclPrefsJobResult(QueuedJob*)));
+ aclSubjob->enqueue();
}
void KSecretCreateCollectionJob::newPasswordJobResult(QueuedJob *job)
{
- AbstractNewPasswordJob *npj = qobject_cast<AbstractNewPasswordJob*>(job);
- Q_ASSERT(npj);
-
- if (npj->cancelled()) {
- setCollection(0);
- setError(ErrorOther, i18n("Creating the collection was cancelled by the \
user."));
- emitResult();
- return;
- }
-
- // TODO: collection needs authentication methods, filenames, ...
- QString errorMessage;
- KSecretCollection *coll = KSecretCollection::create(createId(), npj->password(),
- manager(), errorMessage);
- if (!coll) {
- setCollection(0);
- setError(ErrorOther, errorMessage);
- emitResult();
- return;
- }
- coll->setLabel(label());
-
- // NOTE: coll has to be added to m_collections before serializing it for the
- // first time, so when slotDirectoryChanged is called, the collection
- // is already known.
- m_manager->addCollection(coll);
-
- if (locked()) {
- // TODO: lock
- }
-
- setCollection(coll);
- emitResult();
+ AbstractNewPasswordJob *npj = qobject_cast<AbstractNewPasswordJob*>(job);
+ Q_ASSERT(npj);
+
+ if(npj->cancelled()) {
+ setCollection(0);
+ setError(ErrorOther, i18n("Creating the collection was cancelled by the \
user.")); + emitResult();
+ return;
+ }
+
+ // TODO: collection needs authentication methods, filenames, ...
+ QString errorMessage;
+ KSecretCollection *coll = KSecretCollection::create(createId(), npj->password(),
+ manager(), errorMessage);
+ if(!coll) {
+ setCollection(0);
+ setError(ErrorOther, errorMessage);
+ emitResult();
+ return;
+ }
+ coll->setLabel(label());
+
+ // NOTE: coll has to be added to m_collections before serializing it for the
+ // first time, so when slotDirectoryChanged is called, the collection
+ // is already known.
+ m_manager->addCollection(coll);
+
+ if(locked()) {
+ // TODO: lock
+ }
+
+ setCollection(coll);
+ emitResult();
}
void KSecretCreateCollectionJob::askAclPrefsJobResult(QueuedJob* job)
{
- AbstractAskAclPrefsJob *aclJob = qobject_cast< AbstractAskAclPrefsJob* >(job);
- Q_ASSERT( aclJob );
-
- // TODO: implement this
+ AbstractAskAclPrefsJob *aclJob = qobject_cast< AbstractAskAclPrefsJob* >(job);
+ Q_ASSERT(aclJob);
+
+ // TODO: implement this
}
KSecretUnlockCollectionJob::KSecretUnlockCollectionJob(const CollectionUnlockInfo \
&unlockInfo,
- KSecretCollection *coll)
- : UnlockCollectionJob(unlockInfo, coll), m_collection(coll), m_firstTry(true)
+ KSecretCollection *coll)
+ : UnlockCollectionJob(unlockInfo, coll), m_collection(coll), m_firstTry(true)
{
}
bool KSecretUnlockCollectionJob::isImmediate() const
{
- // unlocked collections don't need a job to open
- if (!m_collection->isLocked()) {
- return true;
- } else {
- return false;
- }
+ // unlocked collections don't need a job to open
+ if(!m_collection->isLocked()) {
+ return true;
+ } else {
+ return false;
+ }
}
void KSecretUnlockCollectionJob::exec()
{
- Q_ASSERT(!collection()->isLocked());
- setResult(true);
- emitResult();
+ Q_ASSERT(!collection()->isLocked());
+ setResult(true);
+ emitResult();
}
void KSecretUnlockCollectionJob::start()
{
- if (!collection()->isLocked()) {
- setResult(true);
- emitResult();
- return;
- }
-
- AbstractUiManager *uiManager = BackendMaster::instance()->uiManager();
-
- AbstractAskAclPrefsJob* askAclPrefsJob = 0;
- // default is always to ask the user
- BackendCollection::ApplicationPermission perm = BackendCollection::PermissionAsk;
- if (unlockInfo().m_peer.isValid()) {
- perm = collection()->applicationPermission(unlockInfo().m_peer.exePath());
- }
- switch ( perm ) {
- case BackendCollection::PermissionDeny:
- setResult(false);
- emitResult();
- break;
- case BackendCollection::PermissionAsk:
- askAclPrefsJob = uiManager->createAskAclPrefsJob( unlockInfo() );
- connect( askAclPrefsJob, SIGNAL(result(QueuedJob*)), \
SLOT(askAclPrefsJobResult(QueuedJob*)));
- askAclPrefsJob->enqueue();
- break;
- case BackendCollection::PermissionAllow:
- // nothing to do, go further
- break;
- }
-
- if ( 0 == askAclPrefsJob ) {
- createAskPasswordJob();
- }
+ if(!collection()->isLocked()) {
+ setResult(true);
+ emitResult();
+ return;
+ }
+
+ AbstractUiManager *uiManager = BackendMaster::instance()->uiManager();
+
+ AbstractAskAclPrefsJob* askAclPrefsJob = 0;
+ // default is always to ask the user
+ BackendCollection::ApplicationPermission perm = \
BackendCollection::PermissionAsk; + if(unlockInfo().m_peer.isValid()) {
+ perm = collection()->applicationPermission(unlockInfo().m_peer.exePath());
+ }
+ switch(perm) {
+ case BackendCollection::PermissionDeny:
+ setResult(false);
+ emitResult();
+ break;
+ case BackendCollection::PermissionAsk:
+ askAclPrefsJob = uiManager->createAskAclPrefsJob(unlockInfo());
+ connect(askAclPrefsJob, SIGNAL(result(QueuedJob*)), \
SLOT(askAclPrefsJobResult(QueuedJob*))); + askAclPrefsJob->enqueue();
+ break;
+ case BackendCollection::PermissionAllow:
+ // nothing to do, go further
+ break;
+ }
+
+ if(0 == askAclPrefsJob) {
+ createAskPasswordJob();
+ }
}
void KSecretUnlockCollectionJob::createAskPasswordJob()
{
- AbstractUiManager *uiManager = BackendMaster::instance()->uiManager();
- // start a job for getting a new password for the collection from the user.
- AbstractAskPasswordJob *subJob = \
uiManager->createAskPasswordJob(m_collection->label().value(),
- !m_firstTry);
- connect(subJob, SIGNAL(result(QueuedJob*)), \
SLOT(askPasswordJobResult(QueuedJob*)));
-
- // if this is not the first try, enqueue in front so the dialog gets shown again
- // right away.
- subJob->enqueue(m_firstTry);
- m_firstTry = false;
+ AbstractUiManager *uiManager = BackendMaster::instance()->uiManager();
+ // start a job for getting a new password for the collection from the user.
+ AbstractAskPasswordJob *subJob = \
uiManager->createAskPasswordJob(m_collection->label().value(), + \
!m_firstTry); + connect(subJob, SIGNAL(result(QueuedJob*)), \
SLOT(askPasswordJobResult(QueuedJob*))); +
+ // if this is not the first try, enqueue in front so the dialog gets shown again
+ // right away.
+ subJob->enqueue(m_firstTry);
+ m_firstTry = false;
}
void KSecretUnlockCollectionJob::askAclPrefsJobResult(QueuedJob *job)
{
- AbstractAskAclPrefsJob *apj = qobject_cast<AbstractAskAclPrefsJob*>(job);
- Q_ASSERT(apj);
- if ( apj->denied()) {
- setResult( false );
- setError( ErrorOther, i18n("Unkocking the collection was denied."));
- emitResult();
- }
- else {
- // now that the access to this collection is allowed, go further and ask the \
password
- createAskPasswordJob();
- }
+ AbstractAskAclPrefsJob *apj = qobject_cast<AbstractAskAclPrefsJob*>(job);
+ Q_ASSERT(apj);
+ if(apj->denied()) {
+ setResult(false);
+ setError(ErrorOther, i18n("Unkocking the collection was denied."));
+ emitResult();
+ } else {
+ // now that the access to this collection is allowed, go further and ask the \
password + createAskPasswordJob();
+ }
}
void KSecretUnlockCollectionJob::askPasswordJobResult(QueuedJob *job)
{
- AbstractAskPasswordJob *apj = qobject_cast<AbstractAskPasswordJob*>(job);
- Q_ASSERT(apj);
-
- if (apj->cancelled()) {
- setResult(false);
- setError(ErrorOther, i18n("Unlocking the collection was cancelled by the \
user."));
- emitResult();
- return;
- }
-
- BackendReturn<bool> rc = m_collection->tryUnlockPassword(apj->password());
- if (rc.isError()) {
- setResult(false);
- setError(rc.error(), rc.errorMessage());
- emitResult();
- } else if (!rc.value()) {
- // try againg the password
- createAskPasswordJob();
- } else {
- setResult(true);
- emitResult();
- }
+ AbstractAskPasswordJob *apj = qobject_cast<AbstractAskPasswordJob*>(job);
+ Q_ASSERT(apj);
+
+ if(apj->cancelled()) {
+ setResult(false);
+ setError(ErrorOther, i18n("Unlocking the collection was cancelled by the \
user.")); + emitResult();
+ return;
+ }
+
+ BackendReturn<bool> rc = m_collection->tryUnlockPassword(apj->password());
+ if(rc.isError()) {
+ setResult(false);
+ setError(rc.error(), rc.errorMessage());
+ emitResult();
+ } else if(!rc.value()) {
+ // try againg the password
+ createAskPasswordJob();
+ } else {
+ setResult(true);
+ emitResult();
+ }
}
KSecretLockCollectionJob::KSecretLockCollectionJob(KSecretCollection *coll)
- : LockCollectionJob(coll), m_collection(coll)
+ : LockCollectionJob(coll), m_collection(coll)
{
}
void KSecretLockCollectionJob::exec()
{
- // nothing to do if already locked
- if (collection()->isLocked()) {
- setResult(true);
- emitResult();
- return;
- }
-
- BackendReturn<bool> rc = m_collection->lock();
- if (rc.isError()) {
- setError(rc.error(), rc.errorMessage());
- setResult(false);
- } else {
- setResult(true);
- }
- emitResult();
+ // nothing to do if already locked
+ if(collection()->isLocked()) {
+ setResult(true);
+ emitResult();
+ return;
+ }
+
+ BackendReturn<bool> rc = m_collection->lock();
+ if(rc.isError()) {
+ setError(rc.error(), rc.errorMessage());
+ setResult(false);
+ } else {
+ setResult(true);
+ }
+ emitResult();
}
KSecretDeleteCollectionJob::KSecretDeleteCollectionJob(const CollectionDeleteInfo& \
deleteInfo)
- : DeleteCollectionJob(deleteInfo)
+ : DeleteCollectionJob(deleteInfo)
{
- Q_ASSERT(deleteInfo.m_collection != 0);
- m_collection = qobject_cast< KSecretCollection* >(deleteInfo.m_collection);
+ Q_ASSERT(deleteInfo.m_collection != 0);
+ m_collection = qobject_cast< KSecretCollection* >(deleteInfo.m_collection);
}
void KSecretDeleteCollectionJob::exec()
{
- BackendReturn<bool> rc = m_collection->deleteCollection();
- if (rc.isError()) {
- setError(rc.error(), rc.errorMessage());
- setResult(false);
- } else {
- setResult(true);
- }
- emitResult();
+ BackendReturn<bool> rc = m_collection->deleteCollection();
+ if(rc.isError()) {
+ setError(rc.error(), rc.errorMessage());
+ setResult(false);
+ } else {
+ setResult(true);
+ }
+ emitResult();
}
KSecretCreateItemJob::KSecretCreateItemJob(const ItemCreateInfo& createInfo,
- KSecretCollection* collection)
- : CreateItemJob(createInfo, collection),
- m_collection(collection)
+ KSecretCollection* collection)
+ : CreateItemJob(createInfo, collection),
+ m_collection(collection)
{
}
void KSecretCreateItemJob::exec()
{
- BackendReturn<BackendItem*> rc = m_collection->createItem(label(), attributes(),
- secret(), locked(), \
replace());
- if (rc.isError()) {
- setError(rc.error(), rc.errorMessage());
- setItem(0);
- } else {
- setItem(rc.value());
- }
- emitResult();
+ BackendReturn<BackendItem*> rc = m_collection->createItem(label(), attributes(),
+ secret(), locked(), replace());
+ if(rc.isError()) {
+ setError(rc.error(), rc.errorMessage());
+ setItem(0);
+ } else {
+ setItem(rc.value());
+ }
+ emitResult();
}
KSecretChangeAuthenticationCollectionJob::KSecretChangeAuthenticationCollectionJob(BackendCollection \
*coll)
- : ChangeAuthenticationCollectionJob(coll)
+ : ChangeAuthenticationCollectionJob(coll)
{
}
void KSecretChangeAuthenticationCollectionJob::exec()
{
- setError(ErrorOther, "Not implemented.");
- setResult(false);
- emitResult();
+ setError(ErrorOther, "Not implemented.");
+ setResult(false);
+ emitResult();
}
-KSecretUnlockItemJob::KSecretUnlockItemJob(const ItemUnlockInfo& unlockInfo,
- KSecretCollection *collection)
- : UnlockItemJob(unlockInfo)
+KSecretUnlockItemJob::KSecretUnlockItemJob(const ItemUnlockInfo& unlockInfo,
+ KSecretCollection *collection)
+ : UnlockItemJob(unlockInfo)
{
- Q_ASSERT( collection != NULL );
- // delegate to an unlock job on the collection
- CollectionUnlockInfo collUnlockInfo( unlockInfo.m_peer );
- m_subJob = collection->createUnlockJob( collUnlockInfo );
+ Q_ASSERT(collection != NULL);
+ // delegate to an unlock job on the collection
+ CollectionUnlockInfo collUnlockInfo(unlockInfo.m_peer);
+ m_subJob = collection->createUnlockJob(collUnlockInfo);
}
-
+
KSecretUnlockItemJob::~KSecretUnlockItemJob()
{
- // delete the subjob if it wasn't executed.
- if (!m_subJob.isNull()) {
- m_subJob->deleteLater();
- }
+ // delete the subjob if it wasn't executed.
+ if(!m_subJob.isNull()) {
+ m_subJob->deleteLater();
+ }
}
bool KSecretUnlockItemJob::isImmediate() const
{
- Q_ASSERT(!m_subJob.isNull());
- return m_subJob->isImmediate();
+ Q_ASSERT(!m_subJob.isNull());
+ return m_subJob->isImmediate();
}
void KSecretUnlockItemJob::exec()
{
- Q_ASSERT(!m_subJob.isNull());
- m_subJob->exec();
- handleSubJobResult(m_subJob);
+ Q_ASSERT(!m_subJob.isNull());
+ m_subJob->exec();
+ handleSubJobResult(m_subJob);
}
void KSecretUnlockItemJob::start()
{
- connect(m_subJob, SIGNAL(result(QueuedJob*)),
- SLOT(handleSubJobResult(QueuedJob*)));
- m_subJob->enqueue();
+ connect(m_subJob, SIGNAL(result(QueuedJob*)),
+ SLOT(handleSubJobResult(QueuedJob*)));
+ m_subJob->enqueue();
}
void KSecretUnlockItemJob::handleSubJobResult(QueuedJob *job)
{
- Q_UNUSED(job);
- Q_ASSERT(!m_subJob.isNull());
- Q_ASSERT(m_subJob == job);
- Q_ASSERT(m_subJob->isFinished());
- setError(m_subJob->error(), m_subJob->errorMessage());
- setResult(m_subJob->result());
- emitResult();
+ Q_UNUSED(job);
+ Q_ASSERT(!m_subJob.isNull());
+ Q_ASSERT(m_subJob == job);
+ Q_ASSERT(m_subJob->isFinished());
+ setError(m_subJob->error(), m_subJob->errorMessage());
+ setResult(m_subJob->result());
+ emitResult();
}
KSecretLockItemJob::KSecretLockItemJob(KSecretItem *item,
KSecretCollection *collection)
- : LockItemJob(item)
+ : LockItemJob(item)
{
- // delegate to a lock job on the collection
- m_subJob = collection->createLockJob();
+ // delegate to a lock job on the collection
+ m_subJob = collection->createLockJob();
}
KSecretLockItemJob::~KSecretLockItemJob()
{
- // delete the subjob if it wasn't executed.
- if (!m_subJob.isNull()) {
- m_subJob->deleteLater();
- }
+ // delete the subjob if it wasn't executed.
+ if(!m_subJob.isNull()) {
+ m_subJob->deleteLater();
+ }
}
bool KSecretLockItemJob::isImmediate() const
{
- Q_ASSERT(!m_subJob.isNull());
- return m_subJob->isImmediate();
+ Q_ASSERT(!m_subJob.isNull());
+ return m_subJob->isImmediate();
}
void KSecretLockItemJob::exec()
{
- Q_ASSERT(!m_subJob.isNull());
- m_subJob->exec();
- handleSubJobResult(m_subJob);
+ Q_ASSERT(!m_subJob.isNull());
+ m_subJob->exec();
+ handleSubJobResult(m_subJob);
}
void KSecretLockItemJob::start()
{
- connect(m_subJob, SIGNAL(result(QueuedJob*)),
- SLOT(handleSubJobResult(QueuedJob*)));
- m_subJob->enqueue();
+ connect(m_subJob, SIGNAL(result(QueuedJob*)),
+ SLOT(handleSubJobResult(QueuedJob*)));
+ m_subJob->enqueue();
}
void KSecretLockItemJob::handleSubJobResult(QueuedJob *job)
{
- Q_UNUSED(job);
- Q_ASSERT(!m_subJob.isNull());
- Q_ASSERT(m_subJob == job);
- Q_ASSERT(m_subJob->isFinished());
- setError(m_subJob->error(), m_subJob->errorMessage());
- setResult(m_subJob->result());
- emitResult();
+ Q_UNUSED(job);
+ Q_ASSERT(!m_subJob.isNull());
+ Q_ASSERT(m_subJob == job);
+ Q_ASSERT(m_subJob->isFinished());
+ setError(m_subJob->error(), m_subJob->errorMessage());
+ setResult(m_subJob->result());
+ emitResult();
}
KSecretDeleteItemJob::KSecretDeleteItemJob(const ItemDeleteInfo &deleteInfo)
- : DeleteItemJob(deleteInfo)
+ : DeleteItemJob(deleteInfo)
{
- Q_ASSERT( deleteInfo.m_item != 0 );
- m_item = qobject_cast< KSecretItem* >(deleteInfo.m_item);
+ Q_ASSERT(deleteInfo.m_item != 0);
+ m_item = qobject_cast< KSecretItem* >(deleteInfo.m_item);
}
void KSecretDeleteItemJob::exec()
{
- // TODO: this could easily be delegated to the collection
- BackendReturn<bool> rc = m_item->deleteItem();
- if (rc.isError()) {
- setError(rc.error(), rc.errorMessage());
- setResult(false);
- } else {
- setResult(true);
- }
- emitResult();
+ // TODO: this could easily be delegated to the collection
+ BackendReturn<bool> rc = m_item->deleteItem();
+ if(rc.isError()) {
+ setError(rc.error(), rc.errorMessage());
+ setResult(false);
+ } else {
+ setResult(true);
+ }
+ emitResult();
}
KSecretChangeAuthenticationItemJob::KSecretChangeAuthenticationItemJob(BackendItem \
*item)
- : ChangeAuthenticationItemJob(item)
+ : ChangeAuthenticationItemJob(item)
{
}
void KSecretChangeAuthenticationItemJob::exec()
{
- setError(ErrorNotSupported);
- setResult(false);
- emitResult();
+ setError(ErrorNotSupported);
+ setResult(false);
+ emitResult();
}
diff --git a/backend/ksecret/ksecretjobs.h b/backend/ksecret/ksecretjobs.h
index e07e0a7..46ce096 100644
--- a/backend/ksecret/ksecretjobs.h
+++ b/backend/ksecret/ksecretjobs.h
@@ -35,23 +35,23 @@
*/
class KSecretCreateCollectionJob : public CreateCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- KSecretCreateCollectionJob(const CollectionCreateInfo &createCollectionInfo,
- KSecretCollectionManager *manager);
- virtual bool isImmediate() const;
- virtual void exec();
-
+ KSecretCreateCollectionJob(const CollectionCreateInfo &createCollectionInfo,
+ KSecretCollectionManager *manager);
+ virtual bool isImmediate() const;
+ virtual void exec();
+
protected:
- virtual void start();
+ virtual void start();
private Q_SLOTS:
- void newPasswordJobResult(QueuedJob *job);
- void askAclPrefsJobResult(QueuedJob *job);
-
+ void newPasswordJobResult(QueuedJob *job);
+ void askAclPrefsJobResult(QueuedJob *job);
+
private:
- KSecretCollectionManager *m_manager;
+ KSecretCollectionManager *m_manager;
};
/**
@@ -59,25 +59,25 @@ private:
*/
class KSecretUnlockCollectionJob : public UnlockCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- KSecretUnlockCollectionJob(const CollectionUnlockInfo &unlockInfo, \
KSecretCollection *coll);
- virtual bool isImmediate() const;
- virtual void exec();
-
+ KSecretUnlockCollectionJob(const CollectionUnlockInfo &unlockInfo, \
KSecretCollection *coll); + virtual bool isImmediate() const;
+ virtual void exec();
+
protected:
- virtual void start();
-
+ virtual void start();
+
private Q_SLOTS:
- void askPasswordJobResult(QueuedJob *job);
- void askAclPrefsJobResult(QueuedJob *job);
-
+ void askPasswordJobResult(QueuedJob *job);
+ void askAclPrefsJobResult(QueuedJob *job);
+
private:
- void createAskPasswordJob();
-
- KSecretCollection *m_collection;
- bool m_firstTry;
+ void createAskPasswordJob();
+
+ KSecretCollection *m_collection;
+ bool m_firstTry;
};
/**
@@ -85,14 +85,14 @@ private:
*/
class KSecretLockCollectionJob : public LockCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- KSecretLockCollectionJob(KSecretCollection *coll);
- virtual void exec();
-
+ KSecretLockCollectionJob(KSecretCollection *coll);
+ virtual void exec();
+
private:
- KSecretCollection *m_collection;
+ KSecretCollection *m_collection;
};
/**
@@ -100,14 +100,14 @@ private:
*/
class KSecretDeleteCollectionJob : public DeleteCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- KSecretDeleteCollectionJob(const CollectionDeleteInfo& deleteInfo);
- virtual void exec();
-
+ KSecretDeleteCollectionJob(const CollectionDeleteInfo& deleteInfo);
+ virtual void exec();
+
private:
- KSecretCollection *m_collection;
+ KSecretCollection *m_collection;
};
/**
@@ -115,15 +115,15 @@ private:
*/
class KSecretCreateItemJob : public CreateItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
KSecretCreateItemJob(const ItemCreateInfo& createInfo,
KSecretCollection* collection);
- virtual void exec();
-
+ virtual void exec();
+
private:
- KSecretCollection *m_collection;
+ KSecretCollection *m_collection;
};
/**
@@ -134,11 +134,11 @@ private:
*/
class KSecretChangeAuthenticationCollectionJob : public \
ChangeAuthenticationCollectionJob {
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- KSecretChangeAuthenticationCollectionJob(BackendCollection *coll);
- virtual void exec();
+ KSecretChangeAuthenticationCollectionJob(BackendCollection *coll);
+ virtual void exec();
};
/**
@@ -146,22 +146,22 @@ public:
*/
class KSecretUnlockItemJob : public UnlockItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- KSecretUnlockItemJob(const ItemUnlockInfo& unlockInfo, KSecretCollection \
*collection);
- virtual ~KSecretUnlockItemJob();
- virtual bool isImmediate() const;
- virtual void exec();
-
+ KSecretUnlockItemJob(const ItemUnlockInfo& unlockInfo, KSecretCollection \
*collection); + virtual ~KSecretUnlockItemJob();
+ virtual bool isImmediate() const;
+ virtual void exec();
+
protected:
- virtual void start();
-
+ virtual void start();
+
private Q_SLOTS:
- void handleSubJobResult(QueuedJob *job);
-
+ void handleSubJobResult(QueuedJob *job);
+
private:
- QPointer<UnlockCollectionJob> m_subJob;
+ QPointer<UnlockCollectionJob> m_subJob;
};
/**
@@ -169,22 +169,22 @@ private:
*/
class KSecretLockItemJob : public LockItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- KSecretLockItemJob(KSecretItem *item, KSecretCollection *collection);
- virtual ~KSecretLockItemJob();
- virtual bool isImmediate() const;
- virtual void exec();
-
+ KSecretLockItemJob(KSecretItem *item, KSecretCollection *collection);
+ virtual ~KSecretLockItemJob();
+ virtual bool isImmediate() const;
+ virtual void exec();
+
protected:
- virtual void start();
-
+ virtual void start();
+
private Q_SLOTS:
- void handleSubJobResult(QueuedJob *job);
-
+ void handleSubJobResult(QueuedJob *job);
+
private:
- QPointer<LockCollectionJob> m_subJob;
+ QPointer<LockCollectionJob> m_subJob;
};
/**
@@ -192,14 +192,14 @@ private:
*/
class KSecretDeleteItemJob : public DeleteItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- KSecretDeleteItemJob(const ItemDeleteInfo &deleteInfo);
- virtual void exec();
-
+ KSecretDeleteItemJob(const ItemDeleteInfo &deleteInfo);
+ virtual void exec();
+
private:
- KSecretItem *m_item;
+ KSecretItem *m_item;
};
/**
@@ -207,11 +207,11 @@ private:
*/
class KSecretChangeAuthenticationItemJob : public ChangeAuthenticationItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- KSecretChangeAuthenticationItemJob(BackendItem *item);
- virtual void exec();
+ KSecretChangeAuthenticationItemJob(BackendItem *item);
+ virtual void exec();
};
#endif
diff --git a/backend/securebuffer.cpp b/backend/securebuffer.cpp
index 5d419ea..22bb5cb 100644
--- a/backend/securebuffer.cpp
+++ b/backend/securebuffer.cpp
@@ -27,15 +27,15 @@
#include "securebuffer_p.h"
SecureBuffer::SecureBuffer(QObject *parent)
- : QIODevice(parent), d(new SecureBufferPrivate(this))
+ : QIODevice(parent), d(new SecureBufferPrivate(this))
{
- d->buf = &d->defaultBuf;
+ d->buf = &d->defaultBuf;
}
SecureBuffer::SecureBuffer(QCA::SecureArray *buf, QObject *parent)
- : QIODevice(parent), d(new SecureBufferPrivate(this))
+ : QIODevice(parent), d(new SecureBufferPrivate(this))
{
- d->buf = buf ? buf : &d->defaultBuf;
+ d->buf = buf ? buf : &d->defaultBuf;
}
SecureBuffer::~SecureBuffer()
@@ -44,177 +44,177 @@ SecureBuffer::~SecureBuffer()
QCA::SecureArray &SecureBuffer::buffer()
{
- return *d->buf;
+ return *d->buf;
}
void SecureBuffer::setBuffer(QCA::SecureArray *secureArray) const
{
- if (isOpen()) {
- qWarning("SecureBuffer::setBuffer: Buffer is open");
- return;
- }
- if (secureArray) {
- d->buf = secureArray;
- } else {
- d->buf = &d->defaultBuf;
- }
- d->defaultBuf.clear();
- d->ioIndex = 0;
+ if(isOpen()) {
+ qWarning("SecureBuffer::setBuffer: Buffer is open");
+ return;
+ }
+ if(secureArray) {
+ d->buf = secureArray;
+ } else {
+ d->buf = &d->defaultBuf;
+ }
+ d->defaultBuf.clear();
+ d->ioIndex = 0;
}
const QCA::SecureArray &SecureBuffer::data() const
{
- return *d->buf;
+ return *d->buf;
}
void SecureBuffer::setData(const QCA::SecureArray &data)
{
- if (isOpen()) {
- qWarning("SecureBuffer::setData: Buffer is open");
- return;
- }
- *d->buf = data;
- d->ioIndex = 0;
+ if(isOpen()) {
+ qWarning("SecureBuffer::setData: Buffer is open");
+ return;
+ }
+ *d->buf = data;
+ d->ioIndex = 0;
}
void SecureBuffer::setData(const QByteArray &data)
{
- if (isOpen()) {
- qWarning("SecureBuffer::setData: Buffer is open");
- return;
- }
- *d->buf = data;
- d->ioIndex = 0;
+ if(isOpen()) {
+ qWarning("SecureBuffer::setData: Buffer is open");
+ return;
+ }
+ *d->buf = data;
+ d->ioIndex = 0;
}
void SecureBuffer::setData(const char *data, int size)
{
- setData(QByteArray(data, size));
+ setData(QByteArray(data, size));
}
bool SecureBuffer::open(QIODevice::OpenMode mode)
{
- // always operate in Unbuffered mode for security reasons.
- mode |= QIODevice::Unbuffered;
-
- if ((mode & QIODevice::Append) == Append) {
- mode |= QIODevice::WriteOnly;
- }
- setOpenMode(mode);
- if (!(isReadable() || isWritable())) {
- qWarning("SecureBuffer::open: File access not specified");
- return false;
- }
-
- if ((mode & QIODevice::Truncate) == QIODevice::Truncate) {
- d->buf->clear();
- }
- if ((mode & QIODevice::Append) == QIODevice::Append) {
- seek(d->buf->size());
- } else {
- seek(0);
- }
-
- return true;
+ // always operate in Unbuffered mode for security reasons.
+ mode |= QIODevice::Unbuffered;
+
+ if((mode & QIODevice::Append) == Append) {
+ mode |= QIODevice::WriteOnly;
+ }
+ setOpenMode(mode);
+ if(!(isReadable() || isWritable())) {
+ qWarning("SecureBuffer::open: File access not specified");
+ return false;
+ }
+
+ if((mode & QIODevice::Truncate) == QIODevice::Truncate) {
+ d->buf->clear();
+ }
+ if((mode & QIODevice::Append) == QIODevice::Append) {
+ seek(d->buf->size());
+ } else {
+ seek(0);
+ }
+
+ return true;
}
void SecureBuffer::close()
{
- QIODevice::close();
+ QIODevice::close();
}
qint64 SecureBuffer::size() const
{
- return qint64(d->buf->size());
+ return qint64(d->buf->size());
}
qint64 SecureBuffer::pos() const
{
- return QIODevice::pos();
+ return QIODevice::pos();
}
bool SecureBuffer::seek(qint64 pos)
{
- if (pos > d->buf->size() && isWritable()) {
- if (seek(d->buf->size())) {
- const qint64 gapSize = pos - d->buf->size();
- if (write(QByteArray(gapSize, 0)) != gapSize) {
- qWarning("SecureBuffer::seek: Unable to fill gap");
+ if(pos > d->buf->size() && isWritable()) {
+ if(seek(d->buf->size())) {
+ const qint64 gapSize = pos - d->buf->size();
+ if(write(QByteArray(gapSize, 0)) != gapSize) {
+ qWarning("SecureBuffer::seek: Unable to fill gap");
+ return false;
+ }
+ } else {
return false;
- }
- } else {
- return false;
- }
- } else if (pos > d->buf->size() || pos < 0) {
- qWarning("SecureBuffer::seek: Invalid pos: %d", int(pos));
- return false;
- }
- d->ioIndex = int(pos);
- return QIODevice::seek(pos);
+ }
+ } else if(pos > d->buf->size() || pos < 0) {
+ qWarning("SecureBuffer::seek: Invalid pos: %d", int(pos));
+ return false;
+ }
+ d->ioIndex = int(pos);
+ return QIODevice::seek(pos);
}
bool SecureBuffer::atEnd() const
{
- return QIODevice::atEnd();
+ return QIODevice::atEnd();
}
bool SecureBuffer::canReadLine() const
{
- if (!isOpen()) {
- return false;
- }
+ if(!isOpen()) {
+ return false;
+ }
- return ::memchr(d->buf->constData() + int(pos()), '\n', int(size())) != 0 || \
QIODevice::canReadLine(); + return ::memchr(d->buf->constData() + int(pos()), \
'\n', int(size())) != 0 || QIODevice::canReadLine(); }
void SecureBuffer::connectNotify(const char *signal)
{
- if (strcmp(signal + 1, "readyRead()") == 0 ||
- strcmp(signal + 1, "bytesWritten(qint64)") == 0) {
- d->signalConnectionCount++;
- }
+ if(strcmp(signal + 1, "readyRead()") == 0 ||
+ strcmp(signal + 1, "bytesWritten(qint64)") == 0) {
+ d->signalConnectionCount++;
+ }
}
void SecureBuffer::disconnectNotify(const char *signal)
{
- if (!signal || strcmp(signal + 1, "readyRead()") == 0 ||
- strcmp(signal + 1, "bytesWritten(qint64)") == 0) {
- d->signalConnectionCount--;
- }
+ if(!signal || strcmp(signal + 1, "readyRead()") == 0 ||
+ strcmp(signal + 1, "bytesWritten(qint64)") == 0) {
+ d->signalConnectionCount--;
+ }
}
qint64 SecureBuffer::readData(char *data, qint64 maxlen)
{
- if ((maxlen = qMin(maxlen, qint64(d->buf->size()) - d->ioIndex)) <= 0) {
- return qint64(0);
- }
- memcpy(data, d->buf->constData() + d->ioIndex, maxlen);
- d->ioIndex += int(maxlen);
- return maxlen;
+ if((maxlen = qMin(maxlen, qint64(d->buf->size()) - d->ioIndex)) <= 0) {
+ return qint64(0);
+ }
+ memcpy(data, d->buf->constData() + d->ioIndex, maxlen);
+ d->ioIndex += int(maxlen);
+ return maxlen;
}
qint64 SecureBuffer::writeData(const char *data, qint64 len)
{
- int extraBytes = d->ioIndex + len - d->buf->size();
- if (extraBytes > 0) { // exceeds current buffer size
- int newSize = d->buf->size() + extraBytes;
- d->buf->resize(newSize);
- if (d->buf->size() != newSize) { // error resizing
- qWarning("SecureBuffer::writeData: Memory allocation error");
- return -1;
- }
- }
-
- memcpy(d->buf->data() + d->ioIndex, (uchar *)data, int(len));
- d->ioIndex += int(len);
-
- d->writtenSinceLastEmit += len;
- if (d->signalConnectionCount && !d->signalsEmitted && !signalsBlocked()) {
- d->signalsEmitted = true;
- QMetaObject::invokeMethod(d, "_q_emitSignals", Qt::QueuedConnection);
- }
-
- return len;
+ int extraBytes = d->ioIndex + len - d->buf->size();
+ if(extraBytes > 0) { // exceeds current buffer size
+ int newSize = d->buf->size() + extraBytes;
+ d->buf->resize(newSize);
+ if(d->buf->size() != newSize) { // error resizing
+ qWarning("SecureBuffer::writeData: Memory allocation error");
+ return -1;
+ }
+ }
+
+ memcpy(d->buf->data() + d->ioIndex, (uchar *)data, int(len));
+ d->ioIndex += int(len);
+
+ d->writtenSinceLastEmit += len;
+ if(d->signalConnectionCount && !d->signalsEmitted && !signalsBlocked()) {
+ d->signalsEmitted = true;
+ QMetaObject::invokeMethod(d, "_q_emitSignals", Qt::QueuedConnection);
+ }
+
+ return len;
}
#include "securebuffer.moc"
diff --git a/backend/securebuffer.h b/backend/securebuffer.h
index a1acd6a..fad3479 100644
--- a/backend/securebuffer.h
+++ b/backend/securebuffer.h
@@ -37,174 +37,174 @@ class SecureBufferPrivate;
*/
class SecureBuffer : public QIODevice
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- Construct a new secure buffer with the given \a parent
- allocating a new SecureArray as its internal storage.
+ /**
+ Construct a new secure buffer with the given \a parent
+ allocating a new SecureArray as its internal storage.
- \param parent the parent object of this SecureBuffer
- */
- explicit SecureBuffer(QObject *parent = 0);
-
- /**
- Construct a new secure buffer using \a buf as its internal
- storage.
-
- \param buf SecureArray to use as internal storage
\param parent the parent object of this SecureBuffer
*/
- SecureBuffer(QCA::SecureArray *buf, QObject *parent = 0);
-
- /**
- Destroys the secure buffer.
- */
- ~SecureBuffer();
+ explicit SecureBuffer(QObject *parent = 0);
- /**
- Returns a reference to the SecureBuffer's internal buffer.
+ /**
+ Construct a new secure buffer using \a buf as its internal
+ storage.
- \return a reference to the internal buffer
- \sa setBuffer(), data()
- */
- QCA::SecureArray &buffer();
+ \param buf SecureArray to use as internal storage
+ \param parent the parent object of this SecureBuffer
+ */
+ SecureBuffer(QCA::SecureArray *buf, QObject *parent = 0);
- /**
- Make the SecureBuffer use the SecureArray pointed to by \a
- secureArray as its internal storage. The SecureBuffer does
- not take ownership of the SecureArray. The caller is responsible
- that the SecureArray remains valid as long as the SecureBuffer
- is not destroyed.
+ /**
+ Destroys the secure buffer.
+ */
+ ~SecureBuffer();
- Does nothing if isOpen() is true.
+ /**
+ Returns a reference to the SecureBuffer's internal buffer.
- If you write something into the buffer, \a secureArray will
- be modified (size as well as contents).
+ \return a reference to the internal buffer
+ \sa setBuffer(), data()
+ */
+ QCA::SecureArray &buffer();
- \param secureArray the SecureArray to use as this buffer's
- internal storage
- */
- void setBuffer(QCA::SecureArray *secureArray) const;
+ /**
+ Make the SecureBuffer use the SecureArray pointed to by \a
+ secureArray as its internal storage. The SecureBuffer does
+ not take ownership of the SecureArray. The caller is responsible
+ that the SecureArray remains valid as long as the SecureBuffer
+ is not destroyed.
- /**
- Returns the data contained in the buffer.
+ Does nothing if isOpen() is true.
- \return the data contained the buffer
- \sa buffer(), setBuffer(), setData()
- */
- const QCA::SecureArray &data() const;
+ If you write something into the buffer, \a secureArray will
+ be modified (size as well as contents).
- /**
- Copy the contents of \a data to the internal buffer replacing all
- previous contents. This does nothing if isOpen() is true.
+ \param secureArray the SecureArray to use as this buffer's
+ internal storage
+ */
+ void setBuffer(QCA::SecureArray *secureArray) const;
- \param data data to copy to the internal buffer
- */
- void setData(const QCA::SecureArray &data);
+ /**
+ Returns the data contained in the buffer.
- /**
- Copy the contents of \a data to the internal buffer replacing all
- previous contents. This does nothing if isOpen() is true.
+ \return the data contained the buffer
+ \sa buffer(), setBuffer(), setData()
+ */
+ const QCA::SecureArray &data() const;
- \param data data to copy to the internal buffer
- */
- void setData(const QByteArray &data);
+ /**
+ Copy the contents of \a data to the internal buffer replacing all
+ previous contents. This does nothing if isOpen() is true.
- /**
- Copy the first \a size bytes of the contents of \a data to the
- internal buffer replacing all previous contents. This does nothing if
- isOpen() is true.
+ \param data data to copy to the internal buffer
+ */
+ void setData(const QCA::SecureArray &data);
- \param data array to copy the data from
- \param size number of bytes to copy from the array
- */
- void setData(const char *data, int size);
+ /**
+ Copy the contents of \a data to the internal buffer replacing all
+ previous contents. This does nothing if isOpen() is true.
- /**
- Open the SecureBuffer and set its \a OpenMode to mode.
+ \param data data to copy to the internal buffer
+ */
+ void setData(const QByteArray &data);
- \param openMode the mode to open the SecureBuffer with
- \return true if opening succeeded, false else
- */
- bool open(QIODevice::OpenMode mode);
+ /**
+ Copy the first \a size bytes of the contents of \a data to the
+ internal buffer replacing all previous contents. This does nothing if
+ isOpen() is true.
- /**
- Closes the SecureBuffer.
- */
- void close();
+ \param data array to copy the data from
+ \param size number of bytes to copy from the array
+ */
+ void setData(const char *data, int size);
- /**
- Returns the size of the underlying SecureArray.
+ /**
+ Open the SecureBuffer and set its \a OpenMode to mode.
- \return the size of the internal buffer
- */
- qint64 size() const;
+ \param openMode the mode to open the SecureBuffer with
+ \return true if opening succeeded, false else
+ */
+ bool open(QIODevice::OpenMode mode);
- /**
- Return the position the data is written to or read from.
+ /**
+ Closes the SecureBuffer.
+ */
+ void close();
- \return the current position inside the internal buffer
- */
- qint64 pos() const;
+ /**
+ Returns the size of the underlying SecureArray.
- /**
- Set the current read/write position to \a pos.
+ \return the size of the internal buffer
+ */
+ qint64 size() const;
- \param pos the position to set
- */
- bool seek(qint64 pos);
+ /**
+ Return the position the data is written to or read from.
- /**
- Check if the current position is at the end of the buffer.
+ \return the current position inside the internal buffer
+ */
+ qint64 pos() const;
- \return true if the current position is at the end of the
- internal buffer, false if it isn't
- */
- bool atEnd() const;
+ /**
+ Set the current read/write position to \a pos.
- /**
- Check if a complete line can be read from the buffer.
+ \param pos the position to set
+ */
+ bool seek(qint64 pos);
- \return true if a complete line can be read from the buffer,
- false if not
- */
- bool canReadLine() const;
+ /**
+ Check if the current position is at the end of the buffer.
-protected:
- /**
- Called when a connection is made to one of the buffer's signals.
+ \return true if the current position is at the end of the
+ internal buffer, false if it isn't
*/
- void connectNotify(const char*);
+ bool atEnd() const;
+
+ /**
+ Check if a complete line can be read from the buffer.
- /**
- Called when a slot is disconnected from one of the buffer's signals.
+ \return true if a complete line can be read from the buffer,
+ false if not
*/
- void disconnectNotify(const char*);
-
- /**
- Read data from the buffer.
+ bool canReadLine() const;
- \param data array to store the data read into
- \param maxlen maximum number of bytes to read
- \return actual number of bytes read or -1 in case of an error
- */
- qint64 readData(char *data, qint64 maxlen);
+protected:
+ /**
+ Called when a connection is made to one of the buffer's signals.
+ */
+ void connectNotify(const char*);
+
+ /**
+ Called when a slot is disconnected from one of the buffer's signals.
+ */
+ void disconnectNotify(const char*);
+
+ /**
+ Read data from the buffer.
+
+ \param data array to store the data read into
+ \param maxlen maximum number of bytes to read
+ \return actual number of bytes read or -1 in case of an error
+ */
+ qint64 readData(char *data, qint64 maxlen);
- /**
- Write data into the buffer.
+ /**
+ Write data into the buffer.
- \param data array to read the data to be written from
- \param len number of bytes to write
- \return actual number of bytes written or -1 in case of an error
- */
- qint64 writeData(const char *data, qint64 len);
+ \param data array to read the data to be written from
+ \param len number of bytes to write
+ \return actual number of bytes written or -1 in case of an error
+ */
+ qint64 writeData(const char *data, qint64 len);
private:
- friend class SecureBufferPrivate;
- SecureBufferPrivate *d;
+ friend class SecureBufferPrivate;
+ SecureBufferPrivate *d;
- Q_DISABLE_COPY(SecureBuffer)
+ Q_DISABLE_COPY(SecureBuffer)
};
#endif
diff --git a/backend/securebuffer_p.h b/backend/securebuffer_p.h
index a989bf9..7d6963a 100644
--- a/backend/securebuffer_p.h
+++ b/backend/securebuffer_p.h
@@ -32,32 +32,32 @@ class SecureBuffer;
class SecureBufferPrivate : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- SecureBufferPrivate(SecureBuffer *parent)
- : q(parent), buf(0), ioIndex(0), writtenSinceLastEmit(0), \
signalConnectionCount(0),
- signalsEmitted(false)
- {}
- ~SecureBufferPrivate() {}
+ SecureBufferPrivate(SecureBuffer *parent)
+ : q(parent), buf(0), ioIndex(0), writtenSinceLastEmit(0), \
signalConnectionCount(0), + signalsEmitted(false)
+ {}
+ ~SecureBufferPrivate() {}
- SecureBuffer *q;
+ SecureBuffer *q;
- QCA::SecureArray *buf;
- QCA::SecureArray defaultBuf;
- int ioIndex;
+ QCA::SecureArray *buf;
+ QCA::SecureArray defaultBuf;
+ int ioIndex;
- qint64 writtenSinceLastEmit;
- int signalConnectionCount;
- bool signalsEmitted;
+ qint64 writtenSinceLastEmit;
+ int signalConnectionCount;
+ bool signalsEmitted;
public Q_SLOTS:
- void _q_emitSignals() {
- emit q->bytesWritten(writtenSinceLastEmit);
- writtenSinceLastEmit = 0;
- emit q->readyRead();
- signalsEmitted = false;
- }
+ void _q_emitSignals() {
+ emit q->bytesWritten(writtenSinceLastEmit);
+ writtenSinceLastEmit = 0;
+ emit q->readyRead();
+ signalsEmitted = false;
+ }
};
#endif
diff --git a/backend/temporary/temporarycollection.cpp \
b/backend/temporary/temporarycollection.cpp index 92101c9..d5746a6 100644
--- a/backend/temporary/temporarycollection.cpp
+++ b/backend/temporary/temporarycollection.cpp
@@ -28,13 +28,13 @@
#include <QtCore/QTimer>
TemporaryCollection::TemporaryCollection(const QString &id,
- BackendCollectionManager *parent)
- : BackendCollection(parent)
+ BackendCollectionManager *parent)
+ : BackendCollection(parent)
{
- m_id = id;
- QDateTime now = QDateTime::currentDateTime();
- m_created = now;
- m_modified = now;
+ m_id = id;
+ QDateTime now = QDateTime::currentDateTime();
+ m_created = now;
+ m_modified = now;
}
TemporaryCollection::~TemporaryCollection()
@@ -43,151 +43,151 @@ TemporaryCollection::~TemporaryCollection()
QString TemporaryCollection::id() const
{
- return m_id;
+ return m_id;
}
BackendReturn<QString> TemporaryCollection::label() const
{
- return m_label;
+ return m_label;
}
BackendReturn<void> TemporaryCollection::setLabel(const QString &label)
{
- m_label = label;
- emit collectionChanged(this);
- return BackendReturn<void>();
+ m_label = label;
+ emit collectionChanged(this);
+ return BackendReturn<void>();
}
QDateTime TemporaryCollection::created() const
{
- return m_created;
+ return m_created;
}
QDateTime TemporaryCollection::modified() const
{
- return m_modified;
+ return m_modified;
}
bool TemporaryCollection::isLocked() const
{
- // temporary collection can't be locked
- return false;
+ // temporary collection can't be locked
+ return false;
}
BackendReturn<QList<BackendItem*> > TemporaryCollection::items() const
{
- return m_items;
+ return m_items;
}
BackendReturn<QList<BackendItem*> > TemporaryCollection::searchItems(
- const QMap<QString, QString> &attributes) const
+ const QMap<QString, QString> &attributes) const
{
- TemporaryItem *titem;
- QList<BackendItem*> foundItems;
- Q_FOREACH(BackendItem *item, m_items) {
- titem = qobject_cast<TemporaryItem*>(item);
- if (titem && titem->matches(attributes)) {
- foundItems.append(item);
- }
- }
- return foundItems;
+ TemporaryItem *titem;
+ QList<BackendItem*> foundItems;
+ Q_FOREACH(BackendItem * item, m_items) {
+ titem = qobject_cast<TemporaryItem*>(item);
+ if(titem && titem->matches(attributes)) {
+ foundItems.append(item);
+ }
+ }
+ return foundItems;
}
-UnlockCollectionJob *TemporaryCollection::createUnlockJob( const \
CollectionUnlockInfo &unlockInfo ) +UnlockCollectionJob \
*TemporaryCollection::createUnlockJob(const CollectionUnlockInfo &unlockInfo) {
- return new TemporaryUnlockCollectionJob(unlockInfo, this);
+ return new TemporaryUnlockCollectionJob(unlockInfo, this);
}
LockCollectionJob *TemporaryCollection::createLockJob()
{
- return new TemporaryLockCollectionJob(this);
+ return new TemporaryLockCollectionJob(this);
}
DeleteCollectionJob *TemporaryCollection::createDeleteJob(const \
CollectionDeleteInfo& deleteJobInfo) {
- deleteJobInfo.m_collection = this;
- TemporaryDeleteCollectionJob *job = new \
TemporaryDeleteCollectionJob(deleteJobInfo);
- connect(job, SIGNAL(result(QueuedJob*)),
- SLOT(deleteCollectionJobResult(QueuedJob*)));
- return job;
+ deleteJobInfo.m_collection = this;
+ TemporaryDeleteCollectionJob *job = new \
TemporaryDeleteCollectionJob(deleteJobInfo); + connect(job, \
SIGNAL(result(QueuedJob*)), + \
SLOT(deleteCollectionJobResult(QueuedJob*))); + return job;
}
CreateItemJob *TemporaryCollection::createCreateItemJob(const ItemCreateInfo& \
createInfo) {
- return new TemporaryCreateItemJob(createInfo, this);
+ return new TemporaryCreateItemJob(createInfo, this);
}
BackendReturn<BackendItem*> TemporaryCollection::createItem(const QString &label,
- const QMap<QString, \
QString> &attributes,
- const QCA::SecureArray \
&secret,
- bool locked, bool \
replace)
-{
- Q_UNUSED(locked);
-
- TemporaryItem *item = 0;
- bool replacing = false;
-
- // check for duplicates
- BackendReturn<QList<BackendItem*> > foundItems = searchItems(attributes);
- if (!foundItems.isError() && foundItems.value().size() > 0) {
- QList<BackendItem*> oldlist = foundItems.value();
- Q_FOREACH(BackendItem *olditem, oldlist) {
- if (olditem->attributes().value() == attributes) {
- if (replace) {
- // replacing an existing item
- item = qobject_cast<TemporaryItem*>(olditem);
- replacing = true;
- } else {
- // item existing but should not be replaced
- return BackendReturn<BackendItem*>(0, ErrorAlreadyExists);
+ const QMap<QString, QString> &attributes,
+ const QCA::SecureArray &secret,
+ bool locked, bool replace)
+{
+ Q_UNUSED(locked);
+
+ TemporaryItem *item = 0;
+ bool replacing = false;
+
+ // check for duplicates
+ BackendReturn<QList<BackendItem*> > foundItems = searchItems(attributes);
+ if(!foundItems.isError() && foundItems.value().size() > 0) {
+ QList<BackendItem*> oldlist = foundItems.value();
+ Q_FOREACH(BackendItem * olditem, oldlist) {
+ if(olditem->attributes().value() == attributes) {
+ if(replace) {
+ // replacing an existing item
+ item = qobject_cast<TemporaryItem*>(olditem);
+ replacing = true;
+ } else {
+ // item existing but should not be replaced
+ return BackendReturn<BackendItem*>(0, ErrorAlreadyExists);
+ }
+ break;
}
- break;
- }
- }
- }
-
- if (!item) {
- item = new TemporaryItem(createId(), this);
- }
- // block signals while changing label, secret and attributes
- item->blockSignals(true);
- item->setLabel(label);
- item->setAttributes(attributes);
- item->setSecret(secret);
- item->blockSignals(false);
-
- if (replacing) {
- emit itemChanged(item);
- } else {
- m_items.append(item);
- // new item, signals need to be wired
- connect(item, SIGNAL(itemDeleted(BackendItem*)), \
SLOT(slotItemDeleted(BackendItem*)));
- connect(item, SIGNAL(itemChanged(BackendItem*)), \
SIGNAL(itemChanged(BackendItem*)));
- emit itemCreated(item);
- }
-
- return item;
+ }
+ }
+
+ if(!item) {
+ item = new TemporaryItem(createId(), this);
+ }
+ // block signals while changing label, secret and attributes
+ item->blockSignals(true);
+ item->setLabel(label);
+ item->setAttributes(attributes);
+ item->setSecret(secret);
+ item->blockSignals(false);
+
+ if(replacing) {
+ emit itemChanged(item);
+ } else {
+ m_items.append(item);
+ // new item, signals need to be wired
+ connect(item, SIGNAL(itemDeleted(BackendItem*)), \
SLOT(slotItemDeleted(BackendItem*))); + connect(item, \
SIGNAL(itemChanged(BackendItem*)), SIGNAL(itemChanged(BackendItem*))); + emit \
itemCreated(item); + }
+
+ return item;
}
ChangeAuthenticationCollectionJob \
*TemporaryCollection::createChangeAuthenticationJob() {
- return new TemporaryChangeAuthenticationCollectionJob(this);
+ return new TemporaryChangeAuthenticationCollectionJob(this);
}
void TemporaryCollection::slotItemDeleted(BackendItem *item)
{
- m_items.removeAll(item);
- emit itemDeleted(item);
+ m_items.removeAll(item);
+ emit itemDeleted(item);
}
void TemporaryCollection::deleteCollectionJobResult(QueuedJob *job)
{
- TemporaryDeleteCollectionJob *dcj = \
qobject_cast<TemporaryDeleteCollectionJob*>(job);
- Q_ASSERT(dcj);
- if (!dcj->result()) {
- return;
- }
- emit collectionDeleted(this);
+ TemporaryDeleteCollectionJob *dcj = \
qobject_cast<TemporaryDeleteCollectionJob*>(job); + Q_ASSERT(dcj);
+ if(!dcj->result()) {
+ return;
+ }
+ emit collectionDeleted(this);
}
#include "temporarycollection.moc"
diff --git a/backend/temporary/temporarycollection.h \
b/backend/temporary/temporarycollection.h index 64f3b97..7e157df 100644
--- a/backend/temporary/temporarycollection.h
+++ b/backend/temporary/temporarycollection.h
@@ -31,151 +31,153 @@ class TemporaryCreateItemJob;
*/
class TemporaryCollection : public BackendCollection
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructor
- *
- * @param id the new collection's identifier
- * @param parent the collection manager that created this collection
- */
- TemporaryCollection(const QString &id, BackendCollectionManager *parent);
-
- /**
- * Destructor
- */
- virtual ~TemporaryCollection();
-
- /**
- * The unique identifier for this collection.
- */
- virtual QString id() const;
-
- /**
- * The human-readable label for this collection.
- * @todo error
- */
- virtual BackendReturn<QString> label() const;
-
- /**
- * Set this collection's human-readable label.
- *
- * @todo error
- * @param label the new label for this collection
- */
- virtual BackendReturn<void> setLabel(const QString &label);
-
- /**
- * The time this collection was created.
- */
- virtual QDateTime created() const;
-
- /**
- * The time this collection was last modified.
- */
- virtual QDateTime modified() const;
-
- /**
- * Check whether this collection is locked.
- *
- * @return true if the collection is locked, false if the collection is
- * unlocked.
- */
- virtual bool isLocked() const;
-
- /**
- * List all items inside this backend.
- *
- * @return a list containing all items inside this backend. An empty list
- * either means that no items were found or that an error occurred
- * (eg. collection needs unlocking before listing the items).
- * @todo error
- */
- virtual BackendReturn<QList<BackendItem*> > items() const;
-
- /**
- * Return all items whose attributes match the search terms.
- *
- * @param attributes attributes against which the items should be matched
- * @return a list of items matching the attributes. An empty list either means \
that
- * no items were found or that an error occurred (eg. collection needs
- * unlocking before listing the items).
- * @todo error
- */
- virtual BackendReturn<QList<BackendItem*> > searchItems(
- const QMap<QString, QString> &attributes) const;
-
- /**
- * Create a job for unlocking this collection.
- */
- virtual UnlockCollectionJob *createUnlockJob( const CollectionUnlockInfo \
&unlockInfo );
-
- /**
- * Create a job for locking this collection.
- */
- virtual LockCollectionJob *createLockJob();
-
- /**
- * Create a job for deleting this collection.
- */
- virtual DeleteCollectionJob *createDeleteJob(const CollectionDeleteInfo& \
deleteJobInfo);
-
- /**
- * Create a job for creating an item.
- *
- * @param label label to assign to the new item
- * @param attributes attributes to store for the new item
- * @param secret the secret to store
- * @param replace if true, an existing item with the same attributes
- * will be replaced, if false no item will be created
- * if one with the same attributes already exists
- * @param locked if true, the item will be locked after creation
- */
- virtual CreateItemJob *createCreateItemJob(const ItemCreateInfo& createInfo);
-
- /**
- * Create a job for changingcoll this collection's authentication.
- */
- virtual ChangeAuthenticationCollectionJob *createChangeAuthenticationJob();
-
- virtual ApplicationPermission applicationPermission(const QString& ) const { \
return PermissionAllow; }
- virtual bool setApplicationPermission(const QString& , ApplicationPermission ) {
- /* no ACL handling */
- return true;
- }
+ /**
+ * Constructor
+ *
+ * @param id the new collection's identifier
+ * @param parent the collection manager that created this collection
+ */
+ TemporaryCollection(const QString &id, BackendCollectionManager *parent);
+
+ /**
+ * Destructor
+ */
+ virtual ~TemporaryCollection();
+
+ /**
+ * The unique identifier for this collection.
+ */
+ virtual QString id() const;
+
+ /**
+ * The human-readable label for this collection.
+ * @todo error
+ */
+ virtual BackendReturn<QString> label() const;
+
+ /**
+ * Set this collection's human-readable label.
+ *
+ * @todo error
+ * @param label the new label for this collection
+ */
+ virtual BackendReturn<void> setLabel(const QString &label);
+
+ /**
+ * The time this collection was created.
+ */
+ virtual QDateTime created() const;
+
+ /**
+ * The time this collection was last modified.
+ */
+ virtual QDateTime modified() const;
+
+ /**
+ * Check whether this collection is locked.
+ *
+ * @return true if the collection is locked, false if the collection is
+ * unlocked.
+ */
+ virtual bool isLocked() const;
+
+ /**
+ * List all items inside this backend.
+ *
+ * @return a list containing all items inside this backend. An empty list
+ * either means that no items were found or that an error occurred
+ * (eg. collection needs unlocking before listing the items).
+ * @todo error
+ */
+ virtual BackendReturn<QList<BackendItem*> > items() const;
+
+ /**
+ * Return all items whose attributes match the search terms.
+ *
+ * @param attributes attributes against which the items should be matched
+ * @return a list of items matching the attributes. An empty list either means \
that + * no items were found or that an error occurred (eg. collection \
needs + * unlocking before listing the items).
+ * @todo error
+ */
+ virtual BackendReturn<QList<BackendItem*> > searchItems(
+ const QMap<QString, QString> &attributes) const;
+
+ /**
+ * Create a job for unlocking this collection.
+ */
+ virtual UnlockCollectionJob *createUnlockJob(const CollectionUnlockInfo \
&unlockInfo); +
+ /**
+ * Create a job for locking this collection.
+ */
+ virtual LockCollectionJob *createLockJob();
+
+ /**
+ * Create a job for deleting this collection.
+ */
+ virtual DeleteCollectionJob *createDeleteJob(const CollectionDeleteInfo& \
deleteJobInfo); +
+ /**
+ * Create a job for creating an item.
+ *
+ * @param label label to assign to the new item
+ * @param attributes attributes to store for the new item
+ * @param secret the secret to store
+ * @param replace if true, an existing item with the same attributes
+ * will be replaced, if false no item will be created
+ * if one with the same attributes already exists
+ * @param locked if true, the item will be locked after creation
+ */
+ virtual CreateItemJob *createCreateItemJob(const ItemCreateInfo& createInfo);
+
+ /**
+ * Create a job for changingcoll this collection's authentication.
+ */
+ virtual ChangeAuthenticationCollectionJob *createChangeAuthenticationJob();
+
+ virtual ApplicationPermission applicationPermission(const QString&) const {
+ return PermissionAllow;
+ }
+ virtual bool setApplicationPermission(const QString& , ApplicationPermission) {
+ /* no ACL handling */
+ return true;
+ }
protected:
- // Method for creating items. This is only called by TemporaryCreateItemJobs.
- BackendReturn<BackendItem*> createItem(const QString &label,
- const QMap<QString, QString> &attributes,
- const QCA::SecureArray &secret, bool \
replace,
- bool locked);
-
+ // Method for creating items. This is only called by TemporaryCreateItemJobs.
+ BackendReturn<BackendItem*> createItem(const QString &label,
+ const QMap<QString, QString> &attributes,
+ const QCA::SecureArray &secret, bool \
replace, + bool locked);
+
private Q_SLOTS:
- /**
- * Remove an item from our list of known items.
- *
- * @param item Item to remove
- */
- void slotItemDeleted(BackendItem *item);
-
- /**
- * Called when a DeleteCollectionJob signals its result.
- *
- * @param job the job that finished
- */
- void deleteCollectionJobResult(QueuedJob *job);
-
+ /**
+ * Remove an item from our list of known items.
+ *
+ * @param item Item to remove
+ */
+ void slotItemDeleted(BackendItem *item);
+
+ /**
+ * Called when a DeleteCollectionJob signals its result.
+ *
+ * @param job the job that finished
+ */
+ void deleteCollectionJobResult(QueuedJob *job);
+
private:
- friend class TemporaryCreateItemJob;
-
- QString m_id;
- QString m_label;
- QDateTime m_created;
- QDateTime m_modified;
-
- QList<BackendItem*> m_items;
+ friend class TemporaryCreateItemJob;
+
+ QString m_id;
+ QString m_label;
+ QDateTime m_created;
+ QDateTime m_modified;
+
+ QList<BackendItem*> m_items;
};
#endif
diff --git a/backend/temporary/temporarycollectionmanager.cpp \
b/backend/temporary/temporarycollectionmanager.cpp index 87445cc..c323bbd 100644
--- a/backend/temporary/temporarycollectionmanager.cpp
+++ b/backend/temporary/temporarycollectionmanager.cpp
@@ -27,7 +27,7 @@
#include <QtCore/QTimer>
TemporaryCollectionManager::TemporaryCollectionManager(QObject *parent)
- : BackendCollectionManager(parent)
+ : BackendCollectionManager(parent)
{
}
@@ -36,28 +36,28 @@ TemporaryCollectionManager::~TemporaryCollectionManager()
}
CreateCollectionJob *TemporaryCollectionManager::createCreateCollectionJob(
- const CollectionCreateInfo &createCollectionInfo)
+ const CollectionCreateInfo &createCollectionInfo)
{
- TemporaryCreateCollectionJob *job = new \
TemporaryCreateCollectionJob(createCollectionInfo,
- this);
- connect(job, SIGNAL(result(QueuedJob*)),
- SLOT(createCollectionJobResult(QueuedJob*)));
- return job;
+ TemporaryCreateCollectionJob *job = new \
TemporaryCreateCollectionJob(createCollectionInfo, + this);
+ connect(job, SIGNAL(result(QueuedJob*)),
+ SLOT(createCollectionJobResult(QueuedJob*)));
+ return job;
}
void TemporaryCollectionManager::createCollectionJobResult(QueuedJob *job)
{
- CreateCollectionJob *ccj = qobject_cast<CreateCollectionJob*>(job);
- Q_ASSERT(ccj);
-
- if (!ccj->collection()) {
- return;
- }
-
- // connect signals
- connect(ccj->collection(), SIGNAL(collectionDeleted(BackendCollection*)),
- SIGNAL(collectionDeleted(BackendCollection*)));
- emit collectionCreated(ccj->collection());
+ CreateCollectionJob *ccj = qobject_cast<CreateCollectionJob*>(job);
+ Q_ASSERT(ccj);
+
+ if(!ccj->collection()) {
+ return;
+ }
+
+ // connect signals
+ connect(ccj->collection(), SIGNAL(collectionDeleted(BackendCollection*)),
+ SIGNAL(collectionDeleted(BackendCollection*)));
+ emit collectionCreated(ccj->collection());
}
#include "temporarycollectionmanager.moc"
diff --git a/backend/temporary/temporarycollectionmanager.h \
b/backend/temporary/temporarycollectionmanager.h index e1a195a..0ecf22f 100644
--- a/backend/temporary/temporarycollectionmanager.h
+++ b/backend/temporary/temporarycollectionmanager.h
@@ -28,36 +28,36 @@
*/
class TemporaryCollectionManager : public BackendCollectionManager
{
- Q_OBJECT
+ Q_OBJECT
public:
- friend class TemporaryCollection;
-
- /**
- * Constructor
- */
- TemporaryCollectionManager(QObject *parent = 0);
-
- /**
- * Destructor
- */
- virtual ~TemporaryCollectionManager();
-
- /**
- * Create a job for creating a new collection.
- *
- * @param label the label of the new collection
- * @param lock ignored. Temporary collections can't be locked.
- */
- virtual CreateCollectionJob *createCreateCollectionJob(const CollectionCreateInfo \
&createCollectionInfo);
-
+ friend class TemporaryCollection;
+
+ /**
+ * Constructor
+ */
+ TemporaryCollectionManager(QObject *parent = 0);
+
+ /**
+ * Destructor
+ */
+ virtual ~TemporaryCollectionManager();
+
+ /**
+ * Create a job for creating a new collection.
+ *
+ * @param label the label of the new collection
+ * @param lock ignored. Temporary collections can't be locked.
+ */
+ virtual CreateCollectionJob *createCreateCollectionJob(const \
CollectionCreateInfo &createCollectionInfo); +
private Q_SLOTS:
- /**
- * Called when a CreateCollectionJob created by this manager finishes.
- *
- * @param job the job that finished
- */
- void createCollectionJobResult(QueuedJob *job);
+ /**
+ * Called when a CreateCollectionJob created by this manager finishes.
+ *
+ * @param job the job that finished
+ */
+ void createCollectionJobResult(QueuedJob *job);
};
#endif
diff --git a/backend/temporary/temporaryitem.cpp \
b/backend/temporary/temporaryitem.cpp index 5b986cb..7362b20 100644
--- a/backend/temporary/temporaryitem.cpp
+++ b/backend/temporary/temporaryitem.cpp
@@ -25,11 +25,11 @@
#include <QtCore/QTimer>
TemporaryItem::TemporaryItem(const QString &id, TemporaryCollection *parent)
- : BackendItem(parent), m_id(id)
+ : BackendItem(parent), m_id(id)
{
- QDateTime now = QDateTime::currentDateTime();
- m_created = now;
- m_modified = now;
+ QDateTime now = QDateTime::currentDateTime();
+ m_created = now;
+ m_modified = now;
}
TemporaryItem::~TemporaryItem()
@@ -38,113 +38,113 @@ TemporaryItem::~TemporaryItem()
QString TemporaryItem::id() const
{
- return m_id;
+ return m_id;
}
BackendReturn<QString> TemporaryItem::label() const
{
- return m_label;
+ return m_label;
}
BackendReturn<void> TemporaryItem::setLabel(const QString &label)
{
- m_label = label;
- markAsModified();
- return BackendReturn<void>();
+ m_label = label;
+ markAsModified();
+ return BackendReturn<void>();
}
BackendReturn<QCA::SecureArray> TemporaryItem::secret() const
{
- return m_secret;
+ return m_secret;
}
BackendReturn<void> TemporaryItem::setSecret(const QCA::SecureArray &secret)
{
- m_secret = secret;
- markAsModified();
- return BackendReturn<void>();
+ m_secret = secret;
+ markAsModified();
+ return BackendReturn<void>();
}
BackendReturn<QMap<QString, QString> > TemporaryItem::attributes() const
{
- return m_attributes;
+ return m_attributes;
}
BackendReturn<void> TemporaryItem::setAttributes(const QMap<QString, QString> \
&attributes) {
- m_attributes = attributes;
- markAsModified();
- return BackendReturn<void>();
+ m_attributes = attributes;
+ markAsModified();
+ return BackendReturn<void>();
}
QDateTime TemporaryItem::created() const
{
- return m_created;
+ return m_created;
}
QDateTime TemporaryItem::modified() const
{
- return m_modified;
+ return m_modified;
}
bool TemporaryItem::isLocked() const
{
- return false;
+ return false;
}
UnlockItemJob *TemporaryItem::createUnlockJob(const ItemUnlockInfo& unlockInfo)
{
- Q_ASSERT( unlockInfo.m_item == 0);
- unlockInfo.m_item = this;
- return new TemporaryUnlockItemJob(unlockInfo);
+ Q_ASSERT(unlockInfo.m_item == 0);
+ unlockInfo.m_item = this;
+ return new TemporaryUnlockItemJob(unlockInfo);
}
LockItemJob *TemporaryItem::createLockJob()
{
- return new TemporaryLockItemJob(this);
+ return new TemporaryLockItemJob(this);
}
DeleteItemJob *TemporaryItem::createDeleteJob(const ItemDeleteInfo& deleteJobInfo)
{
- deleteJobInfo.m_item = this; //FIXME: what if m_item was already != NULL here ?
- TemporaryDeleteItemJob *job = new TemporaryDeleteItemJob(deleteJobInfo);
- connect(job, SIGNAL(result(QueuedJob*)), SLOT(deleteItemJobResult(QueuedJob*)));
- return job;
+ deleteJobInfo.m_item = this; //FIXME: what if m_item was already != NULL here ?
+ TemporaryDeleteItemJob *job = new TemporaryDeleteItemJob(deleteJobInfo);
+ connect(job, SIGNAL(result(QueuedJob*)), SLOT(deleteItemJobResult(QueuedJob*)));
+ return job;
}
ChangeAuthenticationItemJob *TemporaryItem::createChangeAuthenticationJob()
{
- return new TemporaryChangeAuthenticationItemJob(this);
+ return new TemporaryChangeAuthenticationItemJob(this);
}
bool TemporaryItem::matches(const QMap<QString, QString> &attributes)
{
- QMap<QString, QString>::const_iterator it = attributes.constBegin();
- QMap<QString, QString>::const_iterator end = attributes.constEnd();
- for ( ; it != end; ++it) {
- if (!m_attributes.contains(it.key()) ||
- m_attributes.value(it.key()) != it.value()) {
- return false;
- }
- }
-
- return true;
+ QMap<QString, QString>::const_iterator it = attributes.constBegin();
+ QMap<QString, QString>::const_iterator end = attributes.constEnd();
+ for(; it != end; ++it) {
+ if(!m_attributes.contains(it.key()) ||
+ m_attributes.value(it.key()) != it.value()) {
+ return false;
+ }
+ }
+
+ return true;
}
void TemporaryItem::deleteItemJobResult(QueuedJob *job)
{
- TemporaryDeleteItemJob *dij = qobject_cast<TemporaryDeleteItemJob*>(job);
- Q_ASSERT(dij);
- if (!dij->result()) {
- return;
- }
- emit itemDeleted(this);
+ TemporaryDeleteItemJob *dij = qobject_cast<TemporaryDeleteItemJob*>(job);
+ Q_ASSERT(dij);
+ if(!dij->result()) {
+ return;
+ }
+ emit itemDeleted(this);
}
void TemporaryItem::markAsModified()
{
- m_modified = QDateTime::currentDateTime();
- emit itemChanged(this);
+ m_modified = QDateTime::currentDateTime();
+ emit itemChanged(this);
}
#include "temporaryitem.moc"
diff --git a/backend/temporary/temporaryitem.h b/backend/temporary/temporaryitem.h
index 70b3a24..bf37cfd 100644
--- a/backend/temporary/temporaryitem.h
+++ b/backend/temporary/temporaryitem.h
@@ -24,143 +24,143 @@
#include "../backenditem.h"
class TemporaryCollection;
-
+
class TemporaryItem : public BackendItem
{
- Q_OBJECT
+ Q_OBJECT
public:
- friend class TemporaryCollection;
-
- /**
- * Constructor.
- *
- * @param id unique identifier of the new item
- * @param collection collection that created this item
- */
- TemporaryItem(const QString &id, TemporaryCollection *parent);
-
- /**
- * Destructor.
- */
- ~TemporaryItem();
-
- /**
- * The unique identifer for this item.
- */
- virtual QString id() const;
-
- /**
- * The human-readable label for this item.
- * @todo error
- */
- virtual BackendReturn<QString> label() const;
-
- /**
- * Set the human-readable label for this item.
- *
- * @param label the new label for this item
- * @todo error
- */
- virtual BackendReturn<void> setLabel(const QString &label);
-
- /**
- * Get the secret stored inside this item.
- *
- * @return the secret
- * @todo this will most likely become non-const as that might make sense
- * with certain backends me reckons.
- */
- virtual BackendReturn<QCA::SecureArray> secret() const;
-
- /**
- * Set the secret stored inside this item.
- *
- * @param secret the secret to store
- */
- virtual BackendReturn<void> setSecret(const QCA::SecureArray &secret);
-
- /**
- * The attributes of the item.
- *
- * @return the item's attributes
- */
- virtual BackendReturn<QMap<QString, QString> > attributes() const;
-
- /**
- * Set the attributes of this item.
- *
- * @param attributes attributes to assign to this item
- */
- virtual BackendReturn<void> setAttributes(const QMap<QString, QString> \
&attributes);
-
- /**
- * The time this item was created.
- */
- virtual QDateTime created() const;
-
- /**
- * The time this item was last modified.
- */
- virtual QDateTime modified() const;
-
- /**
- * Check whether this item is locked.
- *
- * @return always returns false as temporary items can't be locked.
- */
- virtual bool isLocked() const;
-
- /**
- * Create a job for unlocking this item.
- */
- virtual UnlockItemJob *createUnlockJob(const ItemUnlockInfo& unlockInfo);
-
- /**
- * Create a job for locking this item.
- */
- virtual LockItemJob *createLockJob();
-
- /**
- * Create a job for deleting this item.
- */
- virtual DeleteItemJob *createDeleteJob(const ItemDeleteInfo& deleteJobInfo);
-
- /**
- * Create a job for changing this item's authentication.
- */
- virtual ChangeAuthenticationItemJob *createChangeAuthenticationJob();
-
- /**
- * Check whether this item matches the attributes given.
- *
- * @param attributes attributes to match against
- * @return true if this item matches the attributes, false
- * if the item doesn't match the attributes.
- */
- bool matches(const QMap<QString, QString> &attributes);
+ friend class TemporaryCollection;
+
+ /**
+ * Constructor.
+ *
+ * @param id unique identifier of the new item
+ * @param collection collection that created this item
+ */
+ TemporaryItem(const QString &id, TemporaryCollection *parent);
+
+ /**
+ * Destructor.
+ */
+ ~TemporaryItem();
+
+ /**
+ * The unique identifer for this item.
+ */
+ virtual QString id() const;
+
+ /**
+ * The human-readable label for this item.
+ * @todo error
+ */
+ virtual BackendReturn<QString> label() const;
+
+ /**
+ * Set the human-readable label for this item.
+ *
+ * @param label the new label for this item
+ * @todo error
+ */
+ virtual BackendReturn<void> setLabel(const QString &label);
+
+ /**
+ * Get the secret stored inside this item.
+ *
+ * @return the secret
+ * @todo this will most likely become non-const as that might make sense
+ * with certain backends me reckons.
+ */
+ virtual BackendReturn<QCA::SecureArray> secret() const;
+
+ /**
+ * Set the secret stored inside this item.
+ *
+ * @param secret the secret to store
+ */
+ virtual BackendReturn<void> setSecret(const QCA::SecureArray &secret);
+
+ /**
+ * The attributes of the item.
+ *
+ * @return the item's attributes
+ */
+ virtual BackendReturn<QMap<QString, QString> > attributes() const;
+
+ /**
+ * Set the attributes of this item.
+ *
+ * @param attributes attributes to assign to this item
+ */
+ virtual BackendReturn<void> setAttributes(const QMap<QString, QString> \
&attributes); +
+ /**
+ * The time this item was created.
+ */
+ virtual QDateTime created() const;
+
+ /**
+ * The time this item was last modified.
+ */
+ virtual QDateTime modified() const;
+
+ /**
+ * Check whether this item is locked.
+ *
+ * @return always returns false as temporary items can't be locked.
+ */
+ virtual bool isLocked() const;
+
+ /**
+ * Create a job for unlocking this item.
+ */
+ virtual UnlockItemJob *createUnlockJob(const ItemUnlockInfo& unlockInfo);
+
+ /**
+ * Create a job for locking this item.
+ */
+ virtual LockItemJob *createLockJob();
+
+ /**
+ * Create a job for deleting this item.
+ */
+ virtual DeleteItemJob *createDeleteJob(const ItemDeleteInfo& deleteJobInfo);
+
+ /**
+ * Create a job for changing this item's authentication.
+ */
+ virtual ChangeAuthenticationItemJob *createChangeAuthenticationJob();
+
+ /**
+ * Check whether this item matches the attributes given.
+ *
+ * @param attributes attributes to match against
+ * @return true if this item matches the attributes, false
+ * if the item doesn't match the attributes.
+ */
+ bool matches(const QMap<QString, QString> &attributes);
private Q_SLOTS:
- /**
- * Called when a DeleteItemJob signals its result.
- *
- * @param job the job that finished
- */
- void deleteItemJobResult(QueuedJob *job);
-
+ /**
+ * Called when a DeleteItemJob signals its result.
+ *
+ * @param job the job that finished
+ */
+ void deleteItemJobResult(QueuedJob *job);
+
private:
- /**
- * Mark this item as modified and emit the \sa itemChanged signal.
- */
- void markAsModified();
-
- QString m_id;
- QString m_label;
- QDateTime m_created;
- QDateTime m_modified;
- QMap<QString, QString> m_attributes;
-
- QCA::SecureArray m_secret;
+ /**
+ * Mark this item as modified and emit the \sa itemChanged signal.
+ */
+ void markAsModified();
+
+ QString m_id;
+ QString m_label;
+ QDateTime m_created;
+ QDateTime m_modified;
+ QMap<QString, QString> m_attributes;
+
+ QCA::SecureArray m_secret;
};
#endif
diff --git a/backend/temporary/temporaryjobs.cpp \
b/backend/temporary/temporaryjobs.cpp index 3d6fc50..6ce6e32 100644
--- a/backend/temporary/temporaryjobs.cpp
+++ b/backend/temporary/temporaryjobs.cpp
@@ -23,89 +23,89 @@
#include <secrettool.h>
TemporaryCreateCollectionJob::TemporaryCreateCollectionJob(const \
CollectionCreateInfo &createCollectionInfo,
- \
TemporaryCollectionManager *manager)
- : CreateCollectionJob(createCollectionInfo, manager)
+ TemporaryCollectionManager *manager)
+ : CreateCollectionJob(createCollectionInfo, manager)
{
}
void TemporaryCreateCollectionJob::exec()
{
- TemporaryCollection *coll = new TemporaryCollection(createId(), manager());
- coll->setLabel(label());
+ TemporaryCollection *coll = new TemporaryCollection(createId(), manager());
+ coll->setLabel(label());
- setCollection(coll);
- emitResult();
+ setCollection(coll);
+ emitResult();
}
TemporaryUnlockCollectionJob::TemporaryUnlockCollectionJob(const \
CollectionUnlockInfo &unlockInfo,
- BackendCollection *coll)
- : UnlockCollectionJob(unlockInfo, coll)
+ BackendCollection *coll)
+ : UnlockCollectionJob(unlockInfo, coll)
{
}
-
+
void TemporaryUnlockCollectionJob::exec()
{
- // collection is always unlocked.
- setResult(true);
- emitResult();
+ // collection is always unlocked.
+ setResult(true);
+ emitResult();
}
TemporaryLockCollectionJob::TemporaryLockCollectionJob(BackendCollection *coll)
- : LockCollectionJob(coll)
+ : LockCollectionJob(coll)
{
}
void TemporaryLockCollectionJob::exec()
{
- // collection can not be locked as that's not supported for this backend.
- setError(ErrorNotSupported);
- setResult(false);
- emitResult();
+ // collection can not be locked as that's not supported for this backend.
+ setError(ErrorNotSupported);
+ setResult(false);
+ emitResult();
}
TemporaryDeleteCollectionJob::TemporaryDeleteCollectionJob(const \
CollectionDeleteInfo& deleteInfo)
- : DeleteCollectionJob(deleteInfo)
+ : DeleteCollectionJob(deleteInfo)
{
}
void TemporaryDeleteCollectionJob::exec()
{
- setResult(true);
- collection()->deleteLater();
- emitResult();
+ setResult(true);
+ collection()->deleteLater();
+ emitResult();
}
TemporaryChangeAuthenticationCollectionJob::TemporaryChangeAuthenticationCollectionJob(BackendCollection \
*coll)
- : ChangeAuthenticationCollectionJob(coll)
+ : ChangeAuthenticationCollectionJob(coll)
{
}
void TemporaryChangeAuthenticationCollectionJob::exec()
{
- setError(ErrorNotSupported);
- setResult(false);
- emitResult();
+ setError(ErrorNotSupported);
+ setResult(false);
+ emitResult();
}
TemporaryCreateItemJob::TemporaryCreateItemJob(const ItemCreateInfo& createInfo,
- TemporaryCollection *collection)
- : CreateItemJob(createInfo, collection),
- m_tempColl(collection)
+ TemporaryCollection *collection)
+ : CreateItemJob(createInfo, collection),
+ m_tempColl(collection)
{
}
void TemporaryCreateItemJob::exec()
{
- // let the collection do all the work.
- BackendReturn<BackendItem*> rc = m_tempColl->createItem(label(), attributes(),
- secret(), locked(),
- replace());
- if (rc.isError()) {
- setError(rc.error(), rc.errorMessage());
- } else {
- setItem(rc.value());
- }
- emitResult();
+ // let the collection do all the work.
+ BackendReturn<BackendItem*> rc = m_tempColl->createItem(label(), attributes(),
+ secret(), locked(),
+ replace());
+ if(rc.isError()) {
+ setError(rc.error(), rc.errorMessage());
+ } else {
+ setItem(rc.value());
+ }
+ emitResult();
}
TemporaryUnlockItemJob::TemporaryUnlockItemJob(const ItemUnlockInfo& unlockInfo) : \
UnlockItemJob(unlockInfo) @@ -114,9 +114,9 @@ \
TemporaryUnlockItemJob::TemporaryUnlockItemJob(const ItemUnlockInfo& unlockInfo)
void TemporaryUnlockItemJob::exec()
{
- // item is always unlocked.
- setResult(true);
- emitResult();
+ // item is always unlocked.
+ setResult(true);
+ emitResult();
}
TemporaryLockItemJob::TemporaryLockItemJob(BackendItem *item) : LockItemJob(item)
@@ -125,10 +125,10 @@ TemporaryLockItemJob::TemporaryLockItemJob(BackendItem *item) : \
LockItemJob(item
void TemporaryLockItemJob::exec()
{
- // item can not be locked as that's not supported for this backend.
- setError(ErrorNotSupported);
- setResult(false);
- emitResult();
+ // item can not be locked as that's not supported for this backend.
+ setError(ErrorNotSupported);
+ setResult(false);
+ emitResult();
}
TemporaryDeleteItemJob::TemporaryDeleteItemJob(const ItemDeleteInfo& deleteInfo) : \
DeleteItemJob(deleteInfo) @@ -137,21 +137,21 @@ \
TemporaryDeleteItemJob::TemporaryDeleteItemJob(const ItemDeleteInfo& deleteInfo)
void TemporaryDeleteItemJob::exec()
{
- setResult(true);
- item()->deleteLater();
- emitResult();
+ setResult(true);
+ item()->deleteLater();
+ emitResult();
}
TemporaryChangeAuthenticationItemJob::TemporaryChangeAuthenticationItemJob(BackendItem \
*item)
- : ChangeAuthenticationItemJob(item)
+ : ChangeAuthenticationItemJob(item)
{
}
void TemporaryChangeAuthenticationItemJob::exec()
{
- setError(ErrorNotSupported);
- setResult(false);
- emitResult();
+ setError(ErrorNotSupported);
+ setResult(false);
+ emitResult();
}
#include "temporaryjobs.moc"
diff --git a/backend/temporary/temporaryjobs.h b/backend/temporary/temporaryjobs.h
index e8d3bec..caaa1fe 100644
--- a/backend/temporary/temporaryjobs.h
+++ b/backend/temporary/temporaryjobs.h
@@ -33,12 +33,12 @@
*/
class TemporaryCreateCollectionJob : public CreateCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryCreateCollectionJob(const CollectionCreateInfo &createCollectionInfo,
- TemporaryCollectionManager *manager);
- virtual void exec();
+ TemporaryCreateCollectionJob(const CollectionCreateInfo &createCollectionInfo,
+ TemporaryCollectionManager *manager);
+ virtual void exec();
};
/**
@@ -46,11 +46,11 @@ public:
*/
class TemporaryUnlockCollectionJob : public UnlockCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryUnlockCollectionJob( const CollectionUnlockInfo &unlockInfo, \
BackendCollection *coll);
- virtual void exec();
+ TemporaryUnlockCollectionJob(const CollectionUnlockInfo &unlockInfo, \
BackendCollection *coll); + virtual void exec();
};
/**
@@ -58,11 +58,11 @@ public:
*/
class TemporaryLockCollectionJob : public LockCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryLockCollectionJob(BackendCollection *coll);
- virtual void exec();
+ TemporaryLockCollectionJob(BackendCollection *coll);
+ virtual void exec();
};
/**
@@ -70,11 +70,11 @@ public:
*/
class TemporaryDeleteCollectionJob : public DeleteCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryDeleteCollectionJob(const CollectionDeleteInfo& deleteInfo);
- virtual void exec();
+ TemporaryDeleteCollectionJob(const CollectionDeleteInfo& deleteInfo);
+ virtual void exec();
};
/**
@@ -82,11 +82,11 @@ public:
*/
class TemporaryChangeAuthenticationCollectionJob : public \
ChangeAuthenticationCollectionJob {
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryChangeAuthenticationCollectionJob(BackendCollection *coll);
- virtual void exec();
+ TemporaryChangeAuthenticationCollectionJob(BackendCollection *coll);
+ virtual void exec();
};
/**
@@ -94,15 +94,15 @@ public:
*/
class TemporaryCreateItemJob : public CreateItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryCreateItemJob(const ItemCreateInfo& createInfo,
- TemporaryCollection *collection);
- virtual void exec();
-
+ TemporaryCreateItemJob(const ItemCreateInfo& createInfo,
+ TemporaryCollection *collection);
+ virtual void exec();
+
private:
- TemporaryCollection *m_tempColl;
+ TemporaryCollection *m_tempColl;
};
/**
@@ -110,11 +110,11 @@ private:
*/
class TemporaryUnlockItemJob : public UnlockItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryUnlockItemJob(const ItemUnlockInfo& unlockInfo);
- virtual void exec();
+ TemporaryUnlockItemJob(const ItemUnlockInfo& unlockInfo);
+ virtual void exec();
};
/**
@@ -122,11 +122,11 @@ public:
*/
class TemporaryLockItemJob : public LockItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryLockItemJob(BackendItem *item);
- virtual void exec();
+ TemporaryLockItemJob(BackendItem *item);
+ virtual void exec();
};
/**
@@ -134,11 +134,11 @@ public:
*/
class TemporaryDeleteItemJob : public DeleteItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryDeleteItemJob(const ItemDeleteInfo& deleteInfo);
- virtual void exec();
+ TemporaryDeleteItemJob(const ItemDeleteInfo& deleteInfo);
+ virtual void exec();
};
/**
@@ -146,11 +146,11 @@ public:
*/
class TemporaryChangeAuthenticationItemJob : public ChangeAuthenticationItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TemporaryChangeAuthenticationItemJob(BackendItem *item);
- virtual void exec();
+ TemporaryChangeAuthenticationItemJob(BackendItem *item);
+ virtual void exec();
};
#endif
diff --git a/backend/tests/ksecrettest.cpp b/backend/tests/ksecrettest.cpp
index 40ecc44..7a17ebc 100644
--- a/backend/tests/ksecrettest.cpp
+++ b/backend/tests/ksecrettest.cpp
@@ -31,110 +31,110 @@ Q_DECLARE_METATYPE(BackendItem*)
void KSecretTest::initTestCase()
{
- qRegisterMetaType<BackendCollection*>();
- qRegisterMetaType<BackendItem*>();
- QCA::init();
- BackendMaster *master = BackendMaster::instance();
- master->setUiManager(new NoUiManager);
- m_manager = new KSecretCollectionManager("/tmp", master);
- master->addManager(m_manager);
+ qRegisterMetaType<BackendCollection*>();
+ qRegisterMetaType<BackendItem*>();
+ QCA::init();
+ BackendMaster *master = BackendMaster::instance();
+ master->setUiManager(new NoUiManager);
+ m_manager = new KSecretCollectionManager("/tmp", master);
+ master->addManager(m_manager);
}
void KSecretTest::testCreateCollectionAsync()
{
- CollectionCreateInfo createCollectionInfo("test", Peer());
- CreateCollectionJob *createColl = \
m_manager->createCreateCollectionJob(createCollectionInfo);
- QSignalSpy managerSpy(m_manager, SIGNAL(collectionCreated(BackendCollection*)));
- QSignalSpy masterSpy(BackendMaster::instance(), \
SIGNAL(collectionCreated(BackendCollection*)));
- QTestEventLoop loop;
- QVERIFY(loop.connect(createColl, SIGNAL(result(QueuedJob*)), SLOT(exitLoop())));
- createColl->enqueue();
- if (!createColl->isFinished()) {
- loop.enterLoop(5);
- }
-
- QVERIFY(createColl->isFinished());
- QCOMPARE(createColl->error(), NoError);
- QVERIFY(!createColl->isDismissed());
- QVERIFY(createColl->collection() != 0);
-
- // Verify signals
- QCOMPARE(managerSpy.count(), 1);
- QCOMPARE(managerSpy.takeFirst().at(0).value<BackendCollection*>(), \
createColl->collection());
- QCOMPARE(masterSpy.count(), 1);
- QCOMPARE(masterSpy.takeFirst().at(0).value<BackendCollection*>(), \
createColl->collection());
-
- // Check the collection is present and alive
- BackendMaster *master = BackendMaster::instance();
- QCOMPARE(master->collections().size(), 1);
- QCOMPARE(master->collections().first(), createColl->collection());
- QCOMPARE(master->collections().first()->label().value(), QLatin1String("test"));
-
- // TODO: check collection attributes (eg. timestamps)
-
- // TODO: check if the collection has been written to disk
-
- // remember the collection
- m_collection = createColl->collection();
+ CollectionCreateInfo createCollectionInfo("test", Peer());
+ CreateCollectionJob *createColl = \
m_manager->createCreateCollectionJob(createCollectionInfo); + QSignalSpy \
managerSpy(m_manager, SIGNAL(collectionCreated(BackendCollection*))); + QSignalSpy \
masterSpy(BackendMaster::instance(), SIGNAL(collectionCreated(BackendCollection*))); \
+ QTestEventLoop loop; + QVERIFY(loop.connect(createColl, \
SIGNAL(result(QueuedJob*)), SLOT(exitLoop()))); + createColl->enqueue();
+ if(!createColl->isFinished()) {
+ loop.enterLoop(5);
+ }
+
+ QVERIFY(createColl->isFinished());
+ QCOMPARE(createColl->error(), NoError);
+ QVERIFY(!createColl->isDismissed());
+ QVERIFY(createColl->collection() != 0);
+
+ // Verify signals
+ QCOMPARE(managerSpy.count(), 1);
+ QCOMPARE(managerSpy.takeFirst().at(0).value<BackendCollection*>(), \
createColl->collection()); + QCOMPARE(masterSpy.count(), 1);
+ QCOMPARE(masterSpy.takeFirst().at(0).value<BackendCollection*>(), \
createColl->collection()); +
+ // Check the collection is present and alive
+ BackendMaster *master = BackendMaster::instance();
+ QCOMPARE(master->collections().size(), 1);
+ QCOMPARE(master->collections().first(), createColl->collection());
+ QCOMPARE(master->collections().first()->label().value(), QLatin1String("test"));
+
+ // TODO: check collection attributes (eg. timestamps)
+
+ // TODO: check if the collection has been written to disk
+
+ // remember the collection
+ m_collection = createColl->collection();
}
void KSecretTest::testLockCollectionAsync()
{
- LockCollectionJob *lockColl = m_collection->createLockJob();
- BackendMaster *master = BackendMaster::instance();
- QSignalSpy masterSpy(master, SIGNAL(collectionChanged(BackendCollection*)));
- QSignalSpy managerSpy(m_manager, SIGNAL(collectionChanged(BackendCollection*)));
- QSignalSpy collSpy(m_collection, SIGNAL(collectionChanged(BackendCollection*)));
- QTestEventLoop loop;
- QVERIFY(loop.connect(lockColl, SIGNAL(result(QueuedJob*)), SLOT(exitLoop())));
- lockColl->enqueue();
- if (!lockColl->isFinished()) {
- loop.enterLoop(5);
- }
-
- QVERIFY(lockColl->isFinished());
- QCOMPARE(lockColl->error(), NoError);
- QVERIFY(!lockColl->isDismissed());
- QVERIFY(lockColl->result());
- QVERIFY(m_collection->isLocked());
-
- // Verify signals
- QCOMPARE(managerSpy.count(), 1);
- QCOMPARE(managerSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
- QCOMPARE(masterSpy.count(), 1);
- QCOMPARE(masterSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
- QCOMPARE(collSpy.count(), 1);
- QCOMPARE(collSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
+ LockCollectionJob *lockColl = m_collection->createLockJob();
+ BackendMaster *master = BackendMaster::instance();
+ QSignalSpy masterSpy(master, SIGNAL(collectionChanged(BackendCollection*)));
+ QSignalSpy managerSpy(m_manager, SIGNAL(collectionChanged(BackendCollection*)));
+ QSignalSpy collSpy(m_collection, SIGNAL(collectionChanged(BackendCollection*)));
+ QTestEventLoop loop;
+ QVERIFY(loop.connect(lockColl, SIGNAL(result(QueuedJob*)), SLOT(exitLoop())));
+ lockColl->enqueue();
+ if(!lockColl->isFinished()) {
+ loop.enterLoop(5);
+ }
+
+ QVERIFY(lockColl->isFinished());
+ QCOMPARE(lockColl->error(), NoError);
+ QVERIFY(!lockColl->isDismissed());
+ QVERIFY(lockColl->result());
+ QVERIFY(m_collection->isLocked());
+
+ // Verify signals
+ QCOMPARE(managerSpy.count(), 1);
+ QCOMPARE(managerSpy.takeFirst().at(0).value<BackendCollection*>(), \
m_collection); + QCOMPARE(masterSpy.count(), 1);
+ QCOMPARE(masterSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
+ QCOMPARE(collSpy.count(), 1);
+ QCOMPARE(collSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
}
void KSecretTest::testUnlockCollectionAsync()
{
- CollectionUnlockInfo unlockInfo = CollectionUnlockInfo(Peer());
- UnlockCollectionJob *unlockColl = m_collection->createUnlockJob(unlockInfo);
- BackendMaster *master = BackendMaster::instance();
- QSignalSpy masterSpy(master, SIGNAL(collectionChanged(BackendCollection*)));
- QSignalSpy managerSpy(m_manager, SIGNAL(collectionChanged(BackendCollection*)));
- QSignalSpy collSpy(m_collection, SIGNAL(collectionChanged(BackendCollection*)));
- QTestEventLoop loop;
- QVERIFY(loop.connect(unlockColl, SIGNAL(result(QueuedJob*)), SLOT(exitLoop())));
- unlockColl->enqueue();
- if (!unlockColl->isFinished()) {
- loop.enterLoop(5);
- }
-
- QVERIFY(unlockColl->isFinished());
- QCOMPARE(unlockColl->error(), NoError);
- QVERIFY(!unlockColl->isDismissed());
- QVERIFY(unlockColl->result());
- QVERIFY(!m_collection->isLocked());
-
- // Verify signals
- QCOMPARE(managerSpy.count(), 1);
- QCOMPARE(managerSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
- QCOMPARE(masterSpy.count(), 1);
- QCOMPARE(masterSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
- QCOMPARE(collSpy.count(), 1);
- QCOMPARE(collSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
+ CollectionUnlockInfo unlockInfo = CollectionUnlockInfo(Peer());
+ UnlockCollectionJob *unlockColl = m_collection->createUnlockJob(unlockInfo);
+ BackendMaster *master = BackendMaster::instance();
+ QSignalSpy masterSpy(master, SIGNAL(collectionChanged(BackendCollection*)));
+ QSignalSpy managerSpy(m_manager, SIGNAL(collectionChanged(BackendCollection*)));
+ QSignalSpy collSpy(m_collection, SIGNAL(collectionChanged(BackendCollection*)));
+ QTestEventLoop loop;
+ QVERIFY(loop.connect(unlockColl, SIGNAL(result(QueuedJob*)), SLOT(exitLoop())));
+ unlockColl->enqueue();
+ if(!unlockColl->isFinished()) {
+ loop.enterLoop(5);
+ }
+
+ QVERIFY(unlockColl->isFinished());
+ QCOMPARE(unlockColl->error(), NoError);
+ QVERIFY(!unlockColl->isDismissed());
+ QVERIFY(unlockColl->result());
+ QVERIFY(!m_collection->isLocked());
+
+ // Verify signals
+ QCOMPARE(managerSpy.count(), 1);
+ QCOMPARE(managerSpy.takeFirst().at(0).value<BackendCollection*>(), \
m_collection); + QCOMPARE(masterSpy.count(), 1);
+ QCOMPARE(masterSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
+ QCOMPARE(collSpy.count(), 1);
+ QCOMPARE(collSpy.takeFirst().at(0).value<BackendCollection*>(), m_collection);
}
void KSecretTest::testCreateItemAsync()
@@ -160,6 +160,6 @@ void KSecretTest::testDeleteCollectionAsync()
void KSecretTest::cleanupTestCase()
{
}
-
+
QTEST_MAIN(KSecretTest)
#include "ksecrettest.moc"
diff --git a/backend/tests/ksecrettest.h b/backend/tests/ksecrettest.h
index da9d064..020af76 100644
--- a/backend/tests/ksecrettest.h
+++ b/backend/tests/ksecrettest.h
@@ -28,28 +28,28 @@ class BackendCollection;
class KSecretTest : public QObject
{
- Q_OBJECT
-
+ Q_OBJECT
+
private Q_SLOTS:
- void initTestCase();
-
- void testCreateCollectionAsync();
- void testLockCollectionAsync();
- void testUnlockCollectionAsync();
- void testCreateItemAsync();
- void testReplaceItemAsync();
- void testDoNotReplaceItemAsync();
- void testDeleteItemAsync();
- void testDeleteCollectionAsync();
-
- void cleanupTestCase();
-
+ void initTestCase();
+
+ void testCreateCollectionAsync();
+ void testLockCollectionAsync();
+ void testUnlockCollectionAsync();
+ void testCreateItemAsync();
+ void testReplaceItemAsync();
+ void testDoNotReplaceItemAsync();
+ void testDeleteItemAsync();
+ void testDeleteCollectionAsync();
+
+ void cleanupTestCase();
+
private:
- BackendCollectionManager *m_manager;
- BackendCollection *m_collection;
-
- QDateTime m_collCreated;
- QDateTime m_collModified;
+ BackendCollectionManager *m_manager;
+ BackendCollection *m_collection;
+
+ QDateTime m_collCreated;
+ QDateTime m_collModified;
};
#endif
diff --git a/backend/tests/securebuffertest.cpp b/backend/tests/securebuffertest.cpp
index 6542fba..83f18ba 100644
--- a/backend/tests/securebuffertest.cpp
+++ b/backend/tests/securebuffertest.cpp
@@ -31,7 +31,7 @@
SecureBufferTest::SecureBufferTest()
{
- qRegisterMetaType<QCA::SecureArray>();
+ qRegisterMetaType<QCA::SecureArray>();
}
// Testing get/set functions
@@ -61,7 +61,7 @@ void SecureBufferTest::readBlock()
const int arraySize = 10;
char a[arraySize];
SecureBuffer b;
- QCOMPARE(b.read(a, arraySize), (qint64) -1); // not opened
+ QCOMPARE(b.read(a, arraySize), (qint64) - 1); // not opened
QVERIFY(b.atEnd());
QCA::SecureArray ba;
@@ -69,7 +69,7 @@ void SecureBufferTest::readBlock()
b.setBuffer(&ba);
b.open(QIODevice::WriteOnly);
QTest::ignoreMessage(QtWarningMsg, "QIODevice::read: WriteOnly device");
- QCOMPARE(b.read(a, arraySize), (qint64) -1); // no read access
+ QCOMPARE(b.read(a, arraySize), (qint64) - 1); // no read access
b.close();
b.open(QIODevice::ReadOnly);
@@ -84,9 +84,9 @@ void SecureBufferTest::readBlock()
// read in two chunks
b.close();
b.open(QIODevice::ReadOnly);
- QCOMPARE(b.read(a, arraySize/2), (qint64) arraySize/2);
- QCOMPARE(b.read(a + arraySize/2, arraySize - arraySize/2),
- (qint64)(arraySize - arraySize/2));
+ QCOMPARE(b.read(a, arraySize / 2), (qint64) arraySize / 2);
+ QCOMPARE(b.read(a + arraySize / 2, arraySize - arraySize / 2),
+ (qint64)(arraySize - arraySize / 2));
QVERIFY(b.atEnd());
}
@@ -109,108 +109,108 @@ void SecureBufferTest::writeBlock_data()
{
QTest::addColumn<QString>("str");
- QTest::newRow( "small_bytearray" ) << QString("Test");
- QTest::newRow( "large_bytearray" ) << QString("Lorem ipsum dolor sit amet, \
consectetur adipisicing elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."
- "Lorem ipsum dolor sit amet, consectetur adipisicing \
elit,"
- "sed do eiusmod tempor incididunt ut labore et dolore \
magna aliqua. Ut enim ad"
- "minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea"
- "commodo consequat. Duis aute irure dolor in \
reprehenderit in voluptate velit"
- "esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat"
- "non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum."); + QTest::newRow("small_bytearray") << \
QString("Test"); + QTest::newRow("large_bytearray") << QString("Lorem ipsum dolor \
sit amet, consectetur adipisicing elit," + "sed \
do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + \
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," + \
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad" + \
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" + \
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit" + \
"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" + \
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); }
void SecureBufferTest::writeBlock()
{
- QFETCH( QString, str );
+ QFETCH(QString, str);
QCA::SecureArray ba;
- SecureBuffer buf( &ba );
+ SecureBuffer buf(&ba);
buf.open(QIODevice::ReadWrite);
QByteArray data = str.toLatin1();
- QCOMPARE(buf.write( data.constData(), data.size() ), qint64(data.size()));
+ QCOMPARE(buf.write(data.constData(), data.size()), qint64(data.size()));
QCOMPARE(buf.data(), QCA::SecureArray(data));
}
@@ -232,17 +232,17 @@ void SecureBufferTest::seekTest_data()
}
#define DO_VALID_SEEK(position) { \
- char c; \
- QVERIFY(buf.seek(qint64(position))); \
- QCOMPARE(buf.pos(), qint64(position)); \
- QVERIFY(buf.getChar(&c)); \
- QCOMPARE(QChar(c), str.at(qint64(position))); \
-}
+ char c; \
+ QVERIFY(buf.seek(qint64(position))); \
+ QCOMPARE(buf.pos(), qint64(position)); \
+ QVERIFY(buf.getChar(&c)); \
+ QCOMPARE(QChar(c), str.at(qint64(position))); \
+ }
#define DO_INVALID_SEEK(position) { \
- qint64 prev_pos = buf.pos(); \
- QVERIFY(!buf.seek(qint64(position))); \
- QCOMPARE(buf.pos(), prev_pos); /* position should not be changed */ \
\
-}
+ qint64 prev_pos = buf.pos(); \
+ QVERIFY(!buf.seek(qint64(position))); \
+ QCOMPARE(buf.pos(), prev_pos); /* position should not be changed */ \
\ + }
void SecureBufferTest::seekTest()
{
@@ -257,7 +257,7 @@ void SecureBufferTest::seekTest()
QCOMPARE(buf.pos(), qint64(0));
QByteArray data = str.toLatin1();
- QCOMPARE(buf.write( data.constData(), data.size() ), qint64(data.size()));
+ QCOMPARE(buf.write(data.constData(), data.size()), qint64(data.size()));
QTest::ignoreMessage(QtWarningMsg, "SecureBuffer::seek: Invalid pos: -1");
DO_INVALID_SEEK(-1);
@@ -308,7 +308,7 @@ void SecureBufferTest::read_rawdata()
buffer.open(QIODevice::ReadOnly);
QDataStream in(&buffer);
quint8 ch;
- for (int i = 0; i < (int)sizeof(mydata); ++i) {
+ for(int i = 0; i < (int)sizeof(mydata); ++i) {
QVERIFY(!buffer.atEnd());
in >> ch;
QVERIFY(ch == (quint8)mydata[i]);
@@ -345,14 +345,14 @@ void SecureBufferTest::signalTest()
connect(&buf, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
connect(&buf, SIGNAL(bytesWritten(qint64)), this, \
SLOT(bytesWrittenSlot(qint64)));
- for (int i = 0; i < 10; ++i) {
+ for(int i = 0; i < 10; ++i) {
gotReadyRead = false;
QCOMPARE(buf.write(sample), qint64(sample.size()));
- if (sample.size() > 0) {
+ if(sample.size() > 0) {
QTestEventLoop::instance().enterLoop(5);
- if (QTestEventLoop::instance().timeout())
+ if(QTestEventLoop::instance().timeout())
QFAIL("Timed out when waiting for readyRead()");
- QCOMPARE(totalBytesWritten, qint64(sample.size() * (i + 1)));
+ QCOMPARE(totalBytesWritten, qint64(sample.size() *(i + 1)));
QVERIFY(gotReadyRead);
} else {
QCOMPARE(totalBytesWritten, qint64(0));
@@ -388,9 +388,9 @@ void SecureBufferTest::readLine_data()
QTest::addColumn<QByteArray>("expected");
QTest::newRow("1") << QCA::SecureArray("line1\nline2\n") << 1024
- << QByteArray("line1\n");
+ << QByteArray("line1\n");
QTest::newRow("2") << QCA::SecureArray("hi there") << 1024
- << QByteArray("hi there");
+ << QByteArray("hi there");
QTest::newRow("3") << QCA::SecureArray("l\n") << 3 << QByteArray("l\n");
QTest::newRow("4") << QCA::SecureArray("l\n") << 2 << QByteArray("l");
}
@@ -460,16 +460,16 @@ void SecureBufferTest::readLineBoundaries()
QByteArray line = "This is a line\n";
SecureBuffer buffer;
buffer.open(QIODevice::ReadWrite);
- while (buffer.size() < 16384)
+ while(buffer.size() < 16384)
buffer.write(line);
-/*
- buffer.seek(0);
- QFile out1("out1.txt");
- out1.open(QFile::WriteOnly);
- out1.write(buffer.readAll());
- out1.close();
-*/
+ /*
+ buffer.seek(0);
+ QFile out1("out1.txt");
+ out1.open(QFile::WriteOnly);
+ out1.write(buffer.readAll());
+ out1.close();
+ */
buffer.seek(0);
char c;
@@ -478,7 +478,7 @@ void SecureBufferTest::readLineBoundaries()
QFile out2("out2.txt");
out2.open(QFile::WriteOnly);
- while (!buffer.atEnd())
+ while(!buffer.atEnd())
out2.write(buffer.readLine());
out2.close();
diff --git a/backend/tests/securebuffertest.h b/backend/tests/securebuffertest.h
index 542025e..27c7f97 100644
--- a/backend/tests/securebuffertest.h
+++ b/backend/tests/securebuffertest.h
@@ -37,7 +37,7 @@ class SecureBufferTest : public QObject
Q_OBJECT
public:
- SecureBufferTest();
+ SecureBufferTest();
private slots:
void getSetCheck();
diff --git a/backend/tests/temporarytest.cpp b/backend/tests/temporarytest.cpp
index 74d380c..2a895a3 100644
--- a/backend/tests/temporarytest.cpp
+++ b/backend/tests/temporarytest.cpp
@@ -52,15 +52,15 @@ void TemporaryTest::initTestCase()
void TemporaryTest::testCreateCollectionSync()
{
- CollectionCreateInfo createCollectionInfo("test", Peer());
- CreateCollectionJob *createColl = \
m_manager->createCreateCollectionJob(createCollectionInfo); + CollectionCreateInfo \
createCollectionInfo("test", Peer()); + CreateCollectionJob *createColl = \
m_manager->createCreateCollectionJob(createCollectionInfo);
QSignalSpy managerSpy(m_manager, SIGNAL(collectionCreated(BackendCollection*)));
QSignalSpy masterSpy(m_master, SIGNAL(collectionCreated(BackendCollection*)));
QVERIFY(createColl->isImmediate());
createColl->exec();
-
+
QVERIFY(createColl->isFinished());
QCOMPARE(createColl->error(), NoError);
QVERIFY(!createColl->isDismissed());
@@ -81,7 +81,7 @@ void TemporaryTest::testCreateCollectionSync()
void TemporaryTest::testCreateItemSync()
{
BackendCollection *collection = m_master->collections().first();
- QMap<QString,QString> attr;
+ QMap<QString, QString> attr;
attr["mainattr"] = "haha";
QCA::SecureArray array(4, 'c');
ItemCreateInfo createInfo("testitem", attr, array, false, false, Peer());
@@ -89,7 +89,7 @@ void TemporaryTest::testCreateItemSync()
QSignalSpy collectionSpy(collection, SIGNAL(itemCreated(BackendItem*)));
QVERIFY(createItem->isImmediate());
-
+
createItem->exec();
QVERIFY(createItem->isFinished());
@@ -110,7 +110,7 @@ void TemporaryTest::testCreateItemSync()
void TemporaryTest::testReplaceItemSync()
{
BackendCollection *collection = m_master->collections().first();
- QMap<QString,QString> attr;
+ QMap<QString, QString> attr;
attr["mainattr"] = "haha";
QCA::SecureArray array(QByteArray("arealsecrete243"));
ItemCreateInfo createInfo("testitem2", attr, array, true, false, Peer());
@@ -119,7 +119,7 @@ void TemporaryTest::testReplaceItemSync()
QSignalSpy collectionSpy(collection, SIGNAL(itemChanged(BackendItem*)));
QVERIFY(createItem->isImmediate());
-
+
createItem->exec();
QVERIFY(createItem->isFinished());
@@ -140,7 +140,7 @@ void TemporaryTest::testReplaceItemSync()
void TemporaryTest::testDoNotReplaceItemSync()
{
BackendCollection *collection = m_master->collections().first();
- QMap<QString,QString> attr;
+ QMap<QString, QString> attr;
attr["mainattr"] = "haha";
QCA::SecureArray array(QByteArray("anothersecret"));
ItemCreateInfo createInfo("testitem3", attr, array, false, false, Peer());
@@ -149,7 +149,7 @@ void TemporaryTest::testDoNotReplaceItemSync()
QSignalSpy collectionSpy(collection, SIGNAL(itemChanged(BackendItem*)));
QVERIFY(createItem->isImmediate());
-
+
createItem->exec();
QVERIFY(createItem->isFinished());
@@ -172,7 +172,7 @@ void TemporaryTest::testDeleteItemSync()
ItemDeleteInfo deleteInfo = ItemDeleteInfo(Peer());
DeleteItemJob *deleteItem = item->createDeleteJob(deleteInfo);
QSignalSpy collectionSpy(collection, SIGNAL(itemDeleted(BackendItem*)));
-
+
QVERIFY(deleteItem->isImmediate());
deleteItem->exec();
@@ -226,10 +226,10 @@ void TemporaryTest::testCreateCollectionAsync()
QEventLoop loop;
QVERIFY(loop.connect(createColl, SIGNAL(result(QueuedJob*)), SLOT(quit())));
createColl->enqueue();
- if (!createColl->isFinished()) {
- loop.exec();
+ if(!createColl->isFinished()) {
+ loop.exec();
}
-
+
QVERIFY(createColl->isFinished());
QCOMPARE(createColl->error(), NoError);
QVERIFY(!createColl->isDismissed());
@@ -250,7 +250,7 @@ void TemporaryTest::testCreateCollectionAsync()
void TemporaryTest::testCreateItemAsync()
{
BackendCollection *collection = m_master->collections().first();
- QMap<QString,QString> attr;
+ QMap<QString, QString> attr;
attr["mainattr"] = "haha";
QCA::SecureArray array(4, 'c');
ItemCreateInfo createInfo("testitem", attr, array, false, false, Peer());
@@ -259,10 +259,10 @@ void TemporaryTest::testCreateItemAsync()
QEventLoop loop;
QVERIFY(loop.connect(createItem, SIGNAL(result(QueuedJob*)), SLOT(quit())));
createItem->enqueue();
- if (!createItem->isFinished()) {
- loop.exec();
+ if(!createItem->isFinished()) {
+ loop.exec();
}
-
+
QVERIFY(createItem->isFinished());
QCOMPARE(createItem->error(), NoError);
QVERIFY(!createItem->isDismissed());
@@ -281,7 +281,7 @@ void TemporaryTest::testCreateItemAsync()
void TemporaryTest::testReplaceItemAsync()
{
BackendCollection *collection = m_master->collections().first();
- QMap<QString,QString> attr;
+ QMap<QString, QString> attr;
attr["mainattr"] = "haha";
QCA::SecureArray array(QByteArray("arealsecrete243"));
ItemCreateInfo createInfo("testitem2", attr, array, true, false, Peer());
@@ -291,10 +291,10 @@ void TemporaryTest::testReplaceItemAsync()
QEventLoop loop;
QVERIFY(loop.connect(createItem, SIGNAL(result(QueuedJob*)), SLOT(quit())));
createItem->enqueue();
- if (!createItem->isFinished()) {
- loop.exec();
+ if(!createItem->isFinished()) {
+ loop.exec();
}
-
+
QVERIFY(createItem->isFinished());
QCOMPARE(createItem->error(), NoError);
QVERIFY(!createItem->isDismissed());
@@ -313,20 +313,20 @@ void TemporaryTest::testReplaceItemAsync()
void TemporaryTest::testDoNotReplaceItemAsync()
{
BackendCollection *collection = m_master->collections().first();
- QMap<QString,QString> attr;
+ QMap<QString, QString> attr;
attr["mainattr"] = "haha";
QCA::SecureArray array(QByteArray("anothersecret"));
- ItemCreateInfo createInfo( "testitem3", attr, array, false, false, Peer());
+ ItemCreateInfo createInfo("testitem3", attr, array, false, false, Peer());
CreateItemJob *createItem = collection->createCreateItemJob(createInfo);
QSignalSpy collectionSpy(collection, SIGNAL(itemChanged(BackendItem*)));
QEventLoop loop;
QVERIFY(loop.connect(createItem, SIGNAL(result(QueuedJob*)), SLOT(quit())));
createItem->enqueue();
- if (!createItem->isFinished()) {
- loop.exec();
+ if(!createItem->isFinished()) {
+ loop.exec();
}
-
+
QVERIFY(createItem->isFinished());
QCOMPARE(createItem->error(), ErrorAlreadyExists);
QVERIFY(!createItem->isDismissed());
@@ -350,8 +350,8 @@ void TemporaryTest::testDeleteItemAsync()
QEventLoop loop;
QVERIFY(loop.connect(deleteItem, SIGNAL(result(QueuedJob*)), SLOT(quit())));
deleteItem->enqueue();
- if (!deleteItem->isFinished()) {
- loop.exec();
+ if(!deleteItem->isFinished()) {
+ loop.exec();
}
QVERIFY(deleteItem->isFinished());
@@ -377,10 +377,10 @@ void TemporaryTest::testDeleteCollectionAsync()
QEventLoop loop;
QVERIFY(loop.connect(deleteCollection, SIGNAL(result(QueuedJob*)), \
SLOT(quit()))); deleteCollection->enqueue();
- if (!deleteCollection->isFinished()) {
- loop.exec();
+ if(!deleteCollection->isFinished()) {
+ loop.exec();
}
-
+
QVERIFY(deleteCollection->isFinished());
QCOMPARE(deleteCollection->error(), NoError);
QVERIFY(deleteCollection->result());
@@ -398,7 +398,7 @@ void TemporaryTest::testDeleteCollectionAsync()
void TemporaryTest::cleanupTestCase()
{
- // TODO: delete stuff so this can also be used for valgrind leak-checking.
+ // TODO: delete stuff so this can also be used for valgrind leak-checking.
}
diff --git a/backend/tests/temporarytest.h b/backend/tests/temporarytest.h
index 557acdd..bdf00da 100644
--- a/backend/tests/temporarytest.h
+++ b/backend/tests/temporarytest.h
@@ -29,32 +29,32 @@ class BackendMaster;
class TemporaryTest : public QObject
{
Q_OBJECT
- public:
- TemporaryTest(QObject* parent = 0);
- virtual ~TemporaryTest();
-
- private Q_SLOTS:
- void initTestCase();
-
- void testCreateCollectionSync();
- void testCreateItemSync();
- void testReplaceItemSync();
- void testDoNotReplaceItemSync();
- void testDeleteItemSync();
- void testDeleteCollectionSync();
-
- void testCreateCollectionAsync();
- void testCreateItemAsync();
- void testReplaceItemAsync();
- void testDoNotReplaceItemAsync();
- void testDeleteItemAsync();
- void testDeleteCollectionAsync();
-
- void cleanupTestCase();
-
- private:
- BackendMaster *m_master;
- BackendCollectionManager *m_manager;
+public:
+ TemporaryTest(QObject* parent = 0);
+ virtual ~TemporaryTest();
+
+private Q_SLOTS:
+ void initTestCase();
+
+ void testCreateCollectionSync();
+ void testCreateItemSync();
+ void testReplaceItemSync();
+ void testDoNotReplaceItemSync();
+ void testDeleteItemSync();
+ void testDeleteCollectionSync();
+
+ void testCreateCollectionAsync();
+ void testCreateItemAsync();
+ void testReplaceItemAsync();
+ void testDoNotReplaceItemAsync();
+ void testDeleteItemAsync();
+ void testDeleteCollectionAsync();
+
+ void cleanupTestCase();
+
+private:
+ BackendMaster *m_master;
+ BackendCollectionManager *m_manager;
};
#endif // TEMPORARYTEST_H
diff --git a/frontend/secret/adaptors/collectionadaptor.cpp \
b/frontend/secret/adaptors/collectionadaptor.cpp index 35b431a..df39545 100644
--- a/frontend/secret/adaptors/collectionadaptor.cpp
+++ b/frontend/secret/adaptors/collectionadaptor.cpp
@@ -25,63 +25,63 @@ namespace orgFreedesktopSecret
{
CollectionAdaptor::CollectionAdaptor(Collection *collection)
- : QDBusAbstractAdaptor(collection), m_collection(collection)
+ : QDBusAbstractAdaptor(collection), m_collection(collection)
{
- Q_ASSERT(collection);
+ Q_ASSERT(collection);
- connect(m_collection, SIGNAL(itemCreated(const QDBusObjectPath &)),
- SIGNAL(ItemCreated(const QDBusObjectPath &)));
- connect(m_collection, SIGNAL(itemDeleted(const QDBusObjectPath &)),
- SIGNAL(ItemDeleted(const QDBusObjectPath &)));
- connect(m_collection, SIGNAL(itemChanged(const QDBusObjectPath &)),
- SIGNAL(ItemChanged(const QDBusObjectPath &)));
+ connect(m_collection, SIGNAL(itemCreated(const QDBusObjectPath &)),
+ SIGNAL(ItemCreated(const QDBusObjectPath &)));
+ connect(m_collection, SIGNAL(itemDeleted(const QDBusObjectPath &)),
+ SIGNAL(ItemDeleted(const QDBusObjectPath &)));
+ connect(m_collection, SIGNAL(itemChanged(const QDBusObjectPath &)),
+ SIGNAL(ItemChanged(const QDBusObjectPath &)));
}
const QList<QDBusObjectPath> &CollectionAdaptor::items() const
{
- return m_collection->items();
+ return m_collection->items();
}
void CollectionAdaptor::setLabel(const QString &label)
{
- m_collection->setLabel(label);
+ m_collection->setLabel(label);
}
QString CollectionAdaptor::label() const
{
- return m_collection->label();
+ return m_collection->label();
}
bool CollectionAdaptor::locked() const
{
- return m_collection->locked();
+ return m_collection->locked();
}
qulonglong CollectionAdaptor::created() const
{
- return m_collection->created();
+ return m_collection->created();
}
qulonglong CollectionAdaptor::modified() const
{
- return m_collection->modified();
+ return m_collection->modified();
}
QDBusObjectPath CollectionAdaptor::Delete()
{
- return m_collection->deleteCollection();
+ return m_collection->deleteCollection();
}
QList<QDBusObjectPath> CollectionAdaptor::SearchItems(const StringStringMap \
&attributes) {
- return m_collection->searchItems(attributes);
+ return m_collection->searchItems(attributes);
}
QDBusObjectPath CollectionAdaptor::CreateItem(const QMap<QString, QVariant> \
&properties,
- const Secret &secret, bool replace,
- QDBusObjectPath &prompt)
+ const Secret &secret, bool replace,
+ QDBusObjectPath &prompt)
{
- return m_collection->createItem(properties, secret, replace, prompt);
+ return m_collection->createItem(properties, secret, replace, prompt);
}
}
diff --git a/frontend/secret/adaptors/collectionadaptor.h \
b/frontend/secret/adaptors/collectionadaptor.h index cb7ad00..9de17ae 100644
--- a/frontend/secret/adaptors/collectionadaptor.h
+++ b/frontend/secret/adaptors/collectionadaptor.h
@@ -35,52 +35,52 @@ namespace orgFreedesktopSecret
*/
class CollectionAdaptor : public QDBusAbstractAdaptor
{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Collection")
- Q_PROPERTY(QList<QDBusObjectPath> Items READ items)
- Q_PROPERTY(QString Label READ label WRITE setLabel)
- Q_PROPERTY(bool Locked READ locked)
- Q_PROPERTY(qulonglong Created READ created)
- Q_PROPERTY(qulonglong Modified READ modified)
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Collection")
+ Q_PROPERTY(QList<QDBusObjectPath> Items READ items)
+ Q_PROPERTY(QString Label READ label WRITE setLabel)
+ Q_PROPERTY(bool Locked READ locked)
+ Q_PROPERTY(qulonglong Created READ created)
+ Q_PROPERTY(qulonglong Modified READ modified)
public:
- /**
- * Constructor.
- *
- * @param collection collection object to attach the adaptor to
- */
- CollectionAdaptor(Collection *collection);
+ /**
+ * Constructor.
+ *
+ * @param collection collection object to attach the adaptor to
+ */
+ CollectionAdaptor(Collection *collection);
- const QList<QDBusObjectPath> &items() const;
+ const QList<QDBusObjectPath> &items() const;
- void setLabel(const QString &label);
-
- QString label() const;
+ void setLabel(const QString &label);
- bool locked() const;
+ QString label() const;
- qulonglong created() const;
+ bool locked() const;
- qulonglong modified() const;
+ qulonglong created() const;
+
+ qulonglong modified() const;
public Q_SLOTS:
- QDBusObjectPath Delete();
+ QDBusObjectPath Delete();
- QList<QDBusObjectPath> SearchItems(const StringStringMap &attributes);
+ QList<QDBusObjectPath> SearchItems(const StringStringMap &attributes);
- QDBusObjectPath CreateItem(const QMap<QString, QVariant> &properties,
- const Secret &secret, bool replace,
- QDBusObjectPath &prompt);
+ QDBusObjectPath CreateItem(const QMap<QString, QVariant> &properties,
+ const Secret &secret, bool replace,
+ QDBusObjectPath &prompt);
Q_SIGNALS:
- void ItemCreated(const QDBusObjectPath &item);
+ void ItemCreated(const QDBusObjectPath &item);
- void ItemDeleted(const QDBusObjectPath &item);
+ void ItemDeleted(const QDBusObjectPath &item);
- void ItemChanged(const QDBusObjectPath &item);
+ void ItemChanged(const QDBusObjectPath &item);
private:
- Collection *m_collection;
+ Collection *m_collection;
};
}
diff --git a/frontend/secret/adaptors/dbusstrings.h \
b/frontend/secret/adaptors/dbusstrings.h index 66f1cef..5bdbe92 100644
--- a/frontend/secret/adaptors/dbusstrings.h
+++ b/frontend/secret/adaptors/dbusstrings.h
@@ -23,9 +23,9 @@
/** \file dbusstrings.h
* \brief KSecretService DBus frequently used strings by clients
- *
+ *
* This file aims to reduce typo problems when using strings to
- * construct DBus bindings in client programs.
+ * construct DBus bindings in client programs.
*
* DBUS_SERVICE_XXX macros define service instances
* DBUS_INTERFACE_SECRET_XXX macros define interface instances
diff --git a/frontend/secret/adaptors/dbustypes.cpp \
b/frontend/secret/adaptors/dbustypes.cpp index 6d5362f..3dec5bc 100644
--- a/frontend/secret/adaptors/dbustypes.cpp
+++ b/frontend/secret/adaptors/dbustypes.cpp
@@ -24,10 +24,10 @@
void registerDBusTypes()
{
- // register meta-types needed for this adaptor
- qRegisterMetaType<Secret>();
- qDBusRegisterMetaType<Secret>();
- qRegisterMetaType<StringStringMap>();
- qDBusRegisterMetaType<StringStringMap>();
- qDBusRegisterMetaType<ObjectPathSecretMap>();
+ // register meta-types needed for this adaptor
+ qRegisterMetaType<Secret>();
+ qDBusRegisterMetaType<Secret>();
+ qRegisterMetaType<StringStringMap>();
+ qDBusRegisterMetaType<StringStringMap>();
+ qDBusRegisterMetaType<ObjectPathSecretMap>();
}
diff --git a/frontend/secret/adaptors/itemadaptor.cpp \
b/frontend/secret/adaptors/itemadaptor.cpp index 04f68ea..1c4c548 100644
--- a/frontend/secret/adaptors/itemadaptor.cpp
+++ b/frontend/secret/adaptors/itemadaptor.cpp
@@ -26,59 +26,59 @@ namespace orgFreedesktopSecret
{
ItemAdaptor::ItemAdaptor(Item *item)
- : QDBusAbstractAdaptor(item), m_item(item)
+ : QDBusAbstractAdaptor(item), m_item(item)
{
- Q_ASSERT(item);
+ Q_ASSERT(item);
}
bool ItemAdaptor::locked() const
{
- return m_item->locked();
+ return m_item->locked();
}
void ItemAdaptor::setAttributes(const StringStringMap &attributes)
{
- m_item->setAttributes(attributes);
+ m_item->setAttributes(attributes);
}
StringStringMap ItemAdaptor::attributes() const
{
- return m_item->attributes();
+ return m_item->attributes();
}
void ItemAdaptor::setLabel(const QString &label)
{
- m_item->setLabel(label);
+ m_item->setLabel(label);
}
QString ItemAdaptor::label() const
{
- return m_item->label();
+ return m_item->label();
}
qulonglong ItemAdaptor::created() const
{
- return m_item->created();
+ return m_item->created();
}
qulonglong ItemAdaptor::modified() const
{
- return m_item->modified();
+ return m_item->modified();
}
QDBusObjectPath ItemAdaptor::Delete()
{
- return m_item->deleteItem();
+ return m_item->deleteItem();
}
Secret ItemAdaptor::GetSecret(const QDBusObjectPath &session)
{
- return m_item->getSecret(session);
+ return m_item->getSecret(session);
}
void ItemAdaptor::SetSecret(const Secret &secret)
{
- m_item->setSecret(secret);
+ m_item->setSecret(secret);
}
}
diff --git a/frontend/secret/adaptors/itemadaptor.h \
b/frontend/secret/adaptors/itemadaptor.h index 2037c17..5a9c5e9 100644
--- a/frontend/secret/adaptors/itemadaptor.h
+++ b/frontend/secret/adaptors/itemadaptor.h
@@ -37,45 +37,45 @@ namespace orgFreedesktopSecret
*/
class ItemAdaptor : public QDBusAbstractAdaptor
{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Item")
- Q_PROPERTY(bool Locked READ locked)
- Q_PROPERTY(StringStringMap Attributes READ attributes WRITE setAttributes)
- Q_PROPERTY(QString Label READ label WRITE setLabel)
- Q_PROPERTY(qulonglong Created READ created)
- Q_PROPERTY(qulonglong Modified READ modified)
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Item")
+ Q_PROPERTY(bool Locked READ locked)
+ Q_PROPERTY(StringStringMap Attributes READ attributes WRITE setAttributes)
+ Q_PROPERTY(QString Label READ label WRITE setLabel)
+ Q_PROPERTY(qulonglong Created READ created)
+ Q_PROPERTY(qulonglong Modified READ modified)
public:
- /**
- * Constructor.
- *
- * @param item item object to attach the adaptor to
- */
- ItemAdaptor(Item *item);
+ /**
+ * Constructor.
+ *
+ * @param item item object to attach the adaptor to
+ */
+ ItemAdaptor(Item *item);
- bool locked() const;
+ bool locked() const;
- void setAttributes(const StringStringMap &attributes);
-
- StringStringMap attributes() const;
+ void setAttributes(const StringStringMap &attributes);
- void setLabel(const QString &label);
+ StringStringMap attributes() const;
- QString label() const;
+ void setLabel(const QString &label);
- qulonglong created() const;
+ QString label() const;
- qulonglong modified() const;
+ qulonglong created() const;
+
+ qulonglong modified() const;
public Q_SLOTS:
- QDBusObjectPath Delete();
+ QDBusObjectPath Delete();
- Secret GetSecret(const QDBusObjectPath &session);
+ Secret GetSecret(const QDBusObjectPath &session);
- void SetSecret(const Secret &secret);
+ void SetSecret(const Secret &secret);
private:
- Item *m_item;
+ Item *m_item;
};
}
diff --git a/frontend/secret/adaptors/promptadaptor.cpp \
b/frontend/secret/adaptors/promptadaptor.cpp index 44ddda3..e835420 100644
--- a/frontend/secret/adaptors/promptadaptor.cpp
+++ b/frontend/secret/adaptors/promptadaptor.cpp
@@ -25,26 +25,26 @@ namespace orgFreedesktopSecret
{
PromptAdaptor::PromptAdaptor(PromptBase *prompt)
- : QDBusAbstractAdaptor(prompt), m_prompt(prompt)
+ : QDBusAbstractAdaptor(prompt), m_prompt(prompt)
{
- Q_ASSERT(prompt);
+ Q_ASSERT(prompt);
- connect(prompt, SIGNAL(completed(bool, QVariant)), SLOT(slotCompleted(bool, \
QVariant))); + connect(prompt, SIGNAL(completed(bool, QVariant)), \
SLOT(slotCompleted(bool, QVariant))); }
void PromptAdaptor::Prompt(const QString &windowId)
{
- m_prompt->prompt(windowId);
+ m_prompt->prompt(windowId);
}
void PromptAdaptor::Dismiss()
{
- m_prompt->dismiss();
+ m_prompt->dismiss();
}
void PromptAdaptor::slotCompleted(bool dismissed, const QVariant &result)
{
- emit Completed(dismissed, QDBusVariant(result));
+ emit Completed(dismissed, QDBusVariant(result));
}
}
diff --git a/frontend/secret/adaptors/promptadaptor.h \
b/frontend/secret/adaptors/promptadaptor.h index 8338eca..99f37b2 100644
--- a/frontend/secret/adaptors/promptadaptor.h
+++ b/frontend/secret/adaptors/promptadaptor.h
@@ -33,30 +33,30 @@ namespace orgFreedesktopSecret
*/
class PromptAdaptor : public QDBusAbstractAdaptor
{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Prompt")
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Prompt")
public:
- /**
- * Constructor.
- *
- * @param prompt prompt object to attach the adaptor to
- */
- PromptAdaptor(PromptBase *prompt);
+ /**
+ * Constructor.
+ *
+ * @param prompt prompt object to attach the adaptor to
+ */
+ PromptAdaptor(PromptBase *prompt);
public Q_SLOTS:
- void Prompt(const QString &windowId);
+ void Prompt(const QString &windowId);
- void Dismiss();
+ void Dismiss();
Q_SIGNALS:
- void Completed(bool dismissed, QDBusVariant result);
+ void Completed(bool dismissed, QDBusVariant result);
private Q_SLOTS:
- void slotCompleted(bool dismissed, const QVariant &result);
-
+ void slotCompleted(bool dismissed, const QVariant &result);
+
private:
- PromptBase *m_prompt;
+ PromptBase *m_prompt;
};
}
diff --git a/frontend/secret/adaptors/serviceadaptor.cpp \
b/frontend/secret/adaptors/serviceadaptor.cpp index 276ba19..5758eca 100644
--- a/frontend/secret/adaptors/serviceadaptor.cpp
+++ b/frontend/secret/adaptors/serviceadaptor.cpp
@@ -26,60 +26,60 @@ namespace orgFreedesktopSecret
{
ServiceAdaptor::ServiceAdaptor(Service *service)
- : QDBusAbstractAdaptor(service), m_service(service)
+ : QDBusAbstractAdaptor(service), m_service(service)
{
- Q_ASSERT(service);
+ Q_ASSERT(service);
- // register all types needed for the D-Bus interface
- registerDBusTypes();
+ // register all types needed for the D-Bus interface
+ registerDBusTypes();
- connect(service, SIGNAL(collectionCreated(const QDBusObjectPath&)),
- SIGNAL(CollectionCreated(const QDBusObjectPath&)));
- connect(service, SIGNAL(collectionDeleted(const QDBusObjectPath&)),
- SIGNAL(CollectionDeleted(const QDBusObjectPath&)));
- connect(service, SIGNAL(collectionChanged(const QDBusObjectPath&)),
- SIGNAL(CollectionChanged(const QDBusObjectPath&)));
+ connect(service, SIGNAL(collectionCreated(const QDBusObjectPath&)),
+ SIGNAL(CollectionCreated(const QDBusObjectPath&)));
+ connect(service, SIGNAL(collectionDeleted(const QDBusObjectPath&)),
+ SIGNAL(CollectionDeleted(const QDBusObjectPath&)));
+ connect(service, SIGNAL(collectionChanged(const QDBusObjectPath&)),
+ SIGNAL(CollectionChanged(const QDBusObjectPath&)));
}
const QList<QDBusObjectPath> &ServiceAdaptor::collections() const
{
- return m_service->collections();
+ return m_service->collections();
}
QDBusVariant ServiceAdaptor::OpenSession(const QString &algorithm, const \
QDBusVariant &input,
- QDBusObjectPath &result)
+ QDBusObjectPath &result)
{
- return QDBusVariant(m_service->openSession(algorithm, input.variant(), result));
+ return QDBusVariant(m_service->openSession(algorithm, input.variant(), result));
}
QDBusObjectPath ServiceAdaptor::CreateCollection(const QMap<QString, QVariant> \
&properties,
- QDBusObjectPath &prompt)
+ QDBusObjectPath &prompt)
{
- return m_service->createCollection(properties, prompt);
+ return m_service->createCollection(properties, prompt);
}
QList<QDBusObjectPath> ServiceAdaptor::SearchItems(const StringStringMap \
&attributes,
- QList<QDBusObjectPath> &locked)
+ QList<QDBusObjectPath> &locked)
{
- return m_service->searchItems(attributes, locked);
+ return m_service->searchItems(attributes, locked);
}
QList<QDBusObjectPath> ServiceAdaptor::Unlock(const QList<QDBusObjectPath> &objects,
- QDBusObjectPath &prompt)
+ QDBusObjectPath &prompt)
{
- return m_service->unlock(objects, prompt);
+ return m_service->unlock(objects, prompt);
}
QList<QDBusObjectPath> ServiceAdaptor::Lock(const QList<QDBusObjectPath> &objects,
- QDBusObjectPath &prompt)
+ QDBusObjectPath &prompt)
{
- return m_service->lock(objects, prompt);
+ return m_service->lock(objects, prompt);
}
ObjectPathSecretMap ServiceAdaptor::GetSecrets(const QList<QDBusObjectPath> &items,
- const QDBusObjectPath &session)
+ const QDBusObjectPath &session)
{
- return m_service->getSecrets(items, session);
+ return m_service->getSecrets(items, session);
}
}
diff --git a/frontend/secret/adaptors/serviceadaptor.h \
b/frontend/secret/adaptors/serviceadaptor.h index 436a4bd..416fb6d 100644
--- a/frontend/secret/adaptors/serviceadaptor.h
+++ b/frontend/secret/adaptors/serviceadaptor.h
@@ -37,48 +37,48 @@ namespace orgFreedesktopSecret
*/
class ServiceAdaptor : public QDBusAbstractAdaptor
{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Service")
- Q_PROPERTY(QList<QDBusObjectPath> Collections READ collections)
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Service")
+ Q_PROPERTY(QList<QDBusObjectPath> Collections READ collections)
public:
- /**
- * Constructor.
- *
- * @param service service object to attach the adaptor to
- */
- ServiceAdaptor(Service *service);
+ /**
+ * Constructor.
+ *
+ * @param service service object to attach the adaptor to
+ */
+ ServiceAdaptor(Service *service);
- const QList<QDBusObjectPath> &collections() const;
+ const QList<QDBusObjectPath> &collections() const;
public Q_SLOTS:
- QDBusVariant OpenSession(const QString &algorithm, const QDBusVariant &input,
- QDBusObjectPath &result);
-
- QDBusObjectPath CreateCollection(const QMap<QString, QVariant> &properties,
- QDBusObjectPath &prompt);
-
- QList<QDBusObjectPath> SearchItems(const StringStringMap &attributes,
- QList<QDBusObjectPath> &locked);
-
- QList<QDBusObjectPath> Unlock(const QList<QDBusObjectPath> &objects, \
QDBusObjectPath &prompt);
-
- QList<QDBusObjectPath> Lock(const QList<QDBusObjectPath> &objects, \
QDBusObjectPath &prompt);
-
- ObjectPathSecretMap GetSecrets(const QList<QDBusObjectPath> &items,
- const QDBusObjectPath &session);
+ QDBusVariant OpenSession(const QString &algorithm, const QDBusVariant &input,
+ QDBusObjectPath &result);
+
+ QDBusObjectPath CreateCollection(const QMap<QString, QVariant> &properties,
+ QDBusObjectPath &prompt);
+
+ QList<QDBusObjectPath> SearchItems(const StringStringMap &attributes,
+ QList<QDBusObjectPath> &locked);
+
+ QList<QDBusObjectPath> Unlock(const QList<QDBusObjectPath> &objects, \
QDBusObjectPath &prompt); +
+ QList<QDBusObjectPath> Lock(const QList<QDBusObjectPath> &objects, \
QDBusObjectPath &prompt); +
+ ObjectPathSecretMap GetSecrets(const QList<QDBusObjectPath> &items,
+ const QDBusObjectPath &session);
Q_SIGNALS:
- void CollectionCreated(const QDBusObjectPath &collection);
+ void CollectionCreated(const QDBusObjectPath &collection);
- void CollectionDeleted(const QDBusObjectPath &collection);
+ void CollectionDeleted(const QDBusObjectPath &collection);
- void CollectionChanged(const QDBusObjectPath &collection);
+ void CollectionChanged(const QDBusObjectPath &collection);
private:
- Service *m_service;
+ Service *m_service;
};
-
+
}
#endif
diff --git a/frontend/secret/adaptors/sessionadaptor.cpp \
b/frontend/secret/adaptors/sessionadaptor.cpp index e2d1e53..2fe878e 100644
--- a/frontend/secret/adaptors/sessionadaptor.cpp
+++ b/frontend/secret/adaptors/sessionadaptor.cpp
@@ -25,14 +25,14 @@ namespace orgFreedesktopSecret
{
SessionAdaptor::SessionAdaptor(Session *session)
- : QDBusAbstractAdaptor(session), m_session(session)
+ : QDBusAbstractAdaptor(session), m_session(session)
{
- Q_ASSERT(session);
+ Q_ASSERT(session);
}
void SessionAdaptor::Close()
{
- m_session->close();
+ m_session->close();
}
}
diff --git a/frontend/secret/adaptors/sessionadaptor.h \
b/frontend/secret/adaptors/sessionadaptor.h index 0eb553c..f3a24f7 100644
--- a/frontend/secret/adaptors/sessionadaptor.h
+++ b/frontend/secret/adaptors/sessionadaptor.h
@@ -33,22 +33,22 @@ namespace orgFreedesktopSecret
*/
class SessionAdaptor : public QDBusAbstractAdaptor
{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Session")
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Secret.Session")
public:
- /**
- * Constructor.
- *
- * @param session session object to attach the adaptor to
- */
- SessionAdaptor(Session *session);
+ /**
+ * Constructor.
+ *
+ * @param session session object to attach the adaptor to
+ */
+ SessionAdaptor(Session *session);
public Q_SLOTS:
- void Close();
+ void Close();
private:
- Session *m_session;
+ Session *m_session;
};
}
diff --git a/frontend/secret/collection.cpp b/frontend/secret/collection.cpp
index 05d83f9..0ec3785 100644
--- a/frontend/secret/collection.cpp
+++ b/frontend/secret/collection.cpp
@@ -34,170 +34,169 @@
#include <QtCore/QDebug>
Collection::Collection(BackendCollection *collection, Service *service)
- : QObject(service), m_service(service), m_collection(collection)
+ : QObject(service), m_service(service), m_collection(collection)
{
- Q_ASSERT(collection);
- m_objectPath.setPath(service->objectPath().path() + "/collection/" + \
collection->id());
-
- new orgFreedesktopSecret::CollectionAdaptor(this);
- QDBusConnection::sessionBus().registerObject(m_objectPath.path(), this);
-
- connect(collection, SIGNAL(itemCreated(BackendItem*)),
- SLOT(slotItemCreated(BackendItem*)));
- connect(collection, SIGNAL(itemDeleted(BackendItem*)),
- SLOT(slotItemDeleted(BackendItem*)));
- connect(collection, SIGNAL(itemChanged(BackendItem*)),
- SLOT(slotItemChanged(BackendItem*)));
+ Q_ASSERT(collection);
+ m_objectPath.setPath(service->objectPath().path() + "/collection/" + \
collection->id()); +
+ new orgFreedesktopSecret::CollectionAdaptor(this);
+ QDBusConnection::sessionBus().registerObject(m_objectPath.path(), this);
+
+ connect(collection, SIGNAL(itemCreated(BackendItem*)),
+ SLOT(slotItemCreated(BackendItem*)));
+ connect(collection, SIGNAL(itemDeleted(BackendItem*)),
+ SLOT(slotItemDeleted(BackendItem*)));
+ connect(collection, SIGNAL(itemChanged(BackendItem*)),
+ SLOT(slotItemChanged(BackendItem*)));
}
const QDBusObjectPath &Collection::objectPath() const
{
- return m_objectPath;
+ return m_objectPath;
}
const QList<QDBusObjectPath> &Collection::items() const
{
- return m_items;
+ return m_items;
}
void Collection::setLabel(const QString &label)
{
- BackendReturn<void> rc = m_collection->setLabel(label);
- if (rc.isError()) {
- // TODO: generate D-Bus error
- }
+ BackendReturn<void> rc = m_collection->setLabel(label);
+ if(rc.isError()) {
+ // TODO: generate D-Bus error
+ }
}
QString Collection::label() const
{
- BackendReturn<QString> rc = m_collection->label();
- if (rc.isError()) {
- // TODO: generate D-Bus error
- }
- return rc.value();
+ BackendReturn<QString> rc = m_collection->label();
+ if(rc.isError()) {
+ // TODO: generate D-Bus error
+ }
+ return rc.value();
}
bool Collection::locked() const
{
- return m_collection->isLocked();
+ return m_collection->isLocked();
}
qulonglong Collection::created() const
{
- return m_collection->created().toTime_t();
+ return m_collection->created().toTime_t();
}
qulonglong Collection::modified() const
{
- return m_collection->modified().toTime_t();
+ return m_collection->modified().toTime_t();
}
QDBusObjectPath Collection::deleteCollection()
{
- CollectionDeleteInfo deleteInfo( getCallingPeer() );
- // TODO: init peer here
- DeleteCollectionJob *dcj = m_collection->createDeleteJob(deleteInfo);
- if (dcj->isImmediate()) {
- dcj->exec();
- return QDBusObjectPath("/");
- } else {
- SingleJobPrompt *p = new SingleJobPrompt(m_service, dcj, this);
- return p->objectPath();
- }
+ CollectionDeleteInfo deleteInfo(getCallingPeer());
+ // TODO: init peer here
+ DeleteCollectionJob *dcj = m_collection->createDeleteJob(deleteInfo);
+ if(dcj->isImmediate()) {
+ dcj->exec();
+ return QDBusObjectPath("/");
+ } else {
+ SingleJobPrompt *p = new SingleJobPrompt(m_service, dcj, this);
+ return p->objectPath();
+ }
}
QList<QDBusObjectPath> Collection::searchItems(const QMap<QString, QString> \
&attributes) {
- QList<QDBusObjectPath> rc;
- BackendReturn<QList<BackendItem*> > br = m_collection->searchItems(attributes);
- if (br.isError()) {
- // TODO: generate D-Bus error
- }
- else {
- Q_FOREACH(BackendItem *item, br.value()) {
- rc.append(QDBusObjectPath(m_objectPath.path() + "/" + item->id()));
- }
- }
- return rc;
+ QList<QDBusObjectPath> rc;
+ BackendReturn<QList<BackendItem*> > br = m_collection->searchItems(attributes);
+ if(br.isError()) {
+ // TODO: generate D-Bus error
+ } else {
+ Q_FOREACH(BackendItem * item, br.value()) {
+ rc.append(QDBusObjectPath(m_objectPath.path() + "/" + item->id()));
+ }
+ }
+ return rc;
}
QDBusObjectPath Collection::createItem(const QMap<QString, QVariant> &properties,
const Secret &secret, bool replace,
QDBusObjectPath &prompt)
{
- // default label?
- QString label;
- QMap<QString, QString> attributes;
- bool locked = false;
-
- // get the session object
- QObject *object = \
QDBusConnection::sessionBus().objectRegisteredAt(secret.session().path());
- Session *session;
- if (!(session = qobject_cast<Session*>(object))) {
- // TODO: error, requires session
- }
-
- if (properties.contains("Label")) {
- label = properties["Label"].toString();
- }
- if (properties.contains("Locked")) {
- locked = properties["Locked"].toBool();
- }
- if (properties.contains("Attributes")) {
- attributes = qdbus_cast<StringStringMap>(properties["Attributes"].value<QDBusArgument>());
- }
-
- // TODO: check the parameters before creating the prompt
- bool ok;
- QCA::SecureArray secretValue = session->decrypt(secret, ok);
- if (!ok) {
- // TODO: invalid session
- }
- ItemCreateInfo createInfo ( label, attributes, secretValue, replace, locked, \
getCallingPeer() );
- CreateItemJob *cij = m_collection->createCreateItemJob( createInfo );
- if (cij->isImmediate()) {
- cij->exec();
- if (cij->error() != NoError || !cij->item()) {
- // TODO: error creating the item
- }
-
- // the Item is already created inside slotItemCreated()
- prompt.setPath("/");
- QDBusObjectPath itemPath(m_objectPath.path() + "/" + cij->item()->id());
- return itemPath;
- } else {
- SingleJobPrompt *p = new SingleJobPrompt(m_service, cij, this);
- prompt = p->objectPath();
- return QDBusObjectPath("/");
- }
+ // default label?
+ QString label;
+ QMap<QString, QString> attributes;
+ bool locked = false;
+
+ // get the session object
+ QObject *object = \
QDBusConnection::sessionBus().objectRegisteredAt(secret.session().path()); + \
Session *session; + if(!(session = qobject_cast<Session*>(object))) {
+ // TODO: error, requires session
+ }
+
+ if(properties.contains("Label")) {
+ label = properties["Label"].toString();
+ }
+ if(properties.contains("Locked")) {
+ locked = properties["Locked"].toBool();
+ }
+ if(properties.contains("Attributes")) {
+ attributes = \
qdbus_cast<StringStringMap>(properties["Attributes"].value<QDBusArgument>()); + }
+
+ // TODO: check the parameters before creating the prompt
+ bool ok;
+ QCA::SecureArray secretValue = session->decrypt(secret, ok);
+ if(!ok) {
+ // TODO: invalid session
+ }
+ ItemCreateInfo createInfo(label, attributes, secretValue, replace, locked, \
getCallingPeer()); + CreateItemJob *cij = \
m_collection->createCreateItemJob(createInfo); + if(cij->isImmediate()) {
+ cij->exec();
+ if(cij->error() != NoError || !cij->item()) {
+ // TODO: error creating the item
+ }
+
+ // the Item is already created inside slotItemCreated()
+ prompt.setPath("/");
+ QDBusObjectPath itemPath(m_objectPath.path() + "/" + cij->item()->id());
+ return itemPath;
+ } else {
+ SingleJobPrompt *p = new SingleJobPrompt(m_service, cij, this);
+ prompt = p->objectPath();
+ return QDBusObjectPath("/");
+ }
}
BackendCollection *Collection::backendCollection() const
{
- return m_collection;
+ return m_collection;
}
void Collection::slotItemCreated(BackendItem *item)
{
- Q_ASSERT(item);
- Item *itm = new Item(item, this);
- m_items.append(itm->objectPath());
- emit itemCreated(itm->objectPath());
+ Q_ASSERT(item);
+ Item *itm = new Item(item, this);
+ m_items.append(itm->objectPath());
+ emit itemCreated(itm->objectPath());
}
void Collection::slotItemDeleted(BackendItem *item)
{
- Q_ASSERT(item);
- QDBusObjectPath itmPath(m_objectPath.path() + "/" + item->id());
- m_items.removeAll(itmPath);
- emit itemDeleted(itmPath);
+ Q_ASSERT(item);
+ QDBusObjectPath itmPath(m_objectPath.path() + "/" + item->id());
+ m_items.removeAll(itmPath);
+ emit itemDeleted(itmPath);
}
void Collection::slotItemChanged(BackendItem *item)
{
- Q_ASSERT(item);
- QDBusObjectPath itmPath(m_objectPath.path() + "/" + item->id());
- emit itemChanged(itmPath);
+ Q_ASSERT(item);
+ QDBusObjectPath itmPath(m_objectPath.path() + "/" + item->id());
+ emit itemChanged(itmPath);
}
#include "collection.moc"
diff --git a/frontend/secret/collection.h b/frontend/secret/collection.h
index b73afe7..3638da4 100644
--- a/frontend/secret/collection.h
+++ b/frontend/secret/collection.h
@@ -33,143 +33,143 @@ class BackendItem;
class Service;
class Item;
-
+
/**
* Represents a collection on the D-Bus implementing the \
org.freedesktop.Secret.Collection
* interface.
*/
class Collection : public QObject, protected KSecretDBusContext
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructor.
- *
- * @param collection Backend collection object
- * @param service Parent service
- */
- Collection(BackendCollection *collection, Service *service);
-
- /**
- * Return the collection's path on the D-Bus.
- *
- * @return the Collection object's path
- */
- const QDBusObjectPath &objectPath() const;
-
- /**
- * Get the items stored inside this collection.
- *
- * @return a list of object paths of items inside the collection
- */
- const QList<QDBusObjectPath> &items() const;
-
- /**
- * Set the collection's label.
- *
- * @param label label to set for the collection
- */
- void setLabel(const QString &label);
-
- /**
- * Get the collection's label.
- *
- * @return the collection's label
- */
- QString label() const;
-
- /**
- * Check whether this collection is locked.
- *
- * @return true if the collection is locked, false if it is unlocked
- */
- bool locked() const;
-
- /**
- * Get the collection's creation time as a unix timestamp.
- *
- * @return collection's creation time
- */
- qulonglong created() const;
-
- /**
- * Get the collection's last modification time as a unix timestamp.
- *
- * @return collection's modification time
- */
- qulonglong modified() const;
-
- /**
- * Delete this collection.
- *
- * @return the object path of a Prompt object or special value "/" if the
- * collection was deleted without prompting
- */
- QDBusObjectPath deleteCollection();
-
- /**
- * Search items inside the collection.
- *
- * @param attributes search attributes to match items against
- */
- QList<QDBusObjectPath> searchItems(const QMap<QString, QString> &attributes);
-
- /**
- * Create a new item inside the collection.
- *
- * @param properties Properties for the new item
- * @param secret Secret for the new item
- * @param replace if true, an existing item with the same attributes will be \
replaced,
- * if false and an item with the same attributes exists, no new \
item
- * will be created
- * @param prompt object path of a prompt object if prompting is necessary or "/" \
if
- * the action could be completed without a prompt
- * @return object path of the new item or "/" if prompting is necessary
- */
- QDBusObjectPath createItem(const QMap<QString, QVariant> &properties,
- const Secret &secret, bool replace, QDBusObjectPath \
&prompt);
-
- /**
- * Get the backend collection linked to this object.
- */
- BackendCollection *backendCollection() const;
+ /**
+ * Constructor.
+ *
+ * @param collection Backend collection object
+ * @param service Parent service
+ */
+ Collection(BackendCollection *collection, Service *service);
+
+ /**
+ * Return the collection's path on the D-Bus.
+ *
+ * @return the Collection object's path
+ */
+ const QDBusObjectPath &objectPath() const;
+
+ /**
+ * Get the items stored inside this collection.
+ *
+ * @return a list of object paths of items inside the collection
+ */
+ const QList<QDBusObjectPath> &items() const;
+
+ /**
+ * Set the collection's label.
+ *
+ * @param label label to set for the collection
+ */
+ void setLabel(const QString &label);
+
+ /**
+ * Get the collection's label.
+ *
+ * @return the collection's label
+ */
+ QString label() const;
+
+ /**
+ * Check whether this collection is locked.
+ *
+ * @return true if the collection is locked, false if it is unlocked
+ */
+ bool locked() const;
+
+ /**
+ * Get the collection's creation time as a unix timestamp.
+ *
+ * @return collection's creation time
+ */
+ qulonglong created() const;
+
+ /**
+ * Get the collection's last modification time as a unix timestamp.
+ *
+ * @return collection's modification time
+ */
+ qulonglong modified() const;
+
+ /**
+ * Delete this collection.
+ *
+ * @return the object path of a Prompt object or special value "/" if the
+ * collection was deleted without prompting
+ */
+ QDBusObjectPath deleteCollection();
+
+ /**
+ * Search items inside the collection.
+ *
+ * @param attributes search attributes to match items against
+ */
+ QList<QDBusObjectPath> searchItems(const QMap<QString, QString> &attributes);
+
+ /**
+ * Create a new item inside the collection.
+ *
+ * @param properties Properties for the new item
+ * @param secret Secret for the new item
+ * @param replace if true, an existing item with the same attributes will be \
replaced, + * if false and an item with the same attributes \
exists, no new item + * will be created
+ * @param prompt object path of a prompt object if prompting is necessary or "/" \
if + * the action could be completed without a prompt
+ * @return object path of the new item or "/" if prompting is necessary
+ */
+ QDBusObjectPath createItem(const QMap<QString, QVariant> &properties,
+ const Secret &secret, bool replace, QDBusObjectPath \
&prompt); +
+ /**
+ * Get the backend collection linked to this object.
+ */
+ BackendCollection *backendCollection() const;
Q_SIGNALS:
- /**
- * Signals the creation of a new item.
- *
- * @param item object path of the item that was created
- */
- void itemCreated(const QDBusObjectPath &item);
-
- /**
- * Signals the deletion of an item.
- *
- * @param item object path of the item that was deleted
- */
- void itemDeleted(const QDBusObjectPath &item);
-
- /**
- * Signals that an item inside the collection was changed.
- *
- * @param item object path of the item that was changed
- */
- void itemChanged(const QDBusObjectPath &item);
+ /**
+ * Signals the creation of a new item.
+ *
+ * @param item object path of the item that was created
+ */
+ void itemCreated(const QDBusObjectPath &item);
+
+ /**
+ * Signals the deletion of an item.
+ *
+ * @param item object path of the item that was deleted
+ */
+ void itemDeleted(const QDBusObjectPath &item);
+
+ /**
+ * Signals that an item inside the collection was changed.
+ *
+ * @param item object path of the item that was changed
+ */
+ void itemChanged(const QDBusObjectPath &item);
private Q_SLOTS:
- // handle itemCreated() calls from a backend collection
- void slotItemCreated(BackendItem *item);
- // handle itemDeleted() calls from a backend collection
- void slotItemDeleted(BackendItem *item);
- // handle itemChanged() calls from a backend collection
- void slotItemChanged(BackendItem *item);
-
+ // handle itemCreated() calls from a backend collection
+ void slotItemCreated(BackendItem *item);
+ // handle itemDeleted() calls from a backend collection
+ void slotItemDeleted(BackendItem *item);
+ // handle itemChanged() calls from a backend collection
+ void slotItemChanged(BackendItem *item);
+
private:
- Service *m_service; // parent service
- BackendCollection *m_collection;
- QDBusObjectPath m_objectPath;
- QList<QDBusObjectPath> m_items; // cache for items' object paths
+ Service *m_service; // parent service
+ BackendCollection *m_collection;
+ QDBusObjectPath m_objectPath;
+ QList<QDBusObjectPath> m_items; // cache for items' object paths
};
#endif
diff --git a/frontend/secret/item.cpp b/frontend/secret/item.cpp
index c644bba..89bedbc 100644
--- a/frontend/secret/item.cpp
+++ b/frontend/secret/item.cpp
@@ -30,7 +30,7 @@
#include <QtDBus/QDBusConnection>
Item::Item(BackendItem *item, Collection *collection)
- : QObject(collection), m_item(item)
+ : QObject(collection), m_item(item)
{
Q_ASSERT(item);
m_objectPath.setPath(collection->objectPath().path() + "/" + item->id());
@@ -41,131 +41,131 @@ Item::Item(BackendItem *item, Collection *collection)
const QDBusObjectPath &Item::objectPath() const
{
- return m_objectPath;
+ return m_objectPath;
}
bool Item::locked() const
{
- return m_item->isLocked();
+ return m_item->isLocked();
}
void Item::setAttributes(const QMap<QString, QString> &attributes)
{
- BackendReturn<void> rc = m_item->setAttributes(attributes);
- if (rc.isError()) {
- // TODO: set D-Bus error
- }
+ BackendReturn<void> rc = m_item->setAttributes(attributes);
+ if(rc.isError()) {
+ // TODO: set D-Bus error
+ }
}
QMap<QString, QString> Item::attributes() const
{
- BackendReturn<QMap<QString, QString> > rc = m_item->attributes();
- if (rc.isError()) {
- // TODO: set D-Bus error
- }
- return rc.value();
+ BackendReturn<QMap<QString, QString> > rc = m_item->attributes();
+ if(rc.isError()) {
+ // TODO: set D-Bus error
+ }
+ return rc.value();
}
void Item::setLabel(const QString &label)
{
- BackendReturn<void> rc = m_item->setLabel(label);
- if (rc.isError()) {
- // TODO: set D-Bus error
- }
+ BackendReturn<void> rc = m_item->setLabel(label);
+ if(rc.isError()) {
+ // TODO: set D-Bus error
+ }
}
QString Item::label() const
{
- BackendReturn<QString> rc = m_item->label();
- if (rc.isError()) {
- // TODO: set D-Bus error
- }
- return rc.value();
+ BackendReturn<QString> rc = m_item->label();
+ if(rc.isError()) {
+ // TODO: set D-Bus error
+ }
+ return rc.value();
}
qulonglong Item::created() const
{
- return m_item->created().toTime_t();
+ return m_item->created().toTime_t();
}
qulonglong Item::modified() const
{
- return m_item->modified().toTime_t();
+ return m_item->modified().toTime_t();
}
QDBusObjectPath Item::deleteItem()
{
- ItemDeleteInfo deleteInfo( getCallingPeer() );
- DeleteItemJob *dij = m_item->createDeleteJob( deleteInfo );
- if (dij->isImmediate()) {
- dij->exec();
- return QDBusObjectPath("/");
- } else {
- // FIXME: needs the service!
- SingleJobPrompt *p = new SingleJobPrompt(0, dij, this);
- return p->objectPath();
- }
+ ItemDeleteInfo deleteInfo(getCallingPeer());
+ DeleteItemJob *dij = m_item->createDeleteJob(deleteInfo);
+ if(dij->isImmediate()) {
+ dij->exec();
+ return QDBusObjectPath("/");
+ } else {
+ // FIXME: needs the service!
+ SingleJobPrompt *p = new SingleJobPrompt(0, dij, this);
+ return p->objectPath();
+ }
}
Secret Item::getSecret(const QDBusObjectPath &session)
{
- if (m_item->isLocked()) {
- // TODO: error, requires unlocking
- return Secret();
- }
-
- QObject *object = \
QDBusConnection::sessionBus().objectRegisteredAt(session.path());
- Session *sessionObj;
- if (object && (sessionObj = qobject_cast<Session*>(object))) {
- BackendReturn<QCA::SecureArray> br = m_item->secret();
- if (br.isError()) {
- // TODO: handle error
- return Secret();
- }
- bool ok;
- Secret secret = sessionObj->encrypt(br.value(), ok);
- if (br.isError()) {
- // TODO: error, invalid session
- return Secret();
- }
- return secret;
- } else {
- // TODO: error, requires session
- return Secret();
- }
+ if(m_item->isLocked()) {
+ // TODO: error, requires unlocking
+ return Secret();
+ }
+
+ QObject *object = \
QDBusConnection::sessionBus().objectRegisteredAt(session.path()); + Session \
*sessionObj; + if(object && (sessionObj = qobject_cast<Session*>(object))) {
+ BackendReturn<QCA::SecureArray> br = m_item->secret();
+ if(br.isError()) {
+ // TODO: handle error
+ return Secret();
+ }
+ bool ok;
+ Secret secret = sessionObj->encrypt(br.value(), ok);
+ if(br.isError()) {
+ // TODO: error, invalid session
+ return Secret();
+ }
+ return secret;
+ } else {
+ // TODO: error, requires session
+ return Secret();
+ }
}
void Item::setSecret(const Secret &secret)
{
- if (m_item->isLocked()) {
- // TODO: error, requires unlocking
- return;
- }
-
- QObject *object = \
QDBusConnection::sessionBus().objectRegisteredAt(secret.session().path());
- Session *sessionObj;
- if (object && (sessionObj = qobject_cast<Session*>(object))) {
- bool ok;
- BackendReturn<QCA::SecureArray> br = sessionObj->decrypt(secret, ok);
- if (!ok) {
- // TODO: invalid session
- return;
- }
- BackendReturn<void> rc = m_item->setSecret(br.value());
- if (rc.isError()) {
- // TODO: handle error
- return;
- }
- }
-
- // TODO: error, invalid session
-
- return;
+ if(m_item->isLocked()) {
+ // TODO: error, requires unlocking
+ return;
+ }
+
+ QObject *object = \
QDBusConnection::sessionBus().objectRegisteredAt(secret.session().path()); + \
Session *sessionObj; + if(object && (sessionObj = qobject_cast<Session*>(object))) \
{ + bool ok;
+ BackendReturn<QCA::SecureArray> br = sessionObj->decrypt(secret, ok);
+ if(!ok) {
+ // TODO: invalid session
+ return;
+ }
+ BackendReturn<void> rc = m_item->setSecret(br.value());
+ if(rc.isError()) {
+ // TODO: handle error
+ return;
+ }
+ }
+
+ // TODO: error, invalid session
+
+ return;
}
BackendItem *Item::backendItem() const
{
- return m_item;
+ return m_item;
}
#include "item.moc"
diff --git a/frontend/secret/item.h b/frontend/secret/item.h
index 1e1f116..c7d75fd 100644
--- a/frontend/secret/item.h
+++ b/frontend/secret/item.h
@@ -29,117 +29,117 @@
class BackendItem;
class Collection;
-
+
/**
* Represents an item on the D-Bus implementing the org.freedesktop.Secret.Item
* interface.
*/
class Item : public QObject, protected KSecretDBusContext
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructor.
- *
- * @param item Backend item object
- * @param collection Parent collection
- */
- Item(BackendItem *item, Collection *collection);
-
- /**
- * Return the item's path on the D-Bus.
- *
- * @return the Item object's path
- */
- const QDBusObjectPath &objectPath() const;
+ /**
+ * Constructor.
+ *
+ * @param item Backend item object
+ * @param collection Parent collection
+ */
+ Item(BackendItem *item, Collection *collection);
+
+ /**
+ * Return the item's path on the D-Bus.
+ *
+ * @return the Item object's path
+ */
+ const QDBusObjectPath &objectPath() const;
public: // called by D-Bus adaptors
-
- /**
- * Check whether this item is locked.
- *
- * @return true if the item is locked, false if it is unlocked
- */
- bool locked() const;
-
- /**
- * Set the item's attributes.
- *
- * @param attributes the attributes to set for the item
- */
- void setAttributes(const QMap<QString, QString> &attributes);
-
- /**
- * Get the item's attributes.
- *
- * @return the attributes stored for this item
- */
- QMap<QString, QString> attributes() const;
-
- /**
- * Set the item's human-readable label.
- *
- * @param label label to assign to this item
- */
- void setLabel(const QString &label);
-
- /**
- * Get the human-readable label assigned to this item.
- *
- * @return the item assigned to this item
- */
- QString label() const;
-
- /**
- * Retrieve the item's time of creation as a unix timestamp.
- *
- * @return item's time of creation
- */
- qulonglong created() const;
-
- /**
- * Retrieve the item's last modification date as a unix timestamp.
- *
- * @return item's last time of modification
- */
- qulonglong modified() const;
-
- /**
- * Delete the item from the collection it's in.
- *
- * @return the object path of a prompt object for the operation or "/" if the
- * item was deleted without a prompt.
- */
- QDBusObjectPath deleteItem();
-
- /**
- * Get the secret stored withing the item.
- *
- * @param session Session to use for securing the D-Bus transport
- * @return the (possibly encrypted) Secret structure
- */
- Secret getSecret(const QDBusObjectPath &session);
-
- /**
- * Set the secret stored within the item.
- *
- * @param secret Secret to store inside the item
- */
- void setSecret(const Secret &secret);
+
+ /**
+ * Check whether this item is locked.
+ *
+ * @return true if the item is locked, false if it is unlocked
+ */
+ bool locked() const;
+
+ /**
+ * Set the item's attributes.
+ *
+ * @param attributes the attributes to set for the item
+ */
+ void setAttributes(const QMap<QString, QString> &attributes);
+
+ /**
+ * Get the item's attributes.
+ *
+ * @return the attributes stored for this item
+ */
+ QMap<QString, QString> attributes() const;
+
+ /**
+ * Set the item's human-readable label.
+ *
+ * @param label label to assign to this item
+ */
+ void setLabel(const QString &label);
+
+ /**
+ * Get the human-readable label assigned to this item.
+ *
+ * @return the item assigned to this item
+ */
+ QString label() const;
+
+ /**
+ * Retrieve the item's time of creation as a unix timestamp.
+ *
+ * @return item's time of creation
+ */
+ qulonglong created() const;
+
+ /**
+ * Retrieve the item's last modification date as a unix timestamp.
+ *
+ * @return item's last time of modification
+ */
+ qulonglong modified() const;
+
+ /**
+ * Delete the item from the collection it's in.
+ *
+ * @return the object path of a prompt object for the operation or "/" if the
+ * item was deleted without a prompt.
+ */
+ QDBusObjectPath deleteItem();
+
+ /**
+ * Get the secret stored withing the item.
+ *
+ * @param session Session to use for securing the D-Bus transport
+ * @return the (possibly encrypted) Secret structure
+ */
+ Secret getSecret(const QDBusObjectPath &session);
+
+ /**
+ * Set the secret stored within the item.
+ *
+ * @param secret Secret to store inside the item
+ */
+ void setSecret(const Secret &secret);
public:
- /**
- * Get the backend item associated with this frontend item.
- *
- * @return the backend item belonging to this frontend item
- * @remarks called by other frontend objects
- */
- BackendItem *backendItem() const;
+ /**
+ * Get the backend item associated with this frontend item.
+ *
+ * @return the backend item belonging to this frontend item
+ * @remarks called by other frontend objects
+ */
+ BackendItem *backendItem() const;
private:
- BackendItem *m_item;
- QDBusObjectPath m_objectPath;
+ BackendItem *m_item;
+ QDBusObjectPath m_objectPath;
};
#endif
diff --git a/frontend/secret/ksecretdbuscontext.cpp \
b/frontend/secret/ksecretdbuscontext.cpp index b8a24c5..b2fb620 100644
--- a/frontend/secret/ksecretdbuscontext.cpp
+++ b/frontend/secret/ksecretdbuscontext.cpp
@@ -28,12 +28,12 @@
Peer KSecretDBusContext::getCallingPeer() const
{
- if (calledFromDBus()) {
- QString msgService = message().service();
- uint pid = connection().interface()->servicePid(msgService);
- return Peer(pid);
- // TODO: add syslog entry ?
- } else {
- return Peer();
- }
+ if(calledFromDBus()) {
+ QString msgService = message().service();
+ uint pid = connection().interface()->servicePid(msgService);
+ return Peer(pid);
+ // TODO: add syslog entry ?
+ } else {
+ return Peer();
+ }
}
diff --git a/frontend/secret/ksecretdbuscontext.h \
b/frontend/secret/ksecretdbuscontext.h index f484521..028a3a5 100644
--- a/frontend/secret/ksecretdbuscontext.h
+++ b/frontend/secret/ksecretdbuscontext.h
@@ -33,17 +33,19 @@ class Peer;
class KSecretDBusContext : public QDBusContext
{
public:
- /**
- * The default constructor of this class does nothing
- */
- KSecretDBusContext() { /* nothing to do */ }
+ /**
+ * The default constructor of this class does nothing
+ */
+ KSecretDBusContext() {
+ /* nothing to do */
+ }
- /**
- * Get information about the calling peer
- * @return peer information or an invalid peer if the D-Bus context is not \
available,
- * e.g. when the service method was not called accross D-Bus.
- */
- Peer getCallingPeer() const;
+ /**
+ * Get information about the calling peer
+ * @return peer information or an invalid peer if the D-Bus context is not \
available, + * e.g. when the service method was not called accross D-Bus.
+ */
+ Peer getCallingPeer() const;
};
#endif // KSECRETDEBUSCONTEXT_H
diff --git a/frontend/secret/prompt.cpp b/frontend/secret/prompt.cpp
index 66c1b76..75003f2 100644
--- a/frontend/secret/prompt.cpp
+++ b/frontend/secret/prompt.cpp
@@ -30,13 +30,13 @@
#include <QtDBus/QDBusObjectPath>
PromptBase::PromptBase(Service *service, QObject *parent)
- : QObject(parent), m_serviceObjectPath(service->objectPath())
+ : QObject(parent), m_serviceObjectPath(service->objectPath())
{
- Q_ASSERT(service);
- m_objectPath.setPath(service->objectPath().path() + "/prompts/" + createId());
+ Q_ASSERT(service);
+ m_objectPath.setPath(service->objectPath().path() + "/prompts/" + createId());
- new orgFreedesktopSecret::PromptAdaptor(this);
- QDBusConnection::sessionBus().registerObject(m_objectPath.path(), this);
+ new orgFreedesktopSecret::PromptAdaptor(this);
+ QDBusConnection::sessionBus().registerObject(m_objectPath.path(), this);
}
PromptBase::~PromptBase()
@@ -45,269 +45,261 @@ PromptBase::~PromptBase()
const QDBusObjectPath &PromptBase::objectPath() const
{
- return m_objectPath;
+ return m_objectPath;
}
const QDBusObjectPath &PromptBase::serviceObjectPath() const
{
- return m_serviceObjectPath;
+ return m_serviceObjectPath;
}
void PromptBase::emitCompleted(bool dismissed, const QVariant &result)
{
- emit completed(dismissed, result);
+ emit completed(dismissed, result);
}
SingleJobPrompt::SingleJobPrompt(Service* service, BackendJob* job, QObject* parent)
- : PromptBase(service, parent), m_prompted(false), m_job(job)
+ : PromptBase(service, parent), m_prompted(false), m_job(job)
{
- connect(job, SIGNAL(result(QueuedJob*)), SLOT(jobResult(QueuedJob*)));
+ connect(job, SIGNAL(result(QueuedJob*)), SLOT(jobResult(QueuedJob*)));
}
SingleJobPrompt::~SingleJobPrompt()
{
- // TODO: delete the job?
+ // TODO: delete the job?
}
void SingleJobPrompt::prompt(const QString &windowId)
{
- Q_UNUSED(windowId);
- if (m_prompted) {
- return;
- }
- m_prompted = true;
-
- // TODO: convert windowId to a WId and pass it to the job
- m_job->enqueue();
+ Q_UNUSED(windowId);
+ if(m_prompted) {
+ return;
+ }
+ m_prompted = true;
+
+ // TODO: convert windowId to a WId and pass it to the job
+ m_job->enqueue();
}
void SingleJobPrompt::dismiss()
{
- if (m_prompted) {
- return;
- }
- m_prompted = true;
+ if(m_prompted) {
+ return;
+ }
+ m_prompted = true;
- m_job->dismiss();
+ m_job->dismiss();
}
void SingleJobPrompt::jobResult(QueuedJob *job)
{
- Q_ASSERT(job == m_job);
- // check for errors first
- if (m_job->isDismissed()) {
- emit completed(true, QVariant(""));
- } else if (m_job->error() != NoError) {
- // TODO: figure out how to handle errors gracefully.
- emit completed(false, QVariant(""));
- } else {
- switch (m_job->type()) {
-
- case BackendJob::TypeUnlockCollection:
- case BackendJob::TypeLockCollection:
- case BackendJob::TypeDeleteCollection:
- case BackendJob::TypeChangeAuthenticationCollection:
- case BackendJob::TypeDeleteItem:
- case BackendJob::TypeLockItem:
- case BackendJob::TypeUnlockItem:
- case BackendJob::TypeChangeAuthenticationItem:
- {
+ Q_ASSERT(job == m_job);
+ // check for errors first
+ if(m_job->isDismissed()) {
+ emit completed(true, QVariant(""));
+ } else if(m_job->error() != NoError) {
+ // TODO: figure out how to handle errors gracefully.
+ emit completed(false, QVariant(""));
+ } else {
+ switch(m_job->type()) {
+
+ case BackendJob::TypeUnlockCollection:
+ case BackendJob::TypeLockCollection:
+ case BackendJob::TypeDeleteCollection:
+ case BackendJob::TypeChangeAuthenticationCollection:
+ case BackendJob::TypeDeleteItem:
+ case BackendJob::TypeLockItem:
+ case BackendJob::TypeUnlockItem:
+ case BackendJob::TypeChangeAuthenticationItem: {
BooleanResultJob *brj = qobject_cast<BooleanResultJob*>(m_job);
Q_ASSERT(brj);
emitCompleted(false, QVariant(brj->result()));
- }
- break;
-
- case BackendJob::TypeCreateCollectionMaster:
- {
+ }
+ break;
+
+ case BackendJob::TypeCreateCollectionMaster: {
CreateCollectionMasterJob *ccmj = \
qobject_cast<CreateCollectionMasterJob*>(m_job); Q_ASSERT(ccmj);
QDBusObjectPath result("/");
- if (ccmj->collection()) {
- BackendCollection *coll = ccmj->collection();
- result.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id()); + if(ccmj->collection()) {
+ BackendCollection *coll = ccmj->collection();
+ result.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id()); }
-
+
emitCompleted(false, qVariantFromValue(result));
- }
- break;
-
- case BackendJob::TypeCreateCollection:
- {
+ }
+ break;
+
+ case BackendJob::TypeCreateCollection: {
CreateCollectionJob *ccj = qobject_cast<CreateCollectionJob*>(m_job);
Q_ASSERT(ccj);
QDBusObjectPath result("/");
- if (ccj->collection()) {
- BackendCollection *coll = ccj->collection();
- result.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id()); + if(ccj->collection()) {
+ BackendCollection *coll = ccj->collection();
+ result.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id()); }
-
+
emitCompleted(false, qVariantFromValue(result));
- }
- break;
-
- case BackendJob::TypeCreateItem:
- {
+ }
+ break;
+
+ case BackendJob::TypeCreateItem: {
CreateItemJob *cij = qobject_cast<CreateItemJob*>(m_job);
Q_ASSERT(cij);
QDBusObjectPath result("/");
- if (cij->item()) {
- BackendItem *item = cij->item();
- result.setPath(serviceObjectPath().path() + "/collection/" +
- cij->collection()->id() + "/" + item->id());
+ if(cij->item()) {
+ BackendItem *item = cij->item();
+ result.setPath(serviceObjectPath().path() + "/collection/" +
+ cij->collection()->id() + "/" + item->id());
}
-
+
emitCompleted(false, qVariantFromValue(result));
- }
- break;
-
- default:
- // should not happen!
- Q_ASSERT(false);
- }
- }
-
- deleteLater();
+ }
+ break;
+
+ default:
+ // should not happen!
+ Q_ASSERT(false);
+ }
+ }
+
+ deleteLater();
}
ServiceMultiPrompt::ServiceMultiPrompt(Service *service, const QSet<BackendJob*> \
jobs,
- QObject *parent)
- : PromptBase(service, parent), m_prompted(false), m_jobs(jobs)
+ QObject *parent)
+ : PromptBase(service, parent), m_prompted(false), m_jobs(jobs)
{
- bool jobTypeDetermined = false;
- bool jobTypeUnlock = false;
-
- Q_FOREACH(BackendJob *job, m_jobs) {
- // make sure the subjobs are either all unlock or all lock calls
- bool currentJobTypeUnlock = (job->type() == BackendJob::TypeUnlockCollection \
||
- job->type() == BackendJob::TypeUnlockItem);
- if (jobTypeDetermined && jobTypeUnlock != currentJobTypeUnlock) {
- Q_ASSERT(false);
- } else if (!jobTypeDetermined) {
- jobTypeUnlock = currentJobTypeUnlock;
- jobTypeDetermined = true;
- }
- connect(job, SIGNAL(result(QueuedJob*)), SLOT(jobResult(QueuedJob*)));
- }
+ bool jobTypeDetermined = false;
+ bool jobTypeUnlock = false;
+
+ Q_FOREACH(BackendJob * job, m_jobs) {
+ // make sure the subjobs are either all unlock or all lock calls
+ bool currentJobTypeUnlock = (job->type() == BackendJob::TypeUnlockCollection \
|| + job->type() == BackendJob::TypeUnlockItem);
+ if(jobTypeDetermined && jobTypeUnlock != currentJobTypeUnlock) {
+ Q_ASSERT(false);
+ } else if(!jobTypeDetermined) {
+ jobTypeUnlock = currentJobTypeUnlock;
+ jobTypeDetermined = true;
+ }
+ connect(job, SIGNAL(result(QueuedJob*)), SLOT(jobResult(QueuedJob*)));
+ }
}
ServiceMultiPrompt::~ServiceMultiPrompt()
{
- // TODO: delete jobs if not started?
+ // TODO: delete jobs if not started?
}
void ServiceMultiPrompt::prompt(const QString &windowId)
{
- Q_UNUSED(windowId);
- if (m_prompted) {
- return;
- }
- m_prompted = true;
-
- // TODO: convert windowId to a WId and pass it to the job
- Q_FOREACH(BackendJob *job, m_jobs) {
- job->enqueue();
- }
+ Q_UNUSED(windowId);
+ if(m_prompted) {
+ return;
+ }
+ m_prompted = true;
+
+ // TODO: convert windowId to a WId and pass it to the job
+ Q_FOREACH(BackendJob * job, m_jobs) {
+ job->enqueue();
+ }
}
void ServiceMultiPrompt::dismiss()
{
- if (m_prompted) {
- return;
- }
- m_prompted = true;
-
- Q_FOREACH(BackendJob *job, m_jobs) {
- disconnect(job, SIGNAL(result(QueuedJob*)), this, \
SLOT(jobResult(QueuedJob*)));
- job->dismiss();
- }
-
- // emit result right away so we don't have to catch all result() signals
- // from individual jobs.
- emitCompleted(true, qVariantFromValue(QList<QDBusObjectPath>()));
- deleteLater();
+ if(m_prompted) {
+ return;
+ }
+ m_prompted = true;
+
+ Q_FOREACH(BackendJob * job, m_jobs) {
+ disconnect(job, SIGNAL(result(QueuedJob*)), this, \
SLOT(jobResult(QueuedJob*))); + job->dismiss();
+ }
+
+ // emit result right away so we don't have to catch all result() signals
+ // from individual jobs.
+ emitCompleted(true, qVariantFromValue(QList<QDBusObjectPath>()));
+ deleteLater();
}
void ServiceMultiPrompt::jobResult(QueuedJob *job)
{
- BackendJob *bj = qobject_cast<BackendJob*>(job);
- Q_ASSERT(bj);
- Q_ASSERT(m_jobs.contains(bj));
- // remove job from the set of jobs we're waiting for
- m_jobs.remove(bj);
- if (bj->error() != NoError) {
- // TODO: figure out what to do with erroneous jobs
- } else {
- switch (bj->type()) {
-
- case BackendJob::TypeUnlockCollection:
- {
+ BackendJob *bj = qobject_cast<BackendJob*>(job);
+ Q_ASSERT(bj);
+ Q_ASSERT(m_jobs.contains(bj));
+ // remove job from the set of jobs we're waiting for
+ m_jobs.remove(bj);
+ if(bj->error() != NoError) {
+ // TODO: figure out what to do with erroneous jobs
+ } else {
+ switch(bj->type()) {
+
+ case BackendJob::TypeUnlockCollection: {
UnlockCollectionJob *ucj = qobject_cast<UnlockCollectionJob*>(bj);
Q_ASSERT(ucj);
- if (ucj->result()) {
- BackendCollection *coll = ucj->collection();
- QDBusObjectPath path;
- path.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id());
- m_result.append(path);
+ if(ucj->result()) {
+ BackendCollection *coll = ucj->collection();
+ QDBusObjectPath path;
+ path.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id()); + m_result.append(path);
}
- }
- break;
+ }
+ break;
- case BackendJob::TypeLockCollection:
- {
+ case BackendJob::TypeLockCollection: {
LockCollectionJob *lcj = qobject_cast<LockCollectionJob*>(bj);
Q_ASSERT(lcj);
- if (lcj->result()) {
- BackendCollection *coll = lcj->collection();
- QDBusObjectPath path;
- path.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id());
- m_result.append(path);
+ if(lcj->result()) {
+ BackendCollection *coll = lcj->collection();
+ QDBusObjectPath path;
+ path.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id()); + m_result.append(path);
}
- }
- break;
-
- case BackendJob::TypeUnlockItem:
- {
+ }
+ break;
+
+ case BackendJob::TypeUnlockItem: {
UnlockItemJob *uij = qobject_cast<UnlockItemJob*>(bj);
Q_ASSERT(uij);
- if (uij->result()) {
- BackendItem *item = uij->item();
- BackendCollection *coll = 0;
- // TODO: I NEED THE COLLECTION DAMMIT
- QDBusObjectPath path;
- path.setPath(serviceObjectPath().path() + "/collection/" + coll->id() \
+
- "/" + item->id());
- m_result.append(path);
+ if(uij->result()) {
+ BackendItem *item = uij->item();
+ BackendCollection *coll = 0;
+ // TODO: I NEED THE COLLECTION DAMMIT
+ QDBusObjectPath path;
+ path.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id() + + "/" + item->id());
+ m_result.append(path);
}
- }
- break;
+ }
+ break;
- case BackendJob::TypeLockItem:
- {
+ case BackendJob::TypeLockItem: {
LockItemJob *lij = qobject_cast<LockItemJob*>(bj);
Q_ASSERT(lij);
- if (lij->result()) {
- BackendItem *item = lij->item();
- BackendCollection *coll = 0;
- // TODO: I NEED THE COLLECTION DAMMIT
- QDBusObjectPath path;
- path.setPath(serviceObjectPath().path() + "/collection/" + coll->id() \
+
- "/" + item->id());
- m_result.append(path);
+ if(lij->result()) {
+ BackendItem *item = lij->item();
+ BackendCollection *coll = 0;
+ // TODO: I NEED THE COLLECTION DAMMIT
+ QDBusObjectPath path;
+ path.setPath(serviceObjectPath().path() + "/collection/" + \
coll->id() + + "/" + item->id());
+ m_result.append(path);
}
- }
- break;
-
- default:
- Q_ASSERT(false);
- }
- }
-
- if (m_jobs.isEmpty()) {
- // all jobs finished
- emitCompleted(false, qVariantFromValue(m_result));
- deleteLater();
- }
+ }
+ break;
+
+ default:
+ Q_ASSERT(false);
+ }
+ }
+
+ if(m_jobs.isEmpty()) {
+ // all jobs finished
+ emitCompleted(false, qVariantFromValue(m_result));
+ deleteLater();
+ }
}
#include "prompt.moc"
diff --git a/frontend/secret/prompt.h b/frontend/secret/prompt.h
index c39a986..995eeac 100644
--- a/frontend/secret/prompt.h
+++ b/frontend/secret/prompt.h
@@ -37,71 +37,71 @@ class Service;
*/
class PromptBase : public QObject, protected KSecretDBusContext
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param service Service object (used to derive the object path of the prompt)
- * @param job the job encapsulated by the prompt
- * @param parent Parent object
- */
- PromptBase(Service *service, QObject *parent);
-
- /**
- * Destructor.
- */
- virtual ~PromptBase();
-
- /**
- * Return the prompt's path on the D-Bus.
- *
- * @return the Prompt object's path
- */
- const QDBusObjectPath &objectPath() const;
-
- /**
- * Return the service object's path on the D-Bus.
- *
- * @return the Service object's path
- */
- const QDBusObjectPath &serviceObjectPath() const;
-
- /**
- * Perform the prompt.
- *
- * @param windowId Platform specific window handle to use for showing the prompt
- * @todo implement window handle handling
- */
- virtual void prompt(const QString &windowId) = 0;
-
- /**
- * Dismiss the prompt.
- */
- virtual void dismiss() = 0;
-
+ /**
+ * Constructor.
+ *
+ * @param service Service object (used to derive the object path of the prompt)
+ * @param job the job encapsulated by the prompt
+ * @param parent Parent object
+ */
+ PromptBase(Service *service, QObject *parent);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PromptBase();
+
+ /**
+ * Return the prompt's path on the D-Bus.
+ *
+ * @return the Prompt object's path
+ */
+ const QDBusObjectPath &objectPath() const;
+
+ /**
+ * Return the service object's path on the D-Bus.
+ *
+ * @return the Service object's path
+ */
+ const QDBusObjectPath &serviceObjectPath() const;
+
+ /**
+ * Perform the prompt.
+ *
+ * @param windowId Platform specific window handle to use for showing the prompt
+ * @todo implement window handle handling
+ */
+ virtual void prompt(const QString &windowId) = 0;
+
+ /**
+ * Dismiss the prompt.
+ */
+ virtual void dismiss() = 0;
+
Q_SIGNALS:
- /**
- * Emitted when the operation performed by the prompt was completed
- *
- * @param dismissed if true the prompt was dismissed, if false it was completed
- * @param result result of the operation encapulated by the prompt object
- */
- void completed(bool dismissed, QVariant result);
-
+ /**
+ * Emitted when the operation performed by the prompt was completed
+ *
+ * @param dismissed if true the prompt was dismissed, if false it was completed
+ * @param result result of the operation encapulated by the prompt object
+ */
+ void completed(bool dismissed, QVariant result);
+
protected:
- /**
- * Used to emit completed() signals in derived classes.
- *
- * @param dismissed if true the prompt was dismissed, if false it was completed
- * @param result result of the operation encapsulated by the prompt object
- */
- void emitCompleted(bool dismissed, const QVariant &result);
-
+ /**
+ * Used to emit completed() signals in derived classes.
+ *
+ * @param dismissed if true the prompt was dismissed, if false it was completed
+ * @param result result of the operation encapsulated by the prompt object
+ */
+ void emitCompleted(bool dismissed, const QVariant &result);
+
private:
- QDBusObjectPath m_objectPath; // the prompt object's objectpath
- QDBusObjectPath m_serviceObjectPath; // the service's objectpath
+ QDBusObjectPath m_objectPath; // the prompt object's objectpath
+ QDBusObjectPath m_serviceObjectPath; // the service's objectpath
};
/**
@@ -109,48 +109,48 @@ private:
*/
class SingleJobPrompt : public PromptBase
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param service Service object (used to derive the object path of the prompt)
- * @param job the job encapsulated by the prompt
- * @param parent Parent object
- */
- SingleJobPrompt(Service *service, BackendJob *job, QObject *parent = 0);
-
- /**
- * Destructor.
- */
- virtual ~SingleJobPrompt();
-
- /**
- * Perform the prompt.
- *
- * @param windowId Platform specific window handle to use for showing the prompt
- * @todo implement window handle handling
- */
- virtual void prompt(const QString &windowId);
-
- /**
- * Dismiss the prompt.
- */
- virtual void dismiss();
-
+ /**
+ * Constructor.
+ *
+ * @param service Service object (used to derive the object path of the prompt)
+ * @param job the job encapsulated by the prompt
+ * @param parent Parent object
+ */
+ SingleJobPrompt(Service *service, BackendJob *job, QObject *parent = 0);
+
+ /**
+ * Destructor.
+ */
+ virtual ~SingleJobPrompt();
+
+ /**
+ * Perform the prompt.
+ *
+ * @param windowId Platform specific window handle to use for showing the prompt
+ * @todo implement window handle handling
+ */
+ virtual void prompt(const QString &windowId);
+
+ /**
+ * Dismiss the prompt.
+ */
+ virtual void dismiss();
+
private Q_SLOTS:
- /**
- * Connected to the backend job's result() signal this notifies about
- * the job's completion.
- *
- * @param job the job that finished
- */
- void jobResult(QueuedJob *job);
+ /**
+ * Connected to the backend job's result() signal this notifies about
+ * the job's completion.
+ *
+ * @param job the job that finished
+ */
+ void jobResult(QueuedJob *job);
private:
- bool m_prompted; // true if one of the prompt()/dismiss() methods has been called \
already
- BackendJob *m_job; // the encapulated job
+ bool m_prompted; // true if one of the prompt()/dismiss() methods has been \
called already + BackendJob *m_job; // the encapulated job
};
/**
@@ -158,49 +158,49 @@ private:
*/
class ServiceMultiPrompt : public PromptBase
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param service Service object (used to derive the object path of the prompt)
- * @param jobs the unlock jobs to encapsulate
- * @param parent parent object
- */
- ServiceMultiPrompt(Service *service, const QSet<BackendJob*> jobs, QObject \
*parent = 0);
-
- /**
- * Destructor.
- */
- virtual ~ServiceMultiPrompt();
-
- /**
- * Perform the prompt.
- *
- * @pararm windowId Platform specific window handle to use for showing the prompt
- * @todo implement window handling
- */
- virtual void prompt(const QString &windowId);
-
- /**
- * Dismiss this prompt.
- */
- virtual void dismiss();
-
+ /**
+ * Constructor.
+ *
+ * @param service Service object (used to derive the object path of the prompt)
+ * @param jobs the unlock jobs to encapsulate
+ * @param parent parent object
+ */
+ ServiceMultiPrompt(Service *service, const QSet<BackendJob*> jobs, QObject \
*parent = 0); +
+ /**
+ * Destructor.
+ */
+ virtual ~ServiceMultiPrompt();
+
+ /**
+ * Perform the prompt.
+ *
+ * @pararm windowId Platform specific window handle to use for showing the \
prompt + * @todo implement window handling
+ */
+ virtual void prompt(const QString &windowId);
+
+ /**
+ * Dismiss this prompt.
+ */
+ virtual void dismiss();
+
private Q_SLOTS:
- /**
- * Connected to the backend jobs' result() signals this notifies about a
- * job's completion.
- *
- * @param job the job that finished
- */
- void jobResult(QueuedJob *job);
-
+ /**
+ * Connected to the backend jobs' result() signals this notifies about a
+ * job's completion.
+ *
+ * @param job the job that finished
+ */
+ void jobResult(QueuedJob *job);
+
private:
- bool m_prompted; // true if one of the prompt()/dismiss() methods has been called \
already
- QList<QDBusObjectPath> m_result; // resulting unlocked/locked object paths
- QSet<BackendJob*> m_jobs; // encapsulated jobs
+ bool m_prompted; // true if one of the prompt()/dismiss() methods has been \
called already + QList<QDBusObjectPath> m_result; // resulting unlocked/locked \
object paths + QSet<BackendJob*> m_jobs; // encapsulated jobs
};
#endif
diff --git a/frontend/secret/secret.cpp b/frontend/secret/secret.cpp
index 6639f90..f7c1b03 100644
--- a/frontend/secret/secret.cpp
+++ b/frontend/secret/secret.cpp
@@ -36,57 +36,57 @@ Secret::~Secret()
void Secret::setSession(const QDBusObjectPath &session)
{
- d->m_session = session;
+ d->m_session = session;
}
const QDBusObjectPath &Secret::session() const
{
- return d->m_session;
+ return d->m_session;
}
void Secret::setParameters(const QByteArray ¶meters)
{
- d->m_parameters = parameters;
+ d->m_parameters = parameters;
}
const QByteArray &Secret::parameters() const
{
- return d->m_parameters;
+ return d->m_parameters;
}
void Secret::setValue(const QByteArray &value)
{
- // TODO: encryption
- d->m_value = value;
+ // TODO: encryption
+ d->m_value = value;
}
const QByteArray &Secret::value() const
{
- // TODO: decryption
- return d->m_value;
+ // TODO: decryption
+ return d->m_value;
}
QDBusArgument &operator<<(QDBusArgument &argument, const Secret &secret)
{
- argument.beginStructure();
- argument << secret.session() << secret.parameters() << secret.value();
- argument.endStructure();
- return argument;
+ argument.beginStructure();
+ argument << secret.session() << secret.parameters() << secret.value();
+ argument.endStructure();
+ return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, Secret &secret)
{
- QDBusObjectPath session;
- QByteArray parameters;
- QByteArray value;
-
- argument.beginStructure();
- argument >> session >> parameters >> value;
- argument.endStructure();
-
- secret.setSession(session);
- secret.setParameters(parameters);
- secret.setValue(value);
-
- return argument;
+ QDBusObjectPath session;
+ QByteArray parameters;
+ QByteArray value;
+
+ argument.beginStructure();
+ argument >> session >> parameters >> value;
+ argument.endStructure();
+
+ secret.setSession(session);
+ secret.setParameters(parameters);
+ secret.setValue(value);
+
+ return argument;
}
diff --git a/frontend/secret/secret.h b/frontend/secret/secret.h
index 8173faf..d16f94b 100644
--- a/frontend/secret/secret.h
+++ b/frontend/secret/secret.h
@@ -35,70 +35,70 @@
*/
class Secret
{
- // TODO: this should actually be inside secret.cpp but I'm getting strange
- // errors if I put it there. investigate.
- class SecretData : public QSharedData
- {
- public:
- SecretData() {}
- SecretData(const SecretData &other)
- : QSharedData(other), m_session(other.m_session), \
m_parameters(other.m_parameters),
- m_value(other.m_value) {}
- ~SecretData() {}
- QDBusObjectPath m_session;
- QByteArray m_parameters;
- QByteArray m_value;
- };
-
+ // TODO: this should actually be inside secret.cpp but I'm getting strange
+ // errors if I put it there. investigate.
+ class SecretData : public QSharedData
+ {
+ public:
+ SecretData() {}
+ SecretData(const SecretData &other)
+ : QSharedData(other), m_session(other.m_session), \
m_parameters(other.m_parameters), + m_value(other.m_value) {}
+ ~SecretData() {}
+ QDBusObjectPath m_session;
+ QByteArray m_parameters;
+ QByteArray m_value;
+ };
+
public:
- /**
- * Constructs an empty Secret.
- */
- Secret();
-
- /**
- * Copy constructor.
- */
- Secret(const Secret &other);
-
- /**
- * Destructor.
- */
- ~Secret();
-
- /**
- * Set the session object D-Bus path.
- */
- void setSession(const QDBusObjectPath &session);
-
- /**
- * Get the session object D-Bus path.
- */
- const QDBusObjectPath &session() const;
-
- /**
- * Set the encryption parameters.
- */
- void setParameters(const QByteArray ¶meters);
-
- /**
- * Get the encryption parameters.
- */
- const QByteArray ¶meters() const;
-
- /**
- * Set the secret's encrypted value
- */
- void setValue(const QByteArray &value);
-
- /**
- * Get the secret's encrypted value
- */
- const QByteArray &value() const;
+ /**
+ * Constructs an empty Secret.
+ */
+ Secret();
+
+ /**
+ * Copy constructor.
+ */
+ Secret(const Secret &other);
+
+ /**
+ * Destructor.
+ */
+ ~Secret();
+
+ /**
+ * Set the session object D-Bus path.
+ */
+ void setSession(const QDBusObjectPath &session);
+
+ /**
+ * Get the session object D-Bus path.
+ */
+ const QDBusObjectPath &session() const;
+
+ /**
+ * Set the encryption parameters.
+ */
+ void setParameters(const QByteArray ¶meters);
+
+ /**
+ * Get the encryption parameters.
+ */
+ const QByteArray ¶meters() const;
+
+ /**
+ * Set the secret's encrypted value
+ */
+ void setValue(const QByteArray &value);
+
+ /**
+ * Get the secret's encrypted value
+ */
+ const QByteArray &value() const;
private:
- class SecretData;
- QSharedDataPointer<SecretData> d;
+ class SecretData;
+ QSharedDataPointer<SecretData> d;
};
Q_DECLARE_METATYPE(Secret)
diff --git a/frontend/secret/service.cpp b/frontend/secret/service.cpp
index d87eca1..9edbf4d 100644
--- a/frontend/secret/service.cpp
+++ b/frontend/secret/service.cpp
@@ -39,338 +39,338 @@
//#include <dbus/dbus.h>
Service::Service(BackendMaster *master, QObject *parent)
- : QObject(parent), m_master(master), m_basePath("/org/freedesktop/secrets")
+ : QObject(parent), m_master(master), m_basePath("/org/freedesktop/secrets")
{
- Q_ASSERT(master);
-
- new orgFreedesktopSecret::ServiceAdaptor(this);
- QDBusConnection::sessionBus().registerObject(m_basePath.path(), this);
+ Q_ASSERT(master);
- // TODO: make master singleton so we can get a KWallet-compatible interface
- // on top of it as well.
+ new orgFreedesktopSecret::ServiceAdaptor(this);
+ QDBusConnection::sessionBus().registerObject(m_basePath.path(), this);
- connect(m_master, SIGNAL(collectionCreated(BackendCollection*)),
- SLOT(slotCollectionCreated(BackendCollection*)));
- connect(m_master, SIGNAL(collectionDeleted(BackendCollection*)),
- SLOT(slotCollectionDeleted(BackendCollection*)));
- connect(m_master, SIGNAL(collectionChanged(BackendCollection*)),
- SLOT(slotCollectionChanged(BackendCollection*)));
+ // TODO: make master singleton so we can get a KWallet-compatible interface
+ // on top of it as well.
+
+ connect(m_master, SIGNAL(collectionCreated(BackendCollection*)),
+ SLOT(slotCollectionCreated(BackendCollection*)));
+ connect(m_master, SIGNAL(collectionDeleted(BackendCollection*)),
+ SLOT(slotCollectionDeleted(BackendCollection*)));
+ connect(m_master, SIGNAL(collectionChanged(BackendCollection*)),
+ SLOT(slotCollectionChanged(BackendCollection*)));
+
+ // TODO: add managers to master
- // TODO: add managers to master
-
}
const QDBusObjectPath &Service::objectPath() const
{
- return m_basePath;
+ return m_basePath;
}
const QList<QDBusObjectPath> &Service::collections() const
{
- return m_collections;
+ return m_collections;
}
QVariant Service::openSession(const QString &algorithm, const QVariant &input,
QDBusObjectPath &result)
{
- QVariant output;
- Session *session = Session::create(algorithm, input, output, getCallingPeer(), \
this);
- if (session) {
- result = session->objectPath();
- } else {
- result = QDBusObjectPath("/");
- if (calledFromDBus()) {
- sendErrorReply("org.freedesktop.Secret.Error.NotSupported");
- }
- }
- if (calledFromDBus()) {
- connection().connect(QLatin1String( "org.freedesktop.DBus" ),
- QLatin1String( "/org/freedesktop/DBus" ),
- QLatin1String( "org.freedesktop.DBus.Local"),
- QLatin1String( "Disconnected" ),
- this, SLOT(onDbusDisconnected( QString ) ) );
- }
-
- return output;
+ QVariant output;
+ Session *session = Session::create(algorithm, input, output, getCallingPeer(), \
this); + if(session) {
+ result = session->objectPath();
+ } else {
+ result = QDBusObjectPath("/");
+ if(calledFromDBus()) {
+ sendErrorReply("org.freedesktop.Secret.Error.NotSupported");
+ }
+ }
+ if(calledFromDBus()) {
+ connection().connect(QLatin1String("org.freedesktop.DBus"),
+ QLatin1String("/org/freedesktop/DBus"),
+ QLatin1String("org.freedesktop.DBus.Local"),
+ QLatin1String("Disconnected"),
+ this, SLOT(onDbusDisconnected(QString)));
+ }
+
+ return output;
}
-void Service::onDbusDisconnected ( QString path )
+void Service::onDbusDisconnected(QString path)
{
- kDebug() << "Disconnected " << path;
+ kDebug() << "Disconnected " << path;
}
QDBusObjectPath Service::createCollection(const QMap<QString, QVariant> &properties,
- QDBusObjectPath &prompt)
+ QDBusObjectPath &prompt)
{
- // TODO: default label
- QString label;
-
- if (properties.contains("Label")) {
- label = properties["Label"].toString();
- }
- CollectionCreateInfo createCollectionInfo( label, getCallingPeer() );
- if (properties.contains("Locked")) {
- createCollectionInfo.m_locked = properties["Locked"].toBool();
- }
-
- CreateCollectionMasterJob *job = \
m_master->createCreateCollectionMasterJob(createCollectionInfo);
- if (job->isImmediate()) {
- job->exec();
- if (job->error() != NoError || !job->collection()) {
- // TODO: error creating the collection
- return QDBusObjectPath("/");
- } else {
- BackendCollection *coll = job->collection();
- prompt.setPath("/");
- QDBusObjectPath collPath(m_basePath.path() + "/collection/" + coll->id());
- return collPath;
- }
- } else {
- PromptBase *p = new SingleJobPrompt(this, job, this);
- prompt = p->objectPath();
- return QDBusObjectPath("/");
- }
+ // TODO: default label
+ QString label;
+
+ if(properties.contains("Label")) {
+ label = properties["Label"].toString();
+ }
+ CollectionCreateInfo createCollectionInfo(label, getCallingPeer());
+ if(properties.contains("Locked")) {
+ createCollectionInfo.m_locked = properties["Locked"].toBool();
+ }
+
+ CreateCollectionMasterJob *job = \
m_master->createCreateCollectionMasterJob(createCollectionInfo); + \
if(job->isImmediate()) { + job->exec();
+ if(job->error() != NoError || !job->collection()) {
+ // TODO: error creating the collection
+ return QDBusObjectPath("/");
+ } else {
+ BackendCollection *coll = job->collection();
+ prompt.setPath("/");
+ QDBusObjectPath collPath(m_basePath.path() + "/collection/" + \
coll->id()); + return collPath;
+ }
+ } else {
+ PromptBase *p = new SingleJobPrompt(this, job, this);
+ prompt = p->objectPath();
+ return QDBusObjectPath("/");
+ }
}
QList<QDBusObjectPath> Service::searchItems(const QMap<QString, QString> \
&attributes,
- QList<QDBusObjectPath> &locked)
+ QList<QDBusObjectPath> &locked)
{
- // TODO: check if session exists
- // TODO: should this rather be implemented using Daemon::Collection?
- // TODO: should we implement ACL handling on this call ? Maybe the collection \
unlocking ACL handling may have been sufficient
- QList<QDBusObjectPath> unlocked;
- Q_FOREACH(BackendCollection* collection, m_master->collections()) {
- QString collPath = m_basePath.path() + "/collection/" + collection->id();
- BackendReturn<QList<BackendItem*> > rc = collection->searchItems(attributes);
- if (!rc.isError()) {
- QList<BackendItem*> items = rc.value();
- Q_FOREACH(BackendItem *item, items) {
- if (item->isLocked()) {
- locked.append(QDBusObjectPath(collPath + "/" + item->id()));
- } else {
- unlocked.append(QDBusObjectPath(collPath + "/" + item->id()));
+ // TODO: check if session exists
+ // TODO: should this rather be implemented using Daemon::Collection?
+ // TODO: should we implement ACL handling on this call ? Maybe the collection \
unlocking ACL handling may have been sufficient + QList<QDBusObjectPath> unlocked;
+ Q_FOREACH(BackendCollection * collection, m_master->collections()) {
+ QString collPath = m_basePath.path() + "/collection/" + collection->id();
+ BackendReturn<QList<BackendItem*> > rc = \
collection->searchItems(attributes); + if(!rc.isError()) {
+ QList<BackendItem*> items = rc.value();
+ Q_FOREACH(BackendItem * item, items) {
+ if(item->isLocked()) {
+ locked.append(QDBusObjectPath(collPath + "/" + item->id()));
+ } else {
+ unlocked.append(QDBusObjectPath(collPath + "/" + item->id()));
+ }
}
- }
- }
- }
- return unlocked;
+ }
+ }
+ return unlocked;
}
QList<QDBusObjectPath> Service::unlock(const QList<QDBusObjectPath> &objects,
QDBusObjectPath &prompt)
{
- // TODO: check is session exists
- // TODO: bypass prompt
-
- // objects already unlocked
- QList<QDBusObjectPath> rc;
- // jobs to call asynchronously
- QSet<BackendJob*> unlockJobs;
- QObject *object;
- Item *item;
- Collection *collection;
- BackendItem *bi;
- BackendCollection *bc;
-
- Q_FOREACH(const QDBusObjectPath &path, objects) {
- object = QDBusConnection::sessionBus().objectRegisteredAt(path.path());
- if (!object) {
- continue;
- }
- if ((collection = qobject_cast<Collection*>(object))) {
- bc = collection->backendCollection();
- if (bc) {
- if (!bc->isLocked()) {
- rc.append(path);
- } else {
- CollectionUnlockInfo unlockInfo( getCallingPeer() );
- UnlockCollectionJob *ucj = bc->createUnlockJob( unlockInfo );
- if (ucj->isImmediate()) {
- ucj->exec();
- if (ucj->error() != NoError || !ucj->result()) {
- // not unlocked, maybe due to an error.
- // There's not much to do about it. Silently ignore.
- } else {
- rc.append(path);
- }
- } else {
- unlockJobs.insert(ucj);
- }
+ // TODO: check is session exists
+ // TODO: bypass prompt
+
+ // objects already unlocked
+ QList<QDBusObjectPath> rc;
+ // jobs to call asynchronously
+ QSet<BackendJob*> unlockJobs;
+ QObject *object;
+ Item *item;
+ Collection *collection;
+ BackendItem *bi;
+ BackendCollection *bc;
+
+ Q_FOREACH(const QDBusObjectPath & path, objects) {
+ object = QDBusConnection::sessionBus().objectRegisteredAt(path.path());
+ if(!object) {
+ continue;
+ }
+ if((collection = qobject_cast<Collection*>(object))) {
+ bc = collection->backendCollection();
+ if(bc) {
+ if(!bc->isLocked()) {
+ rc.append(path);
+ } else {
+ CollectionUnlockInfo unlockInfo(getCallingPeer());
+ UnlockCollectionJob *ucj = bc->createUnlockJob(unlockInfo);
+ if(ucj->isImmediate()) {
+ ucj->exec();
+ if(ucj->error() != NoError || !ucj->result()) {
+ // not unlocked, maybe due to an error.
+ // There's not much to do about it. Silently ignore.
+ } else {
+ rc.append(path);
+ }
+ } else {
+ unlockJobs.insert(ucj);
+ }
+ }
}
- }
- } else if ((item = qobject_cast<Item*>(object))) {
- bi = item->backendItem();
- if (bi) {
- if (!bi->isLocked()) {
- rc.append(path);
- } else {
- ItemUnlockInfo unlockInfo( getCallingPeer() );
- UnlockItemJob *uij = bi->createUnlockJob( unlockInfo );
- if (uij->isImmediate()) {
- uij->exec();
- if (uij->error() != NoError ||!uij->result()) {
- // not unlocked, maybe due to an error.
- // There's not much to do about it. Silently ignore.
- } else {
- rc.append(path);
- }
- } else {
- unlockJobs.insert(uij);
- }
+ } else if((item = qobject_cast<Item*>(object))) {
+ bi = item->backendItem();
+ if(bi) {
+ if(!bi->isLocked()) {
+ rc.append(path);
+ } else {
+ ItemUnlockInfo unlockInfo(getCallingPeer());
+ UnlockItemJob *uij = bi->createUnlockJob(unlockInfo);
+ if(uij->isImmediate()) {
+ uij->exec();
+ if(uij->error() != NoError || !uij->result()) {
+ // not unlocked, maybe due to an error.
+ // There's not much to do about it. Silently ignore.
+ } else {
+ rc.append(path);
+ }
+ } else {
+ unlockJobs.insert(uij);
+ }
+ }
}
- }
- }
- // NOTE: objects which either don't exist or whose type is wrong are silently \
ignored.
- }
-
- if (!unlockJobs.isEmpty()) {
- ServiceMultiPrompt *p = new ServiceMultiPrompt(this, unlockJobs, this);
- prompt = p->objectPath();
- } else {
- prompt.setPath("/");
- }
-
- return rc;
+ }
+ // NOTE: objects which either don't exist or whose type is wrong are \
silently ignored. + }
+
+ if(!unlockJobs.isEmpty()) {
+ ServiceMultiPrompt *p = new ServiceMultiPrompt(this, unlockJobs, this);
+ prompt = p->objectPath();
+ } else {
+ prompt.setPath("/");
+ }
+
+ return rc;
}
QList<QDBusObjectPath> Service::lock(const QList<QDBusObjectPath> &objects,
QDBusObjectPath &prompt)
{
- // TODO: check is session exists
- // TODO: do we need ACL handling when locking objects ?
-
- // objects already locked
- QList<QDBusObjectPath> rc;
- // jobs to call asynchronously
- QSet<BackendJob*> lockJobs;
- QObject *object;
- Item *item;
- Collection *collection;
- BackendItem *bi;
- BackendCollection *bc;
-
- Q_FOREACH(const QDBusObjectPath &path, objects) {
- object = QDBusConnection::sessionBus().objectRegisteredAt(path.path());
- if (!object) {
- continue;
- }
- if ((collection = qobject_cast<Collection*>(object))) {
- bc = collection->backendCollection();
- if (bc) {
- if (bc->isLocked()) {
- rc.append(path);
- } else {
- LockCollectionJob *lcj = bc->createLockJob();
- if (lcj->isImmediate()) {
- lcj->exec();
- if (lcj->error() != NoError || !lcj->result()) {
- // not locked, maybe due to an error.
- // There's not much to do about it. Silently ignore.
- } else {
- rc.append(path);
- }
- } else {
- lockJobs.insert(lcj);
- }
+ // TODO: check is session exists
+ // TODO: do we need ACL handling when locking objects ?
+
+ // objects already locked
+ QList<QDBusObjectPath> rc;
+ // jobs to call asynchronously
+ QSet<BackendJob*> lockJobs;
+ QObject *object;
+ Item *item;
+ Collection *collection;
+ BackendItem *bi;
+ BackendCollection *bc;
+
+ Q_FOREACH(const QDBusObjectPath & path, objects) {
+ object = QDBusConnection::sessionBus().objectRegisteredAt(path.path());
+ if(!object) {
+ continue;
+ }
+ if((collection = qobject_cast<Collection*>(object))) {
+ bc = collection->backendCollection();
+ if(bc) {
+ if(bc->isLocked()) {
+ rc.append(path);
+ } else {
+ LockCollectionJob *lcj = bc->createLockJob();
+ if(lcj->isImmediate()) {
+ lcj->exec();
+ if(lcj->error() != NoError || !lcj->result()) {
+ // not locked, maybe due to an error.
+ // There's not much to do about it. Silently ignore.
+ } else {
+ rc.append(path);
+ }
+ } else {
+ lockJobs.insert(lcj);
+ }
+ }
}
- }
- } else if ((item = qobject_cast<Item*>(object))) {
- bi = item->backendItem();
- if (bi) {
- if (bi->isLocked()) {
- rc.append(path);
- } else {
- LockItemJob *lij = bi->createLockJob();
- if (lij->isImmediate()) {
- lij->exec();
- if (lij->error() != NoError || !lij->result()) {
- // not locked, maybe due to an error.
- // There's not much to do about it. Silently ignore.
- } else {
- rc.append(path);
- }
- } else {
- lockJobs.insert(lij);
- }
+ } else if((item = qobject_cast<Item*>(object))) {
+ bi = item->backendItem();
+ if(bi) {
+ if(bi->isLocked()) {
+ rc.append(path);
+ } else {
+ LockItemJob *lij = bi->createLockJob();
+ if(lij->isImmediate()) {
+ lij->exec();
+ if(lij->error() != NoError || !lij->result()) {
+ // not locked, maybe due to an error.
+ // There's not much to do about it. Silently ignore.
+ } else {
+ rc.append(path);
+ }
+ } else {
+ lockJobs.insert(lij);
+ }
+ }
}
- }
- }
- // NOTE: objects which either don't exist or whose type is wrong are silently \
ignored.
- }
-
- if (!lockJobs.isEmpty()) {
- ServiceMultiPrompt *p = new ServiceMultiPrompt(this, lockJobs, this);
- prompt = p->objectPath();
- } else {
- prompt.setPath("/");
- }
-
- return rc;
+ }
+ // NOTE: objects which either don't exist or whose type is wrong are \
silently ignored. + }
+
+ if(!lockJobs.isEmpty()) {
+ ServiceMultiPrompt *p = new ServiceMultiPrompt(this, lockJobs, this);
+ prompt = p->objectPath();
+ } else {
+ prompt.setPath("/");
+ }
+
+ return rc;
}
QMap<QDBusObjectPath, Secret> Service::getSecrets(const QList<QDBusObjectPath> \
&items,
- const QDBusObjectPath &session)
+ const QDBusObjectPath &session)
{
- QMap<QDBusObjectPath, Secret> rc;
- QObject *object;
- Session *sessionObj;
- Item *item;
- bool ok;
- Secret secret;
-
- object = QDBusConnection::sessionBus().objectRegisteredAt(session.path());
- if (!object || !(sessionObj = qobject_cast<Session*>(object))) {
- if (calledFromDBus()) {
- sendErrorReply("org.freedesktop.Secret.Error.NoSession");
- }
- return rc;
- }
-
- Q_FOREACH(const QDBusObjectPath &path, items) {
- object = QDBusConnection::sessionBus().objectRegisteredAt(path.path());
- if (object && (item = qobject_cast<Item*>(object))) {
- BackendItem *bi = item->backendItem();
- if (bi && !bi->isLocked()) {
- BackendReturn<QCA::SecureArray> be = bi->secret();
- // TODO: what should this do if getting the secret failed?
- if (!be.isError()) {
- secret = sessionObj->encrypt(be.value(), ok);
- // TODO: what should this do if encrypting failed?
- if (ok) {
- rc.insert(path, secret);
- }
+ QMap<QDBusObjectPath, Secret> rc;
+ QObject *object;
+ Session *sessionObj;
+ Item *item;
+ bool ok;
+ Secret secret;
+
+ object = QDBusConnection::sessionBus().objectRegisteredAt(session.path());
+ if(!object || !(sessionObj = qobject_cast<Session*>(object))) {
+ if(calledFromDBus()) {
+ sendErrorReply("org.freedesktop.Secret.Error.NoSession");
+ }
+ return rc;
+ }
+
+ Q_FOREACH(const QDBusObjectPath & path, items) {
+ object = QDBusConnection::sessionBus().objectRegisteredAt(path.path());
+ if(object && (item = qobject_cast<Item*>(object))) {
+ BackendItem *bi = item->backendItem();
+ if(bi && !bi->isLocked()) {
+ BackendReturn<QCA::SecureArray> be = bi->secret();
+ // TODO: what should this do if getting the secret failed?
+ if(!be.isError()) {
+ secret = sessionObj->encrypt(be.value(), ok);
+ // TODO: what should this do if encrypting failed?
+ if(ok) {
+ rc.insert(path, secret);
+ }
+ }
}
- }
- }
- }
+ }
+ }
- return rc;
+ return rc;
}
void Service::slotCollectionCreated(BackendCollection *collection)
{
- Q_ASSERT(collection);
- Collection *coll = new Collection(collection, this);
- m_collections.append(coll->objectPath());
- emit collectionCreated(coll->objectPath());
+ Q_ASSERT(collection);
+ Collection *coll = new Collection(collection, this);
+ m_collections.append(coll->objectPath());
+ emit collectionCreated(coll->objectPath());
}
void Service::slotCollectionDeleted(BackendCollection *collection)
{
- Q_ASSERT(collection);
- QDBusObjectPath collPath(m_basePath.path() + "/collection/" + collection->id());
- m_collections.removeAll(collPath);
- // TODO: make sure Daemon::Collection gets destroyed
- emit collectionDeleted(collPath);
+ Q_ASSERT(collection);
+ QDBusObjectPath collPath(m_basePath.path() + "/collection/" + collection->id());
+ m_collections.removeAll(collPath);
+ // TODO: make sure Daemon::Collection gets destroyed
+ emit collectionDeleted(collPath);
}
void Service::slotCollectionChanged(BackendCollection *collection)
{
- Q_ASSERT(collection);
- QDBusObjectPath collPath(m_basePath.path() + "/collection/" + collection->id());
- emit collectionChanged(collPath);
+ Q_ASSERT(collection);
+ QDBusObjectPath collPath(m_basePath.path() + "/collection/" + collection->id());
+ emit collectionChanged(collPath);
}
#include "service.moc"
diff --git a/frontend/secret/service.h b/frontend/secret/service.h
index 958db13..d436e3a 100644
--- a/frontend/secret/service.h
+++ b/frontend/secret/service.h
@@ -33,136 +33,136 @@
class Secret;
class Collection;
-
+
/**
* Main entry point of the secret service D-Bus daemon implementing the
* org.freedesktop.Secret.Service interface.
- *
+ *
* @todo Implement proper session handling
*/
class Service : public QObject, protected KSecretDBusContext
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructor.
- *
- * @param master Backend master to use
- * @param parent Parent object
- */
- Service(BackendMaster *master, QObject *parent = 0);
-
- /**
- * Return the service's path on the D-Bus.
- *
- * @return the Service object's path
- */
- const QDBusObjectPath &objectPath() const;
-
- /**
- * Accessor for the list of known collections.
- *
- * @return all collections known to the service.
- */
- const QList<QDBusObjectPath> &collections() const;
-
- /**
- * Open a unique session for the caller application.
- *
- * @param algorithm the algorithm the caller wishes to use
- * @param input input arguments for the algorithm
- * @param result the object path of the session, if session was created
- * @return output of the session algorithm negotiation
- */
- QVariant openSession(const QString &algorithm, const QVariant &input, \
QDBusObjectPath &result);
-
- /**
- * Create a new collection with the specified properties.
- *
- * @param properties properties for the new collection
- * @param prompt a prompt object if prompting is necessary, or "/" if no prompt \
was needed
- * @return the new collection object or "/" if prompting is necessary
- */
- QDBusObjectPath createCollection(const QMap<QString, QVariant> &properties,
- QDBusObjectPath &prompt);
-
- /**
- * Find items in any collection.
- *
- * @param attributes the attributes an item has to match in order to be found
- * @param locked items found that require authentication
- * @return items found that are already unlocked
- */
- QList<QDBusObjectPath> searchItems(const QMap<QString, QString> &attributes,
- QList<QDBusObjectPath> &locked);
-
- /**
- * Unlock the specified items or collections.
- *
- * @param objects objects to unlock
- * @param prompt a prompt object which can be used to unlock the remaining \
objects or
- * "/" if no prompt is necessary.
- * @return objects that were unlocked without a prompt
- */
- QList<QDBusObjectPath> unlock(const QList<QDBusObjectPath> &objects, \
QDBusObjectPath &prompt);
-
- /**
- * Lock the specified items or collections.
- *
- * @param objects objects to lock
- * @param prompt a prompt to lock the objects or "/" if no prompt is necessary
- * @return objects that were locked without a prompt
- */
- QList<QDBusObjectPath> lock(const QList<QDBusObjectPath> &objects, \
QDBusObjectPath &prompt);
-
- /**
- * Retrieve multiple secrets from different items.
- *
- * @param items items to get secrets for
- * @param session the session to use to encode the secrets
- * @return the secrets for the items.
- */
- QMap<QDBusObjectPath, Secret> getSecrets(const QList<QDBusObjectPath> &items,
- const QDBusObjectPath &session);
-
+ /**
+ * Constructor.
+ *
+ * @param master Backend master to use
+ * @param parent Parent object
+ */
+ Service(BackendMaster *master, QObject *parent = 0);
+
+ /**
+ * Return the service's path on the D-Bus.
+ *
+ * @return the Service object's path
+ */
+ const QDBusObjectPath &objectPath() const;
+
+ /**
+ * Accessor for the list of known collections.
+ *
+ * @return all collections known to the service.
+ */
+ const QList<QDBusObjectPath> &collections() const;
+
+ /**
+ * Open a unique session for the caller application.
+ *
+ * @param algorithm the algorithm the caller wishes to use
+ * @param input input arguments for the algorithm
+ * @param result the object path of the session, if session was created
+ * @return output of the session algorithm negotiation
+ */
+ QVariant openSession(const QString &algorithm, const QVariant &input, \
QDBusObjectPath &result); +
+ /**
+ * Create a new collection with the specified properties.
+ *
+ * @param properties properties for the new collection
+ * @param prompt a prompt object if prompting is necessary, or "/" if no prompt \
was needed + * @return the new collection object or "/" if prompting is necessary
+ */
+ QDBusObjectPath createCollection(const QMap<QString, QVariant> &properties,
+ QDBusObjectPath &prompt);
+
+ /**
+ * Find items in any collection.
+ *
+ * @param attributes the attributes an item has to match in order to be found
+ * @param locked items found that require authentication
+ * @return items found that are already unlocked
+ */
+ QList<QDBusObjectPath> searchItems(const QMap<QString, QString> &attributes,
+ QList<QDBusObjectPath> &locked);
+
+ /**
+ * Unlock the specified items or collections.
+ *
+ * @param objects objects to unlock
+ * @param prompt a prompt object which can be used to unlock the remaining \
objects or + * "/" if no prompt is necessary.
+ * @return objects that were unlocked without a prompt
+ */
+ QList<QDBusObjectPath> unlock(const QList<QDBusObjectPath> &objects, \
QDBusObjectPath &prompt); +
+ /**
+ * Lock the specified items or collections.
+ *
+ * @param objects objects to lock
+ * @param prompt a prompt to lock the objects or "/" if no prompt is necessary
+ * @return objects that were locked without a prompt
+ */
+ QList<QDBusObjectPath> lock(const QList<QDBusObjectPath> &objects, \
QDBusObjectPath &prompt); +
+ /**
+ * Retrieve multiple secrets from different items.
+ *
+ * @param items items to get secrets for
+ * @param session the session to use to encode the secrets
+ * @return the secrets for the items.
+ */
+ QMap<QDBusObjectPath, Secret> getSecrets(const QList<QDBusObjectPath> &items,
+ const QDBusObjectPath &session);
+
Q_SIGNALS:
- /**
- * Emitted when a new collection is discovered or created.
- *
- * @param collection Objectpath of the collection that was discovered/created
- */
- void collectionCreated(const QDBusObjectPath &collection);
-
- /**
- * Emitted when an existing collection was deleted or disappeared.
- *
- * @param collection Objectpath of the collection that was deleted
- */
- void collectionDeleted(const QDBusObjectPath &collection);
-
- /**
- * Emitted when an existing collection changed.
- *
- * @param collection Objectpath of the collection that changed
- */
- void collectionChanged(const QDBusObjectPath &collection);
-
+ /**
+ * Emitted when a new collection is discovered or created.
+ *
+ * @param collection Objectpath of the collection that was discovered/created
+ */
+ void collectionCreated(const QDBusObjectPath &collection);
+
+ /**
+ * Emitted when an existing collection was deleted or disappeared.
+ *
+ * @param collection Objectpath of the collection that was deleted
+ */
+ void collectionDeleted(const QDBusObjectPath &collection);
+
+ /**
+ * Emitted when an existing collection changed.
+ *
+ * @param collection Objectpath of the collection that changed
+ */
+ void collectionChanged(const QDBusObjectPath &collection);
+
private Q_SLOTS:
- // handle collectionCreated() calls from master
- void slotCollectionCreated(BackendCollection *collection);
- // handle collectionDeleted() calls from master
- void slotCollectionDeleted(BackendCollection *collection);
- // handle collectionChanged() calls from master
- void slotCollectionChanged(BackendCollection *collection);
+ // handle collectionCreated() calls from master
+ void slotCollectionCreated(BackendCollection *collection);
+ // handle collectionDeleted() calls from master
+ void slotCollectionDeleted(BackendCollection *collection);
+ // handle collectionChanged() calls from master
+ void slotCollectionChanged(BackendCollection *collection);
+
+ void onDbusDisconnected(QString path);
- void onDbusDisconnected( QString path );
-
private:
- BackendMaster *m_master;
- QList<QDBusObjectPath> m_collections; // cache object paths of collections
- const QDBusObjectPath m_basePath;
+ BackendMaster *m_master;
+ QList<QDBusObjectPath> m_collections; // cache object paths of collections
+ const QDBusObjectPath m_basePath;
};
#endif
diff --git a/frontend/secret/session.cpp b/frontend/secret/session.cpp
index 3d26480..f12d484 100644
--- a/frontend/secret/session.cpp
+++ b/frontend/secret/session.cpp
@@ -30,204 +30,204 @@
Session::Session(Service *parent)
- : QObject(parent),
- m_objectPath(parent->objectPath().path() + "/session/" + createId()), m_cipher(0)
+ : QObject(parent),
+ m_objectPath(parent->objectPath().path() + "/session/" + createId()), \
m_cipher(0) {
- // register on the bus
- new orgFreedesktopSecret::SessionAdaptor(this);
- QDBusConnection::sessionBus().registerObject(m_objectPath.path(), this);
+ // register on the bus
+ new orgFreedesktopSecret::SessionAdaptor(this);
+ QDBusConnection::sessionBus().registerObject(m_objectPath.path(), this);
}
Session::~Session()
{
- delete m_cipher;
+ delete m_cipher;
}
const QDBusObjectPath &Session::objectPath() const
{
- return m_objectPath;
+ return m_objectPath;
}
Session *Session::create(const QString &algorithm, const QVariant &input,
QVariant &output, const Peer &peer, Service *parent)
{
- static QRegExp rxAlgorithm("^dh-ietf(\\d+)-([^-]+)-([^-]+)-([^-]+)$",
- Qt::CaseInsensitive);
-
- Session *session = 0;
-
- if (algorithm == "plain") {
- session = new Session(parent);
- session->m_encrypted = false;
- output.setValue(QString(""));
- } else if (rxAlgorithm.exactMatch(algorithm) &&
+ static QRegExp rxAlgorithm("^dh-ietf(\\d+)-([^-]+)-([^-]+)-([^-]+)$",
+ Qt::CaseInsensitive);
+
+ Session *session = 0;
+
+ if(algorithm == "plain") {
+ session = new Session(parent);
+ session->m_encrypted = false;
+ output.setValue(QString(""));
+ } else if(rxAlgorithm.exactMatch(algorithm) &&
input.type() == QVariant::ByteArray) {
- QString encalgo = rxAlgorithm.cap(2).toLower();
- QString blockmode = rxAlgorithm.cap(3).toLower();
- QString padding = rxAlgorithm.cap(4).toLower();
-
- QCA::KeyGenerator keygen;
-
- // determine the discrete logarithm group to use
- QCA::DLGroupSet groupnum;
- switch (rxAlgorithm.cap(1).toInt()) {
- case 768:
- groupnum = QCA::IETF_768;
- break;
- case 1024:
- groupnum = QCA::IETF_1024;
- break;
- case 1536:
- groupnum = QCA::IETF_1536;
- break;
- case 2048:
- groupnum = QCA::IETF_2048;
- break;
- case 3072:
- groupnum = QCA::IETF_3072;
- break;
- case 4096:
- groupnum = QCA::IETF_4096;
- break;
- case 6144:
- groupnum = QCA::IETF_6144;
- break;
- case 8192:
- groupnum = QCA::IETF_8192;
- break;
- default:
- // no known discrete logarithm group
- return 0;
- }
- QCA::DLGroup dlgroup(keygen.createDLGroup(groupnum));
- if (dlgroup.isNull()) {
- return 0;
- }
-
- // determine if we support (or want to support)
- // the encryption algorithm.
- if ((encalgo == "blowfish" || encalgo == "twofish" ||
- encalgo == "aes128" || encalgo == "aes192" ||
- encalgo == "aes256") &&
- QCA::isSupported(QString("%1-%2-%3").arg(encalgo, blockmode, padding)
- .toLatin1().constData())) {
-
- // get client's public key
- QCA::DHPublicKey clientKey(dlgroup,
- \
QCA::BigInteger(QCA::SecureArray(input.toByteArray())));
- // generate own private key
- QCA::PrivateKey privKey(keygen.createDH(dlgroup));
- // generate the shared symmetric key
- QCA::SymmetricKey sharedKey(privKey.deriveKey(clientKey));
-
- QCA::Cipher::Mode cbm;
- if (blockmode == "cbc") {
- cbm = QCA::Cipher::CBC;
- } else {
- return 0;
- }
-
- QCA::Cipher::Padding cp;
- if (padding == "pkcs7") {
- cp = QCA::Cipher::PKCS7;
- } else if (padding == "default") {
- cp = QCA::Cipher::DefaultPadding;
- } else {
+ QString encalgo = rxAlgorithm.cap(2).toLower();
+ QString blockmode = rxAlgorithm.cap(3).toLower();
+ QString padding = rxAlgorithm.cap(4).toLower();
+
+ QCA::KeyGenerator keygen;
+
+ // determine the discrete logarithm group to use
+ QCA::DLGroupSet groupnum;
+ switch(rxAlgorithm.cap(1).toInt()) {
+ case 768:
+ groupnum = QCA::IETF_768;
+ break;
+ case 1024:
+ groupnum = QCA::IETF_1024;
+ break;
+ case 1536:
+ groupnum = QCA::IETF_1536;
+ break;
+ case 2048:
+ groupnum = QCA::IETF_2048;
+ break;
+ case 3072:
+ groupnum = QCA::IETF_3072;
+ break;
+ case 4096:
+ groupnum = QCA::IETF_4096;
+ break;
+ case 6144:
+ groupnum = QCA::IETF_6144;
+ break;
+ case 8192:
+ groupnum = QCA::IETF_8192;
+ break;
+ default:
+ // no known discrete logarithm group
return 0;
- }
-
- QCA::Cipher *cipher = new QCA::Cipher(encalgo, cbm, cp);
-
- // check if creating the cipher worked and if our shared
- // key is longer than the minimum length required.
- if (sharedKey.size() >= cipher->keyLength().minimum()) {
- // generate the response to the client so it can derive
- // the key as well.
- session = new Session(parent);
- session->m_encrypted = true;
- session->m_cipher = cipher;
- session->m_symmetricKey = sharedKey;
- output.setValue(privKey.toPublicKey().toDH().y().toArray().toByteArray());
- } else {
+ }
+ QCA::DLGroup dlgroup(keygen.createDLGroup(groupnum));
+ if(dlgroup.isNull()) {
return 0;
- }
- }
- } else {
- return 0;
- }
-
- // creating the session was successful
- session->m_peer = peer;
- return session;
+ }
+
+ // determine if we support (or want to support)
+ // the encryption algorithm.
+ if((encalgo == "blowfish" || encalgo == "twofish" ||
+ encalgo == "aes128" || encalgo == "aes192" ||
+ encalgo == "aes256") &&
+ QCA::isSupported(QString("%1-%2-%3").arg(encalgo, blockmode, \
padding) + .toLatin1().constData())) {
+
+ // get client's public key
+ QCA::DHPublicKey clientKey(dlgroup,
+ \
QCA::BigInteger(QCA::SecureArray(input.toByteArray()))); + // generate own \
private key + QCA::PrivateKey privKey(keygen.createDH(dlgroup));
+ // generate the shared symmetric key
+ QCA::SymmetricKey sharedKey(privKey.deriveKey(clientKey));
+
+ QCA::Cipher::Mode cbm;
+ if(blockmode == "cbc") {
+ cbm = QCA::Cipher::CBC;
+ } else {
+ return 0;
+ }
+
+ QCA::Cipher::Padding cp;
+ if(padding == "pkcs7") {
+ cp = QCA::Cipher::PKCS7;
+ } else if(padding == "default") {
+ cp = QCA::Cipher::DefaultPadding;
+ } else {
+ return 0;
+ }
+
+ QCA::Cipher *cipher = new QCA::Cipher(encalgo, cbm, cp);
+
+ // check if creating the cipher worked and if our shared
+ // key is longer than the minimum length required.
+ if(sharedKey.size() >= cipher->keyLength().minimum()) {
+ // generate the response to the client so it can derive
+ // the key as well.
+ session = new Session(parent);
+ session->m_encrypted = true;
+ session->m_cipher = cipher;
+ session->m_symmetricKey = sharedKey;
+ output.setValue(privKey.toPublicKey().toDH().y().toArray().toByteArray());
+ } else {
+ return 0;
+ }
+ }
+ } else {
+ return 0;
+ }
+
+ // creating the session was successful
+ session->m_peer = peer;
+ return session;
}
Secret Session::encrypt(const QCA::SecureArray &value, bool &ok)
{
- ok = false;
-
- Secret s;
- s.setSession(m_objectPath);
- if (m_encrypted) {
- Q_ASSERT(m_cipher);
- QCA::InitializationVector iv(m_cipher->blockSize());
- m_cipher->setup(QCA::Encode, m_symmetricKey, iv);
- QCA::SecureArray encval = m_cipher->update(value);
- if (!m_cipher->ok()) {
- return s;
- }
- encval += m_cipher->final();
- if (m_cipher->ok()) {
- return s;
- }
- s.setValue(encval.toByteArray());
- s.setParameters(iv.toByteArray());
- } else {
- s.setValue(value.toByteArray());
- }
-
-
- ok = true;
- return s;
+ ok = false;
+
+ Secret s;
+ s.setSession(m_objectPath);
+ if(m_encrypted) {
+ Q_ASSERT(m_cipher);
+ QCA::InitializationVector iv(m_cipher->blockSize());
+ m_cipher->setup(QCA::Encode, m_symmetricKey, iv);
+ QCA::SecureArray encval = m_cipher->update(value);
+ if(!m_cipher->ok()) {
+ return s;
+ }
+ encval += m_cipher->final();
+ if(m_cipher->ok()) {
+ return s;
+ }
+ s.setValue(encval.toByteArray());
+ s.setParameters(iv.toByteArray());
+ } else {
+ s.setValue(value.toByteArray());
+ }
+
+
+ ok = true;
+ return s;
}
QCA::SecureArray Session::decrypt(const Secret &secret, bool &ok)
{
- // make sure this is really meant for us
- Q_ASSERT(secret.session() == m_objectPath);
- ok = false;
-
- QCA::SecureArray value;
- if (m_encrypted) {
- Q_ASSERT(m_cipher);
- if (!secret.parameters().size() == m_cipher->blockSize()) {
- return value;
- }
- QCA::InitializationVector iv(secret.parameters());
- m_cipher->setup(QCA::Decode, m_symmetricKey, iv);
- value = m_cipher->update(secret.value());
- if (!m_cipher->ok()) {
- return value;
- }
- value += m_cipher->final();
- if (!m_cipher->ok()) {
- return value;
- }
- } else {
- value = secret.value();
- }
-
- ok = true;
- return value;
+ // make sure this is really meant for us
+ Q_ASSERT(secret.session() == m_objectPath);
+ ok = false;
+
+ QCA::SecureArray value;
+ if(m_encrypted) {
+ Q_ASSERT(m_cipher);
+ if(!secret.parameters().size() == m_cipher->blockSize()) {
+ return value;
+ }
+ QCA::InitializationVector iv(secret.parameters());
+ m_cipher->setup(QCA::Decode, m_symmetricKey, iv);
+ value = m_cipher->update(secret.value());
+ if(!m_cipher->ok()) {
+ return value;
+ }
+ value += m_cipher->final();
+ if(!m_cipher->ok()) {
+ return value;
+ }
+ } else {
+ value = secret.value();
+ }
+
+ ok = true;
+ return value;
}
void Session::close()
{
- deleteLater();
+ deleteLater();
}
const Peer &Session::peer() const
{
- return m_peer;
+ return m_peer;
}
#include "session.moc"
diff --git a/frontend/secret/session.h b/frontend/secret/session.h
index 9e8290c..7a3f65f 100644
--- a/frontend/secret/session.h
+++ b/frontend/secret/session.h
@@ -41,81 +41,81 @@ class Peer;
*/
class Session : public QObject, protected KSecretDBusContext
{
- Q_OBJECT
+ Q_OBJECT
private:
- /**
- * Constructor.
- *
- * @param parent Parent Service object
- */
- Session(Service *parent);
+ /**
+ * Constructor.
+ *
+ * @param parent Parent Service object
+ */
+ Session(Service *parent);
public:
- /**
- * Destructor.
- */
- ~Session();
-
- /**
- * Get the session's object path.
- */
- const QDBusObjectPath &objectPath() const;
-
- /**
- * Try to create a (possibly encrypted) session for the use of transferring
- * secrets.
- *
- * @param algorithm the negotiation/encryption algorithm to use
- * @param input negotiation algorithm input
- * @param output negotiation algorithm output
- * @param parent Parent Service object
- * @return a session object if negotiation was successful, 0 if the algorithm \
isn't
- * supported or an error occurred
- */
- static Session *create(const QString &algorithm, const QVariant &input,
- QVariant &output, const Peer &peer, Service *parent);
-
- /**
- * Encrypt a secret value using this session.
- *
- * @param value value to encrypt
- * @param ok set to true if encrypting succeeds, set to false else
- * @return the secret encrypted for transport
- */
- Secret encrypt(const QCA::SecureArray &value, bool &ok);
-
- /**
- * Decrypt a secret value using this session.
- *
- * @param secret Secret received on the D-Bus
- * @param ok set to true if decrypting succeeds, set to false else
- * @return the unencryped value
- */
- QCA::SecureArray decrypt(const Secret &secret, bool &ok);
-
- /**
- * Close this session.
- */
- void close();
-
- /**
- * Get the session's D-Bus peer (the client requesting the session).
- * If peer() == NULL, then this session was not created accross D-Bus.
- * That can happen only during tests.
- */
- const Peer &peer() const;
-
+ /**
+ * Destructor.
+ */
+ ~Session();
+
+ /**
+ * Get the session's object path.
+ */
+ const QDBusObjectPath &objectPath() const;
+
+ /**
+ * Try to create a (possibly encrypted) session for the use of transferring
+ * secrets.
+ *
+ * @param algorithm the negotiation/encryption algorithm to use
+ * @param input negotiation algorithm input
+ * @param output negotiation algorithm output
+ * @param parent Parent Service object
+ * @return a session object if negotiation was successful, 0 if the algorithm \
isn't + * supported or an error occurred
+ */
+ static Session *create(const QString &algorithm, const QVariant &input,
+ QVariant &output, const Peer &peer, Service *parent);
+
+ /**
+ * Encrypt a secret value using this session.
+ *
+ * @param value value to encrypt
+ * @param ok set to true if encrypting succeeds, set to false else
+ * @return the secret encrypted for transport
+ */
+ Secret encrypt(const QCA::SecureArray &value, bool &ok);
+
+ /**
+ * Decrypt a secret value using this session.
+ *
+ * @param secret Secret received on the D-Bus
+ * @param ok set to true if decrypting succeeds, set to false else
+ * @return the unencryped value
+ */
+ QCA::SecureArray decrypt(const Secret &secret, bool &ok);
+
+ /**
+ * Close this session.
+ */
+ void close();
+
+ /**
+ * Get the session's D-Bus peer (the client requesting the session).
+ * If peer() == NULL, then this session was not created accross D-Bus.
+ * That can happen only during tests.
+ */
+ const Peer &peer() const;
+
private:
- QDBusObjectPath m_objectPath;
- Peer m_peer; // Information about the application that requested this session
-
- // if true, use encryption, if false, use plaintext
- bool m_encrypted;
-
- // the cipher and the symmetric key used for encryption
- QCA::Cipher *m_cipher;
- QCA::SymmetricKey m_symmetricKey;
+ QDBusObjectPath m_objectPath;
+ Peer m_peer; // Information about the application that requested this session
+
+ // if true, use encryption, if false, use plaintext
+ bool m_encrypted;
+
+ // the cipher and the symmetric key used for encryption
+ QCA::Cipher *m_cipher;
+ QCA::SymmetricKey m_symmetricKey;
};
diff --git a/frontend/tests/servicetest.cpp b/frontend/tests/servicetest.cpp
index c8b9726..1dbc57f 100644
--- a/frontend/tests/servicetest.cpp
+++ b/frontend/tests/servicetest.cpp
@@ -41,669 +41,668 @@
void ServiceTest::initTestCase()
{
- QVERIFY(QDBusConnection::sessionBus().registerService("org.freedesktop.Secret"));
-
- QCA::init();
-
- m_master = BackendMaster::instance();
- m_master->setUiManager(new NoUiManager);
- m_tempCollMan = new TemporaryCollectionManager(m_master);
- m_master->addManager(m_tempCollMan);
- m_service = new Service(m_master);
+ QVERIFY(QDBusConnection::sessionBus().registerService("org.freedesktop.Secret"));
+
+ QCA::init();
+
+ m_master = BackendMaster::instance();
+ m_master->setUiManager(new NoUiManager);
+ m_tempCollMan = new TemporaryCollectionManager(m_master);
+ m_master->addManager(m_tempCollMan);
+ m_service = new Service(m_master);
}
void ServiceTest::dbusService()
{
- // make sure the service is available
- QDBusConnectionInterface *ifaceConn = QDBusConnection::sessionBus().interface();
- QVERIFY(ifaceConn && ifaceConn->isValid());
+ // make sure the service is available
+ QDBusConnectionInterface *ifaceConn = QDBusConnection::sessionBus().interface();
+ QVERIFY(ifaceConn && ifaceConn->isValid());
- QDBusReply<bool> registered = \
ifaceConn->isServiceRegistered("org.freedesktop.Secret");
- QVERIFY(registered.isValid());
- QVERIFY(registered.value());
+ QDBusReply<bool> registered = \
ifaceConn->isServiceRegistered("org.freedesktop.Secret"); + \
QVERIFY(registered.isValid()); + QVERIFY(registered.value());
}
void ServiceTest::session()
{
- QDBusInterface ifaceService("org.freedesktop.Secret", \
"/org/freedesktop/secrets");
- QVERIFY(ifaceService.isValid());
- QCA::KeyGenerator keygen;
-
- // "unsupported" session algorithm
- QList<QVariant> unsuppInput;
- unsuppInput << QString("unsupported") << \
QVariant::fromValue(QDBusVariant(QString("")));
- QDBusMessage unsuppReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession",
- unsuppInput);
- QCOMPARE(unsuppReply.type(), QDBusMessage::ErrorMessage);
- QEXPECT_FAIL("", "Error only returned if called via D-Bus (test calls locally)", \
Continue);
- QCOMPARE(unsuppReply.errorName(),
- QLatin1String("org.freedesktop.Secret.Error.NotSupported"));
-
- // "plain" session algorithm
- QDBusObjectPath plainPath;
- QList<QVariant> plainInput;
- plainInput << QString("plain") << QVariant::fromValue(QDBusVariant(""));
- QDBusMessage plainReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession",
- plainInput);
- QCOMPARE(plainReply.type(), QDBusMessage::ReplyMessage);
- QList<QVariant> plainArgs = plainReply.arguments();
- QCOMPARE(plainArgs.size(), 2);
- QCOMPARE(plainArgs.at(0).userType(), qMetaTypeId<QDBusVariant>());
- QCOMPARE(plainArgs.at(0).value<QString>(), QLatin1String(""));
- QCOMPARE(plainArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
- plainPath = plainArgs.at(1).value<QDBusObjectPath>();
- QVERIFY(plainPath.path().startsWith(QLatin1String("/org/freedesktop/secrets/session/")));
- QDBusInterface plainIface("org.freedesktop.Secret", plainPath.path(),
- "org.freedesktop.Secret.Session");
- QVERIFY(plainIface.isValid());
- QDBusMessage plainReply2 = plainIface.call("Close");
- QCOMPARE(plainReply2.type(), QDBusMessage::ReplyMessage);
- QCOMPARE(plainIface.call("Introspect").type(), QDBusMessage::ErrorMessage);
-
- // "dh-ietf1024-aes128-cbc-pkcs7" encryption
- QDBusObjectPath dhPath;
- QList<QVariant> dhInput;
- QCA::DLGroup dhDlgroup(keygen.createDLGroup(QCA::IETF_1024));
- QVERIFY(!dhDlgroup.isNull());
- QCA::PrivateKey dhPrivkey(keygen.createDH(dhDlgroup));
- QCA::PublicKey dhPubkey(dhPrivkey);
- QByteArray dhBytePub(dhPubkey.toDH().y().toArray().toByteArray());
- dhInput << QString("dh-ietf1024-aes128-cbc-pkcs7")
- << QVariant::fromValue(QDBusVariant(dhBytePub));
- QDBusMessage dhReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession",
- dhInput);
- QCOMPARE(dhReply.type(), QDBusMessage::ReplyMessage);
- QList<QVariant> dhArgs = dhReply.arguments();
- QCOMPARE(dhArgs.size(), 2);
- QCOMPARE(dhArgs.at(0).userType(), qMetaTypeId<QDBusVariant>());
- QVariant dhOutputVar = dhArgs.at(0).value<QDBusVariant>().variant();
- QCOMPARE(dhOutputVar.type(), QVariant::ByteArray);
- QByteArray dhOutput = dhOutputVar.toByteArray();
- QCA::DHPublicKey dhServiceKey(dhDlgroup,
- QCA::BigInteger(QCA::SecureArray(dhOutput)));
- QCA::SymmetricKey dhSharedKey(dhPrivkey.deriveKey(dhServiceKey));
- QCA::Cipher *dhCipher = new QCA::Cipher("aes128", QCA::Cipher::CBC, \
QCA::Cipher::PKCS7);
- QVERIFY(dhSharedKey.size() >= dhCipher->keyLength().minimum());
- QCOMPARE(plainArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
- dhPath = dhArgs.at(1).value<QDBusObjectPath>();
- QVERIFY(dhPath.path().startsWith(QLatin1String("/org/freedesktop/secrets/session/")));
- QDBusInterface dhIface("org.freedesktop.Secret", dhPath.path(),
- "org.freedesktop.Secret.Session");
- QVERIFY(dhIface.isValid());
- QDBusMessage dhReply2 = dhIface.call("Close");
- QCOMPARE(dhReply2.type(), QDBusMessage::ReplyMessage);
- QCOMPARE(dhIface.call("Introspect").type(), QDBusMessage::ErrorMessage);
+ QDBusInterface ifaceService("org.freedesktop.Secret", \
"/org/freedesktop/secrets"); + QVERIFY(ifaceService.isValid());
+ QCA::KeyGenerator keygen;
+
+ // "unsupported" session algorithm
+ QList<QVariant> unsuppInput;
+ unsuppInput << QString("unsupported") << \
QVariant::fromValue(QDBusVariant(QString(""))); + QDBusMessage unsuppReply = \
ifaceService.callWithArgumentList(QDBus::Block, "OpenSession", + \
unsuppInput); + QCOMPARE(unsuppReply.type(), QDBusMessage::ErrorMessage);
+ QEXPECT_FAIL("", "Error only returned if called via D-Bus (test calls locally)", \
Continue); + QCOMPARE(unsuppReply.errorName(),
+ QLatin1String("org.freedesktop.Secret.Error.NotSupported"));
+
+ // "plain" session algorithm
+ QDBusObjectPath plainPath;
+ QList<QVariant> plainInput;
+ plainInput << QString("plain") << QVariant::fromValue(QDBusVariant(""));
+ QDBusMessage plainReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession", + plainInput);
+ QCOMPARE(plainReply.type(), QDBusMessage::ReplyMessage);
+ QList<QVariant> plainArgs = plainReply.arguments();
+ QCOMPARE(plainArgs.size(), 2);
+ QCOMPARE(plainArgs.at(0).userType(), qMetaTypeId<QDBusVariant>());
+ QCOMPARE(plainArgs.at(0).value<QString>(), QLatin1String(""));
+ QCOMPARE(plainArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
+ plainPath = plainArgs.at(1).value<QDBusObjectPath>();
+ QVERIFY(plainPath.path().startsWith(QLatin1String("/org/freedesktop/secrets/session/")));
+ QDBusInterface plainIface("org.freedesktop.Secret", plainPath.path(),
+ "org.freedesktop.Secret.Session");
+ QVERIFY(plainIface.isValid());
+ QDBusMessage plainReply2 = plainIface.call("Close");
+ QCOMPARE(plainReply2.type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(plainIface.call("Introspect").type(), QDBusMessage::ErrorMessage);
+
+ // "dh-ietf1024-aes128-cbc-pkcs7" encryption
+ QDBusObjectPath dhPath;
+ QList<QVariant> dhInput;
+ QCA::DLGroup dhDlgroup(keygen.createDLGroup(QCA::IETF_1024));
+ QVERIFY(!dhDlgroup.isNull());
+ QCA::PrivateKey dhPrivkey(keygen.createDH(dhDlgroup));
+ QCA::PublicKey dhPubkey(dhPrivkey);
+ QByteArray dhBytePub(dhPubkey.toDH().y().toArray().toByteArray());
+ dhInput << QString("dh-ietf1024-aes128-cbc-pkcs7")
+ << QVariant::fromValue(QDBusVariant(dhBytePub));
+ QDBusMessage dhReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession", + dhInput);
+ QCOMPARE(dhReply.type(), QDBusMessage::ReplyMessage);
+ QList<QVariant> dhArgs = dhReply.arguments();
+ QCOMPARE(dhArgs.size(), 2);
+ QCOMPARE(dhArgs.at(0).userType(), qMetaTypeId<QDBusVariant>());
+ QVariant dhOutputVar = dhArgs.at(0).value<QDBusVariant>().variant();
+ QCOMPARE(dhOutputVar.type(), QVariant::ByteArray);
+ QByteArray dhOutput = dhOutputVar.toByteArray();
+ QCA::DHPublicKey dhServiceKey(dhDlgroup,
+ QCA::BigInteger(QCA::SecureArray(dhOutput)));
+ QCA::SymmetricKey dhSharedKey(dhPrivkey.deriveKey(dhServiceKey));
+ QCA::Cipher *dhCipher = new QCA::Cipher("aes128", QCA::Cipher::CBC, \
QCA::Cipher::PKCS7); + QVERIFY(dhSharedKey.size() >= \
dhCipher->keyLength().minimum()); + QCOMPARE(plainArgs.at(1).userType(), \
qMetaTypeId<QDBusObjectPath>()); + dhPath = dhArgs.at(1).value<QDBusObjectPath>();
+ QVERIFY(dhPath.path().startsWith(QLatin1String("/org/freedesktop/secrets/session/")));
+ QDBusInterface dhIface("org.freedesktop.Secret", dhPath.path(),
+ "org.freedesktop.Secret.Session");
+ QVERIFY(dhIface.isValid());
+ QDBusMessage dhReply2 = dhIface.call("Close");
+ QCOMPARE(dhReply2.type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(dhIface.call("Introspect").type(), QDBusMessage::ErrorMessage);
}
void ServiceTest::nonBlockingCollection()
{
- QDBusInterface ifaceService("org.freedesktop.Secret", \
"/org/freedesktop/secrets");
- QVERIFY(ifaceService.isValid());
-
- // create a session
- QDBusObjectPath sessionPath;
- QList<QVariant> sessionInput;
- sessionInput << QString("plain") << QVariant::fromValue(QDBusVariant(""));
- QDBusMessage sessionReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession",
- sessionInput);
- sessionPath = sessionReply.arguments().at(1).value<QDBusObjectPath>();
-
- // listen to CollectionCreated/CollectionDeleted/CollectionChanged signals
- ObjectPathSignalSpy createdSpy(&ifaceService, \
SIGNAL(CollectionCreated(QDBusObjectPath)));
- QVERIFY(createdSpy.isValid());
- ObjectPathSignalSpy deletedSpy(&ifaceService, \
SIGNAL(CollectionDeleted(QDBusObjectPath)));
- QVERIFY(deletedSpy.isValid());
- ObjectPathSignalSpy changedSpy(&ifaceService, \
SIGNAL(CollectionChanged(QDBusObjectPath)));
- QVERIFY(changedSpy.isValid());
-
- // create a collection
- QDBusObjectPath collectionPath;
- QMap<QString, QVariant> createProperties;
- QList<QVariant> createInput;
- createProperties["Label"] = "test";
- createProperties["Locked"] = false; // create collection unlocked
- createInput << QVariant::fromValue(createProperties);
- QDBusMessage createReply = ifaceService.callWithArgumentList(QDBus::Block, \
"CreateCollection",
- createInput);
-
- QCOMPARE(createReply.type(), QDBusMessage::ReplyMessage);
- QList<QVariant> createArgs = createReply.arguments();
- QCOMPARE(createArgs.size(), 2);
- QCOMPARE(createArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
- QCOMPARE(createArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
- // CreateCollection is blocking, so the first output (path) should be "/".
- QCOMPARE(createArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
- QDBusObjectPath promptPath = createArgs.at(1).value<QDBusObjectPath>();
- QVERIFY(promptPath.path().startsWith(
- QLatin1String("/org/freedesktop/secrets/prompts/")));
-
- // prompt and wait for the result.
- ClientPrompt *prompt = new ClientPrompt(promptPath);
- prompt->promptAndWait(5000);
- QVERIFY(prompt->completed());
- QVERIFY(!prompt->dismissed());
- QCOMPARE(prompt->result().userType(), qMetaTypeId<QDBusObjectPath>());
- collectionPath = prompt->result().value<QDBusObjectPath>();
- QVERIFY(collectionPath.path().startsWith(
- QLatin1String("/org/freedesktop/secrets/collection/")));
- QDBusInterface ifaceCollection("org.freedesktop.Secret", collectionPath.path(),
- "org.freedesktop.Secret.Collection");
- QVERIFY(ifaceCollection.isValid());
- delete prompt;
-
- // make sure the CollectionCreated signal was sent
- if (createdSpy.size() < 1) {
- createdSpy.waitForSignal(5000);
- }
- QCOMPARE(createdSpy.size(), 1);
- QCOMPARE(createdSpy.takeFirst(), collectionPath);
-
- // read collection properties
- QVariant propItems = ifaceCollection.property("Items");
- QVERIFY(propItems.isValid());
- QVERIFY(propItems.canConvert<QList<QDBusObjectPath> >());
- QList<QDBusObjectPath> propItemsList = propItems.value<QList<QDBusObjectPath> \
>();
- QVERIFY(propItemsList.isEmpty());
- QVariant propLabel = ifaceCollection.property("Label");
- QVERIFY(propLabel.isValid());
- QCOMPARE(propLabel.type(), QVariant::String);
- QCOMPARE(propLabel.value<QString>(), QString("test"));
- QVariant propLocked = ifaceCollection.property("Locked");
- QVERIFY(propLocked.isValid());
- QCOMPARE(propLocked.value<bool>(), false);
- QVariant propCreated = ifaceCollection.property("Created");
- QVERIFY(propCreated.isValid());
- QCOMPARE(propCreated.type(), QVariant::ULongLong);
- qulonglong propCreatedUll = propCreated.value<qulonglong>();
- QVERIFY(QDateTime::currentDateTime().toTime_t() - propCreatedUll < 60);
- QVariant propModified = ifaceCollection.property("Modified");
- QVERIFY(propModified.isValid());
- QCOMPARE(propModified.type(), QVariant::ULongLong);
- QCOMPARE(propModified.value<qulonglong>(), propCreatedUll);
-
- // set the label and re-read it.
- ifaceCollection.setProperty("Label", QString("test2"));
- propLabel = ifaceCollection.property("Label");
- QVERIFY(propLabel.isValid());
- QCOMPARE(propLabel.type(), QVariant::String);
- QCOMPARE(propLabel.value<QString>(), QString("test2"));
-
- // make sure the CollectionChanged signal was sent
- if (changedSpy.size() < 1) {
- changedSpy.waitForSignal(5000);
- }
- QCOMPARE(changedSpy.size(), 1);
- QCOMPARE(changedSpy.takeFirst(), collectionPath);
-
- // delete the collection
- QDBusMessage deleteReply = ifaceCollection.call(QDBus::Block, "Delete");
- QCOMPARE(deleteReply.type(), QDBusMessage::ReplyMessage);
- QList<QVariant> deleteArgs = deleteReply.arguments();
- QCOMPARE(deleteArgs.size(), 1);
- QCOMPARE(deleteArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
- // TemporaryCollection is non-blocking, so the output (prompt) should be "/".
- QCOMPARE(deleteArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
- // make sure the collection is gone
- QCOMPARE(ifaceCollection.call("Introspect").type(), QDBusMessage::ErrorMessage);
-
- // make sure the CollectionDeleted signal was sent
- if (deletedSpy.size() < 1) {
- deletedSpy.waitForSignal(5000);
- }
- QCOMPARE(deletedSpy.size(), 1);
- QCOMPARE(deletedSpy.takeFirst(), collectionPath);
-
- // close the session
- QDBusInterface("org.freedesktop.Secret", sessionPath.path()).call("Close");
+ QDBusInterface ifaceService("org.freedesktop.Secret", \
"/org/freedesktop/secrets"); + QVERIFY(ifaceService.isValid());
+
+ // create a session
+ QDBusObjectPath sessionPath;
+ QList<QVariant> sessionInput;
+ sessionInput << QString("plain") << QVariant::fromValue(QDBusVariant(""));
+ QDBusMessage sessionReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession", + sessionInput);
+ sessionPath = sessionReply.arguments().at(1).value<QDBusObjectPath>();
+
+ // listen to CollectionCreated/CollectionDeleted/CollectionChanged signals
+ ObjectPathSignalSpy createdSpy(&ifaceService, \
SIGNAL(CollectionCreated(QDBusObjectPath))); + QVERIFY(createdSpy.isValid());
+ ObjectPathSignalSpy deletedSpy(&ifaceService, \
SIGNAL(CollectionDeleted(QDBusObjectPath))); + QVERIFY(deletedSpy.isValid());
+ ObjectPathSignalSpy changedSpy(&ifaceService, \
SIGNAL(CollectionChanged(QDBusObjectPath))); + QVERIFY(changedSpy.isValid());
+
+ // create a collection
+ QDBusObjectPath collectionPath;
+ QMap<QString, QVariant> createProperties;
+ QList<QVariant> createInput;
+ createProperties["Label"] = "test";
+ createProperties["Locked"] = false; // create collection unlocked
+ createInput << QVariant::fromValue(createProperties);
+ QDBusMessage createReply = ifaceService.callWithArgumentList(QDBus::Block, \
"CreateCollection", + createInput);
+
+ QCOMPARE(createReply.type(), QDBusMessage::ReplyMessage);
+ QList<QVariant> createArgs = createReply.arguments();
+ QCOMPARE(createArgs.size(), 2);
+ QCOMPARE(createArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
+ QCOMPARE(createArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
+ // CreateCollection is blocking, so the first output (path) should be "/".
+ QCOMPARE(createArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
+ QDBusObjectPath promptPath = createArgs.at(1).value<QDBusObjectPath>();
+ QVERIFY(promptPath.path().startsWith(
+ QLatin1String("/org/freedesktop/secrets/prompts/")));
+
+ // prompt and wait for the result.
+ ClientPrompt *prompt = new ClientPrompt(promptPath);
+ prompt->promptAndWait(5000);
+ QVERIFY(prompt->completed());
+ QVERIFY(!prompt->dismissed());
+ QCOMPARE(prompt->result().userType(), qMetaTypeId<QDBusObjectPath>());
+ collectionPath = prompt->result().value<QDBusObjectPath>();
+ QVERIFY(collectionPath.path().startsWith(
+ QLatin1String("/org/freedesktop/secrets/collection/")));
+ QDBusInterface ifaceCollection("org.freedesktop.Secret", collectionPath.path(),
+ "org.freedesktop.Secret.Collection");
+ QVERIFY(ifaceCollection.isValid());
+ delete prompt;
+
+ // make sure the CollectionCreated signal was sent
+ if(createdSpy.size() < 1) {
+ createdSpy.waitForSignal(5000);
+ }
+ QCOMPARE(createdSpy.size(), 1);
+ QCOMPARE(createdSpy.takeFirst(), collectionPath);
+
+ // read collection properties
+ QVariant propItems = ifaceCollection.property("Items");
+ QVERIFY(propItems.isValid());
+ QVERIFY(propItems.canConvert<QList<QDBusObjectPath> >());
+ QList<QDBusObjectPath> propItemsList = propItems.value<QList<QDBusObjectPath> \
>(); + QVERIFY(propItemsList.isEmpty());
+ QVariant propLabel = ifaceCollection.property("Label");
+ QVERIFY(propLabel.isValid());
+ QCOMPARE(propLabel.type(), QVariant::String);
+ QCOMPARE(propLabel.value<QString>(), QString("test"));
+ QVariant propLocked = ifaceCollection.property("Locked");
+ QVERIFY(propLocked.isValid());
+ QCOMPARE(propLocked.value<bool>(), false);
+ QVariant propCreated = ifaceCollection.property("Created");
+ QVERIFY(propCreated.isValid());
+ QCOMPARE(propCreated.type(), QVariant::ULongLong);
+ qulonglong propCreatedUll = propCreated.value<qulonglong>();
+ QVERIFY(QDateTime::currentDateTime().toTime_t() - propCreatedUll < 60);
+ QVariant propModified = ifaceCollection.property("Modified");
+ QVERIFY(propModified.isValid());
+ QCOMPARE(propModified.type(), QVariant::ULongLong);
+ QCOMPARE(propModified.value<qulonglong>(), propCreatedUll);
+
+ // set the label and re-read it.
+ ifaceCollection.setProperty("Label", QString("test2"));
+ propLabel = ifaceCollection.property("Label");
+ QVERIFY(propLabel.isValid());
+ QCOMPARE(propLabel.type(), QVariant::String);
+ QCOMPARE(propLabel.value<QString>(), QString("test2"));
+
+ // make sure the CollectionChanged signal was sent
+ if(changedSpy.size() < 1) {
+ changedSpy.waitForSignal(5000);
+ }
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.takeFirst(), collectionPath);
+
+ // delete the collection
+ QDBusMessage deleteReply = ifaceCollection.call(QDBus::Block, "Delete");
+ QCOMPARE(deleteReply.type(), QDBusMessage::ReplyMessage);
+ QList<QVariant> deleteArgs = deleteReply.arguments();
+ QCOMPARE(deleteArgs.size(), 1);
+ QCOMPARE(deleteArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
+ // TemporaryCollection is non-blocking, so the output (prompt) should be "/".
+ QCOMPARE(deleteArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
+ // make sure the collection is gone
+ QCOMPARE(ifaceCollection.call("Introspect").type(), QDBusMessage::ErrorMessage);
+
+ // make sure the CollectionDeleted signal was sent
+ if(deletedSpy.size() < 1) {
+ deletedSpy.waitForSignal(5000);
+ }
+ QCOMPARE(deletedSpy.size(), 1);
+ QCOMPARE(deletedSpy.takeFirst(), collectionPath);
+
+ // close the session
+ QDBusInterface("org.freedesktop.Secret", sessionPath.path()).call("Close");
}
void ServiceTest::nonBlockingItem()
{
- QDBusInterface ifaceService("org.freedesktop.Secret", \
"/org/freedesktop/secrets");
-
- // create a session
- QDBusObjectPath sessionPath;
- QList<QVariant> sessionInput;
- sessionInput << QString("plain") << QVariant::fromValue(QDBusVariant(""));
- QDBusMessage sessionReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession",
- sessionInput);
- sessionPath = sessionReply.arguments().at(1).value<QDBusObjectPath>();
-
- // create a collection
- QDBusObjectPath collectionPath;
- QMap<QString, QVariant> collProperties;
- QList<QVariant> collInput;
- collProperties["Label"] = "test3";
- collProperties["Locked"] = false;
- collInput << QVariant::fromValue(collProperties);
- QDBusMessage collReply = ifaceService.callWithArgumentList(QDBus::Block, \
"CreateCollection",
- collInput);
- QDBusObjectPath promptPath = \
collReply.arguments().at(1).value<QDBusObjectPath>();
- ClientPrompt *prompt = new ClientPrompt(promptPath);
- prompt->promptAndWait(5000);
- QVERIFY(prompt->completed());
- collectionPath = prompt->result().value<QDBusObjectPath>();
- delete prompt;
- QDBusInterface ifaceColl("org.freedesktop.Secret", collectionPath.path());
-
- ObjectPathSignalSpy createdSpy(&ifaceColl, SIGNAL(ItemCreated(QDBusObjectPath)));
- QVERIFY(createdSpy.isValid());
- ObjectPathSignalSpy deletedSpy(&ifaceColl, SIGNAL(ItemDeleted(QDBusObjectPath)));
- QVERIFY(deletedSpy.isValid());
- ObjectPathSignalSpy changedSpy(&ifaceColl, SIGNAL(ItemChanged(QDBusObjectPath)));
- QVERIFY(changedSpy.isValid());
-
- // create an item
- QDBusObjectPath itemPath;
- StringStringMap itemAttributes;
- itemAttributes["attribute1"] = "value1";
- itemAttributes["attribute2"] = "value2";
- QMap<QString, QVariant> itemProperties;
- itemProperties["Attributes"] = QVariant::fromValue(itemAttributes);
- itemProperties["Label"] = "item1";
- itemProperties["Locked"] = false;
- QList<QVariant> itemInput;
- Secret secret;
- secret.setSession(sessionPath);
- secret.setValue(QByteArray("mysecret"));
- itemInput << QVariant::fromValue(itemProperties);
- itemInput << QVariant::fromValue(secret);
- itemInput << false;
- QDBusMessage itemReply = ifaceColl.callWithArgumentList(QDBus::Block, \
"CreateItem",
- itemInput);
- QCOMPARE(itemReply.type(), QDBusMessage::ReplyMessage);
- QList<QVariant> itemArgs = itemReply.arguments();
- QCOMPARE(itemArgs.size(), 2);
- QCOMPARE(itemArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
- QCOMPARE(itemArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
- // TemporaryItem is non-blocking, so the second output (prompt) should be "/"
- QCOMPARE(itemArgs.at(1).value<QDBusObjectPath>().path(), QLatin1String("/"));
- itemPath = itemArgs.at(0).value<QDBusObjectPath>();
- QVERIFY(itemPath.path().startsWith(collectionPath.path() + "/"));
- QDBusInterface ifaceItem("org.freedesktop.Secret", itemPath.path(),
- "org.freedesktop.Secret.Item");
- QVERIFY(ifaceItem.isValid());
-
- // make sure the ItemCreated signal was sent
- if (createdSpy.size() < 1) {
- createdSpy.waitForSignal(5000);
- }
- QCOMPARE(createdSpy.size(), 1);
- QCOMPARE(createdSpy.takeFirst(), itemPath);
-
- // check if the collection's Items property contains the item.
- QVariant propItems = ifaceColl.property("Items");
- QVERIFY(propItems.isValid());
- QVERIFY(propItems.canConvert<QList<QDBusObjectPath> >());
- QList<QDBusObjectPath> propItemsList = propItems.value<QList<QDBusObjectPath> \
>();
- QCOMPARE(propItemsList.count(), 1);
- QCOMPARE(propItemsList.at(0), itemPath);
-
- // read item properties
- QVariant propLocked = ifaceItem.property("Locked");
- QVERIFY(propLocked.isValid());
- QCOMPARE(propLocked.type(), QVariant::Bool);
- QCOMPARE(propLocked.value<bool>(), false);
- QVariant propLabel = ifaceItem.property("Label");
- QVERIFY(propLabel.isValid());
- QCOMPARE(propLabel.type(), QVariant::String);
- QCOMPARE(propLabel.value<QString>(), QLatin1String("item1"));
- QVariant propCreated = ifaceItem.property("Created");
- QVERIFY(propCreated.isValid());
- QCOMPARE(propCreated.type(), QVariant::ULongLong);
- qulonglong propCreatedUll = propCreated.value<qulonglong>();
- QVERIFY(QDateTime::currentDateTime().toTime_t() - propCreatedUll < 60);
- QVariant propModified = ifaceItem.property("Modified");
- QVERIFY(propModified.isValid());
- QCOMPARE(propModified.type(), QVariant::ULongLong);
- QCOMPARE(propModified.value<qulonglong>(), propCreatedUll);
- QVariant propAttributes = ifaceItem.property("Attributes");
- QVERIFY(propAttributes.isValid());
- QCOMPARE(propAttributes.userType(), qMetaTypeId<StringStringMap>());
- StringStringMap propAttributesMap = propAttributes.value<StringStringMap>();
- QCOMPARE(propAttributesMap.size(), 2);
- QCOMPARE(propAttributesMap.value("attribute1"), QLatin1String("value1"));
- QCOMPARE(propAttributesMap.value("attribute2"), QLatin1String("value2"));
-
- // read the secret
- QDBusMessage secretReply = ifaceItem.call(QDBus::Block, "GetSecret",
- \
QVariant::fromValue<QDBusObjectPath>(sessionPath));
- QCOMPARE(secretReply.type(), QDBusMessage::ReplyMessage);
- QList<QVariant> secretOutput = secretReply.arguments();
- QCOMPARE(secretOutput.count(), 1);
- Secret outsecret = qdbus_cast<Secret>(secretOutput.at(0));
- QCOMPARE(outsecret.session(), sessionPath);
- QCOMPARE(outsecret.value(), QByteArray("mysecret"));
-
- // set and re-read item properties
- ifaceItem.setProperty("Label", QString("item2"));
- propLabel = ifaceItem.property("Label");
- QVERIFY(propLabel.isValid());
- QCOMPARE(propLabel.type(), QVariant::String);
- QCOMPARE(propLabel.value<QString>(), QLatin1String("item2"));
- propAttributesMap["attribute3"] = "value3";
- propAttributesMap["attribute1"] = "othervalue";
- propAttributesMap.remove("attribute2");
- ifaceItem.setProperty("Attributes", \
QVariant::fromValue<StringStringMap>(propAttributesMap));
- propAttributes = ifaceItem.property("Attributes");
- QVERIFY(propAttributes.isValid());
- QCOMPARE(propAttributes.userType(), qMetaTypeId<StringStringMap>());
- propAttributesMap = propAttributes.value<StringStringMap>();
- QCOMPARE(propAttributesMap.size(), 2);
- QCOMPARE(propAttributesMap.value("attribute1"), QLatin1String("othervalue"));
- QCOMPARE(propAttributesMap.value("attribute3"), QLatin1String("value3"));
-
- // set and re-read the secret
- secret.setValue("mysecret2");
- secretReply = ifaceItem.call(QDBus::Block, "SetSecret", \
QVariant::fromValue<Secret>(secret));
- QCOMPARE(secretReply.type(), QDBusMessage::ReplyMessage);
- secretReply = ifaceItem.call(QDBus::Block, "GetSecret",
- QVariant::fromValue<QDBusObjectPath>(sessionPath));
- QCOMPARE(secretReply.type(), QDBusMessage::ReplyMessage);
- secretOutput = secretReply.arguments();
- QCOMPARE(secretOutput.count(), 1);
- outsecret = qdbus_cast<Secret>(secretOutput.at(0));
- QCOMPARE(outsecret.session(), sessionPath);
- QCOMPARE(outsecret.value(), QByteArray("mysecret2"));
-
-
- // we should have received 2 ItemChanged signals
- if (changedSpy.size() < 3) {
- changedSpy.waitForSignals(3, 5000);
- }
- QCOMPARE(changedSpy.size(), 3);
- QCOMPARE(changedSpy.takeFirst(), itemPath);
- QCOMPARE(changedSpy.takeFirst(), itemPath);
- QCOMPARE(changedSpy.takeFirst(), itemPath);
-
- // delete the item
- QDBusMessage deleteReply = ifaceItem.call(QDBus::Block, "Delete");
- QCOMPARE(deleteReply.type(), QDBusMessage::ReplyMessage);
- QList<QVariant> deleteArgs = deleteReply.arguments();
- QCOMPARE(deleteArgs.size(), 1);
- QCOMPARE(deleteArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
- // TemporaryItem is non-blocking, so the output (prompt) should be "/"
- QCOMPARE(deleteArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
- // make sure the item is gone
- QCOMPARE(ifaceItem.call("Introspect").type(), QDBusMessage::ErrorMessage);
-
- // make sure the ItemDeleted signal was sent
- if (deletedSpy.size() < 1) {
- deletedSpy.waitForSignal(5000);
- }
- QCOMPARE(deletedSpy.size(), 1);
- QCOMPARE(deletedSpy.takeFirst(), itemPath);
-
- // delete the collection
- ifaceColl.call(QDBus::Block, "Delete");
- // close the session
- QDBusInterface("org.freedesktop.Secret", sessionPath.path()).call("Close");
+ QDBusInterface ifaceService("org.freedesktop.Secret", \
"/org/freedesktop/secrets"); +
+ // create a session
+ QDBusObjectPath sessionPath;
+ QList<QVariant> sessionInput;
+ sessionInput << QString("plain") << QVariant::fromValue(QDBusVariant(""));
+ QDBusMessage sessionReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession", + sessionInput);
+ sessionPath = sessionReply.arguments().at(1).value<QDBusObjectPath>();
+
+ // create a collection
+ QDBusObjectPath collectionPath;
+ QMap<QString, QVariant> collProperties;
+ QList<QVariant> collInput;
+ collProperties["Label"] = "test3";
+ collProperties["Locked"] = false;
+ collInput << QVariant::fromValue(collProperties);
+ QDBusMessage collReply = ifaceService.callWithArgumentList(QDBus::Block, \
"CreateCollection", + collInput);
+ QDBusObjectPath promptPath = \
collReply.arguments().at(1).value<QDBusObjectPath>(); + ClientPrompt *prompt = new \
ClientPrompt(promptPath); + prompt->promptAndWait(5000);
+ QVERIFY(prompt->completed());
+ collectionPath = prompt->result().value<QDBusObjectPath>();
+ delete prompt;
+ QDBusInterface ifaceColl("org.freedesktop.Secret", collectionPath.path());
+
+ ObjectPathSignalSpy createdSpy(&ifaceColl, \
SIGNAL(ItemCreated(QDBusObjectPath))); + QVERIFY(createdSpy.isValid());
+ ObjectPathSignalSpy deletedSpy(&ifaceColl, \
SIGNAL(ItemDeleted(QDBusObjectPath))); + QVERIFY(deletedSpy.isValid());
+ ObjectPathSignalSpy changedSpy(&ifaceColl, \
SIGNAL(ItemChanged(QDBusObjectPath))); + QVERIFY(changedSpy.isValid());
+
+ // create an item
+ QDBusObjectPath itemPath;
+ StringStringMap itemAttributes;
+ itemAttributes["attribute1"] = "value1";
+ itemAttributes["attribute2"] = "value2";
+ QMap<QString, QVariant> itemProperties;
+ itemProperties["Attributes"] = QVariant::fromValue(itemAttributes);
+ itemProperties["Label"] = "item1";
+ itemProperties["Locked"] = false;
+ QList<QVariant> itemInput;
+ Secret secret;
+ secret.setSession(sessionPath);
+ secret.setValue(QByteArray("mysecret"));
+ itemInput << QVariant::fromValue(itemProperties);
+ itemInput << QVariant::fromValue(secret);
+ itemInput << false;
+ QDBusMessage itemReply = ifaceColl.callWithArgumentList(QDBus::Block, \
"CreateItem", + itemInput);
+ QCOMPARE(itemReply.type(), QDBusMessage::ReplyMessage);
+ QList<QVariant> itemArgs = itemReply.arguments();
+ QCOMPARE(itemArgs.size(), 2);
+ QCOMPARE(itemArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
+ QCOMPARE(itemArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
+ // TemporaryItem is non-blocking, so the second output (prompt) should be "/"
+ QCOMPARE(itemArgs.at(1).value<QDBusObjectPath>().path(), QLatin1String("/"));
+ itemPath = itemArgs.at(0).value<QDBusObjectPath>();
+ QVERIFY(itemPath.path().startsWith(collectionPath.path() + "/"));
+ QDBusInterface ifaceItem("org.freedesktop.Secret", itemPath.path(),
+ "org.freedesktop.Secret.Item");
+ QVERIFY(ifaceItem.isValid());
+
+ // make sure the ItemCreated signal was sent
+ if(createdSpy.size() < 1) {
+ createdSpy.waitForSignal(5000);
+ }
+ QCOMPARE(createdSpy.size(), 1);
+ QCOMPARE(createdSpy.takeFirst(), itemPath);
+
+ // check if the collection's Items property contains the item.
+ QVariant propItems = ifaceColl.property("Items");
+ QVERIFY(propItems.isValid());
+ QVERIFY(propItems.canConvert<QList<QDBusObjectPath> >());
+ QList<QDBusObjectPath> propItemsList = propItems.value<QList<QDBusObjectPath> \
>(); + QCOMPARE(propItemsList.count(), 1);
+ QCOMPARE(propItemsList.at(0), itemPath);
+
+ // read item properties
+ QVariant propLocked = ifaceItem.property("Locked");
+ QVERIFY(propLocked.isValid());
+ QCOMPARE(propLocked.type(), QVariant::Bool);
+ QCOMPARE(propLocked.value<bool>(), false);
+ QVariant propLabel = ifaceItem.property("Label");
+ QVERIFY(propLabel.isValid());
+ QCOMPARE(propLabel.type(), QVariant::String);
+ QCOMPARE(propLabel.value<QString>(), QLatin1String("item1"));
+ QVariant propCreated = ifaceItem.property("Created");
+ QVERIFY(propCreated.isValid());
+ QCOMPARE(propCreated.type(), QVariant::ULongLong);
+ qulonglong propCreatedUll = propCreated.value<qulonglong>();
+ QVERIFY(QDateTime::currentDateTime().toTime_t() - propCreatedUll < 60);
+ QVariant propModified = ifaceItem.property("Modified");
+ QVERIFY(propModified.isValid());
+ QCOMPARE(propModified.type(), QVariant::ULongLong);
+ QCOMPARE(propModified.value<qulonglong>(), propCreatedUll);
+ QVariant propAttributes = ifaceItem.property("Attributes");
+ QVERIFY(propAttributes.isValid());
+ QCOMPARE(propAttributes.userType(), qMetaTypeId<StringStringMap>());
+ StringStringMap propAttributesMap = propAttributes.value<StringStringMap>();
+ QCOMPARE(propAttributesMap.size(), 2);
+ QCOMPARE(propAttributesMap.value("attribute1"), QLatin1String("value1"));
+ QCOMPARE(propAttributesMap.value("attribute2"), QLatin1String("value2"));
+
+ // read the secret
+ QDBusMessage secretReply = ifaceItem.call(QDBus::Block, "GetSecret",
+ QVariant::fromValue<QDBusObjectPath>(sessionPath));
+ QCOMPARE(secretReply.type(), QDBusMessage::ReplyMessage);
+ QList<QVariant> secretOutput = secretReply.arguments();
+ QCOMPARE(secretOutput.count(), 1);
+ Secret outsecret = qdbus_cast<Secret>(secretOutput.at(0));
+ QCOMPARE(outsecret.session(), sessionPath);
+ QCOMPARE(outsecret.value(), QByteArray("mysecret"));
+
+ // set and re-read item properties
+ ifaceItem.setProperty("Label", QString("item2"));
+ propLabel = ifaceItem.property("Label");
+ QVERIFY(propLabel.isValid());
+ QCOMPARE(propLabel.type(), QVariant::String);
+ QCOMPARE(propLabel.value<QString>(), QLatin1String("item2"));
+ propAttributesMap["attribute3"] = "value3";
+ propAttributesMap["attribute1"] = "othervalue";
+ propAttributesMap.remove("attribute2");
+ ifaceItem.setProperty("Attributes", \
QVariant::fromValue<StringStringMap>(propAttributesMap)); + propAttributes = \
ifaceItem.property("Attributes"); + QVERIFY(propAttributes.isValid());
+ QCOMPARE(propAttributes.userType(), qMetaTypeId<StringStringMap>());
+ propAttributesMap = propAttributes.value<StringStringMap>();
+ QCOMPARE(propAttributesMap.size(), 2);
+ QCOMPARE(propAttributesMap.value("attribute1"), QLatin1String("othervalue"));
+ QCOMPARE(propAttributesMap.value("attribute3"), QLatin1String("value3"));
+
+ // set and re-read the secret
+ secret.setValue("mysecret2");
+ secretReply = ifaceItem.call(QDBus::Block, "SetSecret", \
QVariant::fromValue<Secret>(secret)); + QCOMPARE(secretReply.type(), \
QDBusMessage::ReplyMessage); + secretReply = ifaceItem.call(QDBus::Block, \
"GetSecret", + \
QVariant::fromValue<QDBusObjectPath>(sessionPath)); + QCOMPARE(secretReply.type(), \
QDBusMessage::ReplyMessage); + secretOutput = secretReply.arguments();
+ QCOMPARE(secretOutput.count(), 1);
+ outsecret = qdbus_cast<Secret>(secretOutput.at(0));
+ QCOMPARE(outsecret.session(), sessionPath);
+ QCOMPARE(outsecret.value(), QByteArray("mysecret2"));
+
+
+ // we should have received 2 ItemChanged signals
+ if(changedSpy.size() < 3) {
+ changedSpy.waitForSignals(3, 5000);
+ }
+ QCOMPARE(changedSpy.size(), 3);
+ QCOMPARE(changedSpy.takeFirst(), itemPath);
+ QCOMPARE(changedSpy.takeFirst(), itemPath);
+ QCOMPARE(changedSpy.takeFirst(), itemPath);
+
+ // delete the item
+ QDBusMessage deleteReply = ifaceItem.call(QDBus::Block, "Delete");
+ QCOMPARE(deleteReply.type(), QDBusMessage::ReplyMessage);
+ QList<QVariant> deleteArgs = deleteReply.arguments();
+ QCOMPARE(deleteArgs.size(), 1);
+ QCOMPARE(deleteArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
+ // TemporaryItem is non-blocking, so the output (prompt) should be "/"
+ QCOMPARE(deleteArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
+ // make sure the item is gone
+ QCOMPARE(ifaceItem.call("Introspect").type(), QDBusMessage::ErrorMessage);
+
+ // make sure the ItemDeleted signal was sent
+ if(deletedSpy.size() < 1) {
+ deletedSpy.waitForSignal(5000);
+ }
+ QCOMPARE(deletedSpy.size(), 1);
+ QCOMPARE(deletedSpy.takeFirst(), itemPath);
+
+ // delete the collection
+ ifaceColl.call(QDBus::Block, "Delete");
+ // close the session
+ QDBusInterface("org.freedesktop.Secret", sessionPath.path()).call("Close");
}
void ServiceTest::reInitTestCase()
{
- // remove the TemporaryCollectionManager and replace it with a \
TempBlockingCollectionManager
- m_master->removeManager(m_tempCollMan);
- delete m_tempCollMan;
- m_tempBlockCollMan = new TempBlockingCollectionManager(m_master);
- m_master->addManager(m_tempBlockCollMan);
+ // remove the TemporaryCollectionManager and replace it with a \
TempBlockingCollectionManager + m_master->removeManager(m_tempCollMan);
+ delete m_tempCollMan;
+ m_tempBlockCollMan = new TempBlockingCollectionManager(m_master);
+ m_master->addManager(m_tempBlockCollMan);
}
void ServiceTest::blockingCollection()
{
- ClientPrompt *prompt = 0;
-
- QDBusInterface ifaceService("org.freedesktop.Secret", \
"/org/freedesktop/secrets");
- QVERIFY(ifaceService.isValid());
-
- // create a session
- // create a session
- QDBusObjectPath sessionPath;
- QList<QVariant> sessionInput;
- sessionInput << QString("plain") << QVariant::fromValue(QDBusVariant(""));
- QDBusMessage sessionReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession",
- sessionInput);
- sessionPath = sessionReply.arguments().at(1).value<QDBusObjectPath>();
-
- // listen to CollectionCreated/CollectionDeleted/CollectionChanged signals
- ObjectPathSignalSpy createdSpy(&ifaceService, \
SIGNAL(CollectionCreated(QDBusObjectPath)));
- QVERIFY(createdSpy.isValid());
- ObjectPathSignalSpy deletedSpy(&ifaceService, \
SIGNAL(CollectionDeleted(QDBusObjectPath)));
- QVERIFY(deletedSpy.isValid());
- ObjectPathSignalSpy changedSpy(&ifaceService, \
SIGNAL(CollectionChanged(QDBusObjectPath)));
- QVERIFY(changedSpy.isValid());
-
- // create a collection
- QDBusObjectPath promptPath;
- QMap<QString, QVariant> createProperties;
- QList<QVariant> createInput;
- createProperties["Label"] = "test";
- createProperties["Locked"] = false; // create collection unlocked
- createInput << QVariant::fromValue(createProperties);
- QDBusMessage createReply = ifaceService.callWithArgumentList(QDBus::Block, \
"CreateCollection",
- createInput);
- QCOMPARE(createReply.type(), QDBusMessage::ReplyMessage);
- QList<QVariant> createArgs = createReply.arguments();
- QCOMPARE(createArgs.size(), 2);
- QCOMPARE(createArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
- QCOMPARE(createArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
- // TempBlockingCollection is blocking, so the first output (path) should be "/".
- QCOMPARE(createArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
- promptPath = createArgs.at(1).value<QDBusObjectPath>();
- QVERIFY(promptPath.path().startsWith(
- QLatin1String("/org/freedesktop/secrets/prompts/")));
-
- // dismiss the prompt and wait for the result.
- prompt = new ClientPrompt(promptPath);
- prompt->dismissAndWait(5000);
- QVERIFY(prompt->completed());
- QVERIFY(prompt->dismissed());
- delete prompt;
-
- createReply = ifaceService.callWithArgumentList(QDBus::Block, "CreateCollection",
- createInput);
- QCOMPARE(createReply.type(), QDBusMessage::ReplyMessage);
- createArgs = createReply.arguments();
- QCOMPARE(createArgs.size(), 2);
- QCOMPARE(createArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
- QCOMPARE(createArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
- // TempBlockingCollection is blocking, so the first output (path) should be "/".
- QCOMPARE(createArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
- promptPath = createArgs.at(1).value<QDBusObjectPath>();
- QVERIFY(promptPath.path().startsWith(
- QLatin1String("/org/freedesktop/secrets/prompts/")));
-
- // prompt and wait for the result.
- prompt = new ClientPrompt(promptPath);
- prompt->promptAndWait(5000);
- QVERIFY(prompt->completed());
- QVERIFY(!prompt->dismissed());
- QCOMPARE(prompt->result().userType(), qMetaTypeId<QDBusObjectPath>());
- QDBusObjectPath collectionPath = prompt->result().value<QDBusObjectPath>();
- QVERIFY(collectionPath.path().startsWith(
- QLatin1String("/org/freedesktop/secrets/collection/")));
- QDBusInterface ifaceCollection("org.freedesktop.Secret", collectionPath.path(),
- "org.freedesktop.Secret.Collection");
- QVERIFY(ifaceCollection.isValid());
- delete prompt;
-
- // make sure the CollectionCreated signal was sent
- if (createdSpy.size() < 1) {
- createdSpy.waitForSignal(5000);
- }
- QCOMPARE(createdSpy.size(), 1);
- QCOMPARE(createdSpy.takeFirst(), collectionPath);
-
- // read collection properties
- QVariant propItems = ifaceCollection.property("Items");
- QVERIFY(propItems.isValid());
- QVERIFY(propItems.canConvert<QList<QDBusObjectPath> >());
- QList<QDBusObjectPath> propItemsList = propItems.value<QList<QDBusObjectPath> \
>();
- QVERIFY(propItemsList.isEmpty());
- QVariant propLabel = ifaceCollection.property("Label");
- QVERIFY(propLabel.isValid());
- QCOMPARE(propLabel.type(), QVariant::String);
- QCOMPARE(propLabel.value<QString>(), QString("test"));
- QVariant propLocked = ifaceCollection.property("Locked");
- QVERIFY(propLocked.isValid());
- QCOMPARE(propLocked.value<bool>(), false);
- QVariant propCreated = ifaceCollection.property("Created");
- QVERIFY(propCreated.isValid());
- QCOMPARE(propCreated.type(), QVariant::ULongLong);
- qulonglong propCreatedUll = propCreated.value<qulonglong>();
- QVERIFY(QDateTime::currentDateTime().toTime_t() - propCreatedUll < 60);
- QVariant propModified = ifaceCollection.property("Modified");
- QVERIFY(propModified.isValid());
- QCOMPARE(propModified.type(), QVariant::ULongLong);
- QCOMPARE(propModified.value<qulonglong>(), propCreatedUll);
-
- // set the label and re-read it.
- ifaceCollection.setProperty("Label", QString("test2"));
- propLabel = ifaceCollection.property("Label");
- QVERIFY(propLabel.isValid());
- QCOMPARE(propLabel.type(), QVariant::String);
- QCOMPARE(propLabel.value<QString>(), QString("test2"));
-
- // make sure the CollectionChanged signal was sent
- if (changedSpy.size() < 1) {
- changedSpy.waitForSignal(5000);
- }
- QCOMPARE(changedSpy.size(), 1);
- QCOMPARE(changedSpy.takeFirst(), collectionPath);
-
- // delete the collection
- QDBusMessage deleteReply = ifaceCollection.call(QDBus::Block, "Delete");
- QCOMPARE(deleteReply.type(), QDBusMessage::ReplyMessage);
- QList<QVariant> deleteArgs = deleteReply.arguments();
- QCOMPARE(deleteArgs.size(), 1);
- QCOMPARE(deleteArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
- // TempBlockingCollection is blocking, so the output (prompt) should be a valid \
one.
- promptPath = deleteArgs.at(0).value<QDBusObjectPath>();
- QVERIFY(promptPath.path().startsWith(QLatin1String("/org/freedesktop/secrets/prompts/")));
-
- // dismiss the prompt and wait for the result.
- prompt = new ClientPrompt(promptPath);
- prompt->dismissAndWait(5000);
- QVERIFY(prompt->completed());
- QVERIFY(prompt->dismissed());
- delete prompt;
-
- // retry and complete the prompt this time
- deleteReply = ifaceCollection.call(QDBus::Block, "Delete");
- QCOMPARE(deleteReply.type(), QDBusMessage::ReplyMessage);
- deleteArgs = deleteReply.arguments();
- QCOMPARE(deleteArgs.size(), 1);
- QCOMPARE(deleteArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
- // TempBlockingCollection is blocking, so the output (prompt) should be a valid \
one.
- promptPath = deleteArgs.at(0).value<QDBusObjectPath>();
- QVERIFY(promptPath.path().startsWith(QLatin1String("/org/freedesktop/secrets/prompts/")));
- prompt = new ClientPrompt(promptPath);
- prompt->promptAndWait(5000);
- QVERIFY(prompt->completed());
- QVERIFY(!prompt->dismissed());
- delete prompt;
-
- // make sure the collection is gone
- QCOMPARE(ifaceCollection.call("Introspect").type(), QDBusMessage::ErrorMessage);
-
- // make sure the CollectionDeleted signal was sent
- if (deletedSpy.size() < 1) {
- deletedSpy.waitForSignal(5000);
- }
- QCOMPARE(deletedSpy.size(), 1);
- QCOMPARE(deletedSpy.takeFirst(), collectionPath);
-
- // close the session
- QDBusInterface("org.freedesktop.Secret", sessionPath.path()).call("Close");
+ ClientPrompt *prompt = 0;
+
+ QDBusInterface ifaceService("org.freedesktop.Secret", \
"/org/freedesktop/secrets"); + QVERIFY(ifaceService.isValid());
+
+ // create a session
+ // create a session
+ QDBusObjectPath sessionPath;
+ QList<QVariant> sessionInput;
+ sessionInput << QString("plain") << QVariant::fromValue(QDBusVariant(""));
+ QDBusMessage sessionReply = ifaceService.callWithArgumentList(QDBus::Block, \
"OpenSession", + sessionInput);
+ sessionPath = sessionReply.arguments().at(1).value<QDBusObjectPath>();
+
+ // listen to CollectionCreated/CollectionDeleted/CollectionChanged signals
+ ObjectPathSignalSpy createdSpy(&ifaceService, \
SIGNAL(CollectionCreated(QDBusObjectPath))); + QVERIFY(createdSpy.isValid());
+ ObjectPathSignalSpy deletedSpy(&ifaceService, \
SIGNAL(CollectionDeleted(QDBusObjectPath))); + QVERIFY(deletedSpy.isValid());
+ ObjectPathSignalSpy changedSpy(&ifaceService, \
SIGNAL(CollectionChanged(QDBusObjectPath))); + QVERIFY(changedSpy.isValid());
+
+ // create a collection
+ QDBusObjectPath promptPath;
+ QMap<QString, QVariant> createProperties;
+ QList<QVariant> createInput;
+ createProperties["Label"] = "test";
+ createProperties["Locked"] = false; // create collection unlocked
+ createInput << QVariant::fromValue(createProperties);
+ QDBusMessage createReply = ifaceService.callWithArgumentList(QDBus::Block, \
"CreateCollection", + createInput);
+ QCOMPARE(createReply.type(), QDBusMessage::ReplyMessage);
+ QList<QVariant> createArgs = createReply.arguments();
+ QCOMPARE(createArgs.size(), 2);
+ QCOMPARE(createArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
+ QCOMPARE(createArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
+ // TempBlockingCollection is blocking, so the first output (path) should be "/".
+ QCOMPARE(createArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
+ promptPath = createArgs.at(1).value<QDBusObjectPath>();
+ QVERIFY(promptPath.path().startsWith(
+ QLatin1String("/org/freedesktop/secrets/prompts/")));
+
+ // dismiss the prompt and wait for the result.
+ prompt = new ClientPrompt(promptPath);
+ prompt->dismissAndWait(5000);
+ QVERIFY(prompt->completed());
+ QVERIFY(prompt->dismissed());
+ delete prompt;
+
+ createReply = ifaceService.callWithArgumentList(QDBus::Block, \
"CreateCollection", + createInput);
+ QCOMPARE(createReply.type(), QDBusMessage::ReplyMessage);
+ createArgs = createReply.arguments();
+ QCOMPARE(createArgs.size(), 2);
+ QCOMPARE(createArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
+ QCOMPARE(createArgs.at(1).userType(), qMetaTypeId<QDBusObjectPath>());
+ // TempBlockingCollection is blocking, so the first output (path) should be "/".
+ QCOMPARE(createArgs.at(0).value<QDBusObjectPath>().path(), QLatin1String("/"));
+ promptPath = createArgs.at(1).value<QDBusObjectPath>();
+ QVERIFY(promptPath.path().startsWith(
+ QLatin1String("/org/freedesktop/secrets/prompts/")));
+
+ // prompt and wait for the result.
+ prompt = new ClientPrompt(promptPath);
+ prompt->promptAndWait(5000);
+ QVERIFY(prompt->completed());
+ QVERIFY(!prompt->dismissed());
+ QCOMPARE(prompt->result().userType(), qMetaTypeId<QDBusObjectPath>());
+ QDBusObjectPath collectionPath = prompt->result().value<QDBusObjectPath>();
+ QVERIFY(collectionPath.path().startsWith(
+ QLatin1String("/org/freedesktop/secrets/collection/")));
+ QDBusInterface ifaceCollection("org.freedesktop.Secret", collectionPath.path(),
+ "org.freedesktop.Secret.Collection");
+ QVERIFY(ifaceCollection.isValid());
+ delete prompt;
+
+ // make sure the CollectionCreated signal was sent
+ if(createdSpy.size() < 1) {
+ createdSpy.waitForSignal(5000);
+ }
+ QCOMPARE(createdSpy.size(), 1);
+ QCOMPARE(createdSpy.takeFirst(), collectionPath);
+
+ // read collection properties
+ QVariant propItems = ifaceCollection.property("Items");
+ QVERIFY(propItems.isValid());
+ QVERIFY(propItems.canConvert<QList<QDBusObjectPath> >());
+ QList<QDBusObjectPath> propItemsList = propItems.value<QList<QDBusObjectPath> \
>(); + QVERIFY(propItemsList.isEmpty());
+ QVariant propLabel = ifaceCollection.property("Label");
+ QVERIFY(propLabel.isValid());
+ QCOMPARE(propLabel.type(), QVariant::String);
+ QCOMPARE(propLabel.value<QString>(), QString("test"));
+ QVariant propLocked = ifaceCollection.property("Locked");
+ QVERIFY(propLocked.isValid());
+ QCOMPARE(propLocked.value<bool>(), false);
+ QVariant propCreated = ifaceCollection.property("Created");
+ QVERIFY(propCreated.isValid());
+ QCOMPARE(propCreated.type(), QVariant::ULongLong);
+ qulonglong propCreatedUll = propCreated.value<qulonglong>();
+ QVERIFY(QDateTime::currentDateTime().toTime_t() - propCreatedUll < 60);
+ QVariant propModified = ifaceCollection.property("Modified");
+ QVERIFY(propModified.isValid());
+ QCOMPARE(propModified.type(), QVariant::ULongLong);
+ QCOMPARE(propModified.value<qulonglong>(), propCreatedUll);
+
+ // set the label and re-read it.
+ ifaceCollection.setProperty("Label", QString("test2"));
+ propLabel = ifaceCollection.property("Label");
+ QVERIFY(propLabel.isValid());
+ QCOMPARE(propLabel.type(), QVariant::String);
+ QCOMPARE(propLabel.value<QString>(), QString("test2"));
+
+ // make sure the CollectionChanged signal was sent
+ if(changedSpy.size() < 1) {
+ changedSpy.waitForSignal(5000);
+ }
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.takeFirst(), collectionPath);
+
+ // delete the collection
+ QDBusMessage deleteReply = ifaceCollection.call(QDBus::Block, "Delete");
+ QCOMPARE(deleteReply.type(), QDBusMessage::ReplyMessage);
+ QList<QVariant> deleteArgs = deleteReply.arguments();
+ QCOMPARE(deleteArgs.size(), 1);
+ QCOMPARE(deleteArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
+ // TempBlockingCollection is blocking, so the output (prompt) should be a valid \
one. + promptPath = deleteArgs.at(0).value<QDBusObjectPath>();
+ QVERIFY(promptPath.path().startsWith(QLatin1String("/org/freedesktop/secrets/prompts/")));
+
+ // dismiss the prompt and wait for the result.
+ prompt = new ClientPrompt(promptPath);
+ prompt->dismissAndWait(5000);
+ QVERIFY(prompt->completed());
+ QVERIFY(prompt->dismissed());
+ delete prompt;
+
+ // retry and complete the prompt this time
+ deleteReply = ifaceCollection.call(QDBus::Block, "Delete");
+ QCOMPARE(deleteReply.type(), QDBusMessage::ReplyMessage);
+ deleteArgs = deleteReply.arguments();
+ QCOMPARE(deleteArgs.size(), 1);
+ QCOMPARE(deleteArgs.at(0).userType(), qMetaTypeId<QDBusObjectPath>());
+ // TempBlockingCollection is blocking, so the output (prompt) should be a valid \
one. + promptPath = deleteArgs.at(0).value<QDBusObjectPath>();
+ QVERIFY(promptPath.path().startsWith(QLatin1String("/org/freedesktop/secrets/prompts/")));
+ prompt = new ClientPrompt(promptPath);
+ prompt->promptAndWait(5000);
+ QVERIFY(prompt->completed());
+ QVERIFY(!prompt->dismissed());
+ delete prompt;
+
+ // make sure the collection is gone
+ QCOMPARE(ifaceCollection.call("Introspect").type(), QDBusMessage::ErrorMessage);
+
+ // make sure the CollectionDeleted signal was sent
+ if(deletedSpy.size() < 1) {
+ deletedSpy.waitForSignal(5000);
+ }
+ QCOMPARE(deletedSpy.size(), 1);
+ QCOMPARE(deletedSpy.takeFirst(), collectionPath);
+
+ // close the session
+ QDBusInterface("org.freedesktop.Secret", sessionPath.path()).call("Close");
}
void ServiceTest::blockingItem()
{
- // TODO: test
+ // TODO: test
}
void ServiceTest::cleanupTestCase()
{
- delete m_service;
+ delete m_service;
- QCA::deinit();
+ QCA::deinit();
}
QTEST_KDEMAIN_CORE(ServiceTest)
ObjectPathSignalSpy::ObjectPathSignalSpy(QDBusAbstractInterface *iface,
- const char *signal)
+ const char *signal)
{
- m_valid = connect(iface, signal, SLOT(slotReceived(QDBusObjectPath)));
+ m_valid = connect(iface, signal, SLOT(slotReceived(QDBusObjectPath)));
}
bool ObjectPathSignalSpy::isValid() const
{
- return m_valid;
+ return m_valid;
}
void ObjectPathSignalSpy::waitForSignal(int time)
{
- waitForSignals(1, time);
+ waitForSignals(1, time);
}
void ObjectPathSignalSpy::waitForSignals(int num, int time)
{
- m_numWaiting = num;
- if (count() < m_numWaiting)
- {
- QEventLoop loop;
- loop.connect(this, SIGNAL(doneWaiting()), SLOT(quit()));
- QTimer::singleShot(time, &loop, SLOT(quit()));
- loop.exec();
- }
+ m_numWaiting = num;
+ if(count() < m_numWaiting) {
+ QEventLoop loop;
+ loop.connect(this, SIGNAL(doneWaiting()), SLOT(quit()));
+ QTimer::singleShot(time, &loop, SLOT(quit()));
+ loop.exec();
+ }
}
void ObjectPathSignalSpy::slotReceived(const QDBusObjectPath &objectPath)
{
- append(objectPath);
- if (count() >= m_numWaiting) {
- emit doneWaiting();
- }
+ append(objectPath);
+ if(count() >= m_numWaiting) {
+ emit doneWaiting();
+ }
}
ClientPrompt::ClientPrompt(QDBusObjectPath promptPath)
- : m_completed(false), m_dismissed(false),
- m_interface("org.freedesktop.Secret", promptPath.path())
+ : m_completed(false), m_dismissed(false),
+ m_interface("org.freedesktop.Secret", promptPath.path())
{
- Q_ASSERT(m_interface.isValid());
- connect(&m_interface, SIGNAL(Completed(bool, QDBusVariant)),
- SLOT(slotCompleted(bool, QDBusVariant)));
+ Q_ASSERT(m_interface.isValid());
+ connect(&m_interface, SIGNAL(Completed(bool, QDBusVariant)),
+ SLOT(slotCompleted(bool, QDBusVariant)));
}
void ClientPrompt::promptAndWait(int time)
{
- QDBusMessage reply = m_interface.call(QDBus::Block, "Prompt", QString(""));
- Q_ASSERT(reply.type() == QDBusMessage::ReplyMessage);
- justWait(time);
+ QDBusMessage reply = m_interface.call(QDBus::Block, "Prompt", QString(""));
+ Q_ASSERT(reply.type() == QDBusMessage::ReplyMessage);
+ justWait(time);
}
void ClientPrompt::dismissAndWait(int time)
{
- QDBusMessage reply = m_interface.call(QDBus::Block, "Dismiss");
- Q_ASSERT(reply.type() == QDBusMessage::ReplyMessage);
- justWait(time);
+ QDBusMessage reply = m_interface.call(QDBus::Block, "Dismiss");
+ Q_ASSERT(reply.type() == QDBusMessage::ReplyMessage);
+ justWait(time);
}
void ClientPrompt::slotCompleted(bool dismissed, const QDBusVariant &result)
{
- m_completed = true;
- m_dismissed = dismissed;
- m_result = result.variant();
- m_loop.quit();
+ m_completed = true;
+ m_dismissed = dismissed;
+ m_result = result.variant();
+ m_loop.quit();
}
void ClientPrompt::justWait(int time)
{
- if (time > 0) {
- QTimer::singleShot(time, &m_loop, SLOT(quit()));
- }
- m_loop.exec();
+ if(time > 0) {
+ QTimer::singleShot(time, &m_loop, SLOT(quit()));
+ }
+ m_loop.exec();
}
#include "servicetest.moc"
diff --git a/frontend/tests/servicetest.h b/frontend/tests/servicetest.h
index 4f9dbb3..2133710 100644
--- a/frontend/tests/servicetest.h
+++ b/frontend/tests/servicetest.h
@@ -40,41 +40,41 @@ class QDBusAbstractInterface;
*/
class ServiceTest : public QObject
{
- Q_OBJECT
+ Q_OBJECT
private:
- BackendMaster *m_master;
- TemporaryCollectionManager *m_tempCollMan;
- TempBlockingCollectionManager *m_tempBlockCollMan;
- Service *m_service;
+ BackendMaster *m_master;
+ TemporaryCollectionManager *m_tempCollMan;
+ TempBlockingCollectionManager *m_tempBlockCollMan;
+ Service *m_service;
private Q_SLOTS:
- // create services and collections needed for testing
- void initTestCase();
+ // create services and collections needed for testing
+ void initTestCase();
- // check if Service is registered with D-Bus
- void dbusService();
+ // check if Service is registered with D-Bus
+ void dbusService();
- // open various sessions, make sure they are available on the bus, then close \
them.
- void session();
+ // open various sessions, make sure they are available on the bus, then close \
them. + void session();
- // create and remove collections
- void nonBlockingCollection();
-
- // create and remove items
- void nonBlockingItem();
+ // create and remove collections
+ void nonBlockingCollection();
- // change some of the parameters of the testcase needed for the tests to come
- void reInitTestCase();
-
- // create and remove blocking collections
- void blockingCollection();
+ // create and remove items
+ void nonBlockingItem();
- // create and remove blocking items
- void blockingItem();
+ // change some of the parameters of the testcase needed for the tests to come
+ void reInitTestCase();
- // cleanup
- void cleanupTestCase();
+ // create and remove blocking collections
+ void blockingCollection();
+
+ // create and remove blocking items
+ void blockingItem();
+
+ // cleanup
+ void cleanupTestCase();
};
/**
@@ -83,32 +83,32 @@ private Q_SLOTS:
*/
class ObjectPathSignalSpy : public QObject, public QList<QDBusObjectPath>
{
- Q_OBJECT
+ Q_OBJECT
public:
- // constructor. similar to QSignalSpy's constructor.
- ObjectPathSignalSpy(QDBusAbstractInterface *iface, const char *signal);
-
- // return true if the connection to the signal was successful
- bool isValid() const;
-
- // wait a specified number of ms for the signal to be received.
- void waitForSignal(int time);
-
- // wait a specified number of ms for multiple signals to be received
- void waitForSignals(int num, int time);
+ // constructor. similar to QSignalSpy's constructor.
+ ObjectPathSignalSpy(QDBusAbstractInterface *iface, const char *signal);
+
+ // return true if the connection to the signal was successful
+ bool isValid() const;
+
+ // wait a specified number of ms for the signal to be received.
+ void waitForSignal(int time);
+
+ // wait a specified number of ms for multiple signals to be received
+ void waitForSignals(int num, int time);
Q_SIGNALS:
- // stop waiting for the signal.
- void doneWaiting();
-
+ // stop waiting for the signal.
+ void doneWaiting();
+
private Q_SLOTS:
- // Single slot which receives all of the various signals.
- void slotReceived(const QDBusObjectPath &objectPath);
-
+ // Single slot which receives all of the various signals.
+ void slotReceived(const QDBusObjectPath &objectPath);
+
private:
- bool m_valid;
- int m_numWaiting;
+ bool m_valid;
+ int m_numWaiting;
};
/**
@@ -116,47 +116,47 @@ private:
*/
class ClientPrompt : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- // constructor. wraps around the prompt at promptPath.
- ClientPrompt(QDBusObjectPath promptPath);
+ // constructor. wraps around the prompt at promptPath.
+ ClientPrompt(QDBusObjectPath promptPath);
- // Call the Prompt method and wait some time for completion
- // (sends bogus window-id)
- void promptAndWait(int time);
+ // Call the Prompt method and wait some time for completion
+ // (sends bogus window-id)
+ void promptAndWait(int time);
- // Call the Dismiss method and wait some time for completion
- void dismissAndWait(int time);
+ // Call the Dismiss method and wait some time for completion
+ void dismissAndWait(int time);
- // check if the call has been completed
- bool completed() const {
- return m_completed;
- }
+ // check if the call has been completed
+ bool completed() const {
+ return m_completed;
+ }
- // check if the call was dismissed
- bool dismissed() const {
- return m_dismissed;
- }
+ // check if the call was dismissed
+ bool dismissed() const {
+ return m_dismissed;
+ }
- // get the call's result
- const QVariant &result() const {
- return m_result;
- }
+ // get the call's result
+ const QVariant &result() const {
+ return m_result;
+ }
private Q_SLOTS:
- // listens for Completed signals of the D-Bus prompt.
- void slotCompleted(bool dismissed, const QDBusVariant &result);
+ // listens for Completed signals of the D-Bus prompt.
+ void slotCompleted(bool dismissed, const QDBusVariant &result);
private:
- // just wait (called by *AndWait methods)
- void justWait(int time);
-
- bool m_completed;
- bool m_dismissed;
- QVariant m_result;
- QDBusInterface m_interface;
- QEventLoop m_loop;
+ // just wait (called by *AndWait methods)
+ void justWait(int time);
+
+ bool m_completed;
+ bool m_dismissed;
+ QVariant m_result;
+ QDBusInterface m_interface;
+ QEventLoop m_loop;
};
#endif
diff --git a/frontend/tests/tempblockingcollection.cpp \
b/frontend/tests/tempblockingcollection.cpp index 0c4c12b..5ecbc4d 100644
--- a/frontend/tests/tempblockingcollection.cpp
+++ b/frontend/tests/tempblockingcollection.cpp
@@ -25,12 +25,12 @@
#include <secrettool.h>
TempBlockingCollection::TempBlockingCollection(const QString &id, \
BackendCollectionManager *parent)
- : BackendCollection(parent)
+ : BackendCollection(parent)
{
- m_id = id;
- QDateTime now = QDateTime::currentDateTime();
- m_created = now;
- m_modified = now;
+ m_id = id;
+ QDateTime now = QDateTime::currentDateTime();
+ m_created = now;
+ m_modified = now;
}
TempBlockingCollection::~TempBlockingCollection()
@@ -39,161 +39,161 @@ TempBlockingCollection::~TempBlockingCollection()
QString TempBlockingCollection::id() const
{
- return m_id;
+ return m_id;
}
BackendReturn<QString> TempBlockingCollection::label() const
{
- return m_label;
+ return m_label;
}
BackendReturn<void> TempBlockingCollection::setLabel(const QString &label)
{
- m_label = label;
- emit collectionChanged(this);
- return BackendReturn<void>();
+ m_label = label;
+ emit collectionChanged(this);
+ return BackendReturn<void>();
}
QDateTime TempBlockingCollection::created() const
{
- return m_created;
+ return m_created;
}
QDateTime TempBlockingCollection::modified() const
{
- return m_modified;
+ return m_modified;
}
bool TempBlockingCollection::isLocked() const
{
- return false;
+ return false;
}
BackendReturn<QList<BackendItem*> > TempBlockingCollection::items() const
{
- return m_items;
+ return m_items;
}
BackendReturn<QList<BackendItem*> > TempBlockingCollection::searchItems(
- const QMap<QString, QString> &attributes) const
+ const QMap<QString, QString> &attributes) const
{
- TempBlockingItem *titem;
- QList<BackendItem*> foundItems;
- Q_FOREACH(BackendItem *item, m_items) {
- titem = qobject_cast<TempBlockingItem*>(item);
- if (titem && titem->matches(attributes)) {
- foundItems.append(item);
- }
- }
- return foundItems;
+ TempBlockingItem *titem;
+ QList<BackendItem*> foundItems;
+ Q_FOREACH(BackendItem * item, m_items) {
+ titem = qobject_cast<TempBlockingItem*>(item);
+ if(titem && titem->matches(attributes)) {
+ foundItems.append(item);
+ }
+ }
+ return foundItems;
}
-UnlockCollectionJob *TempBlockingCollection::createUnlockJob( const \
CollectionUnlockInfo &unlockInfo ) +UnlockCollectionJob \
*TempBlockingCollection::createUnlockJob(const CollectionUnlockInfo &unlockInfo) {
- return new TempBlockingUnlockCollectionJob(unlockInfo, this);
+ return new TempBlockingUnlockCollectionJob(unlockInfo, this);
}
LockCollectionJob *TempBlockingCollection::createLockJob()
{
- return new TempBlockingLockCollectionJob(this);
+ return new TempBlockingLockCollectionJob(this);
}
DeleteCollectionJob *TempBlockingCollection::createDeleteJob(const \
CollectionDeleteInfo& deleteJobInfo) {
- deleteJobInfo.m_collection = this;
- TempBlockingDeleteCollectionJob *job = new \
TempBlockingDeleteCollectionJob(deleteJobInfo);
- connect(job, SIGNAL(result(QueuedJob*)),
- SLOT(deleteCollectionJobResult(QueuedJob*)));
- return job;
+ deleteJobInfo.m_collection = this;
+ TempBlockingDeleteCollectionJob *job = new \
TempBlockingDeleteCollectionJob(deleteJobInfo); + connect(job, \
SIGNAL(result(QueuedJob*)), + \
SLOT(deleteCollectionJobResult(QueuedJob*))); + return job;
}
CreateItemJob *TempBlockingCollection::createCreateItemJob(const ItemCreateInfo& \
createInfo) {
- return new TempBlockingCreateItemJob(createInfo, this);
+ return new TempBlockingCreateItemJob(createInfo, this);
}
ChangeAuthenticationCollectionJob \
*TempBlockingCollection::createChangeAuthenticationJob() {
- return new TempBlockingChangeAuthenticationCollectionJob(this);
+ return new TempBlockingChangeAuthenticationCollectionJob(this);
}
BackendReturn<BackendItem*> TempBlockingCollection::createItem(const QString &label,
- const QMap<QString, \
QString> &attributes,
- const \
QCA::SecureArray &secret,
- bool locked, bool \
replace)
-{
- Q_UNUSED(locked);
-
- TempBlockingItem *item = 0;
- bool replacing = false;
-
- // check for duplicates
- BackendReturn<QList<BackendItem*> > foundItems = searchItems(attributes);
- if (!foundItems.isError() && foundItems.value().size() > 0) {
- QList<BackendItem*> oldlist = foundItems.value();
- Q_FOREACH(BackendItem* olditem, oldlist) {
- if (olditem->attributes().value() == attributes) {
- if (replace) {
- // replacing an existing item
- item = qobject_cast<TempBlockingItem*>(olditem);
- replacing = true;
- } else {
- // item existing but should not be replaced
- return BackendReturn<BackendItem*>(0, ErrorAlreadyExists);
+ const QMap<QString, QString> &attributes,
+ const QCA::SecureArray &secret,
+ bool locked, bool replace)
+{
+ Q_UNUSED(locked);
+
+ TempBlockingItem *item = 0;
+ bool replacing = false;
+
+ // check for duplicates
+ BackendReturn<QList<BackendItem*> > foundItems = searchItems(attributes);
+ if(!foundItems.isError() && foundItems.value().size() > 0) {
+ QList<BackendItem*> oldlist = foundItems.value();
+ Q_FOREACH(BackendItem * olditem, oldlist) {
+ if(olditem->attributes().value() == attributes) {
+ if(replace) {
+ // replacing an existing item
+ item = qobject_cast<TempBlockingItem*>(olditem);
+ replacing = true;
+ } else {
+ // item existing but should not be replaced
+ return BackendReturn<BackendItem*>(0, ErrorAlreadyExists);
+ }
+ break;
}
- break;
- }
- }
- }
-
- if (!item) {
- item = new TempBlockingItem(createId(), this);
- }
- item->blockSignals(true);
- item->setLabel(label);
- item->setAttributes(attributes);
- item->setSecret(secret);
- item->blockSignals(false);
-
- if (replacing) {
- emit itemChanged(item);
- } else {
- m_items.append(item);
- // new item, signals need to be wired
- connect(item, SIGNAL(itemDeleted(BackendItem*)), \
SLOT(slotItemDeleted(BackendItem*)));
- connect(item, SIGNAL(itemChanged(BackendItem*)), \
SIGNAL(itemChanged(BackendItem*)));
- emit itemCreated(item);
- }
-
- return item;
+ }
+ }
+
+ if(!item) {
+ item = new TempBlockingItem(createId(), this);
+ }
+ item->blockSignals(true);
+ item->setLabel(label);
+ item->setAttributes(attributes);
+ item->setSecret(secret);
+ item->blockSignals(false);
+
+ if(replacing) {
+ emit itemChanged(item);
+ } else {
+ m_items.append(item);
+ // new item, signals need to be wired
+ connect(item, SIGNAL(itemDeleted(BackendItem*)), \
SLOT(slotItemDeleted(BackendItem*))); + connect(item, \
SIGNAL(itemChanged(BackendItem*)), SIGNAL(itemChanged(BackendItem*))); + emit \
itemCreated(item); + }
+
+ return item;
}
void TempBlockingCollection::slotItemDeleted(BackendItem *item)
{
- m_items.removeAll(item);
- emit itemDeleted(item);
+ m_items.removeAll(item);
+ emit itemDeleted(item);
}
void TempBlockingCollection::deleteCollectionJobResult(QueuedJob *job)
{
- TempBlockingDeleteCollectionJob * dcj = \
qobject_cast<TempBlockingDeleteCollectionJob*>(job);
- Q_ASSERT(dcj);
- if (!dcj->result()) {
- return;
- }
- emit collectionDeleted(this);
+ TempBlockingDeleteCollectionJob * dcj = \
qobject_cast<TempBlockingDeleteCollectionJob*>(job); + Q_ASSERT(dcj);
+ if(!dcj->result()) {
+ return;
+ }
+ emit collectionDeleted(this);
}
-BackendCollection::ApplicationPermission \
TempBlockingCollection::applicationPermission(const QString& ) const \
+BackendCollection::ApplicationPermission \
TempBlockingCollection::applicationPermission(const QString&) const {
- // FIXME: is this the expected behavior in tempblockingcollection ?
- return BackendCollection::PermissionAllow;
+ // FIXME: is this the expected behavior in tempblockingcollection ?
+ return BackendCollection::PermissionAllow;
}
-bool TempBlockingCollection::setApplicationPermission(const QString& , \
BackendCollection::ApplicationPermission ) +bool \
TempBlockingCollection::setApplicationPermission(const QString& , \
BackendCollection::ApplicationPermission) {
- // FIXME: is this the expected behavior in tempblockingcollection ?
- return true;
+ // FIXME: is this the expected behavior in tempblockingcollection ?
+ return true;
}
#include "tempblockingcollection.moc"
diff --git a/frontend/tests/tempblockingcollection.h \
b/frontend/tests/tempblockingcollection.h index 0f15633..c686eb5 100644
--- a/frontend/tests/tempblockingcollection.h
+++ b/frontend/tests/tempblockingcollection.h
@@ -26,46 +26,46 @@
// implement a temporary collection that blocks every call.
class TempBlockingCollection : public BackendCollection
{
- Q_OBJECT
+ Q_OBJECT
public:
- TempBlockingCollection(const QString &id, BackendCollectionManager *parent);
- virtual ~TempBlockingCollection();
- virtual QString id() const;
- virtual BackendReturn<QString> label() const;
- virtual BackendReturn<void> setLabel(const QString &label);
- virtual QDateTime created() const;
- virtual QDateTime modified() const;
- virtual bool isLocked() const;
- virtual BackendReturn<QList<BackendItem*> > items() const;
- virtual BackendReturn<QList<BackendItem*> > searchItems(const QMap<QString, \
QString> &attributes) const;
- virtual UnlockCollectionJob *createUnlockJob( const CollectionUnlockInfo \
&unlockInfo );
- virtual LockCollectionJob *createLockJob();
- virtual DeleteCollectionJob *createDeleteJob(const CollectionDeleteInfo& \
deleteJobInfo);
- virtual CreateItemJob *createCreateItemJob(const ItemCreateInfo& createInfo);
- virtual ChangeAuthenticationCollectionJob *createChangeAuthenticationJob();
- virtual ApplicationPermission applicationPermission(const QString& path) const;
- virtual bool setApplicationPermission(const QString& path, ApplicationPermission \
perm); + TempBlockingCollection(const QString &id, BackendCollectionManager \
*parent); + virtual ~TempBlockingCollection();
+ virtual QString id() const;
+ virtual BackendReturn<QString> label() const;
+ virtual BackendReturn<void> setLabel(const QString &label);
+ virtual QDateTime created() const;
+ virtual QDateTime modified() const;
+ virtual bool isLocked() const;
+ virtual BackendReturn<QList<BackendItem*> > items() const;
+ virtual BackendReturn<QList<BackendItem*> > searchItems(const QMap<QString, \
QString> &attributes) const; + virtual UnlockCollectionJob *createUnlockJob(const \
CollectionUnlockInfo &unlockInfo); + virtual LockCollectionJob *createLockJob();
+ virtual DeleteCollectionJob *createDeleteJob(const CollectionDeleteInfo& \
deleteJobInfo); + virtual CreateItemJob *createCreateItemJob(const ItemCreateInfo& \
createInfo); + virtual ChangeAuthenticationCollectionJob \
*createChangeAuthenticationJob(); + virtual ApplicationPermission \
applicationPermission(const QString& path) const; + virtual bool \
setApplicationPermission(const QString& path, ApplicationPermission perm);
protected:
- BackendReturn<BackendItem*> createItem(const QString &label,
- const QMap<QString, QString> &attributes,
- const QCA::SecureArray &secret, bool \
locked,
- bool replace);
+ BackendReturn<BackendItem*> createItem(const QString &label,
+ const QMap<QString, QString> &attributes,
+ const QCA::SecureArray &secret, bool \
locked, + bool replace);
private Q_SLOTS:
- void slotItemDeleted(BackendItem *item);
- void deleteCollectionJobResult(QueuedJob *job);
+ void slotItemDeleted(BackendItem *item);
+ void deleteCollectionJobResult(QueuedJob *job);
private:
- friend class TempBlockingCreateItemJob;
-
- QString m_id;
- QString m_label;
- QDateTime m_created;
- QDateTime m_modified;
+ friend class TempBlockingCreateItemJob;
- QList<BackendItem*> m_items;
+ QString m_id;
+ QString m_label;
+ QDateTime m_created;
+ QDateTime m_modified;
+
+ QList<BackendItem*> m_items;
};
#endif
diff --git a/frontend/tests/tempblockingcollectionmanager.cpp \
b/frontend/tests/tempblockingcollectionmanager.cpp index c5bdc6f..678df2c 100644
--- a/frontend/tests/tempblockingcollectionmanager.cpp
+++ b/frontend/tests/tempblockingcollectionmanager.cpp
@@ -25,7 +25,7 @@
#include <secrettool.h>
TempBlockingCollectionManager::TempBlockingCollectionManager(QObject *parent)
- : BackendCollectionManager(parent)
+ : BackendCollectionManager(parent)
{
}
@@ -35,26 +35,26 @@ TempBlockingCollectionManager::~TempBlockingCollectionManager()
CreateCollectionJob *TempBlockingCollectionManager::createCreateCollectionJob(const \
CollectionCreateInfo &createCollectionInfo) {
- TempBlockingCreateCollectionJob *job = new \
TempBlockingCreateCollectionJob(createCollectionInfo,
- this);
- connect(job, SIGNAL(result(QueuedJob*)),
- SLOT(createCollectionJobResult(QueuedJob*)));
- return job;
+ TempBlockingCreateCollectionJob *job = new \
TempBlockingCreateCollectionJob(createCollectionInfo, + this);
+ connect(job, SIGNAL(result(QueuedJob*)),
+ SLOT(createCollectionJobResult(QueuedJob*)));
+ return job;
}
void TempBlockingCollectionManager::createCollectionJobResult(QueuedJob *job)
{
- CreateCollectionJob *ccj = qobject_cast<CreateCollectionJob*>(job);
- Q_ASSERT(ccj);
-
- if (!ccj->collection()) {
- return;
- }
-
- // connect signals
- connect(ccj->collection(), SIGNAL(collectionDeleted(BackendCollection*)),
- SIGNAL(collectionDeleted(BackendCollection*)));
- emit collectionCreated(ccj->collection());
+ CreateCollectionJob *ccj = qobject_cast<CreateCollectionJob*>(job);
+ Q_ASSERT(ccj);
+
+ if(!ccj->collection()) {
+ return;
+ }
+
+ // connect signals
+ connect(ccj->collection(), SIGNAL(collectionDeleted(BackendCollection*)),
+ SIGNAL(collectionDeleted(BackendCollection*)));
+ emit collectionCreated(ccj->collection());
}
#include "tempblockingcollectionmanager.moc"
diff --git a/frontend/tests/tempblockingcollectionmanager.h \
b/frontend/tests/tempblockingcollectionmanager.h index b5664d3..3f39635 100644
--- a/frontend/tests/tempblockingcollectionmanager.h
+++ b/frontend/tests/tempblockingcollectionmanager.h
@@ -28,18 +28,18 @@ class TempBlockingCollection;
// implement a temporary collection manager that blocks every call.
class TempBlockingCollectionManager : public BackendCollectionManager
{
- Q_OBJECT
+ Q_OBJECT
public:
- friend class TempBlockingCollection;
+ friend class TempBlockingCollection;
public:
- TempBlockingCollectionManager(QObject *parent = 0);
- virtual ~TempBlockingCollectionManager();
- virtual CreateCollectionJob *createCreateCollectionJob(const CollectionCreateInfo \
&createCollectionInfod);
-
+ TempBlockingCollectionManager(QObject *parent = 0);
+ virtual ~TempBlockingCollectionManager();
+ virtual CreateCollectionJob *createCreateCollectionJob(const \
CollectionCreateInfo &createCollectionInfod); +
private Q_SLOTS:
- void createCollectionJobResult(QueuedJob *job);
+ void createCollectionJobResult(QueuedJob *job);
};
#endif
diff --git a/frontend/tests/tempblockingitem.cpp \
b/frontend/tests/tempblockingitem.cpp index 708c580..c7103df 100644
--- a/frontend/tests/tempblockingitem.cpp
+++ b/frontend/tests/tempblockingitem.cpp
@@ -23,11 +23,11 @@
#include "tempblockingjobs.h"
TempBlockingItem::TempBlockingItem(const QString &id, TempBlockingCollection \
*parent)
- : BackendItem(parent), m_id(id)
+ : BackendItem(parent), m_id(id)
{
- QDateTime now = QDateTime::currentDateTime();
- m_created = now;
- m_modified = now;
+ QDateTime now = QDateTime::currentDateTime();
+ m_created = now;
+ m_modified = now;
}
TempBlockingItem::~TempBlockingItem()
@@ -36,112 +36,112 @@ TempBlockingItem::~TempBlockingItem()
QString TempBlockingItem::id() const
{
- return m_id;
+ return m_id;
}
BackendReturn<QString> TempBlockingItem::label() const
{
- return m_label;
+ return m_label;
}
BackendReturn<void> TempBlockingItem::setLabel(const QString &label)
{
- m_label = label;
- markAsModified();
- return BackendReturn<void>();
+ m_label = label;
+ markAsModified();
+ return BackendReturn<void>();
}
BackendReturn<QCA::SecureArray> TempBlockingItem::secret() const
{
- return m_secret;
+ return m_secret;
}
BackendReturn<void> TempBlockingItem::setSecret(const QCA::SecureArray &secret)
{
- m_secret = secret;
- markAsModified();
- return BackendReturn<void>();
+ m_secret = secret;
+ markAsModified();
+ return BackendReturn<void>();
}
BackendReturn<QMap<QString, QString> > TempBlockingItem::attributes() const
{
- return m_attributes;
+ return m_attributes;
}
BackendReturn<void> TempBlockingItem::setAttributes(const QMap<QString, QString> \
&attributes) {
- m_attributes = attributes;
- markAsModified();
- return BackendReturn<void>();
+ m_attributes = attributes;
+ markAsModified();
+ return BackendReturn<void>();
}
QDateTime TempBlockingItem::created() const
{
- return m_created;
+ return m_created;
}
QDateTime TempBlockingItem::modified() const
{
- return m_modified;
+ return m_modified;
}
bool TempBlockingItem::isLocked() const
{
- return false;
+ return false;
}
-UnlockItemJob *TempBlockingItem::createUnlockJob( const ItemUnlockInfo &unlockInfo )
+UnlockItemJob *TempBlockingItem::createUnlockJob(const ItemUnlockInfo &unlockInfo)
{
- unlockInfo.m_item = this;
- return new TempBlockingUnlockItemJob(unlockInfo);
+ unlockInfo.m_item = this;
+ return new TempBlockingUnlockItemJob(unlockInfo);
}
LockItemJob *TempBlockingItem::createLockJob()
{
- return new TempBlockingLockItemJob(this);
+ return new TempBlockingLockItemJob(this);
}
DeleteItemJob *TempBlockingItem::createDeleteJob(const ItemDeleteInfo& \
deleteJobInfo) {
- deleteJobInfo.m_item = this;
- TempBlockingDeleteItemJob *job = new TempBlockingDeleteItemJob(deleteJobInfo);
- connect(job, SIGNAL(result(QueuedJob*)), SLOT(deleteItemJobResult(QueuedJob*)));
- return job;
+ deleteJobInfo.m_item = this;
+ TempBlockingDeleteItemJob *job = new TempBlockingDeleteItemJob(deleteJobInfo);
+ connect(job, SIGNAL(result(QueuedJob*)), SLOT(deleteItemJobResult(QueuedJob*)));
+ return job;
}
ChangeAuthenticationItemJob *TempBlockingItem::createChangeAuthenticationJob()
{
- return new TempBlockingChangeAuthenticationItemJob(this);
+ return new TempBlockingChangeAuthenticationItemJob(this);
}
bool TempBlockingItem::matches(const QMap<QString, QString> &attributes)
{
- QMap<QString, QString>::const_iterator it = attributes.constBegin();
- QMap<QString, QString>::const_iterator end = attributes.constEnd();
- for ( ; it != end; ++it) {
- if (!m_attributes.contains(it.key()) ||
- m_attributes.value(it.key()) != it.value()) {
- return false;
- }
- }
-
- return true;
+ QMap<QString, QString>::const_iterator it = attributes.constBegin();
+ QMap<QString, QString>::const_iterator end = attributes.constEnd();
+ for(; it != end; ++it) {
+ if(!m_attributes.contains(it.key()) ||
+ m_attributes.value(it.key()) != it.value()) {
+ return false;
+ }
+ }
+
+ return true;
}
void TempBlockingItem::deleteItemJobResult(QueuedJob *job)
{
- TempBlockingDeleteItemJob *dij = qobject_cast<TempBlockingDeleteItemJob*>(job);
- Q_ASSERT(dij);
- if (!dij->result()) {
- return;
- }
- emit itemDeleted(this);
+ TempBlockingDeleteItemJob *dij = qobject_cast<TempBlockingDeleteItemJob*>(job);
+ Q_ASSERT(dij);
+ if(!dij->result()) {
+ return;
+ }
+ emit itemDeleted(this);
}
void TempBlockingItem::markAsModified()
{
- m_modified = QDateTime::currentDateTime();
- emit itemChanged(this);
+ m_modified = QDateTime::currentDateTime();
+ emit itemChanged(this);
}
#include "tempblockingitem.moc"
diff --git a/frontend/tests/tempblockingitem.h b/frontend/tests/tempblockingitem.h
index c0fc91f..507baee 100644
--- a/frontend/tests/tempblockingitem.h
+++ b/frontend/tests/tempblockingitem.h
@@ -28,42 +28,42 @@ class TempBlockingCollection;
// temporary item that blocks every call
class TempBlockingItem : public BackendItem
{
- Q_OBJECT
+ Q_OBJECT
public:
- friend class TempBlockingCollection;
+ friend class TempBlockingCollection;
+
+ TempBlockingItem(const QString &id, TempBlockingCollection *parent);
+ ~TempBlockingItem();
+ virtual QString id() const;
+ virtual BackendReturn<QString> label() const;
+ virtual BackendReturn<void> setLabel(const QString &label);
+ virtual BackendReturn<QCA::SecureArray> secret() const;
+ virtual BackendReturn<void> setSecret(const QCA::SecureArray &secret);
+ virtual BackendReturn<QMap<QString, QString> > attributes() const;
+ virtual BackendReturn<void> setAttributes(const QMap<QString, QString> \
&attributes); + virtual QDateTime created() const;
+ virtual QDateTime modified() const;
+ virtual bool isLocked() const;
+ virtual UnlockItemJob *createUnlockJob(const ItemUnlockInfo &unlockInfo);
+ virtual LockItemJob *createLockJob();
+ virtual DeleteItemJob *createDeleteJob(const ItemDeleteInfo& deleteJobInfo);
+ virtual ChangeAuthenticationItemJob *createChangeAuthenticationJob();
+ bool matches(const QMap<QString, QString> &attributes);
- TempBlockingItem(const QString &id, TempBlockingCollection *parent);
- ~TempBlockingItem();
- virtual QString id() const;
- virtual BackendReturn<QString> label() const;
- virtual BackendReturn<void> setLabel(const QString &label);
- virtual BackendReturn<QCA::SecureArray> secret() const;
- virtual BackendReturn<void> setSecret(const QCA::SecureArray &secret);
- virtual BackendReturn<QMap<QString, QString> > attributes() const;
- virtual BackendReturn<void> setAttributes(const QMap<QString, QString> \
&attributes);
- virtual QDateTime created() const;
- virtual QDateTime modified() const;
- virtual bool isLocked() const;
- virtual UnlockItemJob *createUnlockJob( const ItemUnlockInfo &unlockInfo );
- virtual LockItemJob *createLockJob();
- virtual DeleteItemJob *createDeleteJob(const ItemDeleteInfo& deleteJobInfo);
- virtual ChangeAuthenticationItemJob *createChangeAuthenticationJob();
- bool matches(const QMap<QString, QString> &attributes);
-
private Q_SLOTS:
- void deleteItemJobResult(QueuedJob *job);
-
+ void deleteItemJobResult(QueuedJob *job);
+
private:
- void markAsModified();
-
- QString m_id;
- QString m_label;
- QDateTime m_created;
- QDateTime m_modified;
- QMap<QString, QString> m_attributes;
-
- QCA::SecureArray m_secret;
+ void markAsModified();
+
+ QString m_id;
+ QString m_label;
+ QDateTime m_created;
+ QDateTime m_modified;
+ QMap<QString, QString> m_attributes;
+
+ QCA::SecureArray m_secret;
};
#endif
diff --git a/frontend/tests/tempblockingjobs.cpp \
b/frontend/tests/tempblockingjobs.cpp index 0a5615b..6a8b22a 100644
--- a/frontend/tests/tempblockingjobs.cpp
+++ b/frontend/tests/tempblockingjobs.cpp
@@ -25,134 +25,134 @@
#include <QtCore/QTimer>
TempBlockingCreateCollectionJob::TempBlockingCreateCollectionJob(const \
CollectionCreateInfo &createCollectionInfo,
- \
TempBlockingCollectionManager *manager)
- : CreateCollectionJob(createCollectionInfo, manager)
+ TempBlockingCollectionManager *manager)
+ : CreateCollectionJob(createCollectionInfo, manager)
{
}
void TempBlockingCreateCollectionJob::perform()
{
- TempBlockingCollection *coll = new TempBlockingCollection(createId(), manager());
- coll->setLabel(label());
-
- setCollection(coll);
- emitResult();
+ TempBlockingCollection *coll = new TempBlockingCollection(createId(), \
manager()); + coll->setLabel(label());
+
+ setCollection(coll);
+ emitResult();
}
TempBlockingUnlockCollectionJob::TempBlockingUnlockCollectionJob(const \
CollectionUnlockInfo &unlockInfo,
- BackendCollection* \
coll)
- : UnlockCollectionJob(unlockInfo, coll)
+ BackendCollection* coll)
+ : UnlockCollectionJob(unlockInfo, coll)
{
}
void TempBlockingUnlockCollectionJob::perform()
{
- setResult(true);
- emitResult();
+ setResult(true);
+ emitResult();
}
TempBlockingLockCollectionJob::TempBlockingLockCollectionJob(BackendCollection* \
coll)
- : LockCollectionJob(coll)
+ : LockCollectionJob(coll)
{
}
void TempBlockingLockCollectionJob::perform()
{
- setError(ErrorNotSupported);
- setResult(false);
- emitResult();
+ setError(ErrorNotSupported);
+ setResult(false);
+ emitResult();
}
TempBlockingDeleteCollectionJob::TempBlockingDeleteCollectionJob(const \
CollectionDeleteInfo& deleteInfo)
- : DeleteCollectionJob(deleteInfo)
+ : DeleteCollectionJob(deleteInfo)
{
}
void TempBlockingDeleteCollectionJob::perform()
{
- setResult(true);
- collection()->deleteLater();
- emitResult();
+ setResult(true);
+ collection()->deleteLater();
+ emitResult();
}
TempBlockingChangeAuthenticationCollectionJob::TempBlockingChangeAuthenticationCollectionJob(BackendCollection* \
coll)
- : ChangeAuthenticationCollectionJob(coll)
+ : ChangeAuthenticationCollectionJob(coll)
{
}
void TempBlockingChangeAuthenticationCollectionJob::perform()
{
- setError(ErrorNotSupported);
- setResult(false);
- emitResult();
+ setError(ErrorNotSupported);
+ setResult(false);
+ emitResult();
}
TempBlockingCreateItemJob::TempBlockingCreateItemJob(const ItemCreateInfo& \
createInfo,
- TempBlockingCollection* \
collection)
- : CreateItemJob(createInfo, collection),
- m_tempColl(collection)
+ TempBlockingCollection* collection)
+ : CreateItemJob(createInfo, collection),
+ m_tempColl(collection)
{
}
void TempBlockingCreateItemJob::perform()
{
- BackendReturn<BackendItem*> rc = m_tempColl->createItem(label(), attributes(),
- secret(), locked(),
- replace());
-
- if (rc.isError()) {
- setError(rc.error(), rc.errorMessage());
- } else {
- setItem(rc.value());
- }
- emitResult();
+ BackendReturn<BackendItem*> rc = m_tempColl->createItem(label(), attributes(),
+ secret(), locked(),
+ replace());
+
+ if(rc.isError()) {
+ setError(rc.error(), rc.errorMessage());
+ } else {
+ setItem(rc.value());
+ }
+ emitResult();
}
TempBlockingUnlockItemJob::TempBlockingUnlockItemJob(const ItemUnlockInfo& \
unlockInfo)
- : UnlockItemJob(unlockInfo)
+ : UnlockItemJob(unlockInfo)
{
}
void TempBlockingUnlockItemJob::perform()
{
- setResult(true);
- emitResult();
+ setResult(true);
+ emitResult();
}
TempBlockingLockItemJob::TempBlockingLockItemJob(BackendItem* item)
- : LockItemJob(item)
+ : LockItemJob(item)
{
}
void TempBlockingLockItemJob::perform()
{
- setError(ErrorNotSupported);
- setResult(false);
- emitResult();
+ setError(ErrorNotSupported);
+ setResult(false);
+ emitResult();
}
TempBlockingDeleteItemJob::TempBlockingDeleteItemJob(const ItemDeleteInfo \
&deleteInfo)
- : DeleteItemJob(deleteInfo)
+ : DeleteItemJob(deleteInfo)
{
}
void TempBlockingDeleteItemJob::perform()
{
- setResult(true);
- item()->deleteLater();
- emitResult();
+ setResult(true);
+ item()->deleteLater();
+ emitResult();
}
TempBlockingChangeAuthenticationItemJob::TempBlockingChangeAuthenticationItemJob(BackendItem* \
item)
- : ChangeAuthenticationItemJob(item)
+ : ChangeAuthenticationItemJob(item)
{
}
void TempBlockingChangeAuthenticationItemJob::perform()
{
- setError(ErrorNotSupported);
- setResult(false);
- emitResult();
+ setError(ErrorNotSupported);
+ setResult(false);
+ emitResult();
}
#include "tempblockingjobs.moc"
diff --git a/frontend/tests/tempblockingjobs.h b/frontend/tests/tempblockingjobs.h
index d92805f..d8ab30b 100644
--- a/frontend/tests/tempblockingjobs.h
+++ b/frontend/tests/tempblockingjobs.h
@@ -29,147 +29,207 @@
class TempBlockingCreateCollectionJob : public CreateCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingCreateCollectionJob(const CollectionCreateInfo& createCollectionInfo,
- TempBlockingCollectionManager *manager);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
-
+ TempBlockingCreateCollectionJob(const CollectionCreateInfo& \
createCollectionInfo, + \
TempBlockingCollectionManager *manager); + virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
+
private Q_SLOTS:
- void perform();
+ void perform();
};
class TempBlockingUnlockCollectionJob : public UnlockCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingUnlockCollectionJob(const CollectionUnlockInfo &unlockInfo, \
BackendCollection *coll);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
-
+ TempBlockingUnlockCollectionJob(const CollectionUnlockInfo &unlockInfo, \
BackendCollection *coll); + virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
+
private Q_SLOTS:
- void perform();
+ void perform();
};
class TempBlockingDeleteCollectionJob : public DeleteCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingDeleteCollectionJob(const CollectionDeleteInfo& deleteInfo);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
+ TempBlockingDeleteCollectionJob(const CollectionDeleteInfo& deleteInfo);
+ virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
private Q_SLOTS:
- void perform();
+ void perform();
};
class TempBlockingLockCollectionJob : public LockCollectionJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingLockCollectionJob(BackendCollection *coll);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
+ TempBlockingLockCollectionJob(BackendCollection *coll);
+ virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
private Q_SLOTS:
- void perform();
+ void perform();
};
class TempBlockingChangeAuthenticationCollectionJob : public \
ChangeAuthenticationCollectionJob {
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingChangeAuthenticationCollectionJob(BackendCollection *coll);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
+ TempBlockingChangeAuthenticationCollectionJob(BackendCollection *coll);
+ virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
private Q_SLOTS:
- void perform();
+ void perform();
};
class TempBlockingCreateItemJob : public CreateItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingCreateItemJob(const ItemCreateInfo& createInfo,
- TempBlockingCollection *collection);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
+ TempBlockingCreateItemJob(const ItemCreateInfo& createInfo,
+ TempBlockingCollection *collection);
+ virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
private Q_SLOTS:
- void perform();
-
+ void perform();
+
private:
- TempBlockingCollection* m_tempColl;
+ TempBlockingCollection* m_tempColl;
};
class TempBlockingUnlockItemJob : public UnlockItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingUnlockItemJob(const ItemUnlockInfo& unlockInfo);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
+ TempBlockingUnlockItemJob(const ItemUnlockInfo& unlockInfo);
+ virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
private Q_SLOTS:
- void perform();
+ void perform();
};
class TempBlockingLockItemJob : public LockItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingLockItemJob(BackendItem *item);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
+ TempBlockingLockItemJob(BackendItem *item);
+ virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
private Q_SLOTS:
- void perform();
+ void perform();
};
class TempBlockingDeleteItemJob : public DeleteItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingDeleteItemJob(const ItemDeleteInfo &deleteInfo);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
+ TempBlockingDeleteItemJob(const ItemDeleteInfo &deleteInfo);
+ virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
private Q_SLOTS:
- void perform();
+ void perform();
};
class TempBlockingChangeAuthenticationItemJob : public ChangeAuthenticationItemJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TempBlockingChangeAuthenticationItemJob(BackendItem *item);
- virtual bool isImmediate() const { return false; }
- virtual void exec() { Q_ASSERT(false); }
- virtual void start() { QTimer::singleShot(0, this, SLOT(perform())); }
+ TempBlockingChangeAuthenticationItemJob(BackendItem *item);
+ virtual bool isImmediate() const {
+ return false;
+ }
+ virtual void exec() {
+ Q_ASSERT(false);
+ }
+ virtual void start() {
+ QTimer::singleShot(0, this, SLOT(perform()));
+ }
private Q_SLOTS:
- void perform();
+ void perform();
};
#endif
diff --git a/kwlimporter/importsinglewalletjob.cpp \
b/kwlimporter/importsinglewalletjob.cpp index 8d62af0..b6be42f 100644
--- a/kwlimporter/importsinglewalletjob.cpp
+++ b/kwlimporter/importsinglewalletjob.cpp
@@ -32,11 +32,11 @@
#include <KDebug>
ImportSingleWalletJob::ImportSingleWalletJob(Service *service, const QString& \
walletName, QObject* parent)
- : KJob(parent)
- , m_walletName(walletName)
- , m_service(service)
- , m_isSuspended(false)
- , m_hasKillRequest(false)
+ : KJob(parent)
+ , m_walletName(walletName)
+ , m_service(service)
+ , m_isSuspended(false)
+ , m_hasKillRequest(false)
{
}
@@ -57,7 +57,7 @@ void ImportSingleWalletJob::run()
{
m_wallet = new KWallet::Backend(m_walletName);
// TODO prompt for password here
- if (m_wallet->open(QByteArray()) != 0) {
+ if(m_wallet->open(QByteArray()) != 0) {
kError() << "Could not open wallet " << m_walletName;
// Be async
QMetaObject::invokeMethod(this, "onWalletOpened", Qt::QueuedConnection, \
Q_ARG(bool, false)); @@ -69,7 +69,7 @@ void ImportSingleWalletJob::run()
void ImportSingleWalletJob::onWalletOpened(bool success)
{
- if (!success) {
+ if(!success) {
setErrorText(i18n("The wallet %1 could not be opened", m_walletName));
emitResult();
return;
@@ -83,7 +83,7 @@ void ImportSingleWalletJob::onWalletOpened(bool success)
QDBusObjectPath prompt;
m_collectionPath = m_service->createCollection(createProperties, prompt);
- if (m_collectionPath.path() == "/") {
+ if(m_collectionPath.path() == "/") {
setErrorText(i18n("The collection %1 could not be created", m_walletName));
emitResult();
return;
@@ -91,7 +91,7 @@ void ImportSingleWalletJob::onWalletOpened(bool success)
// Create the interface
m_collectionInterface = new QDBusInterface("org.freedesktop.Secret", \
m_collectionPath.path(), QString(),
- QDBusConnection::sessionBus(), this);
+ QDBusConnection::sessionBus(), this);
// Gather the folder list
m_folderList = m_wallet->folderList();
@@ -102,7 +102,7 @@ void ImportSingleWalletJob::onWalletOpened(bool success)
void ImportSingleWalletJob::processCurrentFolder()
{
- if (!canProceed()) {
+ if(!canProceed()) {
return;
}
@@ -114,11 +114,11 @@ void ImportSingleWalletJob::processCurrentFolder()
void ImportSingleWalletJob::processNextEntry()
{
- if (!canProceed()) {
+ if(!canProceed()) {
return;
}
- if (m_currentEntryList.isEmpty()) {
+ if(m_currentEntryList.isEmpty()) {
// Ok, we're done with this folder. Let's skip to the next one
QMetaObject::invokeMethod(this, "processNextFolder", Qt::QueuedConnection);
return;
@@ -136,7 +136,7 @@ void ImportSingleWalletJob::processNextEntry()
// Read the entry
KWallet::Entry *walletEntry = m_wallet->readEntry(entry);
- if (!walletEntry) {
+ if(!walletEntry) {
// We abort the job here - but maybe we should just spit a warning?
setErrorText(i18n("Could not read the entry %1", entry));
emitResult();
@@ -144,7 +144,7 @@ void ImportSingleWalletJob::processNextEntry()
}
// If it's a map, populate attributes
- if (walletEntry->type() == KWallet::Entry::Map) {
+ if(walletEntry->type() == KWallet::Entry::Map) {
StringStringMap itemAttributes;
// Read the entry
@@ -164,7 +164,7 @@ void ImportSingleWalletJob::processNextEntry()
Secret secret;
- if (walletEntry->type() != KWallet::Entry::Map) {
+ if(walletEntry->type() != KWallet::Entry::Map) {
// Read the entry
secret.setValue(walletEntry->value());
} else {
@@ -176,11 +176,11 @@ void ImportSingleWalletJob::processNextEntry()
itemInput << false;
QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> itemReply =
- \
m_collectionInterface->asyncCallWithArgumentList("CreateItem", itemInput); + \
m_collectionInterface->asyncCallWithArgumentList("CreateItem", itemInput);
itemReply.waitForFinished();
- if (itemReply.isError()) {
+ if(itemReply.isError()) {
// We abort the job here - but maybe we should just spit a warning?
setErrorText(i18n("Calling CreateItem on the secret service daemon for the \
entry %1 failed", entry)); emitResult();
@@ -197,13 +197,13 @@ void ImportSingleWalletJob::processNextEntry()
void ImportSingleWalletJob::processNextFolder()
{
- if (!canProceed()) {
+ if(!canProceed()) {
return;
}
m_status = ProcessingNextFolder;
- if (m_folderList.isEmpty()) {
+ if(m_folderList.isEmpty()) {
// We're done!
emitResult();
return;
@@ -217,7 +217,7 @@ void ImportSingleWalletJob::processNextFolder()
bool ImportSingleWalletJob::doKill()
{
- if (m_status == Initializing) {
+ if(m_status == Initializing) {
return false;
}
@@ -230,17 +230,17 @@ bool ImportSingleWalletJob::doResume()
{
m_isSuspended = false;
- switch (m_status) {
- case ProcessingCurrentFolder:
- case ProcessingEntry:
- processNextEntry();
- break;
- case ProcessingNextFolder:
- processCurrentFolder();
- break;
- default:
- return false;
- break;
+ switch(m_status) {
+ case ProcessingCurrentFolder:
+ case ProcessingEntry:
+ processNextEntry();
+ break;
+ case ProcessingNextFolder:
+ processCurrentFolder();
+ break;
+ default:
+ return false;
+ break;
}
return true;
@@ -248,7 +248,7 @@ bool ImportSingleWalletJob::doResume()
bool ImportSingleWalletJob::doSuspend()
{
- if (m_status == Initializing) {
+ if(m_status == Initializing) {
return false;
}
diff --git a/kwlimporter/importsinglewalletjob.h \
b/kwlimporter/importsinglewalletjob.h index b812bca..a0fb46d 100644
--- a/kwlimporter/importsinglewalletjob.h
+++ b/kwlimporter/importsinglewalletjob.h
@@ -28,7 +28,8 @@
#include <QtDBus/QDBusObjectPath>
-namespace KWallet {
+namespace KWallet
+{
class Backend;
}
diff --git a/kwlimporter/kwalletbackend/blockcipher.h \
b/kwlimporter/kwalletbackend/blockcipher.h index ef8868d..a4c3533 100644
--- a/kwlimporter/kwalletbackend/blockcipher.h
+++ b/kwlimporter/kwalletbackend/blockcipher.h
@@ -22,52 +22,53 @@
/* @internal
*/
-class BlockCipher {
- public:
- BlockCipher();
- virtual ~BlockCipher();
+class BlockCipher
+{
+public:
+ BlockCipher();
+ virtual ~BlockCipher();
- /*
- * Return the current blocksize in bytes.
- */
- int blockSize() const;
+ /*
+ * Return the current blocksize in bytes.
+ */
+ int blockSize() const;
- /*
- * Set the encryption key to key. Return true on success.
- */
- virtual bool setKey(void *key, int bitlength) = 0;
+ /*
+ * Set the encryption key to key. Return true on success.
+ */
+ virtual bool setKey(void *key, int bitlength) = 0;
- /*
- * Get the required (or if it's variable, then the maximum) key
- * length for this cipher in bits.
- */
- virtual int keyLen() const = 0;
+ /*
+ * Get the required (or if it's variable, then the maximum) key
+ * length for this cipher in bits.
+ */
+ virtual int keyLen() const = 0;
- /*
- * True if the key is of a variable length. In this case,
- * getKeyLen() will return the maximum length.
- */
- virtual bool variableKeyLen() const = 0;
+ /*
+ * True if the key is of a variable length. In this case,
+ * getKeyLen() will return the maximum length.
+ */
+ virtual bool variableKeyLen() const = 0;
- /*
- * True if all settings are good and we are ready to encrypt.
- */
- virtual bool readyToGo() const = 0;
+ /*
+ * True if all settings are good and we are ready to encrypt.
+ */
+ virtual bool readyToGo() const = 0;
- /*
- * Encrypt the block. Returns the number of bytes successfully
- * encrypted. Can return -1 on error.
- */
- virtual int encrypt(void *block, int len) = 0;
+ /*
+ * Encrypt the block. Returns the number of bytes successfully
+ * encrypted. Can return -1 on error.
+ */
+ virtual int encrypt(void *block, int len) = 0;
- /*
- * Decrypt the block. Returns as does encrypt();
- */
- virtual int decrypt(void *block, int len) = 0;
+ /*
+ * Decrypt the block. Returns as does encrypt();
+ */
+ virtual int decrypt(void *block, int len) = 0;
- protected:
- int _blksz;
- int _keylen; // in bits
+protected:
+ int _blksz;
+ int _keylen; // in bits
};
#endif // BLOCKCIPHER_H
diff --git a/kwlimporter/kwalletbackend/blowfish.h \
b/kwlimporter/kwalletbackend/blowfish.h index 0d73934..8481cfd 100644
--- a/kwlimporter/kwalletbackend/blowfish.h
+++ b/kwlimporter/kwalletbackend/blowfish.h
@@ -1,16 +1,16 @@
/* This file is part of the KDE project
Copyright (C) 2001 George Staikos <staikos@kde.org>
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -34,36 +34,37 @@
/* @internal
*/
-class BlowFish : public BlockCipher {
- public:
- BlowFish();
- virtual ~BlowFish();
+class BlowFish : public BlockCipher
+{
+public:
+ BlowFish();
+ virtual ~BlowFish();
- virtual bool setKey(void *key, int bitlength);
+ virtual bool setKey(void *key, int bitlength);
- virtual int keyLen() const;
+ virtual int keyLen() const;
- virtual bool variableKeyLen() const;
+ virtual bool variableKeyLen() const;
- virtual bool readyToGo() const;
+ virtual bool readyToGo() const;
- virtual int encrypt(void *block, int len);
+ virtual int encrypt(void *block, int len);
- virtual int decrypt(void *block, int len);
+ virtual int decrypt(void *block, int len);
- private:
- uint32_t _S[4][256];
- uint32_t _P[18];
+private:
+ uint32_t _S[4][256];
+ uint32_t _P[18];
- void *_key;
- int _keylen; // in bits
+ void *_key;
+ int _keylen; // in bits
- bool _init;
+ bool _init;
- bool init();
- uint32_t F(uint32_t x);
- void encipher(uint32_t *xl, uint32_t *xr);
- void decipher(uint32_t *xl, uint32_t *xr);
+ bool init();
+ uint32_t F(uint32_t x);
+ void encipher(uint32_t *xl, uint32_t *xr);
+ void decipher(uint32_t *xl, uint32_t *xr);
};
#endif
diff --git a/kwlimporter/kwalletbackend/blowfishtables.h \
b/kwlimporter/kwalletbackend/blowfishtables.h index bed18f1..c621ff3 100644
--- a/kwlimporter/kwalletbackend/blowfishtables.h
+++ b/kwlimporter/kwalletbackend/blowfishtables.h
@@ -1,16 +1,16 @@
/* This file is part of the KDE project
Copyright (C) 2001 George Staikos <staikos@kde.org>
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -23,188 +23,193 @@
#define BLOWFISHTABLES_H
const unsigned long ks0[256] = {
- 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96,
- 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
- 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
- 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
- 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e,
- 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
- 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6,
- 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
- 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
- 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
- 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1,
- 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
- 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a,
- 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
- 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
- 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
- 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706,
- 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
- 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b,
- 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
- 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
- 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
- 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a,
- 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
- 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760,
- 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
- 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
- 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
- 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33,
- 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
- 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0,
- 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
- 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
- 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
- 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705,
- 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
- 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e,
- 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
- 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
- 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
- 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f,
- 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
- 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a };
+ 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96,
+ 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
+ 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
+ 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
+ 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e,
+ 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
+ 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6,
+ 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
+ 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
+ 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
+ 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1,
+ 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
+ 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a,
+ 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
+ 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
+ 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
+ 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706,
+ 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
+ 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b,
+ 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
+ 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
+ 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
+ 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a,
+ 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
+ 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760,
+ 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
+ 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
+ 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
+ 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33,
+ 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
+ 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0,
+ 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
+ 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
+ 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
+ 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705,
+ 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
+ 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e,
+ 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
+ 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
+ 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
+ 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f,
+ 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
+ 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
+};
const unsigned long ks1[256] = {
- 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
- 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
- 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65,
- 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
- 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
- 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
- 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
- 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
- 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc,
- 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
- 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908,
- 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
- 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
- 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
- 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908,
- 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
- 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
- 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
- 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
- 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
- 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
- 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
- 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
- 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
- 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96,
- 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
- 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
- 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
- 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77,
- 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
- 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054,
- 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
- 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
- 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
- 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
- 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
- 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
- 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
- 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e,
- 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
- 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
- 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
- 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7 };
+ 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
+ 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
+ 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65,
+ 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
+ 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
+ 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
+ 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
+ 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
+ 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc,
+ 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
+ 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908,
+ 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
+ 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
+ 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
+ 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908,
+ 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
+ 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
+ 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
+ 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
+ 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
+ 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
+ 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
+ 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
+ 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
+ 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96,
+ 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
+ 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
+ 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
+ 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77,
+ 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
+ 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054,
+ 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
+ 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
+ 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
+ 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
+ 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
+ 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
+ 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
+ 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e,
+ 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
+ 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
+ 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
+ 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
+};
const unsigned long ks2[256] = {
- 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7,
- 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
- 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af,
- 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
- 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4,
- 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
- 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec,
- 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
- 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332,
- 0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
- 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58,
- 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
- 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22,
- 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
- 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60,
- 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
- 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99,
- 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
- 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74,
- 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
- 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
- 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
- 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979,
- 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
- 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa,
- 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
- 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086,
- 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
- 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24,
- 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
- 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
- 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
- 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09,
- 0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
- 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe,
- 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
- 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0,
- 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
- 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188,
- 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
- 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
- 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
- 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0 };
+ 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7,
+ 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
+ 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af,
+ 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
+ 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4,
+ 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
+ 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec,
+ 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
+ 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332,
+ 0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
+ 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58,
+ 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
+ 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22,
+ 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
+ 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60,
+ 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
+ 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99,
+ 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
+ 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74,
+ 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
+ 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
+ 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
+ 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979,
+ 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
+ 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa,
+ 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
+ 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086,
+ 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
+ 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24,
+ 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
+ 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
+ 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
+ 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09,
+ 0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
+ 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe,
+ 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
+ 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0,
+ 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
+ 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188,
+ 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
+ 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
+ 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
+ 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
+};
const unsigned long ks3[256] = {
- 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
- 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
- 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79,
- 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
- 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
- 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
- 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
- 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
- 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797,
- 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
- 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6,
- 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
- 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
- 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
- 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5,
- 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
- 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce,
- 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
- 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
- 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
- 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb,
- 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
- 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc,
- 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
- 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
- 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
- 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a,
- 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
- 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a,
- 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
- 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
- 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
- 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e,
- 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
- 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623,
- 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
- 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
- 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
- 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3,
- 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
- 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
- 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
- 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 };
+ 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
+ 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
+ 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79,
+ 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
+ 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
+ 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
+ 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
+ 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
+ 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797,
+ 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
+ 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6,
+ 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
+ 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
+ 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
+ 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5,
+ 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
+ 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce,
+ 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
+ 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
+ 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
+ 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb,
+ 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
+ 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc,
+ 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
+ 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
+ 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
+ 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a,
+ 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
+ 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a,
+ 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
+ 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
+ 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
+ 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e,
+ 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
+ 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623,
+ 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
+ 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
+ 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
+ 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3,
+ 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
+ 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
+ 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
+ 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
+};
const unsigned long P[18] = {
- 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
- 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
- 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b };
+ 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
+ 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
+ 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b
+};
#endif // BLOWFISHTABLES_H
diff --git a/kwlimporter/kwalletbackend/cbc.h b/kwlimporter/kwalletbackend/cbc.h
index 1ce971a..b1b92c5 100644
--- a/kwlimporter/kwalletbackend/cbc.h
+++ b/kwlimporter/kwalletbackend/cbc.h
@@ -1,16 +1,16 @@
/* This file is part of the KDE project
Copyright (C) 2001 George Staikos <staikos@kde.org>
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -33,29 +33,30 @@
* calls to the other will fail in this instance.
*/
-class CipherBlockChain : public BlockCipher {
- public:
- CipherBlockChain(BlockCipher *cipher);
- virtual ~CipherBlockChain();
+class CipherBlockChain : public BlockCipher
+{
+public:
+ CipherBlockChain(BlockCipher *cipher);
+ virtual ~CipherBlockChain();
- virtual bool setKey(void *key, int bitlength);
+ virtual bool setKey(void *key, int bitlength);
- virtual int keyLen() const;
+ virtual int keyLen() const;
- virtual bool variableKeyLen() const;
+ virtual bool variableKeyLen() const;
- virtual bool readyToGo() const;
+ virtual bool readyToGo() const;
- virtual int encrypt(void *block, int len);
+ virtual int encrypt(void *block, int len);
- virtual int decrypt(void *block, int len);
+ virtual int decrypt(void *block, int len);
- private:
- BlockCipher *_cipher;
- void *_register;
- void *_next;
- int _len;
- int _reader, _writer;
+private:
+ BlockCipher *_cipher;
+ void *_register;
+ void *_next;
+ int _len;
+ int _reader, _writer;
};
diff --git a/kwlimporter/kwalletbackend/kwalletbackend.h \
b/kwlimporter/kwalletbackend/kwalletbackend.h index 05a0846..b0f2a82 100644
--- a/kwlimporter/kwalletbackend/kwalletbackend.h
+++ b/kwlimporter/kwalletbackend/kwalletbackend.h
@@ -30,144 +30,157 @@
#include "kwalletentry.h"
-namespace KWallet {
+namespace KWallet
+{
/**
* @internal
*/
-class MD5Digest : public QByteArray {
- public:
- MD5Digest() : QByteArray(16, 0) {}
- MD5Digest(const char *data) : QByteArray(data, 16) {}
- MD5Digest(const KMD5::Digest d) : QByteArray(reinterpret_cast<const char *>(d), \
16) {}
- virtual ~MD5Digest() {}
-
- int operator<(const MD5Digest& r) const {
- int i = 0;
- char x, y;
- for (; i < 16; ++i) {
- x = at(i);
- y = r.at(i);
- if (x != y) {
- break;
- }
- }
- if (i < 16 && x < y) {
- return 1;
- }
- return 0;
- }
+class MD5Digest : public QByteArray
+{
+public:
+ MD5Digest() : QByteArray(16, 0) {}
+ MD5Digest(const char *data) : QByteArray(data, 16) {}
+ MD5Digest(const KMD5::Digest d) : QByteArray(reinterpret_cast<const char *>(d), \
16) {} + virtual ~MD5Digest() {}
+
+ int operator<(const MD5Digest& r) const {
+ int i = 0;
+ char x, y;
+ for(; i < 16; ++i) {
+ x = at(i);
+ y = r.at(i);
+ if(x != y) {
+ break;
+ }
+ }
+ if(i < 16 && x < y) {
+ return 1;
+ }
+ return 0;
+ }
};
/* @internal
*/
-class KDE_EXPORT Backend {
- public:
- explicit Backend(const QString& name = QLatin1String("kdewallet"), bool isPath = \
false);
- ~Backend();
-
- // Open and unlock the wallet.
- // If opening succeeds, the password's hash will be remembered.
- // If opening fails, the password's hash will be cleared.
- int open(const QByteArray& password);
-
- // Open and unlock the wallet using a pre-hashed password.
- // If opening succeeds, the password's hash will be remembered.
- // If opening fails, the password's hash will be cleared.
- int openPreHashed(const QByteArray &passwordHash);
-
- // Close the wallet, losing any changes.
- // if save is true, the wallet is saved prior to closing it.
- int close(bool save = false);
-
- // Write the wallet to disk
- int sync();
-
- // Returns true if the current wallet is open.
- bool isOpen() const;
-
- // Returns the current wallet name.
- const QString& walletName() const;
-
- // The list of folders.
- QStringList folderList() const;
-
- // Force creation of a folder.
- bool createFolder(const QString& f);
-
- // Change the folder.
- void setFolder(const QString& f) { _folder = f; }
-
- // Current folder. If empty, it's the global folder.
- const QString& folder() const { return _folder; }
-
- // Does it have this folder?
- bool hasFolder(const QString& f) const { return _entries.contains(f); }
-
- // Look up an entry. Returns null if it doesn't exist.
- Entry *readEntry(const QString& key);
-
- // Look up a list of entries. Supports wildcards.
- // You delete the list
- QList<Entry*> readEntryList(const QString& key);
-
- // Store an entry.
- void writeEntry(Entry *e);
-
- // Does this folder contain this entry?
- bool hasEntry(const QString& key) const;
-
- // Returns true if the entry was removed
- bool removeEntry(const QString& key);
-
- // Returns true if the folder was removed
- bool removeFolder(const QString& f);
-
- // The list of entries in this folder.
- QStringList entryList() const;
-
- // Rename an entry in this folder.
- int renameEntry(const QString& oldName, const QString& newName);
-
- // Set the password used for opening/closing the wallet.
- // This does not sync the wallet to disk!
- void setPassword(const QByteArray &password);
-
- int ref() { return ++_ref; }
-
- int deref();
-
- int refCount() const { return _ref; }
-
- static bool exists(const QString& wallet);
-
- bool folderDoesNotExist(const QString& folder) const;
-
- bool entryDoesNotExist(const QString& folder, const QString& entry) const;
-
- static QString openRCToString(int rc);
-
- private:
- Q_DISABLE_COPY( Backend )
- class BackendPrivate;
- BackendPrivate *const d;
- QString _name;
- QString _path;
- bool _open;
- QString _folder;
- int _ref;
- // Map Folder->Entries
- typedef QMap< QString, Entry* > EntryMap;
- typedef QMap< QString, EntryMap > FolderMap;
- FolderMap _entries;
- typedef QMap<MD5Digest, QList<MD5Digest> > HashMap;
- HashMap _hashes;
- QByteArray _passhash; // password hash used for saving the wallet
-
- // open the wallet with the password already set. This is
- // called internally by both open and openPreHashed.
- int openInternal();
+class KDE_EXPORT Backend
+{
+public:
+ explicit Backend(const QString& name = QLatin1String("kdewallet"), bool isPath = \
false); + ~Backend();
+
+ // Open and unlock the wallet.
+ // If opening succeeds, the password's hash will be remembered.
+ // If opening fails, the password's hash will be cleared.
+ int open(const QByteArray& password);
+
+ // Open and unlock the wallet using a pre-hashed password.
+ // If opening succeeds, the password's hash will be remembered.
+ // If opening fails, the password's hash will be cleared.
+ int openPreHashed(const QByteArray &passwordHash);
+
+ // Close the wallet, losing any changes.
+ // if save is true, the wallet is saved prior to closing it.
+ int close(bool save = false);
+
+ // Write the wallet to disk
+ int sync();
+
+ // Returns true if the current wallet is open.
+ bool isOpen() const;
+
+ // Returns the current wallet name.
+ const QString& walletName() const;
+
+ // The list of folders.
+ QStringList folderList() const;
+
+ // Force creation of a folder.
+ bool createFolder(const QString& f);
+
+ // Change the folder.
+ void setFolder(const QString& f) {
+ _folder = f;
+ }
+
+ // Current folder. If empty, it's the global folder.
+ const QString& folder() const {
+ return _folder;
+ }
+
+ // Does it have this folder?
+ bool hasFolder(const QString& f) const {
+ return _entries.contains(f);
+ }
+
+ // Look up an entry. Returns null if it doesn't exist.
+ Entry *readEntry(const QString& key);
+
+ // Look up a list of entries. Supports wildcards.
+ // You delete the list
+ QList<Entry*> readEntryList(const QString& key);
+
+ // Store an entry.
+ void writeEntry(Entry *e);
+
+ // Does this folder contain this entry?
+ bool hasEntry(const QString& key) const;
+
+ // Returns true if the entry was removed
+ bool removeEntry(const QString& key);
+
+ // Returns true if the folder was removed
+ bool removeFolder(const QString& f);
+
+ // The list of entries in this folder.
+ QStringList entryList() const;
+
+ // Rename an entry in this folder.
+ int renameEntry(const QString& oldName, const QString& newName);
+
+ // Set the password used for opening/closing the wallet.
+ // This does not sync the wallet to disk!
+ void setPassword(const QByteArray &password);
+
+ int ref() {
+ return ++_ref;
+ }
+
+ int deref();
+
+ int refCount() const {
+ return _ref;
+ }
+
+ static bool exists(const QString& wallet);
+
+ bool folderDoesNotExist(const QString& folder) const;
+
+ bool entryDoesNotExist(const QString& folder, const QString& entry) const;
+
+ static QString openRCToString(int rc);
+
+private:
+ Q_DISABLE_COPY(Backend)
+ class BackendPrivate;
+ BackendPrivate *const d;
+ QString _name;
+ QString _path;
+ bool _open;
+ QString _folder;
+ int _ref;
+ // Map Folder->Entries
+ typedef QMap< QString, Entry* > EntryMap;
+ typedef QMap< QString, EntryMap > FolderMap;
+ FolderMap _entries;
+ typedef QMap<MD5Digest, QList<MD5Digest> > HashMap;
+ HashMap _hashes;
+ QByteArray _passhash; // password hash used for saving the wallet
+
+ // open the wallet with the password already set. This is
+ // called internally by both open and openPreHashed.
+ int openInternal();
};
}
diff --git a/kwlimporter/kwalletbackend/kwalletentry.h \
b/kwlimporter/kwalletbackend/kwalletentry.h index d45eb7e..f27efa2 100644
--- a/kwlimporter/kwalletbackend/kwalletentry.h
+++ b/kwlimporter/kwalletbackend/kwalletentry.h
@@ -25,35 +25,39 @@
#include <QtCore/QString>
#include <QtCore/QDataStream>
-namespace KWallet {
+namespace KWallet
+{
/* @internal
*/
-class Entry {
- public:
- enum EntryType { Unknown=0, Password, Stream, Map, Unused=0xffff };
+class Entry
+{
+public:
+ enum EntryType { Unknown = 0, Password, Stream, Map, Unused = 0xffff };
- Entry();
- ~Entry();
+ Entry();
+ ~Entry();
- const QString& key() const;
- const QByteArray& value() const;
- QString password() const;
- const QByteArray& map() const { return value(); }
+ const QString& key() const;
+ const QByteArray& value() const;
+ QString password() const;
+ const QByteArray& map() const {
+ return value();
+ }
- void setValue(const QByteArray& val);
- void setValue(const QString& val);
- void setKey(const QString& key);
+ void setValue(const QByteArray& val);
+ void setValue(const QString& val);
+ void setKey(const QString& key);
- EntryType type() const;
- void setType(EntryType type);
+ EntryType type() const;
+ void setType(EntryType type);
- void copy(const Entry* x);
+ void copy(const Entry* x);
- private:
- QString _key;
- QByteArray _value;
- EntryType _type;
+private:
+ QString _key;
+ QByteArray _value;
+ EntryType _type;
};
}
diff --git a/kwlimporter/kwalletbackend/sha1.h b/kwlimporter/kwalletbackend/sha1.h
index c7d4ee2..9755b4f 100644
--- a/kwlimporter/kwalletbackend/sha1.h
+++ b/kwlimporter/kwalletbackend/sha1.h
@@ -1,17 +1,17 @@
/* This file is part of the KDE project
Copyright (C) 2001 George Staikos <staikos@kde.org>
Based heavily on SHA1 code from GPG 1.0.3 (C) 1998 FSF
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -24,46 +24,47 @@
/* @internal
*/
-class SHA1 {
- public:
- SHA1();
- ~SHA1();
+class SHA1
+{
+public:
+ SHA1();
+ ~SHA1();
- /*
- * The number of bits in the hash generated.
- */
- int size() const;
+ /*
+ * The number of bits in the hash generated.
+ */
+ int size() const;
- /*
- * True if all settings are good and we are ready to hash.
- */
- bool readyToGo() const;
+ /*
+ * True if all settings are good and we are ready to hash.
+ */
+ bool readyToGo() const;
- /*
- * Process a block of data for the hash function.
- */
- int process(const void *block, int len);
+ /*
+ * Process a block of data for the hash function.
+ */
+ int process(const void *block, int len);
- /*
- * Return the digest as a 20 byte array reference.
- * Calling this makes readyToGo() == false.
- */
- const unsigned char *hash();
+ /*
+ * Return the digest as a 20 byte array reference.
+ * Calling this makes readyToGo() == false.
+ */
+ const unsigned char *hash();
- /*
- * Reset the digest so a new one can be calculated.
- */
- int reset();
+ /*
+ * Reset the digest so a new one can be calculated.
+ */
+ int reset();
- protected:
- int _hashlen;
- bool _init;
+protected:
+ int _hashlen;
+ bool _init;
- long _h0, _h1, _h2, _h3, _h4;
- long _nblocks;
- int _count;
- unsigned char _buf[64];
- void transform(void *data);
+ long _h0, _h1, _h2, _h3, _h4;
+ long _nblocks;
+ int _count;
+ unsigned char _buf[64];
+ void transform(void *data);
};
diff --git a/kwlimporter/kwlimporterjob.cpp b/kwlimporter/kwlimporterjob.cpp
index b62f619..e9c133f 100644
--- a/kwlimporter/kwlimporterjob.cpp
+++ b/kwlimporter/kwlimporterjob.cpp
@@ -44,7 +44,7 @@
KwlImporterJob::KwlImporterJob(QObject* parent)
- : KCompositeJob(parent)
+ : KCompositeJob(parent)
{
kDebug();
@@ -87,14 +87,14 @@ void KwlImporterJob::run()
// Obtain the collections labels
QStringList collectionLabels;
- foreach (const QDBusObjectPath &path, service->collections()) {
+ foreach(const QDBusObjectPath & path, service->collections()) {
QDBusInterface ifaceCollection("org.freedesktop.Secret", path.path(),
"org.freedesktop.Secret.Collection");
- if (ifaceCollection.isValid()) {
+ if(ifaceCollection.isValid()) {
QDBusPendingReply< QString > reply = ifaceCollection.asyncCall("Label");
reply.waitForFinished();
- if (!reply.isError()) {
+ if(!reply.isError()) {
collectionLabels << reply;
}
}
@@ -106,16 +106,16 @@ void KwlImporterJob::run()
dir.setFilter(QDir::Files | QDir::Hidden);
- foreach (const QFileInfo &fi, dir.entryInfoList()) {
- QString fn = fi.fileName();
- if (fn.endsWith(QLatin1String(".kwl"))) {
- fn.truncate(fn.length()-4);
- }
- wallets += fn;
+ foreach(const QFileInfo & fi, dir.entryInfoList()) {
+ QString fn = fi.fileName();
+ if(fn.endsWith(QLatin1String(".kwl"))) {
+ fn.truncate(fn.length() - 4);
+ }
+ wallets += fn;
}
- foreach (const QString &walletName, wallets) {
- if (!collectionLabels.contains(walletName)) {
+ foreach(const QString & walletName, wallets) {
+ if(!collectionLabels.contains(walletName)) {
KJob *job = new ImportSingleWalletJob(service, walletName, this);
addSubjob(job);
job->start();
@@ -126,15 +126,14 @@ void KwlImporterJob::run()
void KwlImporterJob::slotResult(KJob* job)
{
// Did job have an error ?
- if ( job->error() && !error() )
- {
+ if(job->error() && !error()) {
// Store it in the parent only if first error
setError(job->error());
setErrorText(job->errorText());
removeSubjob(job);
// Kill all the other subjobs
- foreach (KJob *job, subjobs()) {
+ foreach(KJob * job, subjobs()) {
job->kill();
}
@@ -145,7 +144,7 @@ void KwlImporterJob::slotResult(KJob* job)
removeSubjob(job);
// Any jobs left?
- if (!hasSubjobs()) {
+ if(!hasSubjobs()) {
// Finished!
emitResult();
}
@@ -154,8 +153,8 @@ void KwlImporterJob::slotResult(KJob* job)
bool KwlImporterJob::doKill()
{
// Kill all the subjobs
- foreach (KJob *job, subjobs()) {
- if (!job->kill()) {
+ foreach(KJob * job, subjobs()) {
+ if(!job->kill()) {
return false;
}
}
@@ -166,8 +165,8 @@ bool KwlImporterJob::doKill()
bool KwlImporterJob::doResume()
{
// Resume all the subjobs
- foreach (KJob *job, subjobs()) {
- if (!job->resume()) {
+ foreach(KJob * job, subjobs()) {
+ if(!job->resume()) {
return false;
}
}
@@ -178,8 +177,8 @@ bool KwlImporterJob::doResume()
bool KwlImporterJob::doSuspend()
{
// Suspend all the subjobs
- foreach (KJob *job, subjobs()) {
- if (!job->suspend()) {
+ foreach(KJob * job, subjobs()) {
+ if(!job->suspend()) {
return false;
}
}
diff --git a/lib/jobinfostructs.h b/lib/jobinfostructs.h
index 3b65351..e6ab4ff 100644
--- a/lib/jobinfostructs.h
+++ b/lib/jobinfostructs.h
@@ -25,7 +25,7 @@
*
* This file contain a collection of data objects exchanged by the various
* asynchronous jobs used by the frontend and backend layer to interact.
- * We opted for structs and not classes as these data objects are not
+ * We opted for structs and not classes as these data objects are not
* real full-fledget objets. They only need to transport the various contextual
* parameters needed for the jobs to perform.
*
@@ -33,7 +33,7 @@
* information about the d-bus peer that originated the various operations
* the jobs are requested to do.
*
- * Some of the structures do not have any members. That is on purpose, as
+ * Some of the structures do not have any members. That is on purpose, as
* defining ans using them would allow easy addition of new data pieces to
* exchange on the job chain path.
*/
@@ -49,14 +49,14 @@
* It takes ownership of the Peer pointer and deletes it
* when it's destructor is called.
*/
-struct JobBaseInfo
-{
- /**
- * The peer that requested the delete operation.
- */
- const Peer m_peer;
- JobBaseInfo(const Peer &peer) : m_peer(peer)
- { /* nothing */ }
+struct JobBaseInfo {
+ /**
+ * The peer that requested the delete operation.
+ */
+ const Peer m_peer;
+ JobBaseInfo(const Peer &peer) : m_peer(peer) {
+ /* nothing */
+ }
};
class BackendCollection;
@@ -65,112 +65,112 @@ class BackendCollection;
* This job value object holds information needed when creating
* a new collection.
*/
-struct CollectionCreateInfo : public JobBaseInfo
-{
- const QString m_label; /*!< new collection label */
- bool m_locked; /*!< if true, the collection will be locked after creation */
-
- /**
- * Collection creation job value object constructor
- *
- * @param label New collection's label
- * @param peer Information about the d-bus peer which requests collection \
creation
- */
- CollectionCreateInfo(const QString& label, const Peer &peer) :
- JobBaseInfo(peer), m_label(label), m_locked(false)
- { /* nothing */ }
+struct CollectionCreateInfo : public JobBaseInfo {
+ const QString m_label; /*!< new collection label */
+ bool m_locked; /*!< if true, the collection will be locked after creation */
+
+ /**
+ * Collection creation job value object constructor
+ *
+ * @param label New collection's label
+ * @param peer Information about the d-bus peer which requests collection \
creation + */
+ CollectionCreateInfo(const QString& label, const Peer &peer) :
+ JobBaseInfo(peer), m_label(label), m_locked(false) {
+ /* nothing */
+ }
};
/**
* This job value object holds information needed during collection deletion
*/
-struct CollectionDeleteInfo : public JobBaseInfo
-{
- mutable BackendCollection *m_collection; /*!< the collection to be deleted */
- /**
- * Collection delete job value object constructor
- *
- * @param peer Information about the d-bus peer which requests collection delete
- * @param collection The collection to be deleted. If NULL, it must be specified \
later
- */
- CollectionDeleteInfo(const Peer &peer) : JobBaseInfo(peer), m_collection(0)
- { /* nothing */ }
+struct CollectionDeleteInfo : public JobBaseInfo {
+ mutable BackendCollection *m_collection; /*!< the collection to be deleted */
+ /**
+ * Collection delete job value object constructor
+ *
+ * @param peer Information about the d-bus peer which requests collection delete
+ * @param collection The collection to be deleted. If NULL, it must be specified \
later + */
+ CollectionDeleteInfo(const Peer &peer) : JobBaseInfo(peer), m_collection(0) {
+ /* nothing */
+ }
};
/**
* This job value object holds information neede during collection unlocking
*/
-struct CollectionUnlockInfo : public JobBaseInfo
-{
- mutable BackendCollection *m_collection; // collection may be changed on the job \
path
- /**
- * Collection unlock job value object constructor
- *
- * @param peer Information about the d-bus peer which requests collection \
unlocking
- * @param collection The collection to be unkocked. If NULL, it must be specified \
later.
- */
- CollectionUnlockInfo(const Peer &peer) : JobBaseInfo(peer), m_collection(0)
- { /* nothing */ }
+struct CollectionUnlockInfo : public JobBaseInfo {
+ mutable BackendCollection *m_collection; // collection may be changed on the job \
path + /**
+ * Collection unlock job value object constructor
+ *
+ * @param peer Information about the d-bus peer which requests collection \
unlocking + * @param collection The collection to be unkocked. If NULL, it must \
be specified later. + */
+ CollectionUnlockInfo(const Peer &peer) : JobBaseInfo(peer), m_collection(0) {
+ /* nothing */
+ }
};
class BackendItem;
-struct ItemCreateInfo : public JobBaseInfo
-{
- const QString m_label; /*!< Item label */
- const QMap<QString, QString> m_attributes; /*!< Collection of attributes to set \
for the new item */
- const QCA::SecureArray m_secret; /*!< The secret to store */
- bool m_replace; /*!< If true, replace an item with the same attributes if it \
already exists */
- bool m_locked; /*!< true if the item should be locked after creation, false else \
*/
-
- /**
- * @param label human-readable label for the new item
- * @param attributes attributes to set for the new item
- * @param secret the secret to store
- * @param locked true if the item should be locked after creation, false else
- * @param replace if true, replace an item with the same attributes if it already \
exists
- * @param peer the d-bus peer that initiated the item creation operation
- */
- ItemCreateInfo( const QString &label,
+struct ItemCreateInfo : public JobBaseInfo {
+ const QString m_label; /*!< Item label */
+ const QMap<QString, QString> m_attributes; /*!< Collection of attributes to set \
for the new item */ + const QCA::SecureArray m_secret; /*!< The secret to store */
+ bool m_replace; /*!< If true, replace an item with the same attributes if it \
already exists */ + bool m_locked; /*!< true if the item should be locked after \
creation, false else */ +
+ /**
+ * @param label human-readable label for the new item
+ * @param attributes attributes to set for the new item
+ * @param secret the secret to store
+ * @param locked true if the item should be locked after creation, false else
+ * @param replace if true, replace an item with the same attributes if it \
already exists + * @param peer the d-bus peer that initiated the item creation \
operation + */
+ ItemCreateInfo(const QString &label,
const QMap<QString, QString> &attributes,
const QCA::SecureArray &secret,
bool replace,
bool locked,
const Peer &peer) :
- JobBaseInfo(peer),
- m_label(label), m_attributes(attributes), m_secret(secret),
- m_replace(replace), m_locked(locked)
- { /* nothing */ }
+ JobBaseInfo(peer),
+ m_label(label), m_attributes(attributes), m_secret(secret),
+ m_replace(replace), m_locked(locked) {
+ /* nothing */
+ }
};
/**
- * Item delete job value object
+ * Item delete job value object
*/
-struct ItemDeleteInfo : public JobBaseInfo
-{
- mutable BackendItem* m_item; // item information may be added on the job path so \
let it be mutable
- /**
- * Item delete job value object constructor
- * @param peer the d-bus peer that initiated the item delete operation
- * @param item the item to be deleted. If NULL, it must be specified later.
- */
- ItemDeleteInfo( const Peer &peer) : JobBaseInfo(peer), m_item(0)
- { /* nothing */ }
+struct ItemDeleteInfo : public JobBaseInfo {
+ mutable BackendItem* m_item; // item information may be added on the job path so \
let it be mutable + /**
+ * Item delete job value object constructor
+ * @param peer the d-bus peer that initiated the item delete operation
+ * @param item the item to be deleted. If NULL, it must be specified later.
+ */
+ ItemDeleteInfo(const Peer &peer) : JobBaseInfo(peer), m_item(0) {
+ /* nothing */
+ }
};
/**
* Value object used by item unlocking jobs
*/
-struct ItemUnlockInfo : public JobBaseInfo
-{
- mutable BackendItem *m_item; // item information may be added on the job path so \
let it be mutable
- /**
- * Item unlock value object constructor
- * @param peer the d-bus peer that initiated the item delete operation
- * @param item the item to be deleted. If NULL, it must be specified later.
- */
- ItemUnlockInfo( const Peer &peer) : JobBaseInfo(peer), m_item(0)
- { /* nothing */ }
+struct ItemUnlockInfo : public JobBaseInfo {
+ mutable BackendItem *m_item; // item information may be added on the job path so \
let it be mutable + /**
+ * Item unlock value object constructor
+ * @param peer the d-bus peer that initiated the item delete operation
+ * @param item the item to be deleted. If NULL, it must be specified later.
+ */
+ ItemUnlockInfo(const Peer &peer) : JobBaseInfo(peer), m_item(0) {
+ /* nothing */
+ }
};
#endif // JOBINFOSTRUCTS_H
diff --git a/lib/jobqueue.cpp b/lib/jobqueue.cpp
index e0bfb0a..c211f21 100644
--- a/lib/jobqueue.cpp
+++ b/lib/jobqueue.cpp
@@ -30,54 +30,54 @@ JobQueuePrivate::JobQueuePrivate()
JobQueuePrivate::~JobQueuePrivate()
{
- // TODO: make sure there's no jobs left running when we go down
+ // TODO: make sure there's no jobs left running when we go down
}
void JobQueuePrivate::enqueue(QueuedJob *job, bool inFront)
{
- Q_ASSERT(job);
- if (inFront) {
- m_jobs.prepend(job);
- } else {
- m_jobs.enqueue(job);
- }
-
- if (m_currentJob.isNull()) {
- QTimer::singleShot(0, this, SLOT(process()));
- }
+ Q_ASSERT(job);
+ if(inFront) {
+ m_jobs.prepend(job);
+ } else {
+ m_jobs.enqueue(job);
+ }
+
+ if(m_currentJob.isNull()) {
+ QTimer::singleShot(0, this, SLOT(process()));
+ }
}
void JobQueuePrivate::process()
{
- // check if already processing
- if (!m_currentJob.isNull()) {
- return;
- }
-
- // get a job to execute
- // as the job queue consists of QPointers, jobs which have been dismissed
- // (deleted) are automatically weeded out.
- while (m_currentJob.isNull()) {
- if (m_jobs.isEmpty()) {
- return;
- }
- m_currentJob = m_jobs.dequeue();
- }
-
- connect(m_currentJob.data(), SIGNAL(result(QueuedJob*)),
- SLOT(jobFinished(QueuedJob*)));
- m_currentJob->start();
+ // check if already processing
+ if(!m_currentJob.isNull()) {
+ return;
+ }
+
+ // get a job to execute
+ // as the job queue consists of QPointers, jobs which have been dismissed
+ // (deleted) are automatically weeded out.
+ while(m_currentJob.isNull()) {
+ if(m_jobs.isEmpty()) {
+ return;
+ }
+ m_currentJob = m_jobs.dequeue();
+ }
+
+ connect(m_currentJob.data(), SIGNAL(result(QueuedJob*)),
+ SLOT(jobFinished(QueuedJob*)));
+ m_currentJob->start();
}
void JobQueuePrivate::jobFinished(QueuedJob *job)
{
- Q_UNUSED(job);
- Q_ASSERT(job == m_currentJob);
- m_currentJob = 0;
- // keep processing if there's more jobs
- if (!m_jobs.isEmpty()) {
- QTimer::singleShot(0, this, SLOT(process()));
- }
+ Q_UNUSED(job);
+ Q_ASSERT(job == m_currentJob);
+ m_currentJob = 0;
+ // keep processing if there's more jobs
+ if(!m_jobs.isEmpty()) {
+ QTimer::singleShot(0, this, SLOT(process()));
+ }
}
JobQueue::JobQueue() : d(new JobQueuePrivate)
@@ -86,12 +86,12 @@ JobQueue::JobQueue() : d(new JobQueuePrivate)
JobQueue::~JobQueue()
{
- delete d;
+ delete d;
}
void JobQueue::enqueue(QueuedJob *job, bool inFront)
{
- d->enqueue(job, inFront);
+ d->enqueue(job, inFront);
}
#include "jobqueue_p.moc"
diff --git a/lib/jobqueue.h b/lib/jobqueue.h
index 9275906..3ac954f 100644
--- a/lib/jobqueue.h
+++ b/lib/jobqueue.h
@@ -35,27 +35,27 @@ class JobQueuePrivate;
class JobQueue
{
public:
- /**
- * Constructor.
- */
- JobQueue();
-
- /**
- * Destructor.
- */
- virtual ~JobQueue();
-
- /**
- * Enqueue a job for processing.
- *
- * @param job the job to enqueue
- * @param inFront true to enqueue the job in front so it is the next
- * job to be processed
- */
- void enqueue(QueuedJob *job, bool inFront = false);
-
+ /**
+ * Constructor.
+ */
+ JobQueue();
+
+ /**
+ * Destructor.
+ */
+ virtual ~JobQueue();
+
+ /**
+ * Enqueue a job for processing.
+ *
+ * @param job the job to enqueue
+ * @param inFront true to enqueue the job in front so it is the next
+ * job to be processed
+ */
+ void enqueue(QueuedJob *job, bool inFront = false);
+
private:
- JobQueuePrivate *d;
+ JobQueuePrivate *d;
};
#endif // JOBQUEUE_H
diff --git a/lib/jobqueue_p.h b/lib/jobqueue_p.h
index 77f1a79..58ba1cc 100644
--- a/lib/jobqueue_p.h
+++ b/lib/jobqueue_p.h
@@ -33,44 +33,44 @@ class QueuedJob;
*/
class JobQueuePrivate : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructor.
- */
- JobQueuePrivate();
-
- /**
- * Destructor.
- */
- ~JobQueuePrivate();
-
- /**
- * Enqueue a job for processing.
- *
- * @param job the job to enqueue
- * @param inFront true to enqueue the job in front so it is the next
- * job to be processed
- */
- void enqueue(QueuedJob *job, bool inFront);
+ /**
+ * Constructor.
+ */
+ JobQueuePrivate();
+
+ /**
+ * Destructor.
+ */
+ ~JobQueuePrivate();
+
+ /**
+ * Enqueue a job for processing.
+ *
+ * @param job the job to enqueue
+ * @param inFront true to enqueue the job in front so it is the next
+ * job to be processed
+ */
+ void enqueue(QueuedJob *job, bool inFront);
private Q_SLOTS:
- /**
- * Start processing jobs.
- */
- void process();
-
- /**
- * Used to receive result() signals of the current QueuedJob.
- *
- * @param job the job that sends its result
- */
- void jobFinished(QueuedJob *job);
-
+ /**
+ * Start processing jobs.
+ */
+ void process();
+
+ /**
+ * Used to receive result() signals of the current QueuedJob.
+ *
+ * @param job the job that sends its result
+ */
+ void jobFinished(QueuedJob *job);
+
private:
- QQueue<QPointer<QueuedJob> > m_jobs;
- QPointer<QueuedJob> m_currentJob;
+ QQueue<QPointer<QueuedJob> > m_jobs;
+ QPointer<QueuedJob> m_currentJob;
};
#endif // JOBQUEUE_P_H
diff --git a/lib/peer.cpp b/lib/peer.cpp
index fe119c4..6e09887 100644
--- a/lib/peer.cpp
+++ b/lib/peer.cpp
@@ -28,16 +28,16 @@
class PeerData : public QSharedData
{
public:
- PeerData() : m_valid(false), m_pid(0) {}
- PeerData(const PeerData &other) : QSharedData(other), m_pid(other.m_pid) {}
- ~PeerData() {}
-
- // designates whether this Peer is valid as it's not certain that
- // a pid of 0 can always denote an invalid peer.
- bool m_valid;
-
- // peer process pid
- uint m_pid;
+ PeerData() : m_valid(false), m_pid(0) {}
+ PeerData(const PeerData &other) : QSharedData(other), m_pid(other.m_pid) {}
+ ~PeerData() {}
+
+ // designates whether this Peer is valid as it's not certain that
+ // a pid of 0 can always denote an invalid peer.
+ bool m_valid;
+
+ // peer process pid
+ uint m_pid;
};
Peer::Peer() : d(new PeerData)
@@ -50,18 +50,18 @@ Peer::Peer(const Peer &other) : d(other.d)
Peer &Peer::operator=(const Peer &other)
{
- d = other.d;
- return *this;
+ d = other.d;
+ return *this;
}
Peer::Peer(uint pid) : d(new PeerData)
{
- d->m_valid = true;
- d->m_pid = pid;
-
- kDebug() << "Peer " << pid;
- kDebug() << " cmdLine = " << cmdLine();
- kDebug() << " exePath = " << exePath();
+ d->m_valid = true;
+ d->m_pid = pid;
+
+ kDebug() << "Peer " << pid;
+ kDebug() << " cmdLine = " << cmdLine();
+ kDebug() << " exePath = " << exePath();
}
Peer::~Peer()
@@ -70,46 +70,46 @@ Peer::~Peer()
QString Peer::procFileName() const
{
- Q_ASSERT(d->m_valid);
- return QString("/proc/%1").arg(d->m_pid);
+ Q_ASSERT(d->m_valid);
+ return QString("/proc/%1").arg(d->m_pid);
}
QByteArray Peer::cmdLine() const
{
- if (!d->m_valid) {
- return QByteArray();
- } else {
- QFile procFile(QString("%1/cmd").arg(procFileName()));
- if (!procFile.open(QIODevice::ReadOnly | QIODevice::Text) ||
- procFile.atEnd()) {
- // file doesn't exist or is empty
- return QByteArray();
- } else {
- return procFile.readLine();
- }
- }
+ if(!d->m_valid) {
+ return QByteArray();
+ } else {
+ QFile procFile(QString("%1/cmd").arg(procFileName()));
+ if(!procFile.open(QIODevice::ReadOnly | QIODevice::Text) ||
+ procFile.atEnd()) {
+ // file doesn't exist or is empty
+ return QByteArray();
+ } else {
+ return procFile.readLine();
+ }
+ }
}
bool Peer::isValid() const
{
- return d->m_valid;
+ return d->m_valid;
}
bool Peer::isStillRunning() const
{
- if (!d->m_valid) {
- return false;
- } else {
- return QFile::exists(procFileName());
- }
+ if(!d->m_valid) {
+ return false;
+ } else {
+ return QFile::exists(procFileName());
+ }
}
-QString Peer::exePath() const
+QString Peer::exePath() const
{
- if (!d->m_valid) {
- return QString();
- } else {
- // TODO: add a watch an trigger signal when the peer process ends
- return QFile::symLinkTarget(QString("%1/exe").arg(procFileName()));
- }
+ if(!d->m_valid) {
+ return QString();
+ } else {
+ // TODO: add a watch an trigger signal when the peer process ends
+ return QFile::symLinkTarget(QString("%1/exe").arg(procFileName()));
+ }
}
diff --git a/lib/peer.h b/lib/peer.h
index a16adaf..959f82b 100644
--- a/lib/peer.h
+++ b/lib/peer.h
@@ -34,62 +34,62 @@ class PeerData;
class Peer
{
public:
- /**
- * Construct an invalid (non-existant) Peer.
- */
- Peer();
-
- /**
- * Copy constructor.
- */
- Peer(const Peer &other);
-
- /**
- * Copy operator.
- */
- Peer &operator=(const Peer &other);
-
- /**
- * Construct a valid Peer representing the process with the given pid.
- */
- explicit Peer(uint pid);
-
- /**
- * Destructor.
- */
- ~Peer();
-
- /**
- * Get the running state of the peer process
- */
- bool isStillRunning() const;
-
- /**
- * Get the executable path of the running process
- */
- QString exePath() const;
-
- /**
- * Get the command line used to launch the running process
- */
- QByteArray cmdLine() const;
-
- /**
- * Check if the peer is valid. An invalid peer identifies test applications
- * or requests sent in-process.
- */
- bool isValid() const;
-
+ /**
+ * Construct an invalid (non-existant) Peer.
+ */
+ Peer();
+
+ /**
+ * Copy constructor.
+ */
+ Peer(const Peer &other);
+
+ /**
+ * Copy operator.
+ */
+ Peer &operator=(const Peer &other);
+
+ /**
+ * Construct a valid Peer representing the process with the given pid.
+ */
+ explicit Peer(uint pid);
+
+ /**
+ * Destructor.
+ */
+ ~Peer();
+
+ /**
+ * Get the running state of the peer process
+ */
+ bool isStillRunning() const;
+
+ /**
+ * Get the executable path of the running process
+ */
+ QString exePath() const;
+
+ /**
+ * Get the command line used to launch the running process
+ */
+ QByteArray cmdLine() const;
+
+ /**
+ * Check if the peer is valid. An invalid peer identifies test applications
+ * or requests sent in-process.
+ */
+ bool isValid() const;
+
private:
- /**
- * Helper method witch returns the /proc/pid path for the
- * peer process.
- *
- * @note Must only be called on valid peers.
- */
- QString procFileName() const;
-
- QSharedDataPointer<PeerData> d;
+ /**
+ * Helper method witch returns the /proc/pid path for the
+ * peer process.
+ *
+ * @note Must only be called on valid peers.
+ */
+ QString procFileName() const;
+
+ QSharedDataPointer<PeerData> d;
};
#endif // DEAMON_PEER_H
diff --git a/lib/queuedjob.cpp b/lib/queuedjob.cpp
index a6d8828..ecfe495 100644
--- a/lib/queuedjob.cpp
+++ b/lib/queuedjob.cpp
@@ -24,52 +24,52 @@
class QueuedJobPrivate
{
public:
- JobQueue *m_queue;
- bool m_finished;
- bool m_enqueued;
+ JobQueue *m_queue;
+ bool m_finished;
+ bool m_enqueued;
};
QueuedJob::QueuedJob(JobQueue *queue)
- : d(new QueuedJobPrivate)
+ : d(new QueuedJobPrivate)
{
- Q_ASSERT(queue);
-
- d->m_queue = queue;
- d->m_finished = false;
- d->m_enqueued = false;
+ Q_ASSERT(queue);
+
+ d->m_queue = queue;
+ d->m_finished = false;
+ d->m_enqueued = false;
}
QueuedJob::~QueuedJob()
{
- delete d;
+ delete d;
}
bool QueuedJob::isImmediate() const
{
- return false;
+ return false;
}
bool QueuedJob::isFinished() const
{
- return d->m_finished;
+ return d->m_finished;
}
void QueuedJob::enqueue(bool inFront)
{
- // if the job has already been finished or enqueued, handle this
- // gracefully.
- if (d->m_enqueued || d->m_finished) {
- return;
- }
- d->m_queue->enqueue(this, inFront);
- d->m_enqueued = true;
+ // if the job has already been finished or enqueued, handle this
+ // gracefully.
+ if(d->m_enqueued || d->m_finished) {
+ return;
+ }
+ d->m_queue->enqueue(this, inFront);
+ d->m_enqueued = true;
}
void QueuedJob::emitResult()
{
- d->m_finished = true;
- emit result(this);
- deleteLater();
+ d->m_finished = true;
+ emit result(this);
+ deleteLater();
}
#include "queuedjob.moc"
diff --git a/lib/queuedjob.h b/lib/queuedjob.h
index 25f2630..81c5456 100644
--- a/lib/queuedjob.h
+++ b/lib/queuedjob.h
@@ -37,85 +37,85 @@ class QueuedJobPrivate;
*/
class QueuedJob : public QObject
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param queue queue the job will be enqueued into
- */
- explicit QueuedJob(JobQueue *queue);
-
- /**
- * Destructor.
- */
- virtual ~QueuedJob();
-
- /**
- * Checks if this call can be made immediately/synchronously.
- *
- * @return true if the call can be made immediately, false if it needs to
- * be queued
- * @note The base implementation always returns false, so if your job class
- * isn't immediate, you don't have to reimplement this method.
- */
- virtual bool isImmediate() const;
-
- /**
- * Check whether this job is finished.
- *
- * @return true if the job is finished, false else
- */
- bool isFinished() const;
-
- /**
- * Enqueue this job into the JobQueue passed in its constructor.
- *
- * @param inFront true to enqueue the job in front so it is the next job
- * to be processed
- */
- void enqueue(bool inFront = false);
-
- /**
- * Execute this job synchronously. Implementation of this method should
- * not involve an event-loop and it should only be available if the job
- * advertised that it can be called immediately.
- *
- * @note This method has to call emitResult() before returning. Even if
- * noone is interested in the signal it's used to mark this job
- * as finished and call deleteLater().
- */
- virtual void exec() = 0;
+ /**
+ * Constructor.
+ *
+ * @param queue queue the job will be enqueued into
+ */
+ explicit QueuedJob(JobQueue *queue);
+
+ /**
+ * Destructor.
+ */
+ virtual ~QueuedJob();
+
+ /**
+ * Checks if this call can be made immediately/synchronously.
+ *
+ * @return true if the call can be made immediately, false if it needs to
+ * be queued
+ * @note The base implementation always returns false, so if your job class
+ * isn't immediate, you don't have to reimplement this method.
+ */
+ virtual bool isImmediate() const;
+
+ /**
+ * Check whether this job is finished.
+ *
+ * @return true if the job is finished, false else
+ */
+ bool isFinished() const;
+
+ /**
+ * Enqueue this job into the JobQueue passed in its constructor.
+ *
+ * @param inFront true to enqueue the job in front so it is the next job
+ * to be processed
+ */
+ void enqueue(bool inFront = false);
+
+ /**
+ * Execute this job synchronously. Implementation of this method should
+ * not involve an event-loop and it should only be available if the job
+ * advertised that it can be called immediately.
+ *
+ * @note This method has to call emitResult() before returning. Even if
+ * noone is interested in the signal it's used to mark this job
+ * as finished and call deleteLater().
+ */
+ virtual void exec() = 0;
protected:
- /**
- * Start the job asynchronously.
- *
- * When the job is finished, result() is emitted.
- */
- virtual void start() = 0;
+ /**
+ * Start the job asynchronously.
+ *
+ * When the job is finished, result() is emitted.
+ */
+ virtual void start() = 0;
+
+ /**
+ * Emit the result of this job, notifying every object listening that
+ * it's finished.
+ */
+ void emitResult();
- /**
- * Emit the result of this job, notifying every object listening that
- * it's finished.
- */
- void emitResult();
-
Q_SIGNALS:
- /**
- * Emit the result of this job.
- *
- * As this signal can't be emitted directly from derived classes, use
- * emitResult() to mark the job as finished and emit this signal.
- *
- * @param job The job that finished (this object)
- */
- void result(QueuedJob *job);
-
+ /**
+ * Emit the result of this job.
+ *
+ * As this signal can't be emitted directly from derived classes, use
+ * emitResult() to mark the job as finished and emit this signal.
+ *
+ * @param job The job that finished (this object)
+ */
+ void result(QueuedJob *job);
+
private:
- friend class JobQueuePrivate;
- QueuedJobPrivate *d;
+ friend class JobQueuePrivate;
+ QueuedJobPrivate *d;
};
#endif // QUEUEDJOB_H
diff --git a/lib/secrettool.cpp b/lib/secrettool.cpp
index 41ee316..c30d867 100644
--- a/lib/secrettool.cpp
+++ b/lib/secrettool.cpp
@@ -25,5 +25,5 @@
QString createId()
{
- return QUuid::createUuid().toString().remove(QRegExp("[\\{\\}-]"));
+ return QUuid::createUuid().toString().remove(QRegExp("[\\{\\}-]"));
}
diff --git a/lib/tests/queuedjobtest.cpp b/lib/tests/queuedjobtest.cpp
index a61ecec..610b161 100644
--- a/lib/tests/queuedjobtest.cpp
+++ b/lib/tests/queuedjobtest.cpp
@@ -34,98 +34,98 @@ TestJob::~TestJob()
bool TestJob::isImmediate() const
{
- return true;
+ return true;
}
void TestJob::exec()
{
- doWork();
+ doWork();
}
void TestJob::start()
{
- QTimer::singleShot(0, this, SLOT(doWork()));
+ QTimer::singleShot(0, this, SLOT(doWork()));
}
-
+
void TestJob::doWork()
{
- // nothing to do really
- emitResult();
+ // nothing to do really
+ emitResult();
}
void QueuedJobTest::initTestCase()
{
- m_queue = new JobQueue;
+ m_queue = new JobQueue;
}
void QueuedJobTest::testSync()
{
- QPointer<TestJob> job = new TestJob(m_queue);
- QVERIFY(job->isImmediate());
- QVERIFY(!job->isFinished());
- job->exec();
- QVERIFY(job->isFinished());
-
- // make sure the job gets deleted
- QEventLoop loop;
- QTimer::singleShot(0, &loop, SLOT(quit()));
- loop.exec();
- QVERIFY(job.isNull());
+ QPointer<TestJob> job = new TestJob(m_queue);
+ QVERIFY(job->isImmediate());
+ QVERIFY(!job->isFinished());
+ job->exec();
+ QVERIFY(job->isFinished());
+
+ // make sure the job gets deleted
+ QEventLoop loop;
+ QTimer::singleShot(0, &loop, SLOT(quit()));
+ loop.exec();
+ QVERIFY(job.isNull());
}
void QueuedJobTest::testAsync()
{
- QPointer<TestJob> job = new TestJob(m_queue);
- QEventLoop loop;
- loop.connect(job, SIGNAL(result(QueuedJob*)), SLOT(quit()));
- QVERIFY(!job->isFinished());
- job->enqueue();
- loop.exec();
- // if we end up here, the job will already be deleted
- QVERIFY(job.isNull() || job->isFinished());
- if (!job.isNull()) {
- // if the job wasn't deleted yet, make sure it's getting deleted
- QTimer::singleShot(0, &loop, SLOT(quit()));
- loop.exec();
- QVERIFY(job.isNull());
- }
+ QPointer<TestJob> job = new TestJob(m_queue);
+ QEventLoop loop;
+ loop.connect(job, SIGNAL(result(QueuedJob*)), SLOT(quit()));
+ QVERIFY(!job->isFinished());
+ job->enqueue();
+ loop.exec();
+ // if we end up here, the job will already be deleted
+ QVERIFY(job.isNull() || job->isFinished());
+ if(!job.isNull()) {
+ // if the job wasn't deleted yet, make sure it's getting deleted
+ QTimer::singleShot(0, &loop, SLOT(quit()));
+ loop.exec();
+ QVERIFY(job.isNull());
+ }
}
void QueuedJobTest::testAsyncOrder()
{
- QPointer<TestJob> job1 = new TestJob(m_queue);
- QPointer<TestJob> job2 = new TestJob(m_queue);
- QEventLoop loop1;
- QEventLoop loop2;
- loop1.connect(job1, SIGNAL(result(QueuedJob*)), SLOT(quit()));
- loop2.connect(job2, SIGNAL(result(QueuedJob*)), SLOT(quit()));
- job1->enqueue();
- job2->enqueue();
- loop1.exec();
- loop2.exec();
- QVERIFY(job1.isNull() || job1->isFinished());
- QVERIFY(job2.isNull() || job2->isFinished());
+ QPointer<TestJob> job1 = new TestJob(m_queue);
+ QPointer<TestJob> job2 = new TestJob(m_queue);
+ QEventLoop loop1;
+ QEventLoop loop2;
+ loop1.connect(job1, SIGNAL(result(QueuedJob*)), SLOT(quit()));
+ loop2.connect(job2, SIGNAL(result(QueuedJob*)), SLOT(quit()));
+ job1->enqueue();
+ job2->enqueue();
+ loop1.exec();
+ loop2.exec();
+ QVERIFY(job1.isNull() || job1->isFinished());
+ QVERIFY(job2.isNull() || job2->isFinished());
}
void QueuedJobTest::testAsyncOrderInFront()
{
- QPointer<TestJob> job1 = new TestJob(m_queue);
- QPointer<TestJob> job2 = new TestJob(m_queue);
- QEventLoop loop1;
- QEventLoop loop2;
- loop1.connect(job1, SIGNAL(result(QueuedJob*)), SLOT(quit()));
- loop2.connect(job2, SIGNAL(result(QueuedJob*)), SLOT(quit()));
- job1->enqueue();
- job2->enqueue(true);
- loop2.exec();
- loop1.exec();
- QVERIFY(job1.isNull() || job1->isFinished());
- QVERIFY(job2.isNull() || job2->isFinished());
+ QPointer<TestJob> job1 = new TestJob(m_queue);
+ QPointer<TestJob> job2 = new TestJob(m_queue);
+ QEventLoop loop1;
+ QEventLoop loop2;
+ loop1.connect(job1, SIGNAL(result(QueuedJob*)), SLOT(quit()));
+ loop2.connect(job2, SIGNAL(result(QueuedJob*)), SLOT(quit()));
+ job1->enqueue();
+ job2->enqueue(true);
+ loop2.exec();
+ loop1.exec();
+ QVERIFY(job1.isNull() || job1->isFinished());
+ QVERIFY(job2.isNull() || job2->isFinished());
}
void QueuedJobTest::cleanupTestCase()
{
- delete m_queue;
+ delete m_queue;
}
QTEST_MAIN(QueuedJobTest)
diff --git a/lib/tests/queuedjobtest.h b/lib/tests/queuedjobtest.h
index 3729666..4e2cfc7 100644
--- a/lib/tests/queuedjobtest.h
+++ b/lib/tests/queuedjobtest.h
@@ -28,35 +28,35 @@ class JobQueue;
class TestJob : public QueuedJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- TestJob(JobQueue *queue);
- virtual ~TestJob();
- virtual bool isImmediate() const;
- virtual void exec();
- virtual void start();
-
+ TestJob(JobQueue *queue);
+ virtual ~TestJob();
+ virtual bool isImmediate() const;
+ virtual void exec();
+ virtual void start();
+
protected Q_SLOTS:
- void doWork();
+ void doWork();
};
class QueuedJobTest : public QObject
{
- Q_OBJECT
-
+ Q_OBJECT
+
private Q_SLOTS:
- void initTestCase();
-
- void testSync();
- void testAsync();
- void testAsyncOrder();
- void testAsyncOrderInFront();
-
- void cleanupTestCase();
-
+ void initTestCase();
+
+ void testSync();
+ void testAsync();
+ void testAsyncOrder();
+ void testAsyncOrderInFront();
+
+ void cleanupTestCase();
+
private:
- JobQueue *m_queue;
+ JobQueue *m_queue;
};
#endif // QUEUEDJOBTEST_H
diff --git a/main.cpp b/main.cpp
index 788d63a..094c00e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -32,36 +32,36 @@
int main(int argc, char **argv)
{
- KAboutData aboutdata("ksecretservice", 0, ki18n("KDE Secret Service"),
- "0.0", ki18n("KDE Secret Service"),
- KAboutData::License_GPL, ki18n("(C) 2010 Michael Leupold"));
- aboutdata.addAuthor(ki18n("Michael Leupold"), ki18n("Maintainer"), \
"lemma@confuego.org");
- aboutdata.addCredit(ki18n("Valentin Rusu"), ki18n("ACL Handling"), \
"vrusu@fsfe.org");
- aboutdata.setProgramIconName("ksecretservice");
+ KAboutData aboutdata("ksecretservice", 0, ki18n("KDE Secret Service"),
+ "0.0", ki18n("KDE Secret Service"),
+ KAboutData::License_GPL, ki18n("(C) 2010 Michael \
Leupold")); + aboutdata.addAuthor(ki18n("Michael Leupold"), ki18n("Maintainer"), \
"lemma@confuego.org"); + aboutdata.addCredit(ki18n("Valentin Rusu"), ki18n("ACL \
Handling"), "vrusu@fsfe.org"); + aboutdata.setProgramIconName("ksecretservice");
- KCmdLineArgs::init(argc, argv, &aboutdata);
- KUniqueApplication::addCmdLineOptions();
- KUniqueApplication app;
+ KCmdLineArgs::init(argc, argv, &aboutdata);
+ KUniqueApplication::addCmdLineOptions();
+ KUniqueApplication app;
- app.setQuitOnLastWindowClosed(false);
+ app.setQuitOnLastWindowClosed(false);
- if (!KUniqueApplication::start()) {
- kDebug() << "ksecretservice is already running!";
- return 0;
- }
+ if(!KUniqueApplication::start()) {
+ kDebug() << "ksecretservice is already running!";
+ return 0;
+ }
- if (!QDBusConnection::sessionBus().registerService("org.freedesktop.Secret")) {
- kDebug() << "Couldn't register org.freedesktop.Secret D-Bus service!";
- return 1;
- }
+ if(!QDBusConnection::sessionBus().registerService("org.freedesktop.Secret")) {
+ kDebug() << "Couldn't register org.freedesktop.Secret D-Bus service!";
+ return 1;
+ }
- // initialize QCA
- QCA::Initializer qcaInit;
+ // initialize QCA
+ QCA::Initializer qcaInit;
- BackendMaster *master = BackendMaster::instance();
- master->setUiManager(new DialogUiManager);
- master->addManager(new TemporaryCollectionManager(master));
- Service service(BackendMaster::instance());
+ BackendMaster *master = BackendMaster::instance();
+ master->setUiManager(new DialogUiManager);
+ master->addManager(new TemporaryCollectionManager(master));
+ Service service(BackendMaster::instance());
- return app.exec();
+ return app.exec();
}
diff --git a/ui/abstractacljobs.cpp b/ui/abstractacljobs.cpp
index 37bfbdb..3375ffc 100644
--- a/ui/abstractacljobs.cpp
+++ b/ui/abstractacljobs.cpp
@@ -21,28 +21,28 @@
#include "abstractacljobs.h"
#include <QtGui/QDialog>
-AbstractAskAclPrefsJob::AbstractAskAclPrefsJob(AbstractUiManager *manager,
- const CollectionCreateInfo &jobInfo) \
:
- AbstractUiJob ( manager ),
- m_denied(false)
+AbstractAskAclPrefsJob::AbstractAskAclPrefsJob(AbstractUiManager *manager,
+ const CollectionCreateInfo &jobInfo) :
+ AbstractUiJob(manager),
+ m_denied(false)
{
- m_jobHelper = new AskAclPrefsJobHelper< CollectionCreateInfo >( jobInfo );
+ m_jobHelper = new AskAclPrefsJobHelper< CollectionCreateInfo >(jobInfo);
}
-AbstractAskAclPrefsJob::AbstractAskAclPrefsJob(AbstractUiManager *manager,
- const CollectionUnlockInfo &jobInfo) \
:
- AbstractUiJob ( manager ),
- m_denied(false)
+AbstractAskAclPrefsJob::AbstractAskAclPrefsJob(AbstractUiManager *manager,
+ const CollectionUnlockInfo &jobInfo) :
+ AbstractUiJob(manager),
+ m_denied(false)
{
- m_jobHelper = new AskAclPrefsJobHelper< CollectionUnlockInfo >( jobInfo );
+ m_jobHelper = new AskAclPrefsJobHelper< CollectionUnlockInfo >(jobInfo);
}
void AbstractAskAclPrefsJob::dialogFinished(int result)
{
- if ( result == QDialog::Accepted) {
-
- }
- emitResult();
+ if(result == QDialog::Accepted) {
+
+ }
+ emitResult();
}
diff --git a/ui/abstractacljobs.h b/ui/abstractacljobs.h
index de89a8b..a647e75 100644
--- a/ui/abstractacljobs.h
+++ b/ui/abstractacljobs.h
@@ -26,23 +26,25 @@
class AskAclPrefsJobHelperBase
{
- public:
- AskAclPrefsJobHelperBase() {}
- virtual ~AskAclPrefsJobHelperBase() {}
-
- virtual const JobBaseInfo &jobInfo() const = 0;
+public:
+ AskAclPrefsJobHelperBase() {}
+ virtual ~AskAclPrefsJobHelperBase() {}
+
+ virtual const JobBaseInfo &jobInfo() const = 0;
};
template <class INFO>
class AskAclPrefsJobHelper : public AskAclPrefsJobHelperBase
{
- public:
- AskAclPrefsJobHelper( const INFO &jobInfo ) : m_jobInfo( jobInfo ) {}
-
- virtual const JobBaseInfo &jobInfo() const { return m_jobInfo; }
-
- private:
- INFO m_jobInfo;
+public:
+ AskAclPrefsJobHelper(const INFO &jobInfo) : m_jobInfo(jobInfo) {}
+
+ virtual const JobBaseInfo &jobInfo() const {
+ return m_jobInfo;
+ }
+
+private:
+ INFO m_jobInfo;
};
/**
@@ -50,23 +52,27 @@ class AskAclPrefsJobHelper : public AskAclPrefsJobHelperBase
*/
class AbstractAskAclPrefsJob : public AbstractUiJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
AbstractAskAclPrefsJob(AbstractUiManager *manager, const CollectionCreateInfo \
&jobInfo);
AbstractAskAclPrefsJob(AbstractUiManager *manager, const CollectionUnlockInfo \
&jobInfo);
-
+
// const CollectionCreateInfo &createCollectionInfo() const { return \
dynamic_cast<const CollectionCreateInfo&>( m_jobHelper->jobInfo() ); \
}
-
- bool denied() const { return m_denied; }
- void setDenied(bool denied) { m_denied = denied; }
-
+
+ bool denied() const {
+ return m_denied;
+ }
+ void setDenied(bool denied) {
+ m_denied = denied;
+ }
+
protected Q_SLOTS:
- void dialogFinished(int);
-
+ void dialogFinished(int);
+
private:
- AskAclPrefsJobHelperBase* m_jobHelper;
- bool m_denied;
+ AskAclPrefsJobHelperBase* m_jobHelper;
+ bool m_denied;
};
#endif // ABSTRACTACLJOBS_H
diff --git a/ui/abstractuijobs.cpp b/ui/abstractuijobs.cpp
index 6a5277d..26207ed 100644
--- a/ui/abstractuijobs.cpp
+++ b/ui/abstractuijobs.cpp
@@ -34,14 +34,14 @@ AbstractUiJob::~AbstractUiJob()
void AbstractUiJob::exec()
{
- Q_ASSERT(false);
+ Q_ASSERT(false);
}
AbstractAskPasswordJob::AbstractAskPasswordJob(AbstractUiManager *manager,
- const QString &collection,
- bool secondTry)
- : AbstractUiJob(manager), m_collection(collection), m_secondTry(secondTry),
- m_cancelled(false)
+ const QString &collection,
+ bool secondTry)
+ : AbstractUiJob(manager), m_collection(collection), m_secondTry(secondTry),
+ m_cancelled(false)
{
}
@@ -51,37 +51,37 @@ AbstractAskPasswordJob::~AbstractAskPasswordJob()
const QString &AbstractAskPasswordJob::collection() const
{
- return m_collection;
+ return m_collection;
}
bool AbstractAskPasswordJob::isSecondTry() const
{
- return m_secondTry;
+ return m_secondTry;
}
bool AbstractAskPasswordJob::cancelled() const
{
- return m_cancelled;
+ return m_cancelled;
}
const QCA::SecureArray &AbstractAskPasswordJob::password() const
{
- return m_password;
+ return m_password;
}
void AbstractAskPasswordJob::setCancelled(bool cancelled)
{
- m_cancelled = cancelled;
+ m_cancelled = cancelled;
}
void AbstractAskPasswordJob::setPassword(const QCA::SecureArray &password)
{
- m_password = password;
+ m_password = password;
}
AbstractNewPasswordJob::AbstractNewPasswordJob(AbstractUiManager* manager,
- const QString& collection)
- : AbstractUiJob(manager), m_collection(collection), m_cancelled(false)
+ const QString& collection)
+ : AbstractUiJob(manager), m_collection(collection), m_cancelled(false)
{
}
@@ -91,27 +91,27 @@ AbstractNewPasswordJob::~AbstractNewPasswordJob()
const QString &AbstractNewPasswordJob::collection() const
{
- return m_collection;
+ return m_collection;
}
bool AbstractNewPasswordJob::cancelled() const
{
- return m_cancelled;
+ return m_cancelled;
}
const QCA::SecureArray &AbstractNewPasswordJob::password() const
{
- return m_password;
+ return m_password;
}
void AbstractNewPasswordJob::setCancelled(bool cancelled)
{
- m_cancelled = cancelled;
+ m_cancelled = cancelled;
}
void AbstractNewPasswordJob::setPassword(const QCA::SecureArray &password)
{
- m_password = password;
+ m_password = password;
}
#include "abstractuijobs.moc"
diff --git a/ui/abstractuijobs.h b/ui/abstractuijobs.h
index 23ce0e4..5c0da14 100644
--- a/ui/abstractuijobs.h
+++ b/ui/abstractuijobs.h
@@ -36,29 +36,29 @@ class AbstractUiManager;
*/
class AbstractUiJob : public QueuedJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param manager user interface job manager and parent object
- */
- explicit AbstractUiJob(AbstractUiManager *manager);
-
- /**
- * Destructor.
- */
- virtual ~AbstractUiJob();
-
- /**
- * Default implementation for user interface jobs. As a ui job can rarely be
- * run synchronously, exec() crashes.
- */
- virtual void exec();
-
+ /**
+ * Constructor.
+ *
+ * @param manager user interface job manager and parent object
+ */
+ explicit AbstractUiJob(AbstractUiManager *manager);
+
+ /**
+ * Destructor.
+ */
+ virtual ~AbstractUiJob();
+
+ /**
+ * Default implementation for user interface jobs. As a ui job can rarely be
+ * run synchronously, exec() crashes.
+ */
+ virtual void exec();
+
private:
- friend class UiJobManager;
+ friend class UiJobManager;
};
/**
@@ -66,71 +66,71 @@ private:
*/
class AbstractAskPasswordJob : public AbstractUiJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param manager ui job manager and parent object
- * @param collection label of the collection that should be opened
- * @param secondTry set to true if this is not the user's first try to enter
- * the password correctly
- */
- AbstractAskPasswordJob(AbstractUiManager *manager, const QString &collection,
- bool secondTry);
-
- /**
- * Destructor.
- */
- virtual ~AbstractAskPasswordJob();
-
- /**
- * Get the label of the collection that's about to be unlocked.
- */
- const QString &collection() const;
-
- /**
- * Check whether this is not the user's first try to enter the password.
- */
- bool isSecondTry() const;
-
- /**
- * Check if the dialog was cancelled by the user.
- *
- * @return true if the user cancelled instead of entering a password, false if \
not
- */
- bool cancelled() const;
-
- /**
- * Get the password the user entered.
- *
- * @return the password entered by the user or an empty array if the user
- * didn't enter a password
- */
- const QCA::SecureArray &password() const;
-
+ /**
+ * Constructor.
+ *
+ * @param manager ui job manager and parent object
+ * @param collection label of the collection that should be opened
+ * @param secondTry set to true if this is not the user's first try to enter
+ * the password correctly
+ */
+ AbstractAskPasswordJob(AbstractUiManager *manager, const QString &collection,
+ bool secondTry);
+
+ /**
+ * Destructor.
+ */
+ virtual ~AbstractAskPasswordJob();
+
+ /**
+ * Get the label of the collection that's about to be unlocked.
+ */
+ const QString &collection() const;
+
+ /**
+ * Check whether this is not the user's first try to enter the password.
+ */
+ bool isSecondTry() const;
+
+ /**
+ * Check if the dialog was cancelled by the user.
+ *
+ * @return true if the user cancelled instead of entering a password, false if \
not + */
+ bool cancelled() const;
+
+ /**
+ * Get the password the user entered.
+ *
+ * @return the password entered by the user or an empty array if the user
+ * didn't enter a password
+ */
+ const QCA::SecureArray &password() const;
+
protected:
- /**
- * Set if the user cancels entering a password.
- *
- * @param cancelled true if the user cancelled the dialog, false if not
- */
- void setCancelled(bool cancelled);
-
- /**
- * Set the password entered by the user.
- *
- * @remarks This is used by derived classes
- * @param password password entered by the user
- */
- void setPassword(const QCA::SecureArray &password);
-
+ /**
+ * Set if the user cancels entering a password.
+ *
+ * @param cancelled true if the user cancelled the dialog, false if not
+ */
+ void setCancelled(bool cancelled);
+
+ /**
+ * Set the password entered by the user.
+ *
+ * @remarks This is used by derived classes
+ * @param password password entered by the user
+ */
+ void setPassword(const QCA::SecureArray &password);
+
private:
- QString m_collection; // name of the collection to be unlocked
- bool m_secondTry; // true if this is not the first try
- bool m_cancelled; // the result of the operation
- QCA::SecureArray m_password; // the password entered by the user
+ QString m_collection; // name of the collection to be unlocked
+ bool m_secondTry; // true if this is not the first try
+ bool m_cancelled; // the result of the operation
+ QCA::SecureArray m_password; // the password entered by the user
};
/**
@@ -138,59 +138,59 @@ private:
*/
class AbstractNewPasswordJob : public AbstractUiJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param manager ui job manager and parent object
- * @param collection label of the collection the password is for
- */
- AbstractNewPasswordJob(AbstractUiManager *manager, const QString &collection);
-
- /**
- * Destructor.
- */
- virtual ~AbstractNewPasswordJob();
-
- /**
- * Get the label of the collection the password is for.
- */
- const QString &collection() const;
-
- /**
- * Check if the dialog was cancelled by the user.
- *
- * @return true if the user cancelled instead of entering a password, false else
- */
- bool cancelled() const;
-
- /**
- * Get the password the user entered.
- *
- * @return the password entered by the user or an empty array if the user
- * didn't enter a password
- */
- const QCA::SecureArray &password() const;
-
+ /**
+ * Constructor.
+ *
+ * @param manager ui job manager and parent object
+ * @param collection label of the collection the password is for
+ */
+ AbstractNewPasswordJob(AbstractUiManager *manager, const QString &collection);
+
+ /**
+ * Destructor.
+ */
+ virtual ~AbstractNewPasswordJob();
+
+ /**
+ * Get the label of the collection the password is for.
+ */
+ const QString &collection() const;
+
+ /**
+ * Check if the dialog was cancelled by the user.
+ *
+ * @return true if the user cancelled instead of entering a password, false else
+ */
+ bool cancelled() const;
+
+ /**
+ * Get the password the user entered.
+ *
+ * @return the password entered by the user or an empty array if the user
+ * didn't enter a password
+ */
+ const QCA::SecureArray &password() const;
+
protected:
- /**
- * Set if the user cancels entering a password.
- *
- * @param cancelled true if the user cancelled the dialog, false if not
- */
- void setCancelled(bool cancelled);
-
- /**
- * Set the password entered by the user.
- */
- void setPassword(const QCA::SecureArray &password);
-
+ /**
+ * Set if the user cancels entering a password.
+ *
+ * @param cancelled true if the user cancelled the dialog, false if not
+ */
+ void setCancelled(bool cancelled);
+
+ /**
+ * Set the password entered by the user.
+ */
+ void setPassword(const QCA::SecureArray &password);
+
private:
- QString m_collection; // name of the collection the password is for
- bool m_cancelled; // true if the operation was cancelled
- QCA::SecureArray m_password; // the new password entered by the user
+ QString m_collection; // name of the collection the password is for
+ bool m_cancelled; // true if the operation was cancelled
+ QCA::SecureArray m_password; // the new password entered by the user
};
#endif
diff --git a/ui/abstractuimanager.h b/ui/abstractuimanager.h
index 126e5bc..421d869 100644
--- a/ui/abstractuimanager.h
+++ b/ui/abstractuimanager.h
@@ -32,40 +32,39 @@
* (probably for mobile devices) or even a bogus UI which can be used inside
* unit-tests.
*/
-class AbstractUiManager : public JobQueue
+class AbstractUiManager : public JobQueue
{
public:
- virtual ~AbstractUiManager()
- {
- // TODO: clean-up
- };
-
- /**
- * Create a job for asking for user's password for unlocking a collection.
- *
- * @param collection label of the collection to be unlocked
- * @param secondTry set to true if the user already entered a wrong password \
before
- * @return a job which can be enqueued to ask the user for the unlock password
- */
- virtual AbstractAskPasswordJob *createAskPasswordJob(const QString &collection,
- bool secondTry) = 0;
-
- /**
- * Create a job for asking a user for a new password for a collection.
- *
- * @param collection label of the collection to change the password for
- * @return a job which can be enqueued to ask the user for a new password
- */
- virtual AbstractNewPasswordJob *createNewPasswordJob(const QString &collection) = \
0;
-
- /**
- * Create a job for asking a user for his or her ACL handling preferences
- *
- * @param createCollectionInfo contextual information about collection creation \
job
- * @return a job which can be enqueued to ask for user ACL preferences
- */
- virtual AbstractAskAclPrefsJob *createAskAclPrefsJob(const CollectionUnlockInfo \
&unlockCollectionInfo) = 0;
- virtual AbstractAskAclPrefsJob *createAskAclPrefsJob(const CollectionCreateInfo \
&createCollectionInfo) = 0; + virtual ~AbstractUiManager() {
+ // TODO: clean-up
+ };
+
+ /**
+ * Create a job for asking for user's password for unlocking a collection.
+ *
+ * @param collection label of the collection to be unlocked
+ * @param secondTry set to true if the user already entered a wrong password \
before + * @return a job which can be enqueued to ask the user for the unlock \
password + */
+ virtual AbstractAskPasswordJob *createAskPasswordJob(const QString &collection,
+ bool secondTry) = 0;
+
+ /**
+ * Create a job for asking a user for a new password for a collection.
+ *
+ * @param collection label of the collection to change the password for
+ * @return a job which can be enqueued to ask the user for a new password
+ */
+ virtual AbstractNewPasswordJob *createNewPasswordJob(const QString &collection) \
= 0; +
+ /**
+ * Create a job for asking a user for his or her ACL handling preferences
+ *
+ * @param createCollectionInfo contextual information about collection creation \
job + * @return a job which can be enqueued to ask for user ACL preferences
+ */
+ virtual AbstractAskAclPrefsJob *createAskAclPrefsJob(const CollectionUnlockInfo \
&unlockCollectionInfo) = 0; + virtual AbstractAskAclPrefsJob \
*createAskAclPrefsJob(const CollectionCreateInfo &createCollectionInfo) = 0; };
#endif
diff --git a/ui/dialogaskaclprefsjob.cpp b/ui/dialogaskaclprefsjob.cpp
index 72680a4..0ce28aa 100644
--- a/ui/dialogaskaclprefsjob.cpp
+++ b/ui/dialogaskaclprefsjob.cpp
@@ -19,9 +19,9 @@
#include "dialogaskaclprefsjob.h"
#include <QtGui/QDialog>
-DialogAskCreateAclPrefsJob::DialogAskCreateAclPrefsJob(AbstractUiManager* manager,
- const CollectionCreateInfo& \
jobInfo):
- AbstractAskAclPrefsJob(manager, jobInfo)
+DialogAskCreateAclPrefsJob::DialogAskCreateAclPrefsJob(AbstractUiManager* manager,
+ const CollectionCreateInfo& jobInfo):
+ AbstractAskAclPrefsJob(manager, jobInfo)
{
}
@@ -36,9 +36,9 @@ void DialogAskCreateAclPrefsJob::start()
}
-DialogAskUnlockAclPrefsJob::DialogAskUnlockAclPrefsJob(AbstractUiManager* manager,
- const CollectionUnlockInfo& \
jobInfo):
- AbstractAskAclPrefsJob(manager, jobInfo)
+DialogAskUnlockAclPrefsJob::DialogAskUnlockAclPrefsJob(AbstractUiManager* manager,
+ const CollectionUnlockInfo& jobInfo):
+ AbstractAskAclPrefsJob(manager, jobInfo)
{
}
diff --git a/ui/dialogaskaclprefsjob.h b/ui/dialogaskaclprefsjob.h
index b971a0f..4de7a04 100644
--- a/ui/dialogaskaclprefsjob.h
+++ b/ui/dialogaskaclprefsjob.h
@@ -26,27 +26,27 @@ class DialogAskCreateAclPrefs;
class DialogAskCreateAclPrefsJob : public AbstractAskAclPrefsJob
{
- Q_OBJECT
+ Q_OBJECT
public:
- DialogAskCreateAclPrefsJob( AbstractUiManager* manager, const \
CollectionCreateInfo &jobInfo );
-
+ DialogAskCreateAclPrefsJob(AbstractUiManager* manager, const \
CollectionCreateInfo &jobInfo); +
protected:
- virtual void start();
- virtual void exec();
-
+ virtual void start();
+ virtual void exec();
+
private:
- DialogAskCreateAclPrefs *m_dialog;
+ DialogAskCreateAclPrefs *m_dialog;
};
class DialogAskUnlockAclPrefsJob : public AbstractAskAclPrefsJob
{
- Q_OBJECT
+ Q_OBJECT
public:
- DialogAskUnlockAclPrefsJob( AbstractUiManager* manager, const \
CollectionUnlockInfo &jobInfo );
-
+ DialogAskUnlockAclPrefsJob(AbstractUiManager* manager, const \
CollectionUnlockInfo &jobInfo); +
protected:
- virtual void start();
- virtual void exec();
+ virtual void start();
+ virtual void exec();
};
#endif // DIALOGASKACLPREFSJOB_H
diff --git a/ui/dialoguimanager.cpp b/ui/dialoguimanager.cpp
index 7d43565..5892318 100644
--- a/ui/dialoguimanager.cpp
+++ b/ui/dialoguimanager.cpp
@@ -26,9 +26,9 @@
#include <knewpassworddialog.h>
DialogAskPasswordJob::DialogAskPasswordJob(AbstractUiManager *manager,
- const QString &collection,
- bool secondTry)
- : AbstractAskPasswordJob(manager, collection, secondTry), m_dialog(0)
+ const QString &collection,
+ bool secondTry)
+ : AbstractAskPasswordJob(manager, collection, secondTry), m_dialog(0)
{
}
@@ -38,30 +38,30 @@ DialogAskPasswordJob::~DialogAskPasswordJob()
void DialogAskPasswordJob::start()
{
- Q_ASSERT(!m_dialog);
- // TODO: provide parent widget!
- m_dialog = new KPasswordDialog;
- m_dialog->setAttribute(Qt::WA_DeleteOnClose, true);
- // TODO: needs proper string
- m_dialog->setPrompt("Collection " + collection() + " wants password.");
- connect(m_dialog, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));
- m_dialog->show();
+ Q_ASSERT(!m_dialog);
+ // TODO: provide parent widget!
+ m_dialog = new KPasswordDialog;
+ m_dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ // TODO: needs proper string
+ m_dialog->setPrompt("Collection " + collection() + " wants password.");
+ connect(m_dialog, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));
+ m_dialog->show();
}
void DialogAskPasswordJob::dialogFinished(int result)
{
- Q_ASSERT(m_dialog);
- if (result == QDialog::Accepted) {
- setPassword(QCA::SecureArray(m_dialog->password().toUtf8()));
- } else {
- setCancelled(true);
- }
- emitResult();
+ Q_ASSERT(m_dialog);
+ if(result == QDialog::Accepted) {
+ setPassword(QCA::SecureArray(m_dialog->password().toUtf8()));
+ } else {
+ setCancelled(true);
+ }
+ emitResult();
}
DialogNewPasswordJob::DialogNewPasswordJob(AbstractUiManager *manager,
- const QString &collection)
- : AbstractNewPasswordJob(manager, collection), m_dialog(0)
+ const QString &collection)
+ : AbstractNewPasswordJob(manager, collection), m_dialog(0)
{
}
@@ -71,46 +71,46 @@ DialogNewPasswordJob::~DialogNewPasswordJob()
void DialogNewPasswordJob::start()
{
- Q_ASSERT(!m_dialog);
- // TODO: provide parent widget!
- m_dialog = new KNewPasswordDialog;
- m_dialog->setAttribute(Qt::WA_DeleteOnClose, true);
- // TODO: needs proper string
- m_dialog->setPrompt("Collection " + collection() + " wants new password.");
- connect(m_dialog, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));
- m_dialog->show();
+ Q_ASSERT(!m_dialog);
+ // TODO: provide parent widget!
+ m_dialog = new KNewPasswordDialog;
+ m_dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ // TODO: needs proper string
+ m_dialog->setPrompt("Collection " + collection() + " wants new password.");
+ connect(m_dialog, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));
+ m_dialog->show();
}
void DialogNewPasswordJob::dialogFinished(int result)
{
- Q_ASSERT(m_dialog);
- if (result == QDialog::Accepted) {
- setPassword(QCA::SecureArray(m_dialog->password().toUtf8()));
- } else {
- setCancelled(true);
- }
- emitResult();
+ Q_ASSERT(m_dialog);
+ if(result == QDialog::Accepted) {
+ setPassword(QCA::SecureArray(m_dialog->password().toUtf8()));
+ } else {
+ setCancelled(true);
+ }
+ emitResult();
}
AbstractAskPasswordJob *DialogUiManager::createAskPasswordJob(const QString \
&collection,
- bool secondTry)
+ bool secondTry)
{
- return new DialogAskPasswordJob(this, collection, secondTry);
+ return new DialogAskPasswordJob(this, collection, secondTry);
}
AbstractNewPasswordJob *DialogUiManager::createNewPasswordJob(const QString \
&collection) {
- return new DialogNewPasswordJob(this, collection);
+ return new DialogNewPasswordJob(this, collection);
}
AbstractAskAclPrefsJob *DialogUiManager::createAskAclPrefsJob(const \
CollectionUnlockInfo &unlockCollectionInfo) {
- return new DialogAskUnlockAclPrefsJob(this, unlockCollectionInfo);
+ return new DialogAskUnlockAclPrefsJob(this, unlockCollectionInfo);
}
AbstractAskAclPrefsJob *DialogUiManager::createAskAclPrefsJob(const \
CollectionCreateInfo &createCollectionInfo) {
- return new DialogAskCreateAclPrefsJob(this, createCollectionInfo);
+ return new DialogAskCreateAclPrefsJob(this, createCollectionInfo);
}
#include "dialoguimanager.moc"
diff --git a/ui/dialoguimanager.h b/ui/dialoguimanager.h
index 887ca72..dcb68a4 100644
--- a/ui/dialoguimanager.h
+++ b/ui/dialoguimanager.h
@@ -29,64 +29,64 @@ class KNewPasswordDialog;
class DialogAskPasswordJob : public AbstractAskPasswordJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- */
- DialogAskPasswordJob(AbstractUiManager *manager, const QString &collection, bool \
secondTry);
-
- /**
- * Destructor.
- */
- ~DialogAskPasswordJob();
+ /**
+ * Constructor.
+ */
+ DialogAskPasswordJob(AbstractUiManager *manager, const QString &collection, bool \
secondTry); +
+ /**
+ * Destructor.
+ */
+ ~DialogAskPasswordJob();
protected:
- /**
- * Contains the actual workload of showing the dialog.
- */
- virtual void start();
-
+ /**
+ * Contains the actual workload of showing the dialog.
+ */
+ virtual void start();
+
private Q_SLOTS:
- /**
- * Called when the dialog shown is either accepted or rejected.
- */
- void dialogFinished(int result);
-
+ /**
+ * Called when the dialog shown is either accepted or rejected.
+ */
+ void dialogFinished(int result);
+
private:
- KPasswordDialog *m_dialog;
+ KPasswordDialog *m_dialog;
};
class DialogNewPasswordJob : public AbstractNewPasswordJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- */
- DialogNewPasswordJob(AbstractUiManager *manager, const QString &collection);
-
- /**
- * Destructor.
- */
- ~DialogNewPasswordJob();
-
+ /**
+ * Constructor.
+ */
+ DialogNewPasswordJob(AbstractUiManager *manager, const QString &collection);
+
+ /**
+ * Destructor.
+ */
+ ~DialogNewPasswordJob();
+
protected:
- /**
- * Contains the actual workload of showing the dialog.
- */
- virtual void start();
-
+ /**
+ * Contains the actual workload of showing the dialog.
+ */
+ virtual void start();
+
private Q_SLOTS:
- /**
- * Called when the dialog shown is either accepted or rejected.
- */
- void dialogFinished(int result);
-
+ /**
+ * Called when the dialog shown is either accepted or rejected.
+ */
+ void dialogFinished(int result);
+
private:
- KNewPasswordDialog *m_dialog;
+ KNewPasswordDialog *m_dialog;
};
/**
@@ -95,28 +95,28 @@ private:
class DialogUiManager : public AbstractUiManager
{
public:
- /**
- * Destructor.
- */
- virtual ~DialogUiManager() {};
-
- /**
- * Create a job to ask for a user's password to unlock a collection.
- */
- virtual AbstractAskPasswordJob *createAskPasswordJob(const QString &collection,
- bool secondTry);
-
- /**
- * Create a job to ask a user for a new password for a collection.
- */
- virtual AbstractNewPasswordJob *createNewPasswordJob(const QString &collection);
-
- /**
- * Create a job to ask a user his or her preferences for ACL handling
- * @see AbstractUiManager::createAskAclPrefsJob
- */
- virtual AbstractAskAclPrefsJob *createAskAclPrefsJob(const CollectionUnlockInfo \
&unlockCollectionInfo);
- virtual AbstractAskAclPrefsJob *createAskAclPrefsJob(const CollectionCreateInfo \
&createCollectionInfo); + /**
+ * Destructor.
+ */
+ virtual ~DialogUiManager() {};
+
+ /**
+ * Create a job to ask for a user's password to unlock a collection.
+ */
+ virtual AbstractAskPasswordJob *createAskPasswordJob(const QString &collection,
+ bool secondTry);
+
+ /**
+ * Create a job to ask a user for a new password for a collection.
+ */
+ virtual AbstractNewPasswordJob *createNewPasswordJob(const QString &collection);
+
+ /**
+ * Create a job to ask a user his or her preferences for ACL handling
+ * @see AbstractUiManager::createAskAclPrefsJob
+ */
+ virtual AbstractAskAclPrefsJob *createAskAclPrefsJob(const CollectionUnlockInfo \
&unlockCollectionInfo); + virtual AbstractAskAclPrefsJob \
*createAskAclPrefsJob(const CollectionCreateInfo &createCollectionInfo);
};
diff --git a/ui/nouiaskaclprefsjob.cpp b/ui/nouiaskaclprefsjob.cpp
index 8a89389..df6b199 100644
--- a/ui/nouiaskaclprefsjob.cpp
+++ b/ui/nouiaskaclprefsjob.cpp
@@ -18,23 +18,23 @@
#include "nouiaskaclprefsjob.h"
-NoUiAskAclPrefsJob::NoUiAskAclPrefsJob ( AbstractUiManager* manager,
- const CollectionCreateInfo& \
createCollectionInfo ) :
- AbstractAskAclPrefsJob ( manager, createCollectionInfo )
+NoUiAskAclPrefsJob::NoUiAskAclPrefsJob(AbstractUiManager* manager,
+ const CollectionCreateInfo& \
createCollectionInfo) : + AbstractAskAclPrefsJob(manager, createCollectionInfo)
{
}
-NoUiAskAclPrefsJob::NoUiAskAclPrefsJob(AbstractUiManager* manager,
- const CollectionUnlockInfo& \
unlockCollectionInfo):
- AbstractAskAclPrefsJob(manager, unlockCollectionInfo)
+NoUiAskAclPrefsJob::NoUiAskAclPrefsJob(AbstractUiManager* manager,
+ const CollectionUnlockInfo& \
unlockCollectionInfo): + AbstractAskAclPrefsJob(manager, unlockCollectionInfo)
{
}
void NoUiAskAclPrefsJob::start()
{
- setDenied(false);
- emitResult();
+ setDenied(false);
+ emitResult();
}
diff --git a/ui/nouiaskaclprefsjob.h b/ui/nouiaskaclprefsjob.h
index b844a37..dca75bf 100644
--- a/ui/nouiaskaclprefsjob.h
+++ b/ui/nouiaskaclprefsjob.h
@@ -25,9 +25,9 @@
class NoUiAskAclPrefsJob : public AbstractAskAclPrefsJob
{
public:
- explicit NoUiAskAclPrefsJob( AbstractUiManager* manager, const \
CollectionCreateInfo &createCollectionInfo );
- explicit NoUiAskAclPrefsJob( AbstractUiManager* manager, const \
CollectionUnlockInfo &unlockCollectionInfo );
-
+ explicit NoUiAskAclPrefsJob(AbstractUiManager* manager, const \
CollectionCreateInfo &createCollectionInfo); + explicit \
NoUiAskAclPrefsJob(AbstractUiManager* manager, const CollectionUnlockInfo \
&unlockCollectionInfo); +
protected:
virtual void start();
};
diff --git a/ui/nouimanager.cpp b/ui/nouimanager.cpp
index f1fc5b9..f60c003 100644
--- a/ui/nouimanager.cpp
+++ b/ui/nouimanager.cpp
@@ -25,7 +25,7 @@
NoUiAskPasswordJob::NoUiAskPasswordJob(AbstractUiManager *manager,
bool cancel)
- : AbstractAskPasswordJob(manager, "", false), m_cancel(cancel)
+ : AbstractAskPasswordJob(manager, "", false), m_cancel(cancel)
{
}
@@ -35,22 +35,22 @@ NoUiAskPasswordJob::~NoUiAskPasswordJob()
void NoUiAskPasswordJob::start()
{
- QTimer::singleShot(0, this, SLOT(finish()));
+ QTimer::singleShot(0, this, SLOT(finish()));
}
void NoUiAskPasswordJob::finish()
{
- if (m_cancel) {
- setCancelled(true);
- } else {
- setPassword("default");
- }
- emitResult();
+ if(m_cancel) {
+ setCancelled(true);
+ } else {
+ setPassword("default");
+ }
+ emitResult();
}
NoUiNewPasswordJob::NoUiNewPasswordJob(AbstractUiManager *manager,
bool cancel)
- : AbstractNewPasswordJob(manager, ""), m_cancel(cancel)
+ : AbstractNewPasswordJob(manager, ""), m_cancel(cancel)
{
}
@@ -60,17 +60,17 @@ NoUiNewPasswordJob::~NoUiNewPasswordJob()
void NoUiNewPasswordJob::start()
{
- QTimer::singleShot(0, this, SLOT(finish()));
+ QTimer::singleShot(0, this, SLOT(finish()));
}
void NoUiNewPasswordJob::finish()
{
- if (m_cancel) {
- setCancelled(true);
- } else {
- setPassword("default");
- }
- emitResult();
+ if(m_cancel) {
+ setCancelled(true);
+ } else {
+ setPassword("default");
+ }
+ emitResult();
}
NoUiManager::NoUiManager() : m_cancelAll(false)
@@ -82,17 +82,17 @@ NoUiManager::~NoUiManager()
}
AbstractAskPasswordJob *NoUiManager::createAskPasswordJob(const QString &collection,
- bool secondTry)
+ bool secondTry)
{
- Q_UNUSED(collection);
- Q_UNUSED(secondTry);
- return new NoUiAskPasswordJob(this, m_cancelAll);
+ Q_UNUSED(collection);
+ Q_UNUSED(secondTry);
+ return new NoUiAskPasswordJob(this, m_cancelAll);
}
AbstractNewPasswordJob *NoUiManager::createNewPasswordJob(const QString &collection)
{
- Q_UNUSED(collection);
- return new NoUiNewPasswordJob(this, m_cancelAll);
+ Q_UNUSED(collection);
+ return new NoUiNewPasswordJob(this, m_cancelAll);
}
AbstractAskAclPrefsJob *NoUiManager::createAskAclPrefsJob(const CollectionUnlockInfo \
&unlockCollectionInfo) @@ -102,17 +102,17 @@ AbstractAskAclPrefsJob \
*NoUiManager::createAskAclPrefsJob(const CollectionUnlock
AbstractAskAclPrefsJob *NoUiManager::createAskAclPrefsJob(const CollectionCreateInfo \
&createCollectionInfo) {
- return new NoUiAskAclPrefsJob(this, createCollectionInfo);
+ return new NoUiAskAclPrefsJob(this, createCollectionInfo);
}
void NoUiManager::setCancelAll(bool cancelAll)
{
- m_cancelAll = cancelAll;
+ m_cancelAll = cancelAll;
}
bool NoUiManager::cancelAll() const
{
- return m_cancelAll;
+ return m_cancelAll;
}
#include "nouimanager.moc"
diff --git a/ui/nouimanager.h b/ui/nouimanager.h
index 40e6a56..914e93f 100644
--- a/ui/nouimanager.h
+++ b/ui/nouimanager.h
@@ -26,70 +26,70 @@
class NoUiAskPasswordJob : public AbstractAskPasswordJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param manager the manager creating this job
- * @param cancel if true, this job will be cancelled
- */
- NoUiAskPasswordJob(AbstractUiManager *manager, bool cancel);
-
- /**
- * Destructor.
- */
- virtual ~NoUiAskPasswordJob();
-
+ /**
+ * Constructor.
+ *
+ * @param manager the manager creating this job
+ * @param cancel if true, this job will be cancelled
+ */
+ NoUiAskPasswordJob(AbstractUiManager *manager, bool cancel);
+
+ /**
+ * Destructor.
+ */
+ virtual ~NoUiAskPasswordJob();
+
protected:
- /**
- * Does basically nothing - no UI, no password to enter.
- */
- virtual void start();
-
+ /**
+ * Does basically nothing - no UI, no password to enter.
+ */
+ virtual void start();
+
private Q_SLOTS:
- /**
- * Called from start to emit the result signal.
- */
- void finish();
-
+ /**
+ * Called from start to emit the result signal.
+ */
+ void finish();
+
private:
- bool m_cancel;
+ bool m_cancel;
};
class NoUiNewPasswordJob : public AbstractNewPasswordJob
{
- Q_OBJECT
-
+ Q_OBJECT
+
public:
- /**
- * Constructor.
- *
- * @param manager the manager creating this job
- * @param cancel if true, this job will be cancelled
- */
- NoUiNewPasswordJob(AbstractUiManager *manager, bool cancel);
-
- /**
- * Destructor.
- */
- virtual ~NoUiNewPasswordJob();
-
+ /**
+ * Constructor.
+ *
+ * @param manager the manager creating this job
+ * @param cancel if true, this job will be cancelled
+ */
+ NoUiNewPasswordJob(AbstractUiManager *manager, bool cancel);
+
+ /**
+ * Destructor.
+ */
+ virtual ~NoUiNewPasswordJob();
+
protected:
- /**
- * Does basically nothing - no UI, no new password to enter.
- */
- virtual void start();
-
+ /**
+ * Does basically nothing - no UI, no new password to enter.
+ */
+ virtual void start();
+
private Q_SLOTS:
- /**
- * Called from start to emit the result signal.
- */
- void finish();
-
+ /**
+ * Called from start to emit the result signal.
+ */
+ void finish();
+
private:
- bool m_cancel;
+ bool m_cancel;
};
/**
@@ -103,46 +103,46 @@ private:
class NoUiManager : public AbstractUiManager
{
public:
- /**
- * Constructor.
- */
- NoUiManager();
-
- /**
- * Destructor.
- */
- virtual ~NoUiManager();
-
- /**
- * Create a job to ask for a user's password to unlock a collection.
- */
- virtual AbstractAskPasswordJob *createAskPasswordJob(const QString &collection,
- bool secondTry);
-
- /**
- * Create a job to as a user for a new password for a collection.
- */
- virtual AbstractNewPasswordJob *createNewPasswordJob(const QString &collection);
-
- /**
- * @see AbstractUiManager::createAskPasswordJob
- */
- virtual AbstractAskAclPrefsJob *createAskAclPrefsJob(const CollectionUnlockInfo \
&unlockCollectionInfo);
- virtual AbstractAskAclPrefsJob *createAskAclPrefsJob(const CollectionCreateInfo \
&createCollectionInfo);
-
-
- /**
- * Set to true to cancel all created jobs.
- */
- void setCancelAll(bool cancelAll);
-
- /**
- * True if all created jobs are automatically cancelled, false else.
- */
- bool cancelAll() const;
-
+ /**
+ * Constructor.
+ */
+ NoUiManager();
+
+ /**
+ * Destructor.
+ */
+ virtual ~NoUiManager();
+
+ /**
+ * Create a job to ask for a user's password to unlock a collection.
+ */
+ virtual AbstractAskPasswordJob *createAskPasswordJob(const QString &collection,
+ bool secondTry);
+
+ /**
+ * Create a job to as a user for a new password for a collection.
+ */
+ virtual AbstractNewPasswordJob *createNewPasswordJob(const QString &collection);
+
+ /**
+ * @see AbstractUiManager::createAskPasswordJob
+ */
+ virtual AbstractAskAclPrefsJob *createAskAclPrefsJob(const CollectionUnlockInfo \
&unlockCollectionInfo); + virtual AbstractAskAclPrefsJob \
*createAskAclPrefsJob(const CollectionCreateInfo &createCollectionInfo); +
+
+ /**
+ * Set to true to cancel all created jobs.
+ */
+ void setCancelAll(bool cancelAll);
+
+ /**
+ * True if all created jobs are automatically cancelled, false else.
+ */
+ bool cancelAll() const;
+
private:
- bool m_cancelAll;
+ bool m_cancelAll;
};
#endif
diff --git a/ui/tests/dialoguimanagertest.cpp b/ui/tests/dialoguimanagertest.cpp
index 15d7ab3..2ec6a95 100644
--- a/ui/tests/dialoguimanagertest.cpp
+++ b/ui/tests/dialoguimanagertest.cpp
@@ -27,33 +27,33 @@
void DialogUiManagerTest::initTestCase()
{
- QCA::init();
+ QCA::init();
}
void DialogUiManagerTest::testAskPassword()
{
- DialogUiManager fact;
-
- // ask for a password (asynchronously)
- AbstractAskPasswordJob *asyncJob1 = \
fact.createAskPasswordJob("TESTCOLLECTION-ASYNC1", false);
- AbstractAskPasswordJob *asyncJob2 = \
fact.createAskPasswordJob("TESTCOLLECTION-ASYNC2", false);
- QEventLoop loop;
- connect(asyncJob2, SIGNAL(result(QueuedJob*)), &loop, SLOT(quit()));
- asyncJob1->enqueue();
- asyncJob2->enqueue();
- loop.exec();
+ DialogUiManager fact;
+
+ // ask for a password (asynchronously)
+ AbstractAskPasswordJob *asyncJob1 = \
fact.createAskPasswordJob("TESTCOLLECTION-ASYNC1", false); + \
AbstractAskPasswordJob *asyncJob2 = \
fact.createAskPasswordJob("TESTCOLLECTION-ASYNC2", false); + QEventLoop loop;
+ connect(asyncJob2, SIGNAL(result(QueuedJob*)), &loop, SLOT(quit()));
+ asyncJob1->enqueue();
+ asyncJob2->enqueue();
+ loop.exec();
}
void DialogUiManagerTest::testNewPassword()
{
- DialogUiManager fact;
-
- // ask for a new password (asynchronously)
- AbstractNewPasswordJob *asyncJob1 = fact.createNewPasswordJob("TESTCOLLECTION");
- QEventLoop loop;
- connect(asyncJob1, SIGNAL(result(QueuedJob*)), &loop, SLOT(quit()));
- asyncJob1->enqueue();
- loop.exec();
+ DialogUiManager fact;
+
+ // ask for a new password (asynchronously)
+ AbstractNewPasswordJob *asyncJob1 = fact.createNewPasswordJob("TESTCOLLECTION");
+ QEventLoop loop;
+ connect(asyncJob1, SIGNAL(result(QueuedJob*)), &loop, SLOT(quit()));
+ asyncJob1->enqueue();
+ loop.exec();
}
void DialogUiManagerTest::cleanupTestCase()
diff --git a/ui/tests/dialoguimanagertest.h b/ui/tests/dialoguimanagertest.h
index 477d158..0ab3e5d 100644
--- a/ui/tests/dialoguimanagertest.h
+++ b/ui/tests/dialoguimanagertest.h
@@ -25,15 +25,15 @@
class DialogUiManagerTest : public QObject
{
- Q_OBJECT
-
+ Q_OBJECT
+
private Q_SLOTS:
- void initTestCase();
+ void initTestCase();
- void testAskPassword();
- void testNewPassword();
+ void testAskPassword();
+ void testNewPassword();
- void cleanupTestCase();
+ void cleanupTestCase();
};
#endif
diff --git a/ui/tests/nouimanagertest.cpp b/ui/tests/nouimanagertest.cpp
index 09e4836..037a9db 100644
--- a/ui/tests/nouimanagertest.cpp
+++ b/ui/tests/nouimanagertest.cpp
@@ -28,174 +28,174 @@
void NoUiManagerTest::initTestCase()
{
- QCA::init();
+ QCA::init();
}
void NoUiManagerTest::testAskPassword()
{
- NoUiManager manager;
-
- // create a job and start it
- AbstractAskPasswordJob *job = manager.createAskPasswordJob("TESTCOLLECTION", \
false);
- QVERIFY(!job->isImmediate());
-
- QTestEventLoop loop;
- connect(job, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
- job->enqueue();
- loop.enterLoop(5);
- QVERIFY(!loop.timeout());
-
- // verify job result
- QVERIFY(job->isFinished());
- QVERIFY(!job->cancelled());
- QCOMPARE(job->password().toByteArray(), QByteArray("default"));
-
- // verify job deletion
- connect(job, SIGNAL(destroyed(QObject*)), &loop, SLOT(exitLoop()));
- loop.enterLoop(5);
- QVERIFY(!loop.timeout());
+ NoUiManager manager;
+
+ // create a job and start it
+ AbstractAskPasswordJob *job = manager.createAskPasswordJob("TESTCOLLECTION", \
false); + QVERIFY(!job->isImmediate());
+
+ QTestEventLoop loop;
+ connect(job, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+ job->enqueue();
+ loop.enterLoop(5);
+ QVERIFY(!loop.timeout());
+
+ // verify job result
+ QVERIFY(job->isFinished());
+ QVERIFY(!job->cancelled());
+ QCOMPARE(job->password().toByteArray(), QByteArray("default"));
+
+ // verify job deletion
+ connect(job, SIGNAL(destroyed(QObject*)), &loop, SLOT(exitLoop()));
+ loop.enterLoop(5);
+ QVERIFY(!loop.timeout());
}
void NoUiManagerTest::testNewPassword()
{
- NoUiManager manager;
-
- // create a job and start it
- AbstractNewPasswordJob *job = manager.createNewPasswordJob("TESTCOLLECTION");
- QVERIFY(!job->isImmediate());
-
- QTestEventLoop loop;
- connect(job, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
- job->enqueue();
- loop.enterLoop(5);
- QVERIFY(!loop.timeout());
-
- // verify job result
- QVERIFY(job->isFinished());
- QVERIFY(!job->cancelled());
- QCOMPARE(job->password().toByteArray(), QByteArray("default"));
-
- // verify job deletion
- connect(job, SIGNAL(destroyed(QObject*)), &loop, SLOT(exitLoop()));
- loop.enterLoop(5);
- QVERIFY(!loop.timeout());
+ NoUiManager manager;
+
+ // create a job and start it
+ AbstractNewPasswordJob *job = manager.createNewPasswordJob("TESTCOLLECTION");
+ QVERIFY(!job->isImmediate());
+
+ QTestEventLoop loop;
+ connect(job, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+ job->enqueue();
+ loop.enterLoop(5);
+ QVERIFY(!loop.timeout());
+
+ // verify job result
+ QVERIFY(job->isFinished());
+ QVERIFY(!job->cancelled());
+ QCOMPARE(job->password().toByteArray(), QByteArray("default"));
+
+ // verify job deletion
+ connect(job, SIGNAL(destroyed(QObject*)), &loop, SLOT(exitLoop()));
+ loop.enterLoop(5);
+ QVERIFY(!loop.timeout());
}
void NoUiManagerTest::testJobOrder()
{
- NoUiManager manager;
-
- // create 3 jobs
- AbstractNewPasswordJob *job1 = manager.createNewPasswordJob("1");
- AbstractNewPasswordJob *job2 = manager.createNewPasswordJob("2");
- AbstractNewPasswordJob *job3 = manager.createNewPasswordJob("3");
-
- // enqueue the job so they should end up in order 1 -> 2 -> 3
- job2->enqueue();
- job3->enqueue();
- job1->enqueue(true);
-
- QTestEventLoop loop;
- connect(job1, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
- connect(job2, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
- connect(job3, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
-
- // check if jobs are executed in the right order
- // NOTE: once a job is done it will be deleted, so successive tests
- // for isFinished() might fail on them.
- loop.enterLoop(5);
- QVERIFY(job1->isFinished() && !job2->isFinished() && !job3->isFinished());
-
- loop.enterLoop(5);
- QVERIFY(job2->isFinished() && !job3->isFinished());
-
- loop.enterLoop(5);
- QVERIFY(job3->isFinished());
+ NoUiManager manager;
+
+ // create 3 jobs
+ AbstractNewPasswordJob *job1 = manager.createNewPasswordJob("1");
+ AbstractNewPasswordJob *job2 = manager.createNewPasswordJob("2");
+ AbstractNewPasswordJob *job3 = manager.createNewPasswordJob("3");
+
+ // enqueue the job so they should end up in order 1 -> 2 -> 3
+ job2->enqueue();
+ job3->enqueue();
+ job1->enqueue(true);
+
+ QTestEventLoop loop;
+ connect(job1, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+ connect(job2, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+ connect(job3, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+
+ // check if jobs are executed in the right order
+ // NOTE: once a job is done it will be deleted, so successive tests
+ // for isFinished() might fail on them.
+ loop.enterLoop(5);
+ QVERIFY(job1->isFinished() && !job2->isFinished() && !job3->isFinished());
+
+ loop.enterLoop(5);
+ QVERIFY(job2->isFinished() && !job3->isFinished());
+
+ loop.enterLoop(5);
+ QVERIFY(job3->isFinished());
}
void NoUiManagerTest::testAskPasswordCancelled()
{
- NoUiManager manager;
- manager.setCancelAll(true);
-
- // create a job and start it
- AbstractAskPasswordJob *job = manager.createAskPasswordJob("TESTCOLLECTION", \
false);
- QVERIFY(!job->isImmediate());
-
- QTestEventLoop loop;
- connect(job, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
- job->enqueue();
- loop.enterLoop(5);
- QVERIFY(!loop.timeout());
-
- // verify job result
- QVERIFY(job->isFinished());
- QVERIFY(job->cancelled());
- QCOMPARE(job->password().toByteArray(), QByteArray(""));
-
- // verify job deletion
- connect(job, SIGNAL(destroyed(QObject*)), &loop, SLOT(exitLoop()));
- loop.enterLoop(5);
- QVERIFY(!loop.timeout());
+ NoUiManager manager;
+ manager.setCancelAll(true);
+
+ // create a job and start it
+ AbstractAskPasswordJob *job = manager.createAskPasswordJob("TESTCOLLECTION", \
false); + QVERIFY(!job->isImmediate());
+
+ QTestEventLoop loop;
+ connect(job, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+ job->enqueue();
+ loop.enterLoop(5);
+ QVERIFY(!loop.timeout());
+
+ // verify job result
+ QVERIFY(job->isFinished());
+ QVERIFY(job->cancelled());
+ QCOMPARE(job->password().toByteArray(), QByteArray(""));
+
+ // verify job deletion
+ connect(job, SIGNAL(destroyed(QObject*)), &loop, SLOT(exitLoop()));
+ loop.enterLoop(5);
+ QVERIFY(!loop.timeout());
}
void NoUiManagerTest::testNewPasswordCancelled()
{
- NoUiManager manager;
- manager.setCancelAll(true);
-
- // create a job and start it
- AbstractNewPasswordJob *job = manager.createNewPasswordJob("TESTCOLLECTION");
- QVERIFY(!job->isImmediate());
-
- QTestEventLoop loop;
- connect(job, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
- job->enqueue();
- loop.enterLoop(5);
- QVERIFY(!loop.timeout());
-
- // verify job result
- QVERIFY(job->isFinished());
- QVERIFY(job->cancelled());
- QCOMPARE(job->password().toByteArray(), QByteArray(""));
-
- // verify job deletion
- connect(job, SIGNAL(destroyed(QObject*)), &loop, SLOT(exitLoop()));
- loop.enterLoop(5);
- QVERIFY(!loop.timeout());
+ NoUiManager manager;
+ manager.setCancelAll(true);
+
+ // create a job and start it
+ AbstractNewPasswordJob *job = manager.createNewPasswordJob("TESTCOLLECTION");
+ QVERIFY(!job->isImmediate());
+
+ QTestEventLoop loop;
+ connect(job, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+ job->enqueue();
+ loop.enterLoop(5);
+ QVERIFY(!loop.timeout());
+
+ // verify job result
+ QVERIFY(job->isFinished());
+ QVERIFY(job->cancelled());
+ QCOMPARE(job->password().toByteArray(), QByteArray(""));
+
+ // verify job deletion
+ connect(job, SIGNAL(destroyed(QObject*)), &loop, SLOT(exitLoop()));
+ loop.enterLoop(5);
+ QVERIFY(!loop.timeout());
}
void NoUiManagerTest::testJobOrderCancelled()
{
- NoUiManager manager;
- manager.setCancelAll(true);
-
- // create 3 jobs
- AbstractNewPasswordJob *job1 = manager.createNewPasswordJob("1");
- AbstractNewPasswordJob *job2 = manager.createNewPasswordJob("2");
- AbstractNewPasswordJob *job3 = manager.createNewPasswordJob("3");
-
- // enqueue the job so they should end up in order 1 -> 2 -> 3
- job2->enqueue();
- job3->enqueue();
- job1->enqueue(true);
-
- QTestEventLoop loop;
- connect(job1, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
- connect(job2, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
- connect(job3, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
-
- // check if jobs are executed in the right order
- // NOTE: once a job is done it will be deleted, so successive tests
- // for isFinished() might fail on them.
- loop.enterLoop(5);
- QVERIFY(job1->isFinished() && !job2->isFinished() && !job3->isFinished());
-
- loop.enterLoop(5);
- QVERIFY(job2->isFinished() && !job3->isFinished());
-
- loop.enterLoop(5);
- QVERIFY(job3->isFinished());
+ NoUiManager manager;
+ manager.setCancelAll(true);
+
+ // create 3 jobs
+ AbstractNewPasswordJob *job1 = manager.createNewPasswordJob("1");
+ AbstractNewPasswordJob *job2 = manager.createNewPasswordJob("2");
+ AbstractNewPasswordJob *job3 = manager.createNewPasswordJob("3");
+
+ // enqueue the job so they should end up in order 1 -> 2 -> 3
+ job2->enqueue();
+ job3->enqueue();
+ job1->enqueue(true);
+
+ QTestEventLoop loop;
+ connect(job1, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+ connect(job2, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+ connect(job3, SIGNAL(result(QueuedJob*)), &loop, SLOT(exitLoop()));
+
+ // check if jobs are executed in the right order
+ // NOTE: once a job is done it will be deleted, so successive tests
+ // for isFinished() might fail on them.
+ loop.enterLoop(5);
+ QVERIFY(job1->isFinished() && !job2->isFinished() && !job3->isFinished());
+
+ loop.enterLoop(5);
+ QVERIFY(job2->isFinished() && !job3->isFinished());
+
+ loop.enterLoop(5);
+ QVERIFY(job3->isFinished());
}
void NoUiManagerTest::cleanupTestCase()
diff --git a/ui/tests/nouimanagertest.h b/ui/tests/nouimanagertest.h
index e1e1b45..0477e4c 100644
--- a/ui/tests/nouimanagertest.h
+++ b/ui/tests/nouimanagertest.h
@@ -25,20 +25,20 @@
class NoUiManagerTest: public QObject
{
- Q_OBJECT
-
+ Q_OBJECT
+
private Q_SLOTS:
- void initTestCase();
-
- void testAskPassword();
- void testNewPassword();
- void testJobOrder();
-
- void testAskPasswordCancelled();
- void testNewPasswordCancelled();
- void testJobOrderCancelled();
-
- void cleanupTestCase();
+ void initTestCase();
+
+ void testAskPassword();
+ void testNewPassword();
+ void testJobOrder();
+
+ void testAskPasswordCancelled();
+ void testNewPasswordCancelled();
+ void testJobOrderCancelled();
+
+ void cleanupTestCase();
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic