syncevolution/src/CmdlineSyncClient.h
Zhu, Yongsheng 54c7f159fb command line: add keyring support (MB#3604)
--keyring|-k
  Save or retrieve passwords from the GNOME keyring when modifying the
  configuration or running a synchronization. Note that using this option
  applies to *all* passwords in a configuration, so setting a single
  password as follows moves the other passwords into the keyring, if
  they were not stored there already:
     --keyring --configure --sync-property proxyPassword=foo

  When passwords were stored in the keyring, their value is set to "-"
  in the configuration. This means that when running a synchronization
  without the --keyring argument, the password has to be entered
  interactively.

The implementation introduces new virtual methods for password handling
to properties and iterates over all properties to activate that
special behavior.

Another change is no longer to use cached strings in the SyncEvolutionConfig
to store retrieved passwords. Instead, they are saved as the filter in
the config node. This could help their users to get them but not flush
to files. The main purpose of this change is to make it flexible
to meet the requirements of dynamically added passwords in the backend.
2009-09-21 10:10:28 +02:00

53 lines
1.9 KiB
C++

/*
* Copyright (C) 2009 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) version 3.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef INCL_CMDLINESYNCCLIENT
#define INCL_CMDLINESYNCCLIENT
#include "EvolutionSyncClient.h"
/**
* a command line sync client for the purpose of
* supporting a mechanism to save and retrieve password
* in keyring.
*/
class CmdlineSyncClient : public EvolutionSyncClient {
public:
CmdlineSyncClient(const string &server,
bool doLogging = false,
const set<string> &sources = set<string>(),
bool useKeyring = false);
using EvolutionSyncConfig::savePassword;
/**
* These 2 functions are from ConfigUserInterface and implement it
* to use keyring to retrieve and save password in the keyring.
*/
virtual string askPassword(const string &passwordName, const string &descr, const ConfigPasswordKey &key);
virtual bool savePassword(const string &passwordName, const string &password, const ConfigPasswordKey &key);
void setKeyring(bool keyring) { m_keyring = keyring; }
bool getKeyring() const { return m_keyring; }
private:
/** a bool flag used to indicate whether to use keyring to store password */
bool m_keyring;
};
#endif // INCL_CMDLINESYNCCLIENT