SyncConfig: allow sharing file config tree between configs
A SHARED_LAYOUT config tree caches config nodes. Allow a second config to use those same nodes as an already existing config. This will be useful in combination with indirect password lookup, because then the credentials can be stored as temporary property values and be reused when used multiple times in a process (for example, by CardDAV and by CalDAV).
This commit is contained in:
parent
d9f87251c0
commit
d2a4164668
|
@ -340,6 +340,7 @@ void SyncConfig::makeEphemeral()
|
|||
}
|
||||
|
||||
SyncConfig::SyncConfig(const string &peer,
|
||||
Layout treeLayout,
|
||||
boost::shared_ptr<ConfigTree> tree,
|
||||
const string &redirectPeerRootPath) :
|
||||
m_layout(SHARED_LAYOUT),
|
||||
|
@ -362,11 +363,20 @@ SyncConfig::SyncConfig(const string &peer,
|
|||
m_peer;
|
||||
|
||||
if (tree.get() != NULL) {
|
||||
// existing tree points into simple configuration
|
||||
m_tree = tree;
|
||||
m_layout = HTTP_SERVER_LAYOUT;
|
||||
m_peerPath =
|
||||
m_contextPath = "";
|
||||
m_layout = treeLayout;
|
||||
if (treeLayout == SHARED_LAYOUT) {
|
||||
// Use the standard paths, same as below.
|
||||
splitConfigString(m_peer, m_peerPath, m_contextPath);
|
||||
if (!m_peerPath.empty()) {
|
||||
m_peerPath = m_contextPath + "/peers/" + m_peerPath;
|
||||
}
|
||||
} else {
|
||||
// Existing tree points into simple configuration,
|
||||
// use empty paths.
|
||||
m_peerPath =
|
||||
m_contextPath = "";
|
||||
}
|
||||
} else {
|
||||
// search for configuration in various places...
|
||||
root = getOldRoot();
|
||||
|
@ -835,7 +845,7 @@ boost::shared_ptr<SyncConfig> SyncConfig::createPeerTemplate(const string &serve
|
|||
}
|
||||
|
||||
boost::shared_ptr<ConfigTree> tree(new SingleFileConfigTree(templateConfig));
|
||||
boost::shared_ptr<SyncConfig> config(new SyncConfig(server, tree));
|
||||
boost::shared_ptr<SyncConfig> config(new SyncConfig(server, SyncConfig::HTTP_SERVER_LAYOUT, tree));
|
||||
boost::shared_ptr<PersistentSyncSourceConfig> source;
|
||||
|
||||
config->setDefaults(false);
|
||||
|
|
|
@ -884,6 +884,15 @@ class ConfigPropertyRegistry : public std::list<const ConfigProperty *> {
|
|||
*/
|
||||
class SyncConfig {
|
||||
public:
|
||||
enum Layout {
|
||||
SYNC4J_LAYOUT, /**< .syncj4/evolution/<server>, SyncEvolution <= 0.7.x */
|
||||
HTTP_SERVER_LAYOUT, /**< .config/syncevolution/<server> with sources
|
||||
underneath, SyncEvolution <= 0.9.x */
|
||||
SHARED_LAYOUT /**< .config/syncevolution/<context> containing sources
|
||||
and peers, with source settings shared by peers,
|
||||
SyncEvolution >= 1.0 */
|
||||
};
|
||||
|
||||
/**
|
||||
* Opens the configuration for a specific server,
|
||||
* searching for the config files in the usual
|
||||
|
@ -911,6 +920,8 @@ class SyncConfig {
|
|||
* searching for it; always uses the
|
||||
* current layout in that tree
|
||||
*
|
||||
* @param layout if tree is given, then this is the layout to be used with it
|
||||
*
|
||||
* @param redirectPeerRootPath
|
||||
* Can be used to redirect the per-peer
|
||||
* files into a different directory. Only works
|
||||
|
@ -918,6 +929,7 @@ class SyncConfig {
|
|||
* Used by SyncContext for local sync.
|
||||
*/
|
||||
SyncConfig(const std::string &peer,
|
||||
Layout treeLayout = HTTP_SERVER_LAYOUT,
|
||||
boost::shared_ptr<ConfigTree> tree = boost::shared_ptr<ConfigTree>(),
|
||||
const std::string &redirectPeerRootPath = "");
|
||||
|
||||
|
@ -1575,15 +1587,6 @@ class SyncConfig {
|
|||
virtual InitStateString getDevType() const;
|
||||
/**@}*/
|
||||
|
||||
enum Layout {
|
||||
SYNC4J_LAYOUT, /**< .syncj4/evolution/<server>, SyncEvolution <= 0.7.x */
|
||||
HTTP_SERVER_LAYOUT, /**< .config/syncevolution/<server> with sources
|
||||
underneath, SyncEvolution <= 0.9.x */
|
||||
SHARED_LAYOUT /**< .config/syncevolution/<context> containing sources
|
||||
and peers, with source settings shared by peers,
|
||||
SyncEvolution >= 1.0 */
|
||||
};
|
||||
|
||||
/** config versioning; setting is done internally */
|
||||
int getConfigVersion(ConfigLevel level, ConfigLimit limit) const;
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ SyncContext::SyncContext(const string &client,
|
|||
const boost::shared_ptr<TransportAgent> &agent,
|
||||
bool doLogging) :
|
||||
SyncConfig(client,
|
||||
SyncConfig::HTTP_SERVER_LAYOUT,
|
||||
boost::shared_ptr<ConfigTree>(),
|
||||
rootPath),
|
||||
m_server(client),
|
||||
|
|
Loading…
Reference in a new issue