syncevolution/src/syncevo/ConfigNode.cpp
Patrick Ohly 16bf21f53e command line: specify properties per source and config
The new format of the property name in --sync-property is:
  <name>[@<context>|@<peer>@<context>]

--source-property also allows a source name:
  [<source>/]<name>[@<context>|@<peer>@<context>]

This allows to set source properties differently for different
sources in the same command line invocation. The @<context> or
@<peer>@<context> will be used to set properties differently for
main and target context in a local sync (not used yet).

The advantage of this grammar is that a string can be split purely based
on the syntax in PropertySpecifier::StringToPropSpec().

The patch itself is based on the idea of first collecting all of these
config property filters in a new case-insensitive hash structure,
FullProps in ConfigFilter.cpp/h, as part of parsing command line
parameters.

Then once specific filters for sync or sources are needed, they are
generated from FullProps by collecting all that apply, starting with
the ones with lowest priority and overwriting them with more important
(= more specific) ones. This also covers additional filters, like the
shared properties of the target context when printing a template.

Currently FullProps may contain arbitrary source and config
names. Typos are not detected, which is both hard to implement (which
names and configs are valid in the current invocation?) and also
forces users to be very specific (can't apply one set of filters to
different configs) - this is the same conflict of interest as in
"configure", which allows unknown --enable/disable parameters because
they might be relevant in a sub-configure script.

SyncConfig itself still only stores the filters which apply to it, not
the full set of overrides that the Cmdline has in its m_props. The
advantage is that the API remains the same (no change needed or done
in the syncevo-dbus-server). The disadvantage is that in a local
sync, no information is available about the properties applying to the
target context - probably needs to change.
2011-01-25 11:11:53 +01:00

51 lines
1.7 KiB
C++

/*
* Copyright (C) 2008-2009 Patrick Ohly <patrick.ohly@gmx.de>
* 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
*/
#include <syncevo/FileConfigNode.h>
#include <syncevo/SafeConfigNode.h>
#include <syncevo/declarations.h>
SE_BEGIN_CXX
boost::shared_ptr<ConfigNode> ConfigNode::createFileNode(const string &filename)
{
string::size_type off = filename.rfind('/');
boost::shared_ptr<ConfigNode> filenode;
if (off != filename.npos) {
filenode.reset(new FileConfigNode(filename.substr(0, off),
filename.substr(off + 1),
false));
} else {
filenode.reset(new FileConfigNode(".", filename, false));
}
boost::shared_ptr<SafeConfigNode> savenode(new SafeConfigNode(filenode));
savenode->setMode(false);
return savenode;
}
void ConfigNode::writeProperties(const ConfigProps &props)
{
BOOST_FOREACH(const ConfigProps::value_type &entry, props) {
setProperty(entry.first, entry.second);
}
}
SE_END_CXX