You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
7.2 KiB
200 lines
7.2 KiB
15 years ago
|
/*
|
||
|
This file is part of the KDE libraries
|
||
|
|
||
|
Copyright (c) 2002-2004 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,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
|
||
|
*/
|
||
|
#ifndef _KWALLETD_H_
|
||
|
#define _KWALLETD_H_
|
||
|
|
||
|
#include <kded/kdedmodule.h>
|
||
15 years ago
|
#include <tqintdict.h>
|
||
|
#include <tqstring.h>
|
||
|
#include <tqwidget.h>
|
||
14 years ago
|
#include <tqtimer.h>
|
||
15 years ago
|
#include <tqguardedptr.h>
|
||
12 years ago
|
#include "tdewalletbackend.h"
|
||
15 years ago
|
|
||
|
#include <time.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
class KDirWatch;
|
||
|
class KTimeout;
|
||
|
|
||
|
// @Private
|
||
|
class KWalletTransaction;
|
||
|
|
||
|
class KWalletD : public KDEDModule {
|
||
|
Q_OBJECT
|
||
|
K_DCOP
|
||
|
public:
|
||
15 years ago
|
KWalletD(const TQCString &name);
|
||
15 years ago
|
virtual ~KWalletD();
|
||
|
|
||
|
k_dcop:
|
||
|
// Is the wallet enabled? If not, all open() calls fail.
|
||
|
virtual bool isEnabled() const;
|
||
|
|
||
|
// Open and unlock the wallet
|
||
15 years ago
|
virtual int open(const TQString& wallet, uint wId);
|
||
14 years ago
|
// Open and unlock the wallet
|
||
|
virtual int tryOpen(const TQString& wallet, const TQCString& passwd);
|
||
15 years ago
|
// Open and unlock the wallet with this path
|
||
14 years ago
|
|
||
15 years ago
|
virtual int openPath(const TQString& path, uint wId);
|
||
15 years ago
|
|
||
|
// Asynchronous open - must give the object to return the handle
|
||
|
// to.
|
||
15 years ago
|
virtual void openAsynchronous(const TQString& wallet, const TQCString& returnObject, uint wId);
|
||
15 years ago
|
|
||
|
// Close and lock the wallet
|
||
|
// If force = true, will close it for all users. Behave. This
|
||
|
// can break applications, and is generally intended for use by
|
||
|
// the wallet manager app only.
|
||
15 years ago
|
virtual int close(const TQString& wallet, bool force);
|
||
15 years ago
|
virtual int close(int handle, bool force);
|
||
|
|
||
|
// Save to disk but leave open
|
||
|
virtual ASYNC sync(int handle);
|
||
|
|
||
|
// Physically deletes the wallet from disk.
|
||
15 years ago
|
virtual int deleteWallet(const TQString& wallet);
|
||
15 years ago
|
|
||
|
// Returns true if the wallet is open
|
||
15 years ago
|
virtual bool isOpen(const TQString& wallet) const;
|
||
15 years ago
|
virtual bool isOpen(int handle);
|
||
|
|
||
|
// List the users of this wallet
|
||
15 years ago
|
virtual TQStringList users(const TQString& wallet) const;
|
||
15 years ago
|
|
||
|
// Change the password of this wallet
|
||
15 years ago
|
virtual void changePassword(const TQString& wallet, uint wId);
|
||
15 years ago
|
|
||
|
// A list of all wallets
|
||
15 years ago
|
virtual TQStringList wallets() const;
|
||
15 years ago
|
|
||
|
// A list of all folders in this wallet
|
||
15 years ago
|
virtual TQStringList folderList(int handle);
|
||
15 years ago
|
|
||
|
// Does this wallet have this folder?
|
||
15 years ago
|
virtual bool hasFolder(int handle, const TQString& folder);
|
||
15 years ago
|
|
||
|
// Create this folder
|
||
15 years ago
|
virtual bool createFolder(int handle, const TQString& folder);
|
||
15 years ago
|
|
||
|
// Remove this folder
|
||
15 years ago
|
virtual bool removeFolder(int handle, const TQString& folder);
|
||
15 years ago
|
|
||
|
// List of entries in this folder
|
||
15 years ago
|
virtual TQStringList entryList(int handle, const TQString& folder);
|
||
15 years ago
|
|
||
|
// Read an entry. If the entry does not exist, it just
|
||
|
// returns an empty result. It is your responsibility to check
|
||
|
// hasEntry() first.
|
||
15 years ago
|
virtual TQByteArray readEntry(int handle, const TQString& folder, const TQString& key);
|
||
|
virtual TQByteArray readMap(int handle, const TQString& folder, const TQString& key);
|
||
|
virtual TQString readPassword(int handle, const TQString& folder, const TQString& key);
|
||
|
virtual TQMap<TQString, TQByteArray> readEntryList(int handle, const TQString& folder, const TQString& key);
|
||
|
virtual TQMap<TQString, TQByteArray> readMapList(int handle, const TQString& folder, const TQString& key);
|
||
|
virtual TQMap<TQString, TQString> readPasswordList(int handle, const TQString& folder, const TQString& key);
|
||
15 years ago
|
|
||
|
// Rename an entry. rc=0 on success.
|
||
15 years ago
|
virtual int renameEntry(int handle, const TQString& folder, const TQString& oldName, const TQString& newName);
|
||
15 years ago
|
|
||
|
// Write an entry. rc=0 on success.
|
||
15 years ago
|
virtual int writeEntry(int handle, const TQString& folder, const TQString& key, const TQByteArray& value, int entryType);
|
||
|
virtual int writeEntry(int handle, const TQString& folder, const TQString& key, const TQByteArray& value);
|
||
|
virtual int writeMap(int handle, const TQString& folder, const TQString& key, const TQByteArray& value);
|
||
|
virtual int writePassword(int handle, const TQString& folder, const TQString& key, const TQString& value);
|
||
15 years ago
|
|
||
|
// Does the entry exist?
|
||
15 years ago
|
virtual bool hasEntry(int handle, const TQString& folder, const TQString& key);
|
||
15 years ago
|
|
||
|
// What type is the entry?
|
||
15 years ago
|
virtual int entryType(int handle, const TQString& folder, const TQString& key);
|
||
15 years ago
|
|
||
|
// Remove an entry. rc=0 on success.
|
||
15 years ago
|
virtual int removeEntry(int handle, const TQString& folder, const TQString& key);
|
||
15 years ago
|
|
||
|
// Disconnect an app from a wallet
|
||
15 years ago
|
virtual bool disconnectApplication(const TQString& wallet, const TQCString& application);
|
||
15 years ago
|
|
||
|
virtual void reconfigure();
|
||
|
|
||
|
// Determine
|
||
15 years ago
|
virtual bool folderDoesNotExist(const TQString& wallet, const TQString& folder);
|
||
|
virtual bool keyDoesNotExist(const TQString& wallet, const TQString& folder, const TQString& key);
|
||
15 years ago
|
|
||
|
virtual void closeAllWallets();
|
||
|
|
||
15 years ago
|
virtual TQString networkWallet();
|
||
15 years ago
|
|
||
15 years ago
|
virtual TQString localWallet();
|
||
15 years ago
|
|
||
|
private slots:
|
||
15 years ago
|
void slotAppUnregistered(const TQCString& app);
|
||
15 years ago
|
void emitWalletListDirty();
|
||
|
void timedOut(int);
|
||
|
void notifyFailures();
|
||
|
void processTransactions();
|
||
|
|
||
|
private:
|
||
15 years ago
|
int internalOpen(const TQCString& appid, const TQString& wallet, bool isPath = false, WId w = 0, bool modal = false);
|
||
|
bool isAuthorizedApp(const TQCString& appid, const TQString& wallet, WId w);
|
||
15 years ago
|
// This also validates the handle. May return NULL.
|
||
15 years ago
|
KWallet::Backend* getWallet(const TQCString& appid, int handle);
|
||
15 years ago
|
// Generate a new unique handle.
|
||
|
int generateHandle();
|
||
15 years ago
|
// Invalidate a handle (remove it from the TQMap)
|
||
14 years ago
|
void invalidateHandle(int handle);
|
||
15 years ago
|
// Emit signals about closing wallets
|
||
15 years ago
|
void doCloseSignals(int,const TQString&);
|
||
|
void emitFolderUpdated(const TQString&, const TQString&);
|
||
15 years ago
|
// Internal - close this wallet.
|
||
|
int closeWallet(KWallet::Backend *w, int handle, bool force);
|
||
|
// Implicitly allow access for this application
|
||
15 years ago
|
bool implicitAllow(const TQString& wallet, const TQCString& app);
|
||
|
bool implicitDeny(const TQString& wallet, const TQCString& app);
|
||
|
TQCString friendlyDCOPPeerName();
|
||
15 years ago
|
|
||
15 years ago
|
void doTransactionChangePassword(const TQCString& appid, const TQString& wallet, uint wId);
|
||
|
int doTransactionOpen(const TQCString& appid, const TQString& wallet, uint wId, bool modal);
|
||
15 years ago
|
|
||
15 years ago
|
void setupDialog( TQWidget* dialog, WId wId, const TQCString& appid, bool modal );
|
||
15 years ago
|
void checkActiveDialog();
|
||
|
|
||
15 years ago
|
TQIntDict<KWallet::Backend> _wallets;
|
||
|
TQMap<TQCString,TQValueList<int> > _handles;
|
||
|
TQMap<TQString,TQCString> _passwords;
|
||
15 years ago
|
KDirWatch *_dw;
|
||
|
int _failed;
|
||
|
|
||
|
bool _leaveOpen, _closeIdle, _launchManager, _enabled;
|
||
|
bool _openPrompt, _firstUse, _showingFailureNotify;
|
||
|
int _idleTime;
|
||
15 years ago
|
TQMap<TQString,TQStringList> _implicitAllowMap, _implicitDenyMap;
|
||
15 years ago
|
KTimeout *_timeouts;
|
||
14 years ago
|
TQTimer _tryOpenBlocked;
|
||
15 years ago
|
|
||
15 years ago
|
TQPtrList<KWalletTransaction> _transactions;
|
||
|
TQGuardedPtr< TQWidget > activeDialog;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
#endif
|