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.
156 lines
4.2 KiB
156 lines
4.2 KiB
15 years ago
|
/*=========================================================================
|
||
|
| KCardDAV
|
||
|
|--------------------------------------------------------------------------
|
||
|
| (c) 2010 Timothy Pearson
|
||
|
|
|
||
|
| This project is released under the GNU General Public License.
|
||
|
| Please see the file COPYING for more details.
|
||
|
|--------------------------------------------------------------------------
|
||
|
| CardDAV resource preferences class.
|
||
|
========================================================================*/
|
||
|
|
||
|
/*=========================================================================
|
||
|
| INCLUDES
|
||
|
========================================================================*/
|
||
|
|
||
|
#ifndef KABC_CARDDAVPREFS_H
|
||
|
#define KABC_CARDDAVPREFS_H
|
||
|
|
||
|
#include "prefsskel.h"
|
||
|
|
||
12 years ago
|
#include <tdewallet.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
|
||
15 years ago
|
class TQString;
|
||
15 years ago
|
|
||
|
namespace KABC {
|
||
|
|
||
|
/*=========================================================================
|
||
|
| CLASS
|
||
|
========================================================================*/
|
||
|
|
||
|
/**
|
||
|
* This class provides access to ResourceCardDav preferences.
|
||
|
* It inherits auto-generated CardDavPrefsSkel class to add password-handling code.
|
||
|
* KWallet is used for storing passwords.
|
||
|
* It also adds code to allow multiple CardDAV resources to store settings in the same
|
||
|
* config file.
|
||
|
*/
|
||
|
class CardDavPrefs : public CardDavPrefsSkel {
|
||
|
|
||
|
public:
|
||
|
|
||
|
/**
|
||
|
* @param prefix Unique prefix of the resource instance (use identifier() method).
|
||
|
*/
|
||
15 years ago
|
CardDavPrefs(const TQString& prefix)
|
||
15 years ago
|
: mWallet(NULL)
|
||
|
, mNoWallet(false)
|
||
|
, mPrefix(prefix)
|
||
|
, mPassword(NO_PASSWORD)
|
||
|
{
|
||
|
addPrefix(prefix);
|
||
|
}
|
||
|
|
||
|
virtual ~CardDavPrefs() {
|
||
13 years ago
|
kdDebug() << "removing wallet" << '\n';
|
||
15 years ago
|
removeWallet();
|
||
|
}
|
||
|
|
||
|
virtual void writeConfig();
|
||
|
virtual void readConfig();
|
||
|
|
||
|
/**
|
||
|
* Sets a new password. Also, if remember password flag is true,
|
||
|
* remembers the password in the wallet. So, if you want the password
|
||
|
* to be properly saved, call this method after ensuring the remember flag
|
||
|
* is set.
|
||
|
*/
|
||
15 years ago
|
void setPassword(const TQString& p);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns password. The password is taken from the wallet.
|
||
|
* May return an empty string, if there is no password available.
|
||
|
*/
|
||
15 years ago
|
TQString password();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the username.
|
||
|
*/
|
||
15 years ago
|
TQString getusername();
|
||
15 years ago
|
|
||
|
void setRememberPassword(bool v);
|
||
|
|
||
|
/**
|
||
|
* @return A full URL to connect to CardDAV server (including username and password).
|
||
|
*/
|
||
15 years ago
|
TQString getFullUrl();
|
||
15 years ago
|
|
||
15 years ago
|
bool getUseURI();
|
||
|
|
||
15 years ago
|
protected:
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Add an unique prefix to TDEConfigGroup, so that different instances of the resource
|
||
15 years ago
|
* can use the same config file.
|
||
|
* @param prefix Unique prefix of the resource instance.
|
||
|
*/
|
||
15 years ago
|
void addPrefix(const TQString& prefix);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the wallet or NULL, if the wallet can't be obtained.
|
||
|
*/
|
||
|
KWallet::Wallet* getWallet();
|
||
|
|
||
|
/**
|
||
|
* Tries to set a working folder for the wallet. If the wallet is not configured yet, does nothing.
|
||
|
* @param folder the wallet working folder
|
||
|
* @return true, if the folder has been set, and false otherwise.
|
||
|
*/
|
||
15 years ago
|
bool setWalletFolder(const TQString& folder);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Removes the wallet. If @p noWallet is set, the wallet has been marked inaccessible, so that subsequent
|
||
|
* getWallet calls will not try to recreate it.
|
||
|
*/
|
||
|
void removeWallet(bool noWallet = false);
|
||
|
|
||
|
/**
|
||
|
* Wrire password to the wallet.
|
||
|
* @param password password to write
|
||
|
* @return true on success, false on failure
|
||
|
*/
|
||
15 years ago
|
bool writePasswordToWallet(const TQString& password);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Extracts password from the wallet.
|
||
|
* @param password a variable to save read password to.
|
||
|
* @return true on success, false on failure
|
||
|
*/
|
||
15 years ago
|
bool readPasswordFromWallet(TQString& password);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Clears password in the wallet.
|
||
|
* @return true on success, false on failure
|
||
|
*/
|
||
|
bool removePasswordFromWallet();
|
||
|
|
||
|
private:
|
||
|
|
||
15 years ago
|
static const TQString NO_PASSWORD;
|
||
|
static const TQString WALLET_FOLDER;
|
||
|
static const TQString WALLET_PWD_SUFFIX;
|
||
15 years ago
|
|
||
|
KWallet::Wallet* mWallet;
|
||
|
bool mNoWallet;
|
||
|
|
||
15 years ago
|
TQString mPrefix;
|
||
|
TQString mPassword;
|
||
15 years ago
|
};
|
||
|
|
||
|
} // namespace KABC
|
||
|
|
||
|
#endif // KABC_CARDDAVPREFS_H
|
||
|
|
||
|
|