qtkeychain/keychain.h

129 lines
3.2 KiB
C
Raw Normal View History

2011-10-27 16:15:46 +00:00
/******************************************************************************
* Copyright (C) 2011 Frank Osterfeld <frank.osterfeld@gmail.com> *
* *
* This program 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. For licensing and distribution *
* details, check the accompanying file 'COPYING'. *
*****************************************************************************/
2011-10-27 16:14:37 +00:00
#ifndef KEYCHAIN_H
#define KEYCHAIN_H
2011-10-28 19:27:03 +00:00
#include "qkeychain_export.h"
#include <QtCore/QObject>
2011-10-27 16:15:46 +00:00
#include <QtCore/QString>
2011-10-27 16:14:37 +00:00
class QSettings;
2011-10-27 19:17:54 +00:00
namespace QKeychain {
2011-10-27 18:46:23 +00:00
/**
* Error codes
2011-10-27 18:46:23 +00:00
*/
enum Error {
NoError=0, /**< No error occurred, operation was successful */
EntryNotFound, /**< For the given key no data was found */
CouldNotDeleteEntry, /**< Could not delete existing secret data */
AccessDeniedByUser, /**< User denied access to keychain */
AccessDenied, /**< Access denied for other reasons */
NotImplemented, /**< Not implemented on platform */
OtherError /**< Something else went wrong (errorString() might provide details) */
};
class QKEYCHAIN_EXPORT Job : public QObject {
Q_OBJECT
2011-10-27 16:14:37 +00:00
public:
explicit Job( const QString& service, QObject* parent=0 );
~Job();
QSettings* settings() const;
void setSettings( QSettings* settings );
void start();
2011-10-27 16:14:37 +00:00
QString service() const;
2011-10-27 18:46:23 +00:00
2011-10-27 16:15:46 +00:00
Error error() const;
QString errorString() const;
2011-10-27 16:14:37 +00:00
bool autoDelete() const;
void setAutoDelete( bool autoDelete );
Q_SIGNALS:
void finished( QKeychain::Job* );
protected:
Q_INVOKABLE virtual void doStart() = 0;
void setError( Error error );
void setErrorString( const QString& errorString );
void emitFinished();
void emitFinishedWithError(Error, const QString& errorString);
private:
class Private;
Private* const d;
};
class QKEYCHAIN_EXPORT ReadPasswordJob : public Job {
Q_OBJECT
public:
explicit ReadPasswordJob( const QString& service, QObject* parent=0 );
~ReadPasswordJob();
QString key() const;
void setKey( const QString& key );
QByteArray binaryData() const;
QString textData() const;
protected:
void doStart();
private:
class Private;
Private* const d;
};
class QKEYCHAIN_EXPORT WritePasswordJob : public Job {
Q_OBJECT
public:
explicit WritePasswordJob( const QString& service, QObject* parent=0 );
~WritePasswordJob();
QString key() const;
void setKey( const QString& key );
void setBinaryData( const QByteArray& data );
void setTextData( const QString& data );
protected:
void doStart();
2011-10-27 16:14:37 +00:00
private:
class Private;
Private* const d;
};
class QKEYCHAIN_EXPORT DeletePasswordJob : public Job {
Q_OBJECT
public:
explicit DeletePasswordJob( const QString& service, QObject* parent=0 );
~DeletePasswordJob();
QString key() const;
void setKey( const QString& key );
protected:
void doStart();
private:
class Private;
Private* const d;
};
} // namespace QtKeychain
2011-10-27 19:17:54 +00:00
2011-10-27 16:14:37 +00:00
#endif