00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _KWALLETD_H_
00024 #define _KWALLETD_H_
00025
00026 #include <kdedmodule.h>
00027 #include <QtCore/QString>
00028 #include <QtGui/QImage>
00029 #include <QtCore/QHash>
00030 #include "kwalletbackend.h"
00031 #include <QtCore/QPointer>
00032 #include <time.h>
00033 #include <stdlib.h>
00034 #include <QtDBus/QtDBus>
00035
00036 class KDirWatch;
00037 class KTimeout;
00038
00039
00040 class KWalletTransaction;
00041 class KWalletSyncTimer;
00042
00043 class KWalletD : public QObject {
00044 Q_OBJECT
00045
00046 public:
00047 KWalletD();
00048 virtual ~KWalletD();
00049
00050 public Q_SLOTS:
00051
00052 bool isEnabled() const;
00053
00054
00055 int open(const QString& wallet, qlonglong wId, const QString& appid, const QDBusMessage& msg);
00056
00057
00058 int openPath(const QString& path, qlonglong wId, const QString& appid);
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 int close(const QString& wallet, bool force);
00070 int close(int handle, bool force, const QString& appid);
00071
00072
00073 Q_NOREPLY void sync(int handle, const QString& appid);
00074
00075
00076 int deleteWallet(const QString& wallet);
00077
00078
00079 bool isOpen(const QString& wallet);
00080 bool isOpen(int handle);
00081
00082
00083 QStringList users(const QString& wallet) const;
00084
00085
00086 void changePassword(const QString& wallet, qlonglong wId, const QString& appid, const QDBusMessage& msg);
00087
00088
00089 QStringList wallets() const;
00090
00091
00092 QStringList folderList(int handle, const QString& appid);
00093
00094
00095 bool hasFolder(int handle, const QString& folder, const QString& appid);
00096
00097
00098 bool createFolder(int handle, const QString& folder, const QString& appid);
00099
00100
00101 bool removeFolder(int handle, const QString& folder, const QString& appid);
00102
00103
00104 QStringList entryList(int handle, const QString& folder, const QString& appid);
00105
00106
00107
00108
00109 QByteArray readEntry(int handle, const QString& folder, const QString& key, const QString& appid);
00110 QByteArray readMap(int handle, const QString& folder, const QString& key, const QString& appid);
00111 QString readPassword(int handle, const QString& folder, const QString& key, const QString& appid);
00112 QVariantMap readEntryList(int handle, const QString& folder, const QString& key, const QString& appid);
00113 QVariantMap readMapList(int handle, const QString& folder, const QString& key, const QString& appid);
00114 QVariantMap readPasswordList(int handle, const QString& folder, const QString& key, const QString& appid);
00115
00116
00117 int renameEntry(int handle, const QString& folder, const QString& oldName, const QString& newName, const QString& appid);
00118
00119
00120 int writeEntry(int handle, const QString& folder, const QString& key, const QByteArray& value, int entryType, const QString& appid);
00121 int writeEntry(int handle, const QString& folder, const QString& key, const QByteArray& value, const QString& appid);
00122 int writeMap(int handle, const QString& folder, const QString& key, const QByteArray& value, const QString& appid);
00123 int writePassword(int handle, const QString& folder, const QString& key, const QString& value, const QString& appid);
00124
00125
00126 bool hasEntry(int handle, const QString& folder, const QString& key, const QString& appid);
00127
00128
00129 int entryType(int handle, const QString& folder, const QString& key, const QString& appid);
00130
00131
00132 int removeEntry(int handle, const QString& folder, const QString& key, const QString& appid);
00133
00134
00135 bool disconnectApplication(const QString& wallet, const QString& application);
00136
00137 void reconfigure();
00138
00139
00140 bool folderDoesNotExist(const QString& wallet, const QString& folder);
00141 bool keyDoesNotExist(const QString& wallet, const QString& folder, const QString& key);
00142
00143 void closeAllWallets();
00144
00145 QString networkWallet();
00146
00147 QString localWallet();
00148
00149 void screenSaverChanged(bool);
00150
00151 Q_SIGNALS:
00152 void walletListDirty();
00153 void walletCreated(const QString& wallet);
00154 void walletOpened(const QString& wallet);
00155 void walletDeleted(const QString& wallet);
00156 void walletClosed(const QString& wallet);
00157 void walletClosed(int handle);
00158 void allWalletsClosed();
00159 void folderListUpdated(const QString& wallet);
00160 void folderUpdated(const QString&, const QString&);
00161 void applicationDisconnected(const QString& wallet, const QString& application);
00162
00163 private Q_SLOTS:
00164 void slotServiceUnregistered(const QString& name);
00165 void emitWalletListDirty();
00166 void timedOut(int);
00167 void notifyFailures();
00168 void processTransactions();
00169 void doTransactionSync(const QString& wallet);
00170
00171 private:
00172 int internalOpen(const QString& appid, const QString& wallet, bool isPath, WId w, bool modal);
00173 bool isAuthorizedApp(const QString& appid, const QString& wallet, WId w);
00174
00175 KWallet::Backend* getWallet(const QString& appid, int handle);
00176
00177 int generateHandle();
00178
00179 void invalidateHandle(int handle);
00180
00181 void doCloseSignals(int,const QString&);
00182 void emitFolderUpdated(const QString&, const QString&);
00183
00184 int closeWallet(KWallet::Backend *w, int handle, bool force);
00185
00186 bool implicitAllow(const QString& wallet, const QString& app);
00187 bool implicitDeny(const QString& wallet, const QString& app);
00188
00189 void doTransactionChangePassword(const QString& appid, const QString& wallet, qlonglong wId);
00190 int doTransactionOpen(const QString& appid, const QString& wallet, qlonglong wId, bool modal);
00191 void initiateSync(const QString& wallet);
00192
00193 void setupDialog( QWidget* dialog, WId wId, const QString& appid, bool modal );
00194 void checkActiveDialog();
00195
00196 QPair<int, KWallet::Backend*> findWallet(const QString& walletName) const;
00197
00198 typedef QHash<int, KWallet::Backend *> Wallets;
00199 Wallets _wallets;
00200 QHash<QString,QList<int> > _handles;
00201 QMap<QString,QByteArray> _passwords;
00202 KDirWatch *_dw;
00203 int _failed;
00204
00205 bool _leaveOpen, _closeIdle, _launchManager, _enabled;
00206 bool _openPrompt, _firstUse, _showingFailureNotify;
00207 int _idleTime;
00208 QMap<QString,QStringList> _implicitAllowMap, _implicitDenyMap;
00209 KTimeout *_timeouts;
00210
00211 QList<KWalletTransaction*> _transactions;
00212 QMap<QString,KWalletSyncTimer*> _synctimers;
00213 QPointer< QWidget > activeDialog;
00214 #ifdef Q_WS_X11
00215 QDBusInterface *screensaver;
00216 #endif
00217 };
00218
00219
00220 #endif