kio Library API Documentation

kwalletd.h

00001 /*
00002    This file is part of the KDE libraries
00003 
00004    Copyright (c) 2002-2003 George Staikos <staikos@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 
00021 */
00022 #ifndef _KWALLETD_H_
00023 #define _KWALLETD_H_
00024 
00025 #include <kded/kdedmodule.h>
00026 #include <qintdict.h>
00027 #include <qstring.h>
00028 #include <qwidget.h>
00029 #include "kwalletbackend.h"
00030 
00031 #include <time.h>
00032 #include <stdlib.h>
00033 
00034 class KDirWatch;
00035 class KTimeout;
00036 
00037 // @Private
00038 class KWalletTransaction;
00039 
00040 class KWalletD : public KDEDModule {
00041     Q_OBJECT
00042     K_DCOP
00043     public:
00044         KWalletD(const QCString &name);
00045         virtual ~KWalletD();
00046 
00047     k_dcop:
00048         // Is the wallet enabled?  If not, all open() calls fail.
00049         virtual bool isEnabled() const;
00050 
00051         // Open and unlock the wallet
00052         virtual int open(const QString& wallet, uint wId);
00053 
00054         // Open and unlock the wallet with this path
00055         virtual int openPath(const QString& path, uint wId);
00056 
00057         // Asynchronous open - must give the object to return the handle
00058         // to.
00059         virtual void openAsynchronous(const QString& wallet, const QCString& returnObject, uint wId);
00060 
00061         // Close and lock the wallet
00062         // If force = true, will close it for all users.  Behave.  This
00063         // can break applications, and is generally intended for use by
00064         // the wallet manager app only.
00065         virtual int close(const QString& wallet, bool force);
00066         virtual int close(int handle, bool force);
00067 
00068         // Save to disk but leave open
00069         virtual ASYNC sync(int handle);
00070 
00071         // Physically deletes the wallet from disk.
00072         virtual int deleteWallet(const QString& wallet);
00073 
00074         // Returns true if the wallet is open
00075         virtual bool isOpen(const QString& wallet) const;
00076         virtual bool isOpen(int handle);
00077 
00078         // List the users of this wallet
00079         virtual QStringList users(const QString& wallet) const;
00080 
00081         // Change the password of this wallet
00082         virtual void changePassword(const QString& wallet, uint wId);
00083 
00084         // A list of all wallets
00085         virtual QStringList wallets() const;
00086 
00087         // A list of all folders in this wallet
00088         virtual QStringList folderList(int handle);
00089 
00090         // Does this wallet have this folder?
00091         virtual bool hasFolder(int handle, const QString& folder);
00092 
00093         // Create this folder
00094         virtual bool createFolder(int handle, const QString& folder);
00095 
00096         // Remove this folder
00097         virtual bool removeFolder(int handle, const QString& folder);
00098 
00099         // List of entries in this folder
00100         virtual QStringList entryList(int handle, const QString& folder);
00101 
00102         // Read an entry.  If the entry does not exist, it just
00103         // returns an empty result.  It is your responsibility to check
00104         // hasEntry() first.
00105         virtual QByteArray readEntry(int handle, const QString& folder, const QString& key);
00106         virtual QByteArray readMap(int handle, const QString& folder, const QString& key);
00107         virtual QString readPassword(int handle, const QString& folder, const QString& key);
00108 
00109         // Rename an entry.  rc=0 on success.
00110         virtual int renameEntry(int handle, const QString& folder, const QString& oldName, const QString& newName);
00111 
00112         // Write an entry.  rc=0 on success.
00113         virtual int writeEntry(int handle, const QString& folder, const QString& key, const QByteArray& value, int entryType);
00114         virtual int writeEntry(int handle, const QString& folder, const QString& key, const QByteArray& value);
00115         virtual int writeMap(int handle, const QString& folder, const QString& key, const QByteArray& value);
00116         virtual int writePassword(int handle, const QString& folder, const QString& key, const QString& value);
00117 
00118         // Does the entry exist?
00119         virtual bool hasEntry(int handle, const QString& folder, const QString& key);
00120 
00121         // What type is the entry?
00122         virtual int entryType(int handle, const QString& folder, const QString& key);
00123 
00124         // Remove an entry.  rc=0 on success.
00125         virtual int removeEntry(int handle, const QString& folder, const QString& key);
00126 
00127         // Disconnect an app from a wallet
00128         virtual bool disconnectApplication(const QString& wallet, const QCString& application);
00129 
00130         virtual void reconfigure();
00131 
00132         // Determine
00133         virtual bool folderDoesNotExist(const QString& wallet, const QString& folder);
00134         virtual bool keyDoesNotExist(const QString& wallet, const QString& folder, const QString& key);
00135 
00136         virtual void closeAllWallets();
00137 
00138         virtual QString networkWallet();
00139 
00140         virtual QString localWallet();
00141 
00142     private slots:
00143         void slotAppUnregistered(const QCString& app);
00144         void emitWalletListDirty();
00145         void timedOut(int);
00146 
00147     private:
00148         int internalOpen(const QCString& appid, const QString& wallet, bool isPath = false, WId w = 0);
00149         // This also validates the handle.  May return NULL.
00150         KWallet::Backend* getWallet(const QCString& appid, int handle);
00151         // Generate a new unique handle.
00152         int generateHandle();
00153         // Invalidate a handle (remove it from the QMap)
00154         void invalidateHandle(int handle);
00155         // Emit signals about closing wallets
00156         void doCloseSignals(int,const QString&);
00157         void emitFolderUpdated(const QString&, const QString&);
00158         // Internal - close this wallet.
00159         int closeWallet(KWallet::Backend *w, int handle, bool force);
00160         // Implicitly allow access for this application
00161         bool implicitAllow(const QString& wallet, const QCString& app);
00162         QCString friendlyDCOPPeerName();
00163 
00164         void processTransactions();
00165         void doTransactionChangePassword(const QCString& appid, const QString& wallet, uint wId);
00166         int doTransactionOpen(const QCString& appid, const QString& wallet, uint wId);
00167 
00168         QIntDict<KWallet::Backend> _wallets;
00169         QMap<QCString,QValueList<int> > _handles;
00170         QMap<QString,QCString> _passwords;
00171         KDirWatch *_dw;
00172         int _failed;
00173 
00174         bool _leaveOpen, _closeIdle, _launchManager, _enabled, _openPrompt, _firstUse;
00175         int _idleTime;
00176         QMap<QString,QStringList> _implicitAllowMap;
00177         KTimeout *_timeouts;
00178 
00179         QPtrList<KWalletTransaction> _transactions;
00180 };
00181 
00182 
00183 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 23 17:12:24 2004 by doxygen 1.3.8-20040913 written by Dimitri van Heesch, © 1997-2003