kwallet.h
00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2002-2004 George Staikos <staikos@kde.org> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 00022 #ifndef _KWALLET_H 00023 #define _KWALLET_H 00024 00025 #include <qglobal.h> 00026 #ifdef Q_OS_UNIX 00027 00028 #include <qstring.h> 00029 #include <qstringlist.h> 00030 #include <qobject.h> 00031 #include <dcopobject.h> 00032 00033 class DCOPRef; 00034 00036 namespace KWallet { 00037 00048 class KIO_EXPORT Wallet : public QObject, public DCOPObject { 00049 K_DCOP 00050 Q_OBJECT 00051 protected: 00058 Wallet(int handle, const QString& name); 00063 Wallet(const Wallet&); 00064 00065 public: 00066 enum EntryType { Unknown=0, Password, Stream, Map, Unused=0xffff }; 00067 00071 virtual ~Wallet(); 00072 00078 static QStringList walletList(); 00079 00085 static bool isEnabled(); 00086 00092 static bool isOpen(const QString& name); 00093 00103 static int closeWallet(const QString& name, bool force); 00104 00111 static int deleteWallet(const QString& name); 00112 00119 static bool disconnectApplication(const QString& wallet, const QCString& app); 00120 00121 enum OpenType { Synchronous=0, Asynchronous, Path, OpenTypeUnused=0xff }; 00122 00139 static Wallet* openWallet(const QString& name, WId w = 0, OpenType ot = Synchronous); 00140 00147 static QStringList users(const QString& wallet); 00148 00152 static const QString LocalWallet(); 00153 00157 static const QString NetworkWallet(); 00158 00165 static const QString PasswordFolder(); 00166 00173 static const QString FormDataFolder(); 00174 00181 static void changePassword(const QString& name, WId w = 0); 00182 00189 virtual int sync(); 00190 00196 virtual int lockWallet(); 00197 00201 virtual const QString& walletName() const; 00202 00208 virtual bool isOpen() const; 00209 00215 virtual void requestChangePassword(WId w = 0); 00216 00221 virtual QStringList folderList(); 00222 00228 virtual bool hasFolder(const QString& f); 00229 00237 virtual bool setFolder(const QString& f); 00238 00244 virtual bool removeFolder(const QString& f); 00245 00251 virtual bool createFolder(const QString& f); 00252 00259 virtual const QString& currentFolder() const; 00260 00266 virtual QStringList entryList(); 00267 00274 virtual int renameEntry(const QString& oldName, const QString& newName); 00275 00285 virtual int readEntry(const QString& key, QByteArray& value); 00286 00295 virtual int readMap(const QString& key, QMap<QString,QString>& value); 00296 00305 virtual int readPassword(const QString& key, QString& value); 00306 00319 int readEntryList(const QString& key, QMap<QString, QByteArray>& value); 00320 00332 int readMapList(const QString& key, QMap<QString, QMap<QString, QString> >& value); 00333 00345 int readPasswordList(const QString& key, QMap<QString, QString>& value); 00346 00357 virtual int writeEntry(const QString& key, const QByteArray& value, EntryType entryType); 00358 00366 virtual int writeEntry(const QString& key, const QByteArray& value); 00367 00374 virtual int writeMap(const QString& key, const QMap<QString,QString>& value); 00375 00382 virtual int writePassword(const QString& key, const QString& value); 00383 00389 virtual bool hasEntry(const QString& key); 00390 00396 virtual int removeEntry(const QString& key); 00397 00404 virtual EntryType entryType(const QString& key); 00405 00416 static bool folderDoesNotExist(const QString& wallet, const QString& folder); 00417 00429 static bool keyDoesNotExist(const QString& wallet, const QString& folder, 00430 const QString& key); 00431 00432 signals: 00436 void walletClosed(); 00437 00442 void folderUpdated(const QString& folder); 00443 00447 void folderListUpdated(); 00448 00453 void folderRemoved(const QString& folder); 00454 00459 void walletOpened(bool success); 00460 00461 private: 00462 k_dcop: 00467 ASYNC slotWalletClosed(int handle); 00468 00473 ASYNC slotFolderUpdated(const QString& wallet, const QString& folder); 00474 00479 ASYNC slotFolderListUpdated(const QString& wallet); 00480 00485 ASYNC slotApplicationDisconnected(const QString& wallet, const QCString& application); 00486 00491 ASYNC walletOpenResult(int rc); 00492 00493 private slots: 00498 void slotAppUnregistered(const QCString&); 00499 00500 private: 00501 class WalletPrivate; 00502 WalletPrivate *d; 00503 QString _name; 00504 QString _folder; 00505 int _handle; 00506 DCOPRef *_dcopRef; 00507 00508 protected: 00512 virtual void virtual_hook(int id, void *data); 00513 }; 00514 00515 } 00516 00517 #endif //Q_OS_UNIX 00518 00519 #endif //_KWALLET_H 00520