2008-03-19 12:29:14 +01:00
/*
2009-03-25 15:21:04 +01:00
* Copyright ( C ) 2008 - 2009 Patrick Ohly < patrick . ohly @ gmx . de >
* Copyright ( C ) 2009 Intel Corporation
2009-04-30 18:14:03 +02:00
*
* 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
2008-03-19 12:29:14 +01:00
*/
2009-10-05 14:49:32 +02:00
# include <syncevo/Cmdline.h>
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
# include <syncevo/CmdlineSyncClient.h>
2009-10-05 14:49:32 +02:00
# include <syncevo/FilterConfigNode.h>
# include <syncevo/VolatileConfigNode.h>
2011-01-10 15:56:53 +01:00
# include <syncevo/IniConfigNode.h>
2009-10-05 14:49:32 +02:00
# include <syncevo/SyncSource.h>
# include <syncevo/SyncContext.h>
# include <syncevo/util.h>
2012-06-20 12:31:24 +02:00
# include <syncevo/SuspendFlags.h>
2009-10-02 17:23:53 +02:00
# include "test.h"
2008-03-19 12:29:14 +01:00
2011-12-01 18:46:49 +01:00
# include <synthesis/SDK_util.h>
2008-03-19 17:43:31 +01:00
# include <unistd.h>
# include <errno.h>
2010-06-11 15:44:57 +02:00
# include <fstream>
2008-03-19 12:29:14 +01:00
# include <iostream>
2009-04-15 21:03:26 +02:00
# include <iomanip>
2008-03-28 23:32:00 +01:00
# include <sstream>
2008-03-19 12:29:14 +01:00
# include <memory>
# include <set>
2010-03-03 16:20:53 +01:00
# include <list>
2008-03-19 15:35:22 +01:00
# include <algorithm>
2008-03-19 12:29:14 +01:00
using namespace std ;
# include <boost/shared_ptr.hpp>
2009-06-10 17:28:45 +02:00
# include <boost/algorithm/string/join.hpp>
2010-06-11 15:44:57 +02:00
# include <boost/algorithm/string/split.hpp>
2008-03-29 16:41:11 +01:00
# include <boost/algorithm/string.hpp>
2011-10-03 16:27:55 +02:00
# include <boost/tokenizer.hpp>
2008-03-30 15:11:45 +02:00
# include <boost/foreach.hpp>
2010-09-30 17:10:57 +02:00
# include <boost/range.hpp>
2013-07-29 13:57:46 +02:00
# include <boost/assign/list_of.hpp>
2010-06-11 15:44:57 +02:00
# include <fstream>
2011-06-18 01:29:27 +02:00
2009-10-05 14:49:32 +02:00
# include <syncevo/declarations.h>
2011-06-18 01:29:27 +02:00
using namespace std ;
2009-10-02 17:23:53 +02:00
SE_BEGIN_CXX
2010-06-30 17:36:54 +02:00
// synopsis and options char strings
# include "CmdlineHelp.c"
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
Cmdline : : Cmdline ( int argc , const char * const * argv ) :
2008-03-19 12:29:14 +01:00
m_argc ( argc ) ,
m_argv ( argv ) ,
2009-10-06 17:22:47 +02:00
m_validSyncProps ( SyncConfig : : getRegistry ( ) ) ,
redesigned SyncSource base class + API
The main motivation for this change is that it allows the implementor
of a backend to choose the implementations for the different aspects
of a datasource (change tracking, item import/export, logging, ...)
independently of each other. For example, change tracking via revision
strings can now be combined with exchanging data with the Synthesis
engine via a single string (the traditional method in SyncEvolution)
and with direct access to the Synthesis field list (now possible for
the first time).
The new backend API is based on the concept of providing
implementations for certain functionality via function objects instead
of implementing certain virtual methods. The advantage is that
implementors can define their own, custom interfaces and mix and match
implementations of the different groups of functionality.
Logging (see SyncSourceLogging in a later commit) can be done by
wrapping some arbitrary other item import/export function objects
(decorator design pattern).
The class hierarchy is now this:
- SyncSourceBase: interface for common utility code, all other
classes are derived from it and thus can use that code
- SyncSource: base class which implements SyncSourceBase and
hooks a datasource into the SyncEvolution core;
its "struct Operations" holds the function objects which
can be implemented in different ways
- TestingSyncSource: combines some of the following classes
into an interface that is expected by the client-test
program; backends only have to derive from (and implement this)
if they want to use the automated testing
- TrackingSyncSource: provides the same functionality as
before (change tracking via revision strings, item import/export
as string) in a single interface; the description of the pure
virtual methods are duplicated so that developers can go through
this class and find everything they need to know to implement
it
The following classes contain the code that was previously
found in the EvolutionSyncSource base class. Implementors
can derive from them and call the init() methods to inherit
and activate the functionality:
- SyncSourceSession: binds Synthesis session callbacks to
virtual methods beginSync(), endSync()
- SyncSourceChanges: implements Synthesis item tracking callbacks
with set of LUIDs that the user of the class has to fill
- SyncSourceDelete: binds Synthesis delete callback to
virtual method
- SyncSourceRaw: read and write items in the backends format,
used for testing and backup/restore
- SyncSourceSerialize: exchanges items with Synthesis engine
using a string representation of the data; this is how
EvolutionSyncSource has traditionally worked, so much of the
same virtual methods are now in this class
- SyncSourceRevisions: utility class which does change tracking
via some kind of "revision" string which changes each time
an item is modified; this code was previously in the
TrackingSyncSource
2009-08-25 09:27:46 +02:00
m_validSourceProps ( SyncSourceConfig : : getRegistry ( ) )
2008-03-19 12:29:14 +01:00
{ }
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
Cmdline : : Cmdline ( const vector < string > & args ) :
2010-03-15 02:33:43 +01:00
m_args ( args ) ,
m_validSyncProps ( SyncConfig : : getRegistry ( ) ) ,
m_validSourceProps ( SyncSourceConfig : : getRegistry ( ) )
{
m_argc = args . size ( ) ;
m_argvArray . reset ( new const char * [ args . size ( ) ] ) ;
for ( int i = 0 ; i < m_argc ; i + + ) {
m_argvArray [ i ] = m_args [ i ] . c_str ( ) ;
}
m_argv = m_argvArray . get ( ) ;
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
Cmdline : : Cmdline ( const char * arg , . . . ) :
2010-10-29 10:06:00 +02:00
m_validSyncProps ( SyncConfig : : getRegistry ( ) ) ,
m_validSourceProps ( SyncSourceConfig : : getRegistry ( ) )
{
va_list argList ;
va_start ( argList , arg ) ;
for ( const char * curr = arg ;
curr ;
curr = va_arg ( argList , const char * ) ) {
m_args . push_back ( curr ) ;
}
va_end ( argList ) ;
m_argc = m_args . size ( ) ;
m_argvArray . reset ( new const char * [ m_args . size ( ) ] ) ;
for ( int i = 0 ; i < m_argc ; i + + ) {
m_argvArray [ i ] = m_args [ i ] . c_str ( ) ;
}
m_argv = m_argvArray . get ( ) ;
}
2009-10-05 14:49:32 +02:00
bool Cmdline : : parse ( )
2008-03-19 12:29:14 +01:00
{
2010-04-06 10:38:24 +02:00
vector < string > parsed ;
return parse ( parsed ) ;
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
/**
* Detects " --sync foo " , " --sync=foo " , " -s foo " .
*/
2014-01-07 10:16:05 +01:00
static bool IsKeyword ( const std : : string & arg ,
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
const char * longWord ,
const char * shortWord )
{
return boost : : istarts_with ( arg , std : : string ( longWord ) + " = " ) | |
boost : : iequals ( arg , longWord ) | |
boost : : iequals ( arg , shortWord ) ;
}
2010-04-06 10:38:24 +02:00
bool Cmdline : : parse ( vector < string > & parsed )
{
parsed . clear ( ) ;
2010-04-07 18:21:54 +02:00
if ( m_argc ) {
parsed . push_back ( m_argv [ 0 ] ) ;
}
2010-06-11 15:44:57 +02:00
m_delimiter = " \n \n " ;
2010-04-07 18:21:54 +02:00
2010-06-11 12:52:35 +02:00
// All command line options which ask for a specific operation,
// like --restore, --print-config, ... Used to detect conflicting
// operations.
vector < string > operations ;
2008-03-19 12:29:14 +01:00
int opt = 1 ;
command line + daemon: usability improvements (MB #5043)
This patch changes what is shown to the user and how the user
interacts with the command line. Details below.
"--use-daemon [yes/no]" implies that yes/no is optional (square
brackets!), with "yes" being the option that could be expected for a
plain "--use-daemon" parameter. But the implementation always expects
a "yes" or "no" parameter. The original format suggested was
"--use-daemon[=yes/no]"
This patch switches to that format, changes --use-daemon into --daemon
(to be consistent with --keyring) and enables the same format for
--keyring. Although not documented, 0/f/false and 1/t/true are also
accepted. Because the value becomes part of the parameter, m_argc checks
had to be adapted.
The documentation for "--use-daemon" was inserted in the middle of the
"--keyring documentation".
"Parameter not set" has to be available to the Cmdline caller in the
command line too, in addition to true/false. This was done originally
with a string which is empty, "yes" or "no". Using a tri-state
Cmdline::Bool class makes this a bit more explicit and removes the
ambiguity around what useDaemon() returns (values weren't documented).
When running without --daemon and no daemon available, the
first lines of output were:
ERROR: org.<cryptic error>
[INFO] itodo20: inactive
....
=> The command line should fall back *silently* to running in-process.
=> Error messages should be formatted and logged as such, using SE_LOG_ERROR().
Old code might not have done that and we need to preserve that for compatibility
with frontends, but new code should use [ERROR] as output.
=> D-Bus error messages (as in the case above) must have some user (and developer!)
comprehensible explanation what went wrong. The D-Bus error class itself
is no enough.
Although I haven't tested it, I suspect that the code also would have
re-run the operation in-process after the D-Bus server already
executed it and failed.
I rewrote this so that a check for "daemon available" without error messages
is done first before committing to using the daemon. Once that decision is made,
the command line will not fall back to in-process execution.
Rewrote several error messages. Telling a user of a distro's binary to
"re-configure" is misleading (he didn't configure himself).
"can't" => "cannot", punctuation changes. Not sure whether is always an
improvement, comments welcome.
Comment on coding style: I've used "if ()" instead of "if()" because that is
the GNU recommendation.
2010-03-26 18:47:41 +01:00
bool ok ;
2008-03-19 12:29:14 +01:00
while ( opt < m_argc ) {
2010-04-06 10:38:24 +02:00
parsed . push_back ( m_argv [ opt ] ) ;
2011-02-03 14:05:16 +01:00
if ( boost : : iequals ( m_argv [ opt ] , " -- " ) ) {
// separator between options and <config> <source>:
// swallow it and leave option parsing
opt + + ;
2008-03-19 12:29:14 +01:00
break ;
}
2011-02-03 14:05:16 +01:00
if ( m_argv [ opt ] [ 0 ] ! = ' - ' ) {
if ( strchr ( m_argv [ opt ] , ' = ' ) ) {
// property assignment
if ( ! parseProp ( UNKNOWN_PROPERTY_TYPE ,
NULL ,
m_argv [ opt ] ,
NULL ) ) {
return false ;
} else {
opt + + ;
continue ;
}
} else {
break ;
}
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
if ( IsKeyword ( m_argv [ opt ] , " --sync " , " -s " ) ) {
if ( ! parseAssignment ( opt , parsed , SOURCE_PROPERTY_TYPE , " sync " , NULL ) ) {
2008-03-19 12:29:14 +01:00
return false ;
}
2008-08-03 22:48:45 +02:00
// disable requirement to add --run explicitly in order to
// be compatible with traditional command lines
m_run = true ;
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
} else if ( IsKeyword ( m_argv [ opt ] , " --keyring " , " -k " ) ) {
if ( ! parseAssignment ( opt , parsed , SYNC_PROPERTY_TYPE , " keyring " , " true " ) ) {
return false ;
}
2008-03-29 16:41:11 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --sync-property " ) | |
boost : : iequals ( m_argv [ opt ] , " -y " ) ) {
2008-03-19 12:29:14 +01:00
opt + + ;
2011-01-25 11:11:53 +01:00
if ( ! parseProp ( SYNC_PROPERTY_TYPE ,
2008-03-19 12:29:14 +01:00
m_argv [ opt - 1 ] , opt = = m_argc ? NULL : m_argv [ opt ] ) ) {
return false ;
}
2010-04-09 05:24:03 +02:00
parsed . push_back ( m_argv [ opt ] ) ;
2008-03-29 16:41:11 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --source-property " ) | |
2014-07-28 15:29:41 +02:00
boost : : iequals ( m_argv [ opt ] , " --datastore-property " ) | |
2008-03-29 16:41:11 +01:00
boost : : iequals ( m_argv [ opt ] , " -z " ) ) {
2008-03-19 12:29:14 +01:00
opt + + ;
2011-01-25 11:11:53 +01:00
if ( ! parseProp ( SOURCE_PROPERTY_TYPE ,
2008-03-19 12:29:14 +01:00
m_argv [ opt - 1 ] , opt = = m_argc ? NULL : m_argv [ opt ] ) ) {
return false ;
}
2010-04-09 05:24:03 +02:00
parsed . push_back ( m_argv [ opt ] ) ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --template " ) | |
2008-03-29 16:41:11 +01:00
boost : : iequals ( m_argv [ opt ] , " -l " ) ) {
2008-03-19 12:29:14 +01:00
opt + + ;
if ( opt > = m_argc ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , string ( " missing parameter for " ) + cmdOpt ( m_argv [ opt - 1 ] ) ) ;
2008-03-19 12:29:14 +01:00
return false ;
}
2010-04-09 05:24:03 +02:00
parsed . push_back ( m_argv [ opt ] ) ;
2008-03-19 12:29:14 +01:00
m_template = m_argv [ opt ] ;
2008-03-30 23:50:51 +02:00
m_configure = true ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
string temp = boost : : trim_copy ( m_template ) ;
if ( temp . find ( " ? " ) = = 0 ) {
m_printTemplates = true ;
2008-03-19 17:43:31 +01:00
m_dontrun = true ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
m_template = temp . substr ( 1 ) ;
2008-03-19 17:43:31 +01:00
}
2011-10-03 16:27:55 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --print-databases " ) ) {
operations . push_back ( m_argv [ opt ] ) ;
m_printDatabases = true ;
2012-09-13 18:02:07 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --create-database " ) ) {
operations . push_back ( m_argv [ opt ] ) ;
m_createDatabase = true ;
} else if ( boost : : iequals ( m_argv [ opt ] , " --remove-database " ) ) {
operations . push_back ( m_argv [ opt ] ) ;
m_removeDatabase = true ;
2010-01-20 11:36:19 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --print-servers " ) | |
boost : : iequals ( m_argv [ opt ] , " --print-peers " ) | |
boost : : iequals ( m_argv [ opt ] , " --print-configs " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2008-03-19 12:29:14 +01:00
m_printServers = true ;
2008-03-29 16:41:11 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --print-config " ) | |
boost : : iequals ( m_argv [ opt ] , " -p " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2008-03-19 12:29:14 +01:00
m_printConfig = true ;
2009-04-15 15:58:05 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --print-sessions " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2009-04-15 15:58:05 +02:00
m_printSessions = true ;
2008-03-29 16:41:11 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --configure " ) | |
boost : : iequals ( m_argv [ opt ] , " -c " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2008-03-19 12:29:14 +01:00
m_configure = true ;
2009-04-15 14:02:09 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --remove " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2009-04-15 14:02:09 +02:00
m_remove = true ;
2008-08-03 15:00:51 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --run " ) | |
boost : : iequals ( m_argv [ opt ] , " -r " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2008-08-03 15:00:51 +02:00
m_run = true ;
2009-04-23 16:47:07 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --restore " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2009-04-23 16:47:07 +02:00
opt + + ;
if ( opt > = m_argc ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , string ( " missing parameter for " ) + cmdOpt ( m_argv [ opt - 1 ] ) ) ;
2009-04-23 16:47:07 +02:00
return false ;
}
m_restore = m_argv [ opt ] ;
if ( m_restore . empty ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , string ( " missing parameter for " ) + cmdOpt ( m_argv [ opt - 1 ] ) ) ;
2009-04-23 16:47:07 +02:00
return false ;
}
2010-04-06 10:38:24 +02:00
//if can't convert it successfully, it's an invalid path
if ( ! relToAbs ( m_restore ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , string ( " parameter ' " ) + m_restore + " ' for " + cmdOpt ( m_argv [ opt - 1 ] ) + " must be log directory " ) ;
2009-04-23 16:47:07 +02:00
return false ;
}
2010-04-06 10:38:24 +02:00
parsed . push_back ( m_restore ) ;
2009-04-23 16:47:07 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --before " ) ) {
m_before = true ;
} else if ( boost : : iequals ( m_argv [ opt ] , " --after " ) ) {
m_after = true ;
2010-06-11 15:44:57 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --print-items " ) ) {
operations . push_back ( m_argv [ opt ] ) ;
m_printItems = m_accessItems = true ;
} else if ( ( boost : : iequals ( m_argv [ opt ] , " --export " ) & & ( m_export = true ) ) | |
( boost : : iequals ( m_argv [ opt ] , " --import " ) & & ( m_import = true ) ) | |
( boost : : iequals ( m_argv [ opt ] , " --update " ) & & ( m_update = true ) ) ) {
operations . push_back ( m_argv [ opt ] ) ;
m_accessItems = true ;
opt + + ;
if ( opt > = m_argc | | ! m_argv [ opt ] [ 0 ] ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , string ( " missing parameter for " ) + cmdOpt ( m_argv [ opt - 1 ] ) ) ;
2010-06-11 15:44:57 +02:00
return false ;
}
m_itemPath = m_argv [ opt ] ;
if ( m_itemPath ! = " - " ) {
string dir , file ;
splitPath ( m_itemPath , dir , file ) ;
if ( dir . empty ( ) ) {
dir = " . " ;
}
if ( ! relToAbs ( dir ) ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , dir , errno ) ;
2010-06-11 15:44:57 +02:00
}
m_itemPath = dir + " / " + file ;
}
parsed . push_back ( m_itemPath ) ;
} else if ( boost : : iequals ( m_argv [ opt ] , " --delimiter " ) ) {
opt + + ;
if ( opt > = m_argc ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , string ( " missing parameter for " ) + cmdOpt ( m_argv [ opt - 1 ] ) ) ;
2010-06-11 15:44:57 +02:00
return false ;
}
m_delimiter = m_argv [ opt ] ;
parsed . push_back ( m_delimiter ) ;
2010-06-11 18:43:01 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --delete-items " ) ) {
operations . push_back ( m_argv [ opt ] ) ;
m_deleteItems = m_accessItems = true ;
2009-04-23 16:47:07 +02:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --dry-run " ) ) {
m_dryrun = true ;
2008-03-29 16:41:11 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --migrate " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2008-03-19 12:29:14 +01:00
m_migrate = true ;
2008-03-29 16:41:11 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --status " ) | |
boost : : iequals ( m_argv [ opt ] , " -t " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2008-03-19 12:29:14 +01:00
m_status = true ;
2008-03-29 16:41:11 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --quiet " ) | |
boost : : iequals ( m_argv [ opt ] , " -q " ) ) {
2008-03-19 12:29:14 +01:00
m_quiet = true ;
2008-03-29 16:41:11 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --help " ) | |
boost : : iequals ( m_argv [ opt ] , " -h " ) ) {
2008-03-19 12:29:14 +01:00
m_usage = true ;
2008-03-29 16:41:11 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --version " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2008-03-19 12:29:14 +01:00
m_version = true ;
command line + daemon: usability improvements (MB #5043)
This patch changes what is shown to the user and how the user
interacts with the command line. Details below.
"--use-daemon [yes/no]" implies that yes/no is optional (square
brackets!), with "yes" being the option that could be expected for a
plain "--use-daemon" parameter. But the implementation always expects
a "yes" or "no" parameter. The original format suggested was
"--use-daemon[=yes/no]"
This patch switches to that format, changes --use-daemon into --daemon
(to be consistent with --keyring) and enables the same format for
--keyring. Although not documented, 0/f/false and 1/t/true are also
accepted. Because the value becomes part of the parameter, m_argc checks
had to be adapted.
The documentation for "--use-daemon" was inserted in the middle of the
"--keyring documentation".
"Parameter not set" has to be available to the Cmdline caller in the
command line too, in addition to true/false. This was done originally
with a string which is empty, "yes" or "no". Using a tri-state
Cmdline::Bool class makes this a bit more explicit and removes the
ambiguity around what useDaemon() returns (values weren't documented).
When running without --daemon and no daemon available, the
first lines of output were:
ERROR: org.<cryptic error>
[INFO] itodo20: inactive
....
=> The command line should fall back *silently* to running in-process.
=> Error messages should be formatted and logged as such, using SE_LOG_ERROR().
Old code might not have done that and we need to preserve that for compatibility
with frontends, but new code should use [ERROR] as output.
=> D-Bus error messages (as in the case above) must have some user (and developer!)
comprehensible explanation what went wrong. The D-Bus error class itself
is no enough.
Although I haven't tested it, I suspect that the code also would have
re-run the operation in-process after the D-Bus server already
executed it and failed.
I rewrote this so that a check for "daemon available" without error messages
is done first before committing to using the daemon. Once that decision is made,
the command line will not fall back to in-process execution.
Rewrote several error messages. Telling a user of a distro's binary to
"re-configure" is misleading (he didn't configure himself).
"can't" => "cannot", punctuation changes. Not sure whether is always an
improvement, comments welcome.
Comment on coding style: I've used "if ()" instead of "if()" because that is
the GNU recommendation.
2010-03-26 18:47:41 +01:00
} else if ( parseBool ( opt , " --daemon " , NULL , true , m_useDaemon , ok ) ) {
if ( ! ok ) {
return false ;
2010-03-15 02:33:43 +01:00
}
} else if ( boost : : iequals ( m_argv [ opt ] , " --monitor " ) | |
boost : : iequals ( m_argv [ opt ] , " -m " ) ) {
2010-06-11 12:52:35 +02:00
operations . push_back ( m_argv [ opt ] ) ;
2010-03-15 02:33:43 +01:00
m_monitor = true ;
2011-11-21 17:38:34 +01:00
} else if ( boost : : iequals ( m_argv [ opt ] , " --luids " ) ) {
// all following parameters are luids; can't be combined
// with setting config and source name
while ( + + opt < m_argc ) {
2012-04-27 09:11:06 +02:00
parsed . push_back ( m_argv [ opt ] ) ;
2011-11-21 17:38:34 +01:00
m_luids . push_back ( CmdlineLUID : : toLUID ( m_argv [ opt ] ) ) ;
}
2008-03-19 13:11:39 +01:00
} else {
usage ( false , string ( m_argv [ opt ] ) + " : unknown parameter " ) ;
return false ;
2008-03-19 12:29:14 +01:00
}
opt + + ;
}
if ( opt < m_argc ) {
m_server = m_argv [ opt + + ] ;
while ( opt < m_argc ) {
2010-04-06 10:38:24 +02:00
parsed . push_back ( m_argv [ opt ] ) ;
2010-06-11 15:44:57 +02:00
if ( m_sources . empty ( ) | |
! m_accessItems ) {
m_sources . insert ( m_argv [ opt + + ] ) ;
} else {
// first additional parameter was source, rest are luids
2010-09-01 15:48:29 +02:00
m_luids . push_back ( CmdlineLUID : : toLUID ( m_argv [ opt + + ] ) ) ;
2010-06-11 15:44:57 +02:00
}
2008-03-19 12:29:14 +01:00
}
}
2010-06-11 12:52:35 +02:00
// check whether we have conflicting operations requested by user
if ( operations . size ( ) > 1 ) {
usage ( false , boost : : join ( operations , " " ) + " : mutually exclusive operations " ) ;
return false ;
}
2010-06-11 15:44:57 +02:00
// common sanity checking for item listing/import/export/update
if ( m_accessItems ) {
if ( ( m_import | | m_update ) & & m_dryrun ) {
usage ( false , operations [ 0 ] + " : --dry-run not supported " ) ;
return false ;
}
}
2008-03-19 12:29:14 +01:00
return true ;
}
command line + daemon: usability improvements (MB #5043)
This patch changes what is shown to the user and how the user
interacts with the command line. Details below.
"--use-daemon [yes/no]" implies that yes/no is optional (square
brackets!), with "yes" being the option that could be expected for a
plain "--use-daemon" parameter. But the implementation always expects
a "yes" or "no" parameter. The original format suggested was
"--use-daemon[=yes/no]"
This patch switches to that format, changes --use-daemon into --daemon
(to be consistent with --keyring) and enables the same format for
--keyring. Although not documented, 0/f/false and 1/t/true are also
accepted. Because the value becomes part of the parameter, m_argc checks
had to be adapted.
The documentation for "--use-daemon" was inserted in the middle of the
"--keyring documentation".
"Parameter not set" has to be available to the Cmdline caller in the
command line too, in addition to true/false. This was done originally
with a string which is empty, "yes" or "no". Using a tri-state
Cmdline::Bool class makes this a bit more explicit and removes the
ambiguity around what useDaemon() returns (values weren't documented).
When running without --daemon and no daemon available, the
first lines of output were:
ERROR: org.<cryptic error>
[INFO] itodo20: inactive
....
=> The command line should fall back *silently* to running in-process.
=> Error messages should be formatted and logged as such, using SE_LOG_ERROR().
Old code might not have done that and we need to preserve that for compatibility
with frontends, but new code should use [ERROR] as output.
=> D-Bus error messages (as in the case above) must have some user (and developer!)
comprehensible explanation what went wrong. The D-Bus error class itself
is no enough.
Although I haven't tested it, I suspect that the code also would have
re-run the operation in-process after the D-Bus server already
executed it and failed.
I rewrote this so that a check for "daemon available" without error messages
is done first before committing to using the daemon. Once that decision is made,
the command line will not fall back to in-process execution.
Rewrote several error messages. Telling a user of a distro's binary to
"re-configure" is misleading (he didn't configure himself).
"can't" => "cannot", punctuation changes. Not sure whether is always an
improvement, comments welcome.
Comment on coding style: I've used "if ()" instead of "if()" because that is
the GNU recommendation.
2010-03-26 18:47:41 +01:00
bool Cmdline : : parseBool ( int opt , const char * longName , const char * shortName ,
bool def , Bool & value ,
bool & ok )
{
string option = m_argv [ opt ] ;
string param ;
size_t pos = option . find ( ' = ' ) ;
if ( pos ! = option . npos ) {
param = option . substr ( pos + 1 ) ;
option . resize ( pos ) ;
}
if ( ( longName & & boost : : iequals ( option , longName ) ) | |
( shortName & & boost : : iequals ( option , shortName ) ) ) {
ok = true ;
if ( param . empty ( ) ) {
value = def ;
} else if ( boost : : iequals ( param , " t " ) | |
boost : : iequals ( param , " 1 " ) | |
boost : : iequals ( param , " true " ) | |
boost : : iequals ( param , " yes " ) ) {
value = true ;
} else if ( boost : : iequals ( param , " f " ) | |
boost : : iequals ( param , " 0 " ) | |
boost : : iequals ( param , " false " ) | |
boost : : iequals ( param , " no " ) ) {
value = false ;
} else {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , string ( " parameter in ' " ) + m_argv [ opt ] + " ' must be 1/t/true/yes or 0/f/false/no " ) ;
command line + daemon: usability improvements (MB #5043)
This patch changes what is shown to the user and how the user
interacts with the command line. Details below.
"--use-daemon [yes/no]" implies that yes/no is optional (square
brackets!), with "yes" being the option that could be expected for a
plain "--use-daemon" parameter. But the implementation always expects
a "yes" or "no" parameter. The original format suggested was
"--use-daemon[=yes/no]"
This patch switches to that format, changes --use-daemon into --daemon
(to be consistent with --keyring) and enables the same format for
--keyring. Although not documented, 0/f/false and 1/t/true are also
accepted. Because the value becomes part of the parameter, m_argc checks
had to be adapted.
The documentation for "--use-daemon" was inserted in the middle of the
"--keyring documentation".
"Parameter not set" has to be available to the Cmdline caller in the
command line too, in addition to true/false. This was done originally
with a string which is empty, "yes" or "no". Using a tri-state
Cmdline::Bool class makes this a bit more explicit and removes the
ambiguity around what useDaemon() returns (values weren't documented).
When running without --daemon and no daemon available, the
first lines of output were:
ERROR: org.<cryptic error>
[INFO] itodo20: inactive
....
=> The command line should fall back *silently* to running in-process.
=> Error messages should be formatted and logged as such, using SE_LOG_ERROR().
Old code might not have done that and we need to preserve that for compatibility
with frontends, but new code should use [ERROR] as output.
=> D-Bus error messages (as in the case above) must have some user (and developer!)
comprehensible explanation what went wrong. The D-Bus error class itself
is no enough.
Although I haven't tested it, I suspect that the code also would have
re-run the operation in-process after the D-Bus server already
executed it and failed.
I rewrote this so that a check for "daemon available" without error messages
is done first before committing to using the daemon. Once that decision is made,
the command line will not fall back to in-process execution.
Rewrote several error messages. Telling a user of a distro's binary to
"re-configure" is misleading (he didn't configure himself).
"can't" => "cannot", punctuation changes. Not sure whether is always an
improvement, comments welcome.
Comment on coding style: I've used "if ()" instead of "if()" because that is
the GNU recommendation.
2010-03-26 18:47:41 +01:00
ok = false ;
}
// was our option
return true ;
} else {
// keep searching for match
return false ;
}
}
2010-03-15 02:33:43 +01:00
bool Cmdline : : isSync ( )
{
2010-06-11 13:00:05 +02:00
// make sure command line arguments really try to run sync
if ( m_usage | | m_version | |
m_printServers | | boost : : trim_copy ( m_server ) = = " ? " | |
m_printTemplates | | m_dontrun | |
m_argc = = 1 | | ( m_useDaemon . wasSet ( ) & & m_argc = = 2 ) | |
2011-10-03 16:27:55 +02:00
m_printDatabases | |
2012-09-13 18:02:07 +02:00
m_createDatabase | |
m_removeDatabase | |
2010-06-11 13:00:05 +02:00
m_printConfig | | m_remove | |
( m_server = = " " & & m_argc > 1 ) | |
m_configure | | m_migrate | |
m_status | | m_printSessions | |
! m_restore . empty ( ) | |
2010-06-11 15:44:57 +02:00
m_accessItems | |
2010-06-11 13:00:05 +02:00
m_dryrun | |
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
( ! m_run & & m_props . hasProperties ( FullProps : : IGNORE_GLOBAL_PROPS ) ) ) {
2010-03-15 02:33:43 +01:00
return false ;
2010-06-11 13:00:05 +02:00
} else {
return true ;
2010-03-15 02:33:43 +01:00
}
}
2012-04-30 15:25:01 +02:00
bool Cmdline : : isRestore ( ) const
{
return ! m_restore . empty ( ) ;
}
2010-04-07 18:23:33 +02:00
bool Cmdline : : dontRun ( ) const
{
// this mimics the if() checks in run()
if ( m_usage | | m_version | |
m_printServers | | boost : : trim_copy ( m_server ) = = " ? " | |
m_printTemplates ) {
return false ;
} else {
return m_dontrun ;
}
}
2011-02-01 16:32:22 +01:00
void Cmdline : : makeObsolete ( boost : : shared_ptr < SyncConfig > & from )
2011-02-01 15:33:09 +01:00
{
2011-02-01 16:32:22 +01:00
string oldname = from - > getRootPath ( ) ;
string newname , suffix ;
2011-08-19 16:19:12 +02:00
for ( int counter = 0 ; true ; counter + + ) {
2011-02-01 15:33:09 +01:00
ostringstream newsuffix ;
newsuffix < < " .old " ;
if ( counter ) {
newsuffix < < " . " < < counter ;
}
suffix = newsuffix . str ( ) ;
newname = oldname + suffix ;
2011-08-19 16:19:12 +02:00
if ( from - > hasPeerProperties ( ) ) {
boost : : shared_ptr < SyncConfig > renamed ( new SyncConfig ( from - > getPeerName ( ) + suffix ) ) ;
if ( renamed - > exists ( ) ) {
// don't pick a config name which has the same peer name
// as some other, existing config
continue ;
}
}
// now renaming should succeed, but let's check anyway
2011-02-01 15:33:09 +01:00
if ( ! rename ( oldname . c_str ( ) ,
newname . c_str ( ) ) ) {
break ;
} else if ( errno ! = EEXIST & & errno ! = ENOTEMPTY ) {
2011-02-01 16:32:22 +01:00
SE_THROW ( StringPrintf ( " renaming %s to %s: %s " ,
oldname . c_str ( ) ,
newname . c_str ( ) ,
strerror ( errno ) ) ) ;
2011-02-01 15:33:09 +01:00
}
}
2011-02-01 16:32:22 +01:00
string newConfigName ;
string oldContext = from - > getContextName ( ) ;
if ( from - > hasPeerProperties ( ) ) {
newConfigName = from - > getPeerName ( ) + suffix + oldContext ;
} else {
newConfigName = oldContext + suffix ;
}
2013-09-09 10:32:12 +02:00
// Clear old pointer first. That frees cached data in SyncConfig,
// which otherwise fails to notice that we moved files on disk
// around.
from . reset ( ) ;
2011-02-01 16:32:22 +01:00
from . reset ( new SyncConfig ( newConfigName ) ) ;
2011-02-01 15:33:09 +01:00
}
void Cmdline : : copyConfig ( const boost : : shared_ptr < SyncConfig > & from ,
const boost : : shared_ptr < SyncConfig > & to ,
const set < string > & selectedSources )
{
const set < string > * sources = NULL ;
set < string > allSources ;
if ( ! selectedSources . empty ( ) ) {
// use explicitly selected sources
sources = & selectedSources ;
} else {
// need an explicit list of all sources which will be copied,
// for the createFilters() call below
BOOST_FOREACH ( const std : : string & source , from - > getSyncSources ( ) ) {
allSources . insert ( source ) ;
}
sources = & allSources ;
}
// Apply config changes on-the-fly. Regardless what we do
// (changing an existing config, migrating, creating from
// a template), existing shared properties in the desired
// context must be preserved unless explicitly overwritten.
// Therefore read those, update with command line properties,
// then set as filter.
ConfigProps syncFilter ;
SourceProps sourceFilters ;
m_props . createFilters ( to - > getContextName ( ) , to - > getConfigName ( ) , sources , syncFilter , sourceFilters ) ;
from - > setConfigFilter ( true , " " , syncFilter ) ;
BOOST_FOREACH ( const SourceProps : : value_type & entry , sourceFilters ) {
from - > setConfigFilter ( false , entry . first , entry . second ) ;
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
// Modify behavior of target UI before using it: set keyring
// property separately.
InitStateTri keyring = from - > getKeyring ( ) ;
if ( keyring . wasSet ( ) ) {
to - > setKeyring ( keyring ) ;
}
2011-02-01 15:33:09 +01:00
// Write into the requested configuration, creating it if necessary.
to - > prepareConfigForWrite ( ) ;
to - > copy ( * from , sources ) ;
}
void Cmdline : : finishCopy ( const boost : : shared_ptr < SyncConfig > & from ,
const boost : : shared_ptr < SyncContext > & to )
{
// give a change to do something before flushing configs to files
2012-03-06 13:34:51 +01:00
to - > preFlush ( to - > getUserInterfaceNonNull ( ) ) ;
2011-02-01 15:33:09 +01:00
// done, now write it
m_configModified = true ;
to - > flush ( ) ;
// migrating peer?
if ( m_migrate & &
from - > hasPeerProperties ( ) ) {
// also copy .synthesis dir
string fromDir , toDir ;
fromDir = from - > getRootPath ( ) + " /.synthesis " ;
toDir = to - > getRootPath ( ) + " /.synthesis " ;
if ( isDir ( fromDir ) ) {
cp_r ( fromDir , toDir ) ;
}
// Succeeded so far, remove "ConsumerReady" flag from migrated
// config to hide that old config from normal UI users. Must
// do this without going through SyncConfig, because that
// would bump the version.
BoolConfigProperty ready ( " ConsumerReady " , " " , " 0 " ) ;
2011-08-19 16:19:12 +02:00
// Also disable auto-syncing in the migrated config.
StringConfigProperty autosync ( " autoSync " , " " , " " ) ;
{
2012-06-05 10:27:29 +02:00
IniFileConfigNode node ( from - > getRootPath ( ) , " config.ini " , false ) ;
2011-08-19 16:19:12 +02:00
if ( ready . getPropertyValue ( node ) ) {
ready . setProperty ( node , false ) ;
}
if ( ! autosync . getProperty ( node ) . empty ( ) ) {
2012-06-05 12:57:33 +02:00
autosync . setProperty ( node , InitStateString ( " 0 " , true ) ) ;
2011-08-19 16:19:12 +02:00
}
node . flush ( ) ;
}
// same for very old configs
{
2012-06-05 10:27:29 +02:00
IniFileConfigNode node ( from - > getRootPath ( ) + " /spds/syncml " , " config.txt " , false ) ;
2011-08-19 16:19:12 +02:00
if ( ! autosync . getProperty ( node ) . empty ( ) ) {
2012-06-05 12:57:33 +02:00
autosync . setProperty ( node , InitStateString ( " 0 " , true ) ) ;
2011-08-19 16:19:12 +02:00
}
node . flush ( ) ;
2011-02-01 15:33:09 +01:00
}
// Set ConsumerReady for migrated SyncEvolution < 1.2
// configs, because in older releases all existing
// configurations where shown. SyncEvolution 1.2 is more
// strict and assumes that ConsumerReady must be set
// explicitly. The sync-ui always has set the flag for
// configs created or modified with it, but the command
// line did not. Matches similar code in
// syncevo-dbus-server.
if ( from - > getConfigVersion ( CONFIG_LEVEL_PEER , CONFIG_CUR_VERSION ) = = 0 /* SyncEvolution < 1.2 */ ) {
to - > setConsumerReady ( true ) ;
to - > flush ( ) ;
}
}
}
2011-02-01 22:14:22 +01:00
void Cmdline : : migratePeer ( const std : : string & fromPeer , const std : : string & toPeer )
{
boost : : shared_ptr < SyncConfig > from ( new SyncConfig ( fromPeer ) ) ;
makeObsolete ( from ) ;
// hack: move to different target config for createSyncClient()
m_server = toPeer ;
boost : : shared_ptr < SyncContext > to ( createSyncClient ( ) ) ;
2011-03-02 11:05:18 +01:00
// Special case for Memotoo: explicitly set preferred sync format
// to vCard 3.0 as part of the SyncEvolution 1.1.x -> 1.2 migration,
// because it works better. Template was also updated in 1.2, but
// that alone wouldn't improve existing configs.
if ( from - > getConfigVersion ( CONFIG_LEVEL_PEER , CONFIG_CUR_VERSION ) = = 0 ) {
vector < string > urls = from - > getSyncURL ( ) ;
if ( urls . size ( ) = = 1 & &
urls [ 0 ] = = " http://sync.memotoo.com/syncML " ) {
boost : : shared_ptr < SyncContext > to ( createSyncClient ( ) ) ;
m_props [ to - > getContextName ( ) ] . m_sourceProps [ " addressbook " ] . insert ( make_pair ( " syncFormat " , " text/vcard " ) ) ;
}
}
2011-02-01 22:14:22 +01:00
copyConfig ( from , to , set < string > ( ) ) ;
finishCopy ( from , to ) ;
}
2010-09-30 17:10:57 +02:00
/**
* Finds first instance of delimiter string in other string . In
* addition , it treats " \n \n " in a special way : that delimiter also
* matches " \n \r \n " .
*/
class FindDelimiter {
const string m_delimiter ;
public :
FindDelimiter ( const string & delimiter ) :
m_delimiter ( delimiter )
{ }
boost : : iterator_range < string : : iterator > operator ( ) ( string : : iterator begin ,
string : : iterator end )
{
if ( m_delimiter = = " \n \n " ) {
// match both "\n\n" and "\n\r\n"
while ( end - begin > = 2 ) {
if ( * begin = = ' \n ' ) {
if ( * ( begin + 1 ) = = ' \n ' ) {
return boost : : iterator_range < string : : iterator > ( begin , begin + 2 ) ;
} else if ( end - begin > = 3 & &
* ( begin + 1 ) = = ' \r ' & &
* ( begin + 2 ) = = ' \n ' ) {
return boost : : iterator_range < string : : iterator > ( begin , begin + 3 ) ;
}
}
+ + begin ;
}
return boost : : iterator_range < string : : iterator > ( end , end ) ;
} else {
boost : : sub_range < string > range ( begin , end ) ;
return boost : : find_first ( range , m_delimiter ) ;
}
}
} ;
2013-06-26 11:33:08 +02:00
static void ShowLUID ( SyncSourceLogging * logging , const std : : string & luid )
{
string description ;
if ( logging ) {
description = logging - > getDescription ( luid ) ;
}
SE_LOG_SHOW ( NULL , " %s%s%s " ,
CmdlineLUID : : fromLUID ( luid ) . c_str ( ) ,
description . empty ( ) ? " " : " : " ,
description . c_str ( ) ) ;
}
static void ExportLUID ( SyncSourceRaw * raw ,
ostream * out ,
const std : : string & defDelimiter ,
const std : : string & itemPath ,
bool & haveItem , bool & haveNewline ,
const std : : string & luid )
{
string item ;
raw - > readItemRaw ( luid , item ) ;
if ( ! out ) {
// write into directory
2014-04-23 12:06:30 +02:00
string fullPath = itemPath + " / " + CmdlineLUID : : fromLUID ( luid ) ;
ofstream file ( fullPath . c_str ( ) ) ;
2013-06-26 11:33:08 +02:00
file < < item ;
file . close ( ) ;
if ( file . bad ( ) ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , fullPath , errno ) ;
2013-06-26 11:33:08 +02:00
}
} else {
std : : string delimiter ;
if ( haveItem ) {
if ( defDelimiter . size ( ) > 1 & &
haveNewline & &
defDelimiter [ 0 ] = = ' \n ' ) {
// already wrote initial newline, skip it
delimiter = defDelimiter . substr ( 1 ) ;
} else {
delimiter = defDelimiter ;
}
}
if ( out = = & std : : cout ) {
// special case, use logging infrastructure
SE_LOG_SHOW ( NULL , " %s%s " ,
delimiter . c_str ( ) ,
item . c_str ( ) ) ;
// always prints newline
haveNewline = true ;
} else {
// write to file
* out < < delimiter < < item ;
haveNewline = boost : : ends_with ( item , " \n " ) ;
}
haveItem = true ;
}
}
2009-10-05 14:49:32 +02:00
bool Cmdline : : run ( ) {
2009-04-23 16:47:07 +02:00
// --dry-run is only supported by some operations.
// Be very strict about it and make sure it is off in all
// potentially harmful operations, otherwise users might
// expect it to have an effect when it doesn't.
2011-01-25 11:11:53 +01:00
// TODO: check filter properties for invalid config and source
// names
2008-03-19 12:29:14 +01:00
if ( m_usage ) {
usage ( true ) ;
} else if ( m_version ) {
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " SyncEvolution %s%s \n %s%s " ,
2012-04-11 17:29:41 +02:00
VERSION ,
SyncContext : : isStableRelease ( ) ? " " : " (pre-release) " ,
EDSAbiWrapperInfo ( ) ,
SyncSource : : backendsInfo ( ) . c_str ( ) ) ;
2008-03-30 15:11:45 +02:00
} else if ( m_printServers | | boost : : trim_copy ( m_server ) = = " ? " ) {
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
dumpConfigs ( " Configured servers: " ,
SyncConfig : : getConfigs ( ) ) ;
} else if ( m_printTemplates ) {
SyncConfig : : DeviceList devices ;
if ( m_template . empty ( ) ) {
2011-05-18 10:04:49 +02:00
devices . push_back ( SyncConfig : : DeviceDescription ( " " , " " , SyncConfig : : MATCH_FOR_CLIENT_MODE ) ) ;
2011-04-20 22:02:54 +02:00
dumpConfigTemplates ( " Available configuration templates (servers): " ,
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
SyncConfig : : getPeerTemplates ( devices ) , false ) ;
} else {
//limiting at templates for syncml clients only.
2010-02-23 05:06:05 +01:00
devices . push_back ( SyncConfig : : DeviceDescription ( " " , m_template , SyncConfig : : MATCH_FOR_SERVER_MODE ) ) ;
2011-04-20 22:02:54 +02:00
dumpConfigTemplates ( " Available configuration templates (clients): " ,
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
SyncConfig : : matchPeerTemplates ( devices ) , true ) ;
}
2008-03-19 12:29:14 +01:00
} else if ( m_dontrun ) {
// user asked for information
2012-09-13 18:02:07 +02:00
} else if ( m_printDatabases | | m_createDatabase | | m_removeDatabase ) {
// manipulate databases
redesigned SyncSource base class + API
The main motivation for this change is that it allows the implementor
of a backend to choose the implementations for the different aspects
of a datasource (change tracking, item import/export, logging, ...)
independently of each other. For example, change tracking via revision
strings can now be combined with exchanging data with the Synthesis
engine via a single string (the traditional method in SyncEvolution)
and with direct access to the Synthesis field list (now possible for
the first time).
The new backend API is based on the concept of providing
implementations for certain functionality via function objects instead
of implementing certain virtual methods. The advantage is that
implementors can define their own, custom interfaces and mix and match
implementations of the different groups of functionality.
Logging (see SyncSourceLogging in a later commit) can be done by
wrapping some arbitrary other item import/export function objects
(decorator design pattern).
The class hierarchy is now this:
- SyncSourceBase: interface for common utility code, all other
classes are derived from it and thus can use that code
- SyncSource: base class which implements SyncSourceBase and
hooks a datasource into the SyncEvolution core;
its "struct Operations" holds the function objects which
can be implemented in different ways
- TestingSyncSource: combines some of the following classes
into an interface that is expected by the client-test
program; backends only have to derive from (and implement this)
if they want to use the automated testing
- TrackingSyncSource: provides the same functionality as
before (change tracking via revision strings, item import/export
as string) in a single interface; the description of the pure
virtual methods are duplicated so that developers can go through
this class and find everything they need to know to implement
it
The following classes contain the code that was previously
found in the EvolutionSyncSource base class. Implementors
can derive from them and call the init() methods to inherit
and activate the functionality:
- SyncSourceSession: binds Synthesis session callbacks to
virtual methods beginSync(), endSync()
- SyncSourceChanges: implements Synthesis item tracking callbacks
with set of LUIDs that the user of the class has to fill
- SyncSourceDelete: binds Synthesis delete callback to
virtual method
- SyncSourceRaw: read and write items in the backends format,
used for testing and backup/restore
- SyncSourceSerialize: exchanges items with Synthesis engine
using a string representation of the data; this is how
EvolutionSyncSource has traditionally worked, so much of the
same virtual methods are now in this class
- SyncSourceRevisions: utility class which does change tracking
via some kind of "revision" string which changes each time
an item is modified; this code was previously in the
TrackingSyncSource
2009-08-25 09:27:46 +02:00
const SourceRegistry & registry ( SyncSource : : getSourceRegistry ( ) ) ;
2011-10-03 16:27:55 +02:00
boost : : shared_ptr < SyncSourceNodes > nodes ;
std : : string header ;
boost : : shared_ptr < SyncContext > context ;
2012-06-28 13:53:58 +02:00
FilterConfigNode : : ConfigFilter sourceFilter ;
std : : string sourceName ;
FilterConfigNode : : ConfigFilter : : const_iterator backend ;
2011-10-03 16:27:55 +02:00
2012-09-13 18:02:07 +02:00
void ( Cmdline : : * operation ) ( SyncSource * , const std : : string & ) =
m_printDatabases ? & Cmdline : : listDatabases :
m_createDatabase ? & Cmdline : : createDatabase :
& Cmdline : : removeDatabase ;
2011-10-03 16:27:55 +02:00
if ( ! m_server . empty ( ) ) {
// list for specific backend chosen via config
if ( m_sources . size ( ) ! = 1 ) {
2014-07-28 15:29:41 +02:00
SE_THROW ( StringPrintf ( " must specify exactly one datastore after the config name '%s' " ,
2011-10-03 16:27:55 +02:00
m_server . c_str ( ) ) ) ;
}
2012-06-28 13:53:58 +02:00
sourceName = * m_sources . begin ( ) ;
sourceFilter = m_props . createSourceFilter ( m_server , sourceName ) ;
backend = sourceFilter . find ( " backend " ) ;
context . reset ( createSyncClient ( ) ) ;
2011-10-03 16:27:55 +02:00
if ( ! context - > exists ( ) ) {
SE_THROW ( StringPrintf ( " config '%s' does not exist " , m_server . c_str ( ) ) ) ;
}
2012-06-28 13:53:58 +02:00
nodes . reset ( new SyncSourceNodes ( context - > getSyncSourceNodesNoTracking ( sourceName ) ) ) ;
header = StringPrintf ( " %s/%s " , m_server . c_str ( ) , sourceName . c_str ( ) ) ;
2011-10-03 16:27:55 +02:00
if ( ! nodes - > dataConfigExists ( ) ) {
SE_THROW ( StringPrintf ( " %s does not exist " ,
header . c_str ( ) ) ) ;
}
} else {
2012-06-28 13:53:58 +02:00
sourceFilter = m_props . createSourceFilter ( m_server , " " ) ;
backend = sourceFilter . find ( " backend " ) ;
context . reset ( createSyncClient ( ) ) ;
2011-10-03 16:27:55 +02:00
boost : : shared_ptr < FilterConfigNode > sharedNode ( new VolatileConfigNode ( ) ) ;
boost : : shared_ptr < FilterConfigNode > configNode ( new VolatileConfigNode ( ) ) ;
boost : : shared_ptr < FilterConfigNode > hiddenNode ( new VolatileConfigNode ( ) ) ;
boost : : shared_ptr < FilterConfigNode > trackingNode ( new VolatileConfigNode ( ) ) ;
boost : : shared_ptr < FilterConfigNode > serverNode ( new VolatileConfigNode ( ) ) ;
nodes . reset ( new SyncSourceNodes ( true , sharedNode , configNode , hiddenNode , trackingNode , serverNode , " " ) ) ;
header = backend ! = sourceFilter . end ( ) ?
backend - > second :
" ??? " ;
}
nodes - > getProperties ( ) - > setFilter ( sourceFilter ) ;
FilterConfigNode : : ConfigFilter syncFilter = m_props . createSyncFilter ( m_server ) ;
context - > setConfigFilter ( true , " " , syncFilter ) ;
SyncSourceParams params ( " list " , * nodes , context ) ;
if ( ! m_server . empty ( ) | | backend ! = sourceFilter . end ( ) ) {
// list for specific backend
2012-09-13 18:02:07 +02:00
params . m_name = sourceName ;
2011-10-03 16:27:55 +02:00
auto_ptr < SyncSource > source ( SyncSource : : createSource ( params , false , NULL ) ) ;
if ( source . get ( ) ! = NULL ) {
2012-06-28 13:53:58 +02:00
if ( ! m_server . empty ( ) & & nodes ) {
// ensure that we have passwords for this config
2013-07-29 13:57:46 +02:00
PasswordConfigProperty : : checkPasswords ( context - > getUserInterfaceNonNull ( ) ,
* context ,
PasswordConfigProperty : : CHECK_PASSWORD_ALL ,
boost : : assign : : list_of ( sourceName ) ) ;
2012-06-28 13:53:58 +02:00
}
2012-09-13 18:02:07 +02:00
( this - > * operation ) ( source . get ( ) , header ) ;
2011-10-03 16:27:55 +02:00
} else {
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s: \n cannot access databases " , header . c_str ( ) ) ;
2011-10-03 16:27:55 +02:00
}
} else {
// list for all backends
BOOST_FOREACH ( const RegisterSyncSource * source , registry ) {
BOOST_FOREACH ( const Values : : value_type & alias , source - > m_typeValues ) {
if ( ! alias . empty ( ) & & source - > m_enabled ) {
SourceType type ( * alias . begin ( ) ) ;
nodes - > getProperties ( ) - > setProperty ( " backend " , type . m_backend ) ;
2012-03-08 11:15:22 +01:00
std : : string header = boost : : join ( alias , " = " ) ;
try {
2012-09-13 18:02:07 +02:00
// The name is used in error messages. We
// don't have a source name, so let's fall
// back to the backend instead.
params . m_name = type . m_backend ;
2012-03-08 11:15:22 +01:00
auto_ptr < SyncSource > source ( SyncSource : : createSource ( params , false ) ) ;
2012-09-13 18:02:07 +02:00
( this - > * operation ) ( source . get ( ) , header ) ;
2012-03-08 11:15:22 +01:00
} catch ( . . . ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " %s: \n accessing databases failed " , header . c_str ( ) ) ;
2012-03-08 11:15:22 +01:00
Exception : : handle ( ) ;
2011-10-03 16:27:55 +02:00
}
2008-03-19 12:29:14 +01:00
}
}
}
}
} else if ( m_printConfig ) {
2009-10-06 17:22:47 +02:00
boost : : shared_ptr < SyncConfig > config ;
2009-11-24 19:26:58 +01:00
ConfigProps syncFilter ;
2011-01-25 11:11:53 +01:00
SourceProps sourceFilters ;
2008-03-19 15:35:22 +01:00
if ( m_template . empty ( ) ) {
2008-03-30 13:43:36 +02:00
if ( m_server . empty ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , " --print-config requires either a --template or a server name. " ) ;
2008-03-30 13:43:36 +02:00
return false ;
}
2009-10-06 17:22:47 +02:00
config . reset ( new SyncConfig ( m_server ) ) ;
2008-03-19 15:35:22 +01:00
if ( ! config - > exists ( ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " Server '%s' has not been configured yet. " , m_server . c_str ( ) ) ;
2008-03-19 15:35:22 +01:00
return false ;
}
2009-11-24 19:26:58 +01:00
2011-01-25 11:11:53 +01:00
// No need to include a context or additional sources,
// because reading the m_server config already includes
// the right information.
m_props . createFilters ( " " , m_server , NULL , syncFilter , sourceFilters ) ;
2008-03-19 15:35:22 +01:00
} else {
2009-11-24 19:26:58 +01:00
string peer , context ;
2011-03-02 11:20:27 +01:00
SyncConfig : : splitConfigString ( SyncConfig : : normalizeConfigString ( m_template ,
SyncConfig : : NormalizeFlags ( SyncConfig : : NORMALIZE_SHORTHAND | SyncConfig : : NORMALIZE_IS_NEW ) ) ,
peer , context ) ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
config = SyncConfig : : createPeerTemplate ( peer ) ;
2008-03-19 15:35:22 +01:00
if ( ! config . get ( ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " No configuration template for '%s' available. " , m_template . c_str ( ) ) ;
2008-03-19 15:35:22 +01:00
return false ;
}
2009-11-24 19:26:58 +01:00
2011-01-25 11:11:53 +01:00
// When instantiating a template, include the properties
// of the target context as filter to preserve shared
// properties, the final name inside that context as
// peer config name, and the sources defined in the template.
list < string > sourcelist = config - > getSyncSources ( ) ;
set < string > sourceset ( sourcelist . begin ( ) , sourcelist . end ( ) ) ;
m_props . createFilters ( std : : string ( " @ " ) + context , " " ,
& sourceset ,
syncFilter , sourceFilters ) ;
2008-03-19 15:35:22 +01:00
}
2010-03-02 16:27:22 +01:00
// determine whether we dump a peer or a context
int flags = DUMP_PROPS_NORMAL ;
string peer , context ;
SyncConfig : : splitConfigString ( config - > getConfigName ( ) , peer , context ) ;
if ( peer . empty ( ) ) {
flags | = HIDE_PER_PEER ;
2010-03-03 16:20:53 +01:00
checkForPeerProps ( ) ;
2010-03-02 16:27:22 +01:00
}
2008-08-03 15:00:51 +02:00
if ( m_sources . empty ( ) | |
m_sources . find ( " main " ) ! = m_sources . end ( ) ) {
2008-03-19 15:35:22 +01:00
boost : : shared_ptr < FilterConfigNode > syncProps ( config - > getProperties ( ) ) ;
2009-11-24 19:26:58 +01:00
syncProps - > setFilter ( syncFilter ) ;
2010-03-02 16:27:22 +01:00
dumpProperties ( * syncProps , config - > getRegistry ( ) , flags ) ;
2008-03-19 12:29:14 +01:00
}
2008-07-06 22:49:19 +02:00
list < string > sources = config - > getSyncSources ( ) ;
sources . sort ( ) ;
2008-07-11 22:25:02 +02:00
BOOST_FOREACH ( const string & name , sources ) {
2008-03-19 12:29:14 +01:00
if ( m_sources . empty ( ) | |
2008-07-11 22:25:02 +02:00
m_sources . find ( name ) ! = m_sources . end ( ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " [%s] " , name . c_str ( ) ) ;
2009-11-13 14:52:00 +01:00
SyncSourceNodes nodes = config - > getSyncSourceNodes ( name ) ;
boost : : shared_ptr < FilterConfigNode > sourceProps = nodes . getProperties ( ) ;
2011-01-25 11:11:53 +01:00
sourceProps - > setFilter ( sourceFilters . createSourceFilter ( name ) ) ;
2010-01-20 11:36:19 +01:00
dumpProperties ( * sourceProps , SyncSourceConfig : : getRegistry ( ) ,
2010-03-02 16:27:22 +01:00
flags | ( ( name ! = * ( - - sources . end ( ) ) ) ? HIDE_LEGEND : DUMP_PROPS_NORMAL ) ) ;
2008-03-19 12:29:14 +01:00
}
}
} else if ( m_configure | | m_migrate ) {
2011-11-21 17:38:34 +01:00
if ( ! needConfigName ( ) ) {
return false ;
}
2009-04-23 16:47:07 +02:00
if ( m_dryrun ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , " --dry-run not supported for configuration changes " ) ;
2009-04-23 16:47:07 +02:00
}
2011-01-17 15:00:50 +01:00
// name of renamed config ("foo.old") after migration
string newname ;
2011-01-11 17:43:23 +01:00
// True if the target configuration is a context like @default
// or @foobar. Relevant in several places in the following
// code.
bool configureContext = false ;
2008-03-30 15:11:45 +02:00
bool fromScratch = false ;
2009-11-24 19:26:58 +01:00
string peer , context ;
SyncConfig : : splitConfigString ( SyncConfig : : normalizeConfigString ( m_server ) , peer , context ) ;
2010-03-03 16:20:53 +01:00
if ( peer . empty ( ) ) {
2011-01-11 17:43:23 +01:00
configureContext = true ;
2010-03-03 16:20:53 +01:00
checkForPeerProps ( ) ;
}
2008-03-30 15:11:45 +02:00
2011-01-11 17:43:23 +01:00
// Make m_server a fully-qualified name. Useful in error
// messages and essential for migrating "foo" where "foo"
// happens to map to "foo@bar". Otherwise "foo" will be
// mapped incorrectly to "foo@default" after renaming
// "foo@bar" to "foo.old@bar".
//
// The inverse problem can occur for "foo@default": after
// renaming, "foo" without "@default" would be mapped to
// "foo@somewhere-else" if such a config exists.
m_server = peer + " @ " + context ;
2010-09-29 15:00:16 +02:00
2008-03-19 17:43:31 +01:00
// Both config changes and migration are implemented as copying from
// another config (template resp. old one). Migration also moves
2011-03-23 12:14:31 +01:00
// the old config. The target configuration is determined by m_server,
// but the exact semantic of it depends on the operation.
2009-10-06 17:22:47 +02:00
boost : : shared_ptr < SyncConfig > from ;
2011-03-23 12:14:31 +01:00
boost : : shared_ptr < SyncContext > to ;
2011-02-01 22:14:22 +01:00
string origPeer ;
2008-03-19 17:43:31 +01:00
if ( m_migrate ) {
2011-02-01 15:33:09 +01:00
if ( ! m_sources . empty ( ) ) {
2014-07-28 15:29:41 +02:00
SE_LOG_ERROR ( NULL , " cannot migrate individual datastores " ) ;
2011-02-01 15:33:09 +01:00
return false ;
}
2009-11-25 16:10:44 +01:00
string oldContext = context ;
2009-10-06 17:22:47 +02:00
from . reset ( new SyncConfig ( m_server ) ) ;
2008-03-19 17:43:31 +01:00
if ( ! from - > exists ( ) ) {
2009-11-25 16:10:44 +01:00
// for migration into a different context, search for config without context
oldContext = " " ;
from . reset ( new SyncConfig ( peer ) ) ;
if ( ! from - > exists ( ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " Server '%s' has not been configured yet. " , m_server . c_str ( ) ) ;
2009-11-25 16:10:44 +01:00
return false ;
}
2008-03-19 17:43:31 +01:00
}
2011-02-01 15:33:09 +01:00
// Check if we are migrating an individual peer inside
// a context which itself is too old. In that case,
// the whole context and everything inside it needs to
// be migrated.
2011-02-01 22:14:22 +01:00
if ( ! configureContext ) {
bool obsoleteContext = false ;
if ( from - > getLayout ( ) < SyncConfig : : SHARED_LAYOUT ) {
// check whether @default context exists and is too old;
// in that case migrate it first
SyncConfig target ( " @default " ) ;
if ( target . exists ( ) & &
target . getConfigVersion ( CONFIG_LEVEL_CONTEXT , CONFIG_CUR_VERSION ) <
CONFIG_CONTEXT_MIN_VERSION ) {
// migrate all peers inside @default *and* the one outside
origPeer = m_server ;
m_server = " @default " ;
obsoleteContext = true ;
}
} else {
// config already is inside a context; need to check that context
if ( from - > getConfigVersion ( CONFIG_LEVEL_CONTEXT , CONFIG_CUR_VERSION ) <
CONFIG_CONTEXT_MIN_VERSION ) {
m_server = string ( " @ " ) + context ;
obsoleteContext = true ;
}
}
if ( obsoleteContext ) {
// hack: move to different config and back later
from . reset ( new SyncConfig ( m_server ) ) ;
peer = " " ;
configureContext = true ;
}
2011-01-10 15:51:10 +01:00
}
2011-02-01 16:32:22 +01:00
// rename on disk and point "from" to it
makeObsolete ( from ) ;
2011-03-23 12:14:31 +01:00
// modify the config referenced by the (possibly modified) m_server
to . reset ( createSyncClient ( ) ) ;
2008-03-19 17:43:31 +01:00
} else {
2009-10-06 17:22:47 +02:00
from . reset ( new SyncConfig ( m_server ) ) ;
2011-03-23 12:14:31 +01:00
// m_server known, modify it
to . reset ( createSyncClient ( ) ) ;
2008-03-19 17:43:31 +01:00
if ( ! from - > exists ( ) ) {
// creating from scratch, look for template
2008-03-30 15:11:45 +02:00
fromScratch = true ;
2010-03-02 21:28:28 +01:00
string configTemplate ;
if ( m_template . empty ( ) ) {
2010-09-29 15:00:16 +02:00
if ( configureContext ) {
2010-08-02 14:27:48 +02:00
// configuring a context, template doesn't matter =>
// use default "SyncEvolution" template
configTemplate =
peer = " SyncEvolution " ;
2011-05-19 11:59:02 +02:00
from = SyncConfig : : createPeerTemplate ( peer ) ;
2011-06-29 03:42:43 +02:00
} else if ( peer = = " target-config " ) {
2011-05-19 11:59:02 +02:00
// Configuring the source context for local sync
// => determine template based on context name.
configTemplate = context ;
from = SyncConfig : : createPeerTemplate ( context ) ;
} else {
// template is the peer name
configTemplate = m_server ;
from = SyncConfig : : createPeerTemplate ( peer ) ;
2010-08-02 14:27:48 +02:00
}
2010-03-02 21:28:28 +01:00
} else {
// Template is specified explicitly. It must not contain a context,
// because the context comes from the config name.
configTemplate = m_template ;
2011-03-02 11:20:27 +01:00
if ( SyncConfig : : splitConfigString ( SyncConfig : : normalizeConfigString ( configTemplate ,
SyncConfig : : NormalizeFlags ( SyncConfig : : NORMALIZE_SHORTHAND | SyncConfig : : NORMALIZE_IS_NEW ) ) ,
peer , context ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " Template %s must not specify a context. " , configTemplate . c_str ( ) ) ;
2010-03-02 21:28:28 +01:00
return false ;
}
string tmp ;
SyncConfig : : splitConfigString ( SyncConfig : : normalizeConfigString ( m_server ) , tmp , context ) ;
2011-05-19 11:59:02 +02:00
from = SyncConfig : : createPeerTemplate ( peer ) ;
2010-03-02 21:28:28 +01:00
}
2011-03-23 12:14:31 +01:00
list < string > missing ;
2011-05-19 11:59:02 +02:00
if ( ! from . get ( ) ) {
// check if all obligatory sync properties are specified; needed
// for both the "is complete" check and the error message below
2011-03-23 12:14:31 +01:00
ConfigProps syncProps = m_props . createSyncFilter ( to - > getContextName ( ) ) ;
bool complete = true ;
BOOST_FOREACH ( const ConfigProperty * prop , SyncConfig : : getRegistry ( ) ) {
if ( prop - > isObligatory ( ) & &
syncProps . find ( prop - > getMainName ( ) ) = = syncProps . end ( ) ) {
missing . push_back ( prop - > getMainName ( ) ) ;
complete = false ;
}
}
2011-05-19 11:59:02 +02:00
// if everything was specified and no invalid template name was given, allow user
// to proceed with "none" template; if a template was specified, we skip
// this and go directly to the code below which prints an error message
if ( complete & &
m_template . empty ( ) ) {
2011-03-23 12:14:31 +01:00
from = SyncConfig : : createPeerTemplate ( " none " ) ;
}
}
if ( ! from . get ( ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " No configuration template for '%s' available. " , configTemplate . c_str ( ) ) ;
2011-04-20 22:02:54 +02:00
if ( m_template . empty ( ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_INFO ( NULL ,
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
" Use '--template none' and/or specify relevant properties on the command line to create a configuration without a template. Need values for: %s " ,
boost : : join ( missing , " , " ) . c_str ( ) ) ;
2011-04-20 22:02:54 +02:00
} else if ( missing . empty ( ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_INFO ( NULL , " All relevant properties seem to be set, omit the --template parameter to proceed. " ) ;
2011-04-20 22:02:54 +02:00
}
2013-04-08 19:17:36 +02:00
SE_LOG_INFO ( NULL , " \n " ) ;
2011-04-20 22:02:54 +02:00
SyncConfig : : DeviceList devices ;
devices . push_back ( SyncConfig : : DeviceDescription ( " " , " " , SyncConfig : : MATCH_ALL ) ) ;
dumpConfigTemplates ( " Available configuration templates (clients and servers): " ,
command line: use both stdout and stderr
Traditionally, the "syncevolution" command line tool mixed its
INFO/ERROR/DEBUG messages into the normal stdout. This has the major
drawback that error messages get lost during operations like
syncevolution --export - @default addressbook | grep "John Doe"
Now anything which not the expected result of the operation is always
sent to stderr. Obviously this includes ERROR messages. INFO and DEBUG
are harder to decide. Because they usually convey meta information
about the running operation, they are also sent to stderr.
This changes the behavior of
syncevolution --run foo eds_event | less
"less" will capture only the following output:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Local data changes to be applied during synchronization:
*** eds_event ***
no changes
Synchronization successful.
Changes applied during synchronization:
+---------------|-----------------------|-----------------------|-CON-+
| | LOCAL | REMOTE | FLI |
| Source | NEW | MOD | DEL | ERR | NEW | MOD | DEL | ERR | CTS |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| eds_event | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| two-way, 0 KB sent by client, 0 KB received |
| item(s) in database backup: 2 before sync, 2 after it |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| start Wed Apr 11 14:34:11 2012, duration 0:03min |
| synchronization completed successfully |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
Data modified locally during synchronization:
*** eds_event ***
no changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To get the traditional behavior with bash or sh as shell, use
syncevolution --run foo eds_event 2>&1 | less
Some "normal" output in error messages was changed to INFO and thus
now appears on stderr after the corresponding ERROR message. Empty
lines which were used to separate different parts now also have a tag,
for the sake of consistency with the surrounding output.
The main implementation change is in LogRedirect, which now decides
whether LogStdout shall send the message to stdout or stderr. This has
the desired effect in the "syncevolution" binary, which uses
LogRedirect. Other binaries inherit the same change, although there it
usually doesn't matter.
The Cmdline unit testing mirrors this change in the way how it stores
and checks Cmdline output and also was adapted to the prefix changes.
2012-04-11 14:38:54 +02:00
SyncConfig : : getPeerTemplates ( devices ) ,
false ,
Logger : : INFO ) ;
2008-03-19 17:43:31 +01:00
return false ;
}
}
}
2010-09-29 15:00:16 +02:00
// Which sources are configured is determined as follows:
2011-02-01 15:33:09 +01:00
// - all sources in the template by default (empty set), except when
2010-09-29 15:00:16 +02:00
// - sources are listed explicitly, and either
// - updating an existing config or
// - configuring a context.
//
// This implies that when configuring a peer from scratch, all
// sources in the template will be created, with command line
// source properties applied to all of them. This might not be
// what we want, but because this is how we have done it
// traditionally, I keep this behavior for now.
2011-02-01 15:33:09 +01:00
//
// When migrating, m_sources is empty and thus the whole set of
// sources will be migrated. Checking it here for clarity's sake.
set < string > sources ;
if ( ! m_migrate & &
! m_sources . empty ( ) & &
2010-09-29 15:00:16 +02:00
( ! fromScratch | | configureContext ) ) {
2011-02-01 15:33:09 +01:00
sources = m_sources ;
2011-01-25 11:11:53 +01:00
}
2011-03-23 12:14:31 +01:00
// Also copy (aka create) sources listed on the command line if
// creating from scratch and
// - "--template none" enables the "do what I want" mode or
// - source properties apply to it.
// Creating from scratch with other sources is a possible typo
// and will trigger an error below.
if ( fromScratch ) {
BOOST_FOREACH ( const string & source , m_sources ) {
if ( m_template = = " none " | |
! m_props . createSourceFilter ( to - > getContextName ( ) , source ) . empty ( ) ) {
sources . insert ( source ) ;
}
}
}
2011-02-14 14:08:40 +01:00
// Special case for migration away from "type": older
// SyncEvolution could cope with "type" only set correctly for
// peers. Real-world case: Memotoo config, context had "type =
// calendar" set for address book.
//
// Setting "backend" based on an incorrect "type" from the
// context would lead to a broken, unusable config. Solution:
// take "backend" and "databaseFormat" from a peer config when
// migrating a context.
//
// Note that peers are assumed to be consistent. Not attempt is
// made to detect a config which has inconsistent peer configs.
if ( m_migrate & & configureContext & &
from - > getConfigVersion ( CONFIG_LEVEL_CONTEXT , CONFIG_CUR_VERSION ) = = 0 ) {
list < string > peers = from - > getPeers ( ) ;
peers . sort ( ) ; // make code below deterministic
BOOST_FOREACH ( const std : : string source , from - > getSyncSources ( ) ) {
BOOST_FOREACH ( const string & peer , peers ) {
2012-06-05 10:27:29 +02:00
IniFileConfigNode node ( from - > getRootPath ( ) + " /peers/ " + peer + " /sources/ " + source ,
" config.ini " ,
true ) ;
2011-02-14 14:08:40 +01:00
string sync = node . readProperty ( " sync " ) ;
if ( sync . empty ( ) | |
boost : : iequals ( sync , " none " ) | |
boost : : iequals ( sync , " disabled " ) ) {
// ignore this peer, it doesn't use the source
continue ;
}
SourceType type ( node . readProperty ( " type " ) ) ;
if ( ! type . m_backend . empty ( ) ) {
// found some "type": use "backend" and
// "dataFormat" in filter, unless the user
// already set a value there
ConfigProps syncFilter ;
SourceProps sourceFilters ;
set < string > set ;
set . insert ( source ) ;
m_props . createFilters ( to - > getContextName ( ) , " " ,
& set , syncFilter , sourceFilters ) ;
const ConfigProps & sourceFilter = sourceFilters [ source ] ;
if ( sourceFilter . find ( " backend " ) = = sourceFilter . end ( ) ) {
m_props [ to - > getContextName ( ) ] . m_sourceProps [ source ] [ " backend " ] = type . m_backend ;
}
if ( ! type . m_localFormat . empty ( ) & &
sourceFilter . find ( " databaseFormat " ) = = sourceFilter . end ( ) ) {
m_props [ to - > getContextName ( ) ] . m_sourceProps [ source ] [ " databaseFormat " ] = type . m_localFormat ;
}
// use it without bothering to keep looking
// (no consistenty check!)
break ;
}
}
}
}
2012-06-20 12:34:19 +02:00
// TODO: update complete --configure output to be more informative.
// This is a first step, but shouldn't be done in isolation.
2013-04-08 19:17:36 +02:00
// SE_LOG_INFO(NULL, "%s configuration %s",
2012-06-20 12:34:19 +02:00
// fromScratch ? "creating" : "updating",
// to->getConfigName().c_str());
2011-02-01 15:33:09 +01:00
// copy and filter into the target config: createSyncClient()
// creates a SyncContext for m_server, with propert
// implementation of the password handling methods in derived
// classes (D-Bus server, real command line)
copyConfig ( from , to , sources ) ;
2008-03-30 15:11:45 +02:00
2008-07-02 21:36:02 +02:00
// Sources are active now according to the server default.
// Disable all sources not selected by user (if any selected)
// and those which have no database.
if ( fromScratch ) {
2008-03-30 15:11:45 +02:00
list < string > configuredSources = to - > getSyncSources ( ) ;
2008-07-02 21:36:02 +02:00
set < string > sources = m_sources ;
2012-06-20 12:31:24 +02:00
SuspendFlags & s = SuspendFlags : : getSuspendFlags ( ) ;
2008-03-30 15:11:45 +02:00
BOOST_FOREACH ( const string & source , configuredSources ) {
redesigned SyncSource base class + API
The main motivation for this change is that it allows the implementor
of a backend to choose the implementations for the different aspects
of a datasource (change tracking, item import/export, logging, ...)
independently of each other. For example, change tracking via revision
strings can now be combined with exchanging data with the Synthesis
engine via a single string (the traditional method in SyncEvolution)
and with direct access to the Synthesis field list (now possible for
the first time).
The new backend API is based on the concept of providing
implementations for certain functionality via function objects instead
of implementing certain virtual methods. The advantage is that
implementors can define their own, custom interfaces and mix and match
implementations of the different groups of functionality.
Logging (see SyncSourceLogging in a later commit) can be done by
wrapping some arbitrary other item import/export function objects
(decorator design pattern).
The class hierarchy is now this:
- SyncSourceBase: interface for common utility code, all other
classes are derived from it and thus can use that code
- SyncSource: base class which implements SyncSourceBase and
hooks a datasource into the SyncEvolution core;
its "struct Operations" holds the function objects which
can be implemented in different ways
- TestingSyncSource: combines some of the following classes
into an interface that is expected by the client-test
program; backends only have to derive from (and implement this)
if they want to use the automated testing
- TrackingSyncSource: provides the same functionality as
before (change tracking via revision strings, item import/export
as string) in a single interface; the description of the pure
virtual methods are duplicated so that developers can go through
this class and find everything they need to know to implement
it
The following classes contain the code that was previously
found in the EvolutionSyncSource base class. Implementors
can derive from them and call the init() methods to inherit
and activate the functionality:
- SyncSourceSession: binds Synthesis session callbacks to
virtual methods beginSync(), endSync()
- SyncSourceChanges: implements Synthesis item tracking callbacks
with set of LUIDs that the user of the class has to fill
- SyncSourceDelete: binds Synthesis delete callback to
virtual method
- SyncSourceRaw: read and write items in the backends format,
used for testing and backup/restore
- SyncSourceSerialize: exchanges items with Synthesis engine
using a string representation of the data; this is how
EvolutionSyncSource has traditionally worked, so much of the
same virtual methods are now in this class
- SyncSourceRevisions: utility class which does change tracking
via some kind of "revision" string which changes each time
an item is modified; this code was previously in the
TrackingSyncSource
2009-08-25 09:27:46 +02:00
boost : : shared_ptr < PersistentSyncSourceConfig > sourceConfig ( to - > getSyncSourceConfig ( source ) ) ;
2008-07-02 21:36:02 +02:00
string disable = " " ;
set < string > : : iterator entry = sources . find ( source ) ;
bool selected = entry ! = sources . end ( ) ;
if ( ! m_sources . empty ( ) & &
! selected ) {
disable = " not selected " ;
} else {
if ( entry ! = sources . end ( ) ) {
// The command line parameter matched a valid source.
// All entries left afterwards must have been typos.
sources . erase ( entry ) ;
}
2012-06-20 12:34:19 +02:00
// check whether the sync source works; this can
// take some time, so allow the user to abort
2013-04-08 19:17:36 +02:00
SE_LOG_INFO ( NULL , " %s: looking for databases... " ,
2012-06-20 12:34:19 +02:00
source . c_str ( ) ) ;
2013-09-19 09:09:19 +02:00
// Even if the peer config does not exist yet
// (fromScratch == true), the source config itself
// may already exist with a username/password
// using the keyring. Need to retrieve that
// password before using the source.
//
// We need to check for databases again here,
// because otherwise we don't know whether the
// source is usable. The "database" property can
// be empty in a usable source, and the "sync"
// property in some potential other peer config
// is not accessible.
PasswordConfigProperty : : checkPasswords ( to - > getUserInterfaceNonNull ( ) ,
* to ,
PasswordConfigProperty : : CHECK_PASSWORD_SOURCE |
PasswordConfigProperty : : CHECK_PASSWORD_RESOLVE_PASSWORD |
PasswordConfigProperty : : CHECK_PASSWORD_RESOLVE_USERNAME ,
boost : : assign : : list_of ( source ) ) ;
2011-04-19 13:46:15 +02:00
SyncSourceParams params ( source , to - > getSyncSourceNodes ( source ) , to ) ;
2010-03-17 10:03:59 +01:00
auto_ptr < SyncSource > syncSource ( SyncSource : : createSource ( params , false , to . get ( ) ) ) ;
2008-07-02 21:36:02 +02:00
if ( syncSource . get ( ) = = NULL ) {
disable = " no backend available " ;
} else {
try {
redesigned SyncSource base class + API
The main motivation for this change is that it allows the implementor
of a backend to choose the implementations for the different aspects
of a datasource (change tracking, item import/export, logging, ...)
independently of each other. For example, change tracking via revision
strings can now be combined with exchanging data with the Synthesis
engine via a single string (the traditional method in SyncEvolution)
and with direct access to the Synthesis field list (now possible for
the first time).
The new backend API is based on the concept of providing
implementations for certain functionality via function objects instead
of implementing certain virtual methods. The advantage is that
implementors can define their own, custom interfaces and mix and match
implementations of the different groups of functionality.
Logging (see SyncSourceLogging in a later commit) can be done by
wrapping some arbitrary other item import/export function objects
(decorator design pattern).
The class hierarchy is now this:
- SyncSourceBase: interface for common utility code, all other
classes are derived from it and thus can use that code
- SyncSource: base class which implements SyncSourceBase and
hooks a datasource into the SyncEvolution core;
its "struct Operations" holds the function objects which
can be implemented in different ways
- TestingSyncSource: combines some of the following classes
into an interface that is expected by the client-test
program; backends only have to derive from (and implement this)
if they want to use the automated testing
- TrackingSyncSource: provides the same functionality as
before (change tracking via revision strings, item import/export
as string) in a single interface; the description of the pure
virtual methods are duplicated so that developers can go through
this class and find everything they need to know to implement
it
The following classes contain the code that was previously
found in the EvolutionSyncSource base class. Implementors
can derive from them and call the init() methods to inherit
and activate the functionality:
- SyncSourceSession: binds Synthesis session callbacks to
virtual methods beginSync(), endSync()
- SyncSourceChanges: implements Synthesis item tracking callbacks
with set of LUIDs that the user of the class has to fill
- SyncSourceDelete: binds Synthesis delete callback to
virtual method
- SyncSourceRaw: read and write items in the backends format,
used for testing and backup/restore
- SyncSourceSerialize: exchanges items with Synthesis engine
using a string representation of the data; this is how
EvolutionSyncSource has traditionally worked, so much of the
same virtual methods are now in this class
- SyncSourceRevisions: utility class which does change tracking
via some kind of "revision" string which changes each time
an item is modified; this code was previously in the
TrackingSyncSource
2009-08-25 09:27:46 +02:00
SyncSource : : Databases databases = syncSource - > getDatabases ( ) ;
2008-07-10 21:17:42 +02:00
if ( databases . empty ( ) ) {
2008-07-02 21:36:02 +02:00
disable = " no database to synchronize " ;
}
} catch ( . . . ) {
2013-02-27 15:10:22 +01:00
std : : string explanation ;
Exception : : handle ( explanation , HANDLE_EXCEPTION_NO_ERROR ) ;
disable = " backend failed: " + explanation ;
2008-07-02 21:36:02 +02:00
}
}
2012-06-20 12:31:24 +02:00
s . checkForNormal ( ) ;
2013-04-08 19:17:36 +02:00
SE_LOG_INFO ( NULL , " %s: %s \n " ,
2012-06-20 12:34:19 +02:00
source . c_str ( ) ,
disable . empty ( ) ? " okay " : disable . c_str ( ) ) ;
2008-07-02 21:36:02 +02:00
}
2010-09-29 15:00:16 +02:00
// Do sanity checking of source (can it be enabled?),
// but only set the sync mode if configuring a peer.
// A context-only config doesn't have the "sync"
// property.
string syncMode ;
2008-07-02 21:36:02 +02:00
if ( ! disable . empty ( ) ) {
// abort if the user explicitly asked for the sync source
// and it cannot be enabled, otherwise disable it silently
if ( selected ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , source + " : " + disable ) ;
2008-07-02 21:36:02 +02:00
}
2010-09-29 15:00:16 +02:00
syncMode = " disabled " ;
2008-07-02 21:36:02 +02:00
} else if ( selected ) {
// user absolutely wants it: enable even if off by default
2011-01-25 11:11:53 +01:00
ConfigProps filter = m_props . createSourceFilter ( m_server , source ) ;
ConfigProps : : const_iterator sync = filter . find ( " sync " ) ;
syncMode = sync = = filter . end ( ) ? " two-way " : sync - > second ;
2010-09-29 15:00:16 +02:00
}
if ( ! syncMode . empty ( ) & &
! configureContext ) {
sourceConfig - > setSync ( syncMode ) ;
2008-07-02 21:36:02 +02:00
}
}
if ( ! sources . empty ( ) ) {
2014-07-28 15:29:41 +02:00
Exception : : throwError ( SE_HERE , string ( " no such datastore(s): " ) + boost : : join ( sources , " " ) ) ;
2008-03-30 15:11:45 +02:00
}
}
2008-03-19 17:43:31 +01:00
2011-02-01 15:33:09 +01:00
// flush, move .synthesis dir, set ConsumerReady, ...
finishCopy ( from , to ) ;
2009-11-25 15:30:07 +01:00
2011-02-01 15:33:09 +01:00
// Now also migrate all peers inside context?
if ( configureContext & & m_migrate ) {
2011-02-01 22:14:22 +01:00
BOOST_FOREACH ( const string & peer , from - > getPeers ( ) ) {
migratePeer ( peer + from - > getContextName ( ) , peer + to - > getContextName ( ) ) ;
}
if ( ! origPeer . empty ( ) ) {
migratePeer ( origPeer , origPeer + to - > getContextName ( ) ) ;
}
2011-01-17 15:00:50 +01:00
}
2009-04-15 14:02:09 +02:00
} else if ( m_remove ) {
2011-11-21 17:38:34 +01:00
if ( ! needConfigName ( ) ) {
return false ;
}
2009-04-23 16:47:07 +02:00
if ( m_dryrun ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , " --dry-run not supported for removing configurations " ) ;
2009-04-23 16:47:07 +02:00
}
2009-04-15 14:02:09 +02:00
// extra sanity check
if ( ! m_sources . empty ( ) | |
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
m_props . hasProperties ( FullProps : : IGNORE_GLOBAL_PROPS ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , " too many parameters for --remove " ) ;
2009-04-15 14:02:09 +02:00
return false ;
} else {
2009-10-06 17:22:47 +02:00
boost : : shared_ptr < SyncConfig > config ;
config . reset ( new SyncConfig ( m_server ) ) ;
2009-10-13 22:08:33 +02:00
if ( ! config - > exists ( ) ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , string ( " no such configuration: " ) + m_server ) ;
2009-10-13 22:08:33 +02:00
}
2009-04-15 14:02:09 +02:00
config - > remove ( ) ;
2010-08-25 21:03:31 +02:00
m_configModified = true ;
2009-04-15 14:02:09 +02:00
return true ;
}
2010-06-11 15:44:57 +02:00
} else if ( m_accessItems ) {
// need access to specific source
boost : : shared_ptr < SyncContext > context ;
context . reset ( createSyncClient ( ) ) ;
2010-06-23 10:04:49 +02:00
2011-11-21 17:38:34 +01:00
// operating on exactly one source (can be optional)
string sourceName ;
bool haveSourceName = ! m_sources . empty ( ) ;
if ( haveSourceName ) {
sourceName = * m_sources . begin ( ) ;
}
2011-01-25 11:11:53 +01:00
2010-06-23 10:04:49 +02:00
// apply filters
2011-01-25 11:11:53 +01:00
context - > setConfigFilter ( true , " " , m_props . createSyncFilter ( m_server ) ) ;
context - > setConfigFilter ( false , " " , m_props . createSourceFilter ( m_server , sourceName ) ) ;
2010-06-23 10:04:49 +02:00
2010-06-16 13:51:50 +02:00
SyncSourceNodes sourceNodes = context - > getSyncSourceNodesNoTracking ( sourceName ) ;
2010-10-08 15:00:08 +02:00
SyncSourceParams params ( sourceName , sourceNodes , context ) ;
2011-11-21 17:38:34 +01:00
cxxptr < SyncSource > source ;
try {
source . set ( SyncSource : : createSource ( params , true ) ) ;
} catch ( const StatusException & ex ) {
// Creating the source failed. Detect some common reasons for this
// and log those instead. None of these situations are fatal by themselves,
// but in combination they are a problem.
if ( ex . syncMLStatus ( ) = = SyncMLStatus ( sysync : : LOCERR_CFGPARSE ) ) {
std : : list < std : : string > explanation ;
explanation . push_back ( ex . what ( ) ) ;
if ( ! m_server . empty ( ) & & ! context - > exists ( ) ) {
explanation . push_back ( StringPrintf ( " configuration '%s' does not exist " , m_server . c_str ( ) ) ) ;
}
if ( haveSourceName & & ! sourceNodes . exists ( ) ) {
2014-07-28 15:29:41 +02:00
explanation . push_back ( StringPrintf ( " datastore '%s' does not exist " , sourceName . c_str ( ) ) ) ;
2011-11-21 17:38:34 +01:00
} else if ( ! haveSourceName ) {
2014-07-28 15:29:41 +02:00
explanation . push_back ( " no datastore selected " ) ;
2011-11-21 17:38:34 +01:00
}
SyncSourceConfig sourceConfig ( sourceName , sourceNodes ) ;
if ( ! sourceConfig . getBackend ( ) . wasSet ( ) ) {
explanation . push_back ( " backend property not set " ) ;
}
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , SyncMLStatus ( sysync : : LOCERR_CFGPARSE ) ,
2011-11-21 17:38:34 +01:00
boost : : join ( explanation , " \n " ) ) ;
} else {
throw ;
}
}
2010-06-11 15:44:57 +02:00
sysync : : TSyError err ;
# define CHECK_ERROR(_op) if (err) { SE_THROW_EXCEPTION_STATUS(StatusException, string(source->getName()) + ": " + (_op), SyncMLStatus(err)); }
2013-07-29 13:57:46 +02:00
PasswordConfigProperty : : checkPasswords ( context - > getUserInterfaceNonNull ( ) ,
* context ,
PasswordConfigProperty : : CHECK_PASSWORD_ALL ,
boost : : assign : : list_of ( source - > getName ( ) ) ) ;
2013-06-11 15:25:37 +02:00
source - > setNeedChanges ( false ) ;
2010-06-11 15:44:57 +02:00
source - > open ( ) ;
const SyncSource : : Operations & ops = source - > getOperations ( ) ;
if ( m_printItems ) {
SyncSourceLogging * logging = dynamic_cast < SyncSourceLogging * > ( source . get ( ) ) ;
if ( ! ops . m_startDataRead | |
! ops . m_readNextItem ) {
2014-04-02 14:57:56 +02:00
source - > throwError ( SE_HERE , " reading items not supported " ) ;
2010-06-11 15:44:57 +02:00
}
2011-08-03 11:08:02 +02:00
2014-04-03 12:09:04 +02:00
err = ops . m_startDataRead ( " " , " " ) ;
2010-06-11 15:44:57 +02:00
CHECK_ERROR ( " reading items " ) ;
2013-06-28 08:58:18 +02:00
source - > setReadAheadOrder ( SyncSourceBase : : READ_ALL_ITEMS ) ;
2013-06-26 11:33:08 +02:00
processLUIDs ( source , boost : : bind ( ShowLUID , logging , _1 ) ) ;
2010-06-11 18:43:01 +02:00
} else if ( m_deleteItems ) {
if ( ! ops . m_deleteItem ) {
2014-04-02 14:57:56 +02:00
source - > throwError ( SE_HERE , " deleting items not supported " ) ;
2010-06-11 18:43:01 +02:00
}
2010-10-26 09:40:41 +02:00
list < string > luids ;
bool deleteAll = std : : find ( m_luids . begin ( ) , m_luids . end ( ) , " * " ) ! = m_luids . end ( ) ;
2014-04-03 12:09:04 +02:00
err = ops . m_startDataRead ( " " , " " ) ;
2010-06-11 18:43:01 +02:00
CHECK_ERROR ( " reading items " ) ;
2010-10-26 09:40:41 +02:00
if ( deleteAll ) {
readLUIDs ( source , luids ) ;
} else {
luids = m_luids ;
}
2010-06-11 18:43:01 +02:00
if ( ops . m_endDataRead ) {
2014-04-03 12:09:04 +02:00
err = ops . m_endDataRead ( ) ;
2010-06-11 18:43:01 +02:00
CHECK_ERROR ( " stop reading items " ) ;
}
if ( ops . m_startDataWrite ) {
2014-04-03 12:09:04 +02:00
err = ops . m_startDataWrite ( ) ;
2010-06-11 18:43:01 +02:00
CHECK_ERROR ( " writing items " ) ;
}
2010-10-26 09:40:41 +02:00
BOOST_FOREACH ( const string & luid , luids ) {
2010-06-11 18:43:01 +02:00
sysync : : ItemIDType id ;
2010-09-01 15:48:29 +02:00
id . item = ( char * ) luid . c_str ( ) ;
2014-04-03 12:09:04 +02:00
err = ops . m_deleteItem ( & id ) ;
2010-06-11 18:43:01 +02:00
CHECK_ERROR ( " deleting item " ) ;
}
2010-08-23 18:20:01 +02:00
char * token ;
2014-04-03 12:09:04 +02:00
err = ops . m_endDataWrite ( true , & token ) ;
2010-08-23 18:20:01 +02:00
if ( token ) {
free ( token ) ;
}
CHECK_ERROR ( " stop writing items " ) ;
2010-06-11 15:44:57 +02:00
} else {
SyncSourceRaw * raw = dynamic_cast < SyncSourceRaw * > ( source . get ( ) ) ;
if ( ! raw ) {
2014-04-02 14:57:56 +02:00
source - > throwError ( SE_HERE , " reading/writing items directly not supported " ) ;
2010-06-11 15:44:57 +02:00
}
if ( m_import | | m_update ) {
2014-04-03 12:09:04 +02:00
err = ops . m_startDataRead ( " " , " " ) ;
2010-06-11 15:44:57 +02:00
CHECK_ERROR ( " reading items " ) ;
if ( ops . m_endDataRead ) {
2014-04-03 12:09:04 +02:00
err = ops . m_endDataRead ( ) ;
2010-06-11 15:44:57 +02:00
CHECK_ERROR ( " stop reading items " ) ;
}
if ( ops . m_startDataWrite ) {
2014-04-03 12:09:04 +02:00
err = ops . m_startDataWrite ( ) ;
2010-06-11 15:44:57 +02:00
CHECK_ERROR ( " writing items " ) ;
}
cxxptr < ifstream > inFile ;
if ( m_itemPath = = " - " | |
! isDir ( m_itemPath ) ) {
string content ;
string luid ;
if ( m_itemPath = = " - " ) {
2012-03-06 13:34:51 +01:00
context - > getUserInterfaceNonNull ( ) . readStdin ( content ) ;
2010-06-11 15:44:57 +02:00
} else if ( ! ReadFile ( m_itemPath , content ) ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , m_itemPath , errno ) ;
2010-06-11 15:44:57 +02:00
}
if ( m_delimiter = = " none " ) {
if ( m_update ) {
if ( m_luids . size ( ) ! = 1 ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , " need exactly one LUID parameter " ) ;
2010-06-11 15:44:57 +02:00
} else {
luid = * m_luids . begin ( ) ;
}
}
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " #0: %s " ,
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
insertItem ( raw , luid , content ) . getEncoded ( ) . c_str ( ) ) ;
2010-06-11 15:44:57 +02:00
} else {
typedef boost : : split_iterator < string : : iterator > string_split_iterator ;
int count = 0 ;
2010-09-30 17:10:57 +02:00
FindDelimiter finder ( m_delimiter ) ;
2010-06-11 15:44:57 +02:00
// when updating, check number of luids in advance
if ( m_update ) {
unsigned long total = 0 ;
for ( string_split_iterator it =
2010-09-30 17:10:57 +02:00
boost : : make_split_iterator ( content , finder ) ;
2010-06-11 15:44:57 +02:00
it ! = string_split_iterator ( ) ;
+ + it ) {
total + + ;
}
if ( total ! = m_luids . size ( ) ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , StringPrintf ( " %lu items != %lu luids, must match => aborting " ,
2010-06-11 15:44:57 +02:00
total , ( unsigned long ) m_luids . size ( ) ) ) ;
}
}
list < string > : : const_iterator luidit = m_luids . begin ( ) ;
for ( string_split_iterator it =
2010-09-30 17:10:57 +02:00
boost : : make_split_iterator ( content , finder ) ;
2010-06-11 15:44:57 +02:00
it ! = string_split_iterator ( ) ;
+ + it ) {
string luid ;
if ( m_update ) {
if ( luidit = = m_luids . end ( ) ) {
// was checked above
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , " internal error, not enough luids " ) ;
2010-06-11 15:44:57 +02:00
}
luid = * luidit ;
+ + luidit ;
}
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " #%d: %s " ,
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
count ,
insertItem ( raw ,
luid ,
string ( it - > begin ( ) , it - > end ( ) ) ) . getEncoded ( ) . c_str ( ) ) ;
2010-06-11 15:44:57 +02:00
count + + ;
}
}
} else {
ReadDir dir ( m_itemPath ) ;
int count = 0 ;
BOOST_FOREACH ( const string & entry , dir ) {
string content ;
string path = m_itemPath + " / " + entry ;
if ( ! ReadFile ( path , content ) ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , path , errno ) ;
2010-06-11 15:44:57 +02:00
}
2014-04-23 12:06:30 +02:00
std : : string luid ;
if ( m_update ) {
luid = CmdlineLUID : : toLUID ( entry ) ;
}
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " #%d: %s: %s " ,
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
count ,
entry . c_str ( ) ,
2014-04-23 12:06:30 +02:00
insertItem ( raw , luid , content ) . getEncoded ( ) . c_str ( ) ) ;
2012-09-25 20:54:55 +02:00
count + + ;
2010-06-11 15:44:57 +02:00
}
}
2010-08-23 18:20:01 +02:00
char * token = NULL ;
2014-04-03 12:09:04 +02:00
err = ops . m_endDataWrite ( true , & token ) ;
2010-08-23 18:20:01 +02:00
if ( token ) {
free ( token ) ;
}
CHECK_ERROR ( " stop writing items " ) ;
2010-06-11 15:44:57 +02:00
} else if ( m_export ) {
2014-04-03 12:09:04 +02:00
err = ops . m_startDataRead ( " " , " " ) ;
2010-06-11 15:44:57 +02:00
CHECK_ERROR ( " reading items " ) ;
ostream * out = NULL ;
cxxptr < ofstream > outFile ;
if ( m_itemPath = = " - " ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
// not actually used, falls back to SE_LOG_SHOW()
out = & std : : cout ;
2010-06-11 15:44:57 +02:00
} else if ( ! isDir ( m_itemPath ) ) {
outFile . set ( new ofstream ( m_itemPath . c_str ( ) ) ) ;
out = outFile ;
}
bool haveItem = false ; // have written one item
bool haveNewline = false ; // that item had a newline at the end
2013-06-26 11:33:08 +02:00
if ( m_luids . empty ( ) ) {
// Read all items.
2013-06-28 08:58:18 +02:00
raw - > setReadAheadOrder ( SyncSourceBase : : READ_ALL_ITEMS ) ;
2013-06-26 11:33:08 +02:00
processLUIDs ( source , boost : : bind ( ExportLUID ,
raw ,
out ,
boost : : ref ( m_delimiter ) ,
boost : : ref ( m_itemPath ) ,
boost : : ref ( haveItem ) ,
boost : : ref ( haveNewline ) ,
_1 ) ) ;
} else {
2013-06-28 08:58:18 +02:00
SyncSourceBase : : ReadAheadItems luids ;
luids . reserve ( m_luids . size ( ) ) ;
luids . insert ( luids . begin ( ) , m_luids . begin ( ) , m_luids . end ( ) ) ;
raw - > setReadAheadOrder ( SyncSourceBase : : READ_SELECTED_ITEMS , luids ) ;
2013-06-26 11:33:08 +02:00
BOOST_FOREACH ( const string & luid , m_luids ) {
ExportLUID ( raw , out , m_delimiter , m_itemPath , haveItem , haveNewline , luid ) ;
2010-06-11 15:44:57 +02:00
}
}
2013-06-28 08:58:18 +02:00
raw - > setReadAheadOrder ( SyncSourceBase : : READ_NONE ) ;
2010-06-11 15:44:57 +02:00
if ( outFile ) {
outFile - > close ( ) ;
if ( outFile - > bad ( ) ) {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , m_itemPath , errno ) ;
2010-06-11 15:44:57 +02:00
}
}
}
}
source - > close ( ) ;
2008-03-19 12:29:14 +01:00
} else {
2011-11-21 17:38:34 +01:00
if ( ! needConfigName ( ) ) {
return false ;
}
2009-09-14 21:54:43 +02:00
std : : set < std : : string > unmatchedSources ;
boost : : shared_ptr < SyncContext > context ;
context . reset ( createSyncClient ( ) ) ;
2011-01-25 11:38:49 +01:00
context - > setConfigProps ( m_props ) ;
2009-09-14 21:54:43 +02:00
context - > setQuiet ( m_quiet ) ;
context - > setDryRun ( m_dryrun ) ;
2011-01-25 11:11:53 +01:00
context - > setConfigFilter ( true , " " , m_props . createSyncFilter ( m_server ) ) ;
2009-09-14 21:54:43 +02:00
if ( m_sources . empty ( ) ) {
2011-01-25 11:11:53 +01:00
// Special semantic of 'no source selected': apply
// filter (if any exists) only to sources which are
// *active*. Configuration of inactive sources is left
// unchanged. This way we don't activate sync sources
// accidentally when the sync mode is modified
// temporarily.
BOOST_FOREACH ( const std : : string & source ,
context - > getSyncSources ( ) ) {
boost : : shared_ptr < PersistentSyncSourceConfig > source_config =
context - > getSyncSourceConfig ( source ) ;
2011-10-24 19:52:01 +02:00
if ( ! source_config - > isDisabled ( ) ) {
2011-01-25 11:11:53 +01:00
context - > setConfigFilter ( false , source , m_props . createSourceFilter ( m_server , source ) ) ;
2009-09-14 21:54:43 +02:00
}
}
} else {
// apply (possibly empty) source filter to selected sources
BOOST_FOREACH ( const std : : string & source ,
m_sources ) {
boost : : shared_ptr < PersistentSyncSourceConfig > source_config =
context - > getSyncSourceConfig ( source ) ;
2011-01-25 11:11:53 +01:00
ConfigProps filter = m_props . createSourceFilter ( m_server , source ) ;
2009-09-14 21:54:43 +02:00
if ( ! source_config | | ! source_config - > exists ( ) ) {
// invalid source name in m_sources, remember and
// report this below
unmatchedSources . insert ( source ) ;
2011-01-25 11:11:53 +01:00
} else if ( filter . find ( " sync " ) = = filter . end ( ) ) {
2009-09-14 21:54:43 +02:00
// Sync mode is not set, must override the
// "sync=disabled" set below with the original
// sync mode for the source or (if that is also
// "disabled") with "two-way". The latter is part
// of the command line semantic that listing a
// source activates it.
string sync = source_config - > getSync ( ) ;
configuration: added possibility to define property name aliases
The goal is to allow multiple names for properties. This will be used
to replace legacy names like "evolutionsource", but it could also be
used to allow abbreviations on the command line.
First the patch replaces the single ConfigProperty::m_name with a list
of names, of which the first one is the current name of the
property.
The name that is to be used depends on the node which is to be
manipulated: if it already has a property under an alias, that alias
is read and also written, so existing configuration continue to use
the old config name (avoids the problem of having to remove the old
name and insert the new one at the same spot in a .ini file). Old
configs continue to parse okay. Writing into node which has none of
the names set, as in migrating into a fresh config, uses the new
names.
Most of the patch deals with the removal of a single, unique name,
either by picking the name so that it matches a node, using the
default name or simply hard-coding a property name ("sync").
The command line accepts all aliases, then uses the main name for
overriding configuration options.
2011-01-18 15:18:21 +01:00
filter [ " sync " ] =
2009-09-14 21:54:43 +02:00
sync = = " disabled " ? " two-way " : sync ;
context - > setConfigFilter ( false , source , filter ) ;
} else {
// sync mode is set, can use m_sourceProps
// directly to apply it
2011-01-25 11:11:53 +01:00
context - > setConfigFilter ( false , source , filter ) ;
2009-09-14 21:54:43 +02:00
}
}
// temporarily disable the rest
FilterConfigNode : : ConfigFilter disabled ;
2012-06-05 12:57:33 +02:00
disabled [ " sync " ] = InitStateString ( " disabled " , true ) ;
2009-09-14 21:54:43 +02:00
context - > setConfigFilter ( false , " " , disabled ) ;
}
// check whether there were any sources specified which do not exist
2014-01-07 09:48:23 +01:00
if ( ! unmatchedSources . empty ( ) ) {
2014-07-28 15:29:41 +02:00
Exception : : throwError ( SE_HERE , string ( " no such datastore(s): " ) + boost : : join ( unmatchedSources , " " ) ) ;
2009-09-14 21:54:43 +02:00
}
2008-03-19 12:29:14 +01:00
if ( m_status ) {
2009-09-14 21:54:43 +02:00
context - > status ( ) ;
2009-04-15 15:58:05 +02:00
} else if ( m_printSessions ) {
vector < string > dirs ;
2009-09-14 21:54:43 +02:00
context - > getSessions ( dirs ) ;
2009-04-16 12:07:49 +02:00
bool first = true ;
2009-04-15 15:58:05 +02:00
BOOST_FOREACH ( const string & dir , dirs ) {
2009-04-16 12:07:49 +02:00
if ( first ) {
first = false ;
} else if ( ! m_quiet ) {
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " \n " ) ;
2009-04-16 12:07:49 +02:00
}
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s " , dir . c_str ( ) ) ;
2009-04-16 12:07:49 +02:00
if ( ! m_quiet ) {
SyncReport report ;
2009-09-14 21:54:43 +02:00
context - > readSessionInfo ( dir , report ) ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
ostringstream out ;
out < < report ;
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s " , out . str ( ) . c_str ( ) ) ;
2009-04-16 12:07:49 +02:00
}
2009-04-15 15:58:05 +02:00
}
2009-04-23 16:47:07 +02:00
} else if ( ! m_restore . empty ( ) ) {
// sanity checks: either --after or --before must be given, sources must be selected
if ( ( ! m_after & & ! m_before ) | |
( m_after & & m_before ) ) {
usage ( false , " --restore <log dir> must be used with either --after (restore database as it was after that sync) or --before (restore data from before sync) " ) ;
return false ;
}
if ( m_sources . empty ( ) ) {
2014-07-28 15:29:41 +02:00
usage ( false , " Datastores must be selected explicitly for --restore to prevent accidental restore. " ) ;
2009-04-23 16:47:07 +02:00
return false ;
}
2009-09-14 21:54:43 +02:00
context - > restore ( m_restore ,
m_after ?
SyncContext : : DATABASE_AFTER_SYNC :
SyncContext : : DATABASE_BEFORE_SYNC ) ;
2008-03-19 12:29:14 +01:00
} else {
2009-04-23 16:47:07 +02:00
if ( m_dryrun ) {
2012-06-05 13:20:38 +02:00
usage ( false , " --dry-run not supported for running a synchronization " ) ;
return false ;
2009-04-23 16:47:07 +02:00
}
2008-08-03 15:00:51 +02:00
// safety catch: if props are given, then --run
// is required
if ( ! m_run & &
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
( m_props . hasProperties ( FullProps : : IGNORE_GLOBAL_PROPS ) ) ) {
2008-08-03 15:00:51 +02:00
usage ( false , " Properties specified, but neither '--configure' nor '--run' - what did you want? " ) ;
return false ;
}
2010-10-29 10:07:57 +02:00
return ( context - > sync ( & m_report ) = = STATUS_OK ) ;
2008-03-19 12:29:14 +01:00
}
}
return true ;
}
2010-06-11 15:44:57 +02:00
void Cmdline : : readLUIDs ( SyncSource * source , list < string > & luids )
2013-06-26 11:33:08 +02:00
{
processLUIDs ( source , boost : : bind ( & list < string > : : push_back , boost : : ref ( luids ) , _1 ) ) ;
}
void Cmdline : : processLUIDs ( SyncSource * source , const boost : : function < void ( const std : : string & ) > & process )
2010-06-11 15:44:57 +02:00
{
const SyncSource : : Operations & ops = source - > getOperations ( ) ;
sysync : : ItemIDType id ;
sysync : : sInt32 status ;
2014-04-03 12:09:04 +02:00
sysync : : TSyError err = ops . m_readNextItem ( & id , & status , true ) ;
2010-06-11 15:44:57 +02:00
CHECK_ERROR ( " next item " ) ;
while ( status ! = sysync : : ReadNextItem_EOF ) {
2013-06-26 11:33:08 +02:00
process ( id . item ) ;
2011-12-01 18:46:49 +01:00
StrDispose ( id . item ) ;
StrDispose ( id . parent ) ;
2014-04-03 12:09:04 +02:00
err = ops . m_readNextItem ( & id , & status , false ) ;
2010-06-11 15:44:57 +02:00
CHECK_ERROR ( " next item " ) ;
}
}
2010-09-01 15:48:29 +02:00
CmdlineLUID Cmdline : : insertItem ( SyncSourceRaw * source , const string & luid , const string & data )
2010-06-11 15:44:57 +02:00
{
2010-09-01 15:48:29 +02:00
SyncSourceRaw : : InsertItemResult res = source - > insertItemRaw ( luid , data ) ;
CmdlineLUID cluid ;
cluid . setLUID ( res . m_luid ) ;
return cluid ;
2010-06-11 15:44:57 +02:00
}
2009-10-05 14:49:32 +02:00
string Cmdline : : cmdOpt ( const char * opt , const char * param )
2008-03-19 12:29:14 +01:00
{
string res = " ' " ;
2011-02-03 14:05:16 +01:00
if ( opt ) {
res + = opt ;
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
// parameter was provided as part of option
bool included = opt & & param & &
boost : : ends_with ( std : : string ( opt ) ,
std : : string ( " = " ) + param ) ;
if ( ! included & & opt & & param ) {
2008-03-19 12:29:14 +01:00
res + = " " ;
2011-02-03 14:05:16 +01:00
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
if ( ! included & & param ) {
2008-03-19 12:29:14 +01:00
res + = param ;
}
res + = " ' " ;
return res ;
}
2011-01-25 11:11:53 +01:00
bool Cmdline : : parseProp ( PropertyType propertyType ,
const char * opt ,
const char * param ,
const char * propname )
2008-03-19 12:29:14 +01:00
{
2011-01-25 11:11:53 +01:00
std : : string args = cmdOpt ( opt , param ) ;
2008-03-19 12:29:14 +01:00
if ( ! param ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , string ( " missing parameter for " ) + args ) ;
2008-03-19 12:29:14 +01:00
return false ;
2011-01-25 11:11:53 +01:00
}
// determine property name and parameter for it
string propstr ;
string paramstr ;
if ( propname ) {
propstr = propname ;
paramstr = param ;
2008-03-30 15:11:45 +02:00
} else if ( boost : : trim_copy ( string ( param ) ) = = " ? " ) {
2011-01-25 11:11:53 +01:00
paramstr = param ;
2008-03-19 12:29:14 +01:00
} else {
2011-01-25 11:11:53 +01:00
const char * equal = strchr ( param , ' = ' ) ;
if ( ! equal ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , string ( " the '=<value>' part is missing in: " ) + args ) ;
2011-01-25 11:11:53 +01:00
return false ;
}
propstr . assign ( param , equal - param ) ;
paramstr . assign ( equal + 1 ) ;
}
boost : : trim ( propstr ) ;
boost : : trim_left ( paramstr ) ;
// parse full property string
PropertySpecifier spec = PropertySpecifier : : StringToPropSpec ( propstr ) ;
// determine property type and registry
const ConfigPropertyRegistry * validProps = NULL ;
switch ( propertyType ) {
case SYNC_PROPERTY_TYPE :
validProps = & m_validSyncProps ;
break ;
case SOURCE_PROPERTY_TYPE :
validProps = & m_validSourceProps ;
break ;
case UNKNOWN_PROPERTY_TYPE :
// must guess based on both registries
if ( ! propstr . empty ( ) ) {
bool isSyncProp = m_validSyncProps . find ( spec . m_property ) ! = NULL ;
bool isSourceProp = m_validSourceProps . find ( spec . m_property ) ! = NULL ;
if ( isSyncProp ) {
if ( isSourceProp ) {
2014-07-28 15:29:41 +02:00
usage ( false , StringPrintf ( " property '%s' in %s could be both a sync and a datastore property, use --sync-property or --datastore-property to disambiguate it " , propname , args . c_str ( ) ) ) ;
2011-01-25 11:11:53 +01:00
return false ;
} else {
validProps = & m_validSyncProps ;
}
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
} else if ( isSourceProp | |
boost : : iequals ( spec . m_property , " type " ) ) {
2011-01-25 11:11:53 +01:00
validProps = & m_validSourceProps ;
} else {
2012-04-11 10:58:51 +02:00
if ( propname ) {
usage ( false , StringPrintf ( " unrecognized property '%s' in %s " , propname , args . c_str ( ) ) ) ;
} else {
usage ( false , StringPrintf ( " unrecognized property in %s " , args . c_str ( ) ) ) ;
}
2008-03-19 12:29:14 +01:00
return false ;
}
2011-01-25 11:11:53 +01:00
} else {
2012-04-11 10:58:51 +02:00
usage ( false , StringPrintf ( " a property name must be given in %s " , args . c_str ( ) ) ) ;
return false ;
2008-03-19 12:29:14 +01:00
}
2011-01-25 11:11:53 +01:00
}
2008-03-19 12:29:14 +01:00
2011-01-25 11:11:53 +01:00
if ( boost : : trim_copy ( string ( param ) ) = = " ? " ) {
m_dontrun = true ;
if ( propname ) {
2011-02-03 14:05:16 +01:00
return listPropValues ( * validProps , spec . m_property , opt ? opt : " " ) ;
2011-01-25 11:11:53 +01:00
} else {
2011-02-03 14:05:16 +01:00
return listProperties ( * validProps , opt ? opt : " " ) ;
2011-01-25 11:11:53 +01:00
}
} else {
2008-03-30 15:11:45 +02:00
if ( boost : : trim_copy ( paramstr ) = = " ? " ) {
2008-03-19 12:29:14 +01:00
m_dontrun = true ;
2011-02-03 14:05:16 +01:00
return listPropValues ( * validProps , spec . m_property , args ) ;
2008-03-19 12:29:14 +01:00
} else {
2011-01-25 11:11:53 +01:00
const ConfigProperty * prop = validProps - > find ( spec . m_property ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
if ( ! prop & & boost : : iequals ( spec . m_property , " type " ) ) {
// compatiblity mode for "type": map to the properties which
// replaced it
prop = validProps - > find ( " backend " ) ;
if ( ! prop ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " backend: no such property " ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
return false ;
}
SourceType sourceType ( paramstr ) ;
string error ;
if ( ! prop - > checkValue ( sourceType . m_backend , error ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " %s: %s " , args . c_str ( ) , error . c_str ( ) ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
return false ;
}
ContextProps & props = m_props [ spec . m_config ] ;
2012-06-05 12:57:33 +02:00
props . m_sourceProps [ spec . m_source ] [ " backend " ] =
InitStateString ( sourceType . m_backend ,
! sourceType . m_backend . empty ( ) ) ;
props . m_sourceProps [ spec . m_source ] [ " databaseFormat " ] =
InitStateString ( sourceType . m_localFormat ,
! sourceType . m_localFormat . empty ( ) ) ;
props . m_sourceProps [ spec . m_source ] [ " syncFormat " ] =
InitStateString ( sourceType . m_format ,
! sourceType . m_format . empty ( ) ) ;
props . m_sourceProps [ spec . m_source ] [ " forceSyncFormat " ] =
sourceType . m_forceFormat ?
InitStateString ( " 1 " , true ) :
InitStateString ( " 0 " , false ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
return true ;
} else if ( ! prop ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " %s: no such property " , args . c_str ( ) ) ;
2008-03-19 12:29:14 +01:00
return false ;
} else {
string error ;
if ( ! prop - > checkValue ( paramstr , error ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " %s: %s " , args . c_str ( ) , error . c_str ( ) ) ;
2008-03-19 12:29:14 +01:00
return false ;
} else {
2011-01-25 11:11:53 +01:00
ContextProps & props = m_props [ spec . m_config ] ;
if ( validProps = = & m_validSyncProps ) {
2011-01-25 11:45:28 +01:00
// complain if sync property includes source prefix
if ( ! spec . m_source . empty ( ) ) {
2014-07-28 15:29:41 +02:00
SE_LOG_ERROR ( NULL , " %s: datastore name '%s' not allowed in sync property " ,
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
args . c_str ( ) ,
spec . m_source . c_str ( ) ) ;
2011-01-25 11:45:28 +01:00
return false ;
}
2011-01-25 11:11:53 +01:00
props . m_syncProps [ spec . m_property ] = paramstr ;
} else {
props . m_sourceProps [ spec . m_source ] [ spec . m_property ] = paramstr ;
}
2008-03-19 12:29:14 +01:00
return true ;
}
}
}
}
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
bool Cmdline : : parseAssignment ( int & opt , vector < string > & parsed ,
PropertyType propertyType ,
const char * propname ,
const char * def )
{
string param ;
bool haveParam = false ;
string cmdopt ( m_argv [ opt ] ) ;
size_t off = cmdopt . find ( ' = ' ) ;
if ( off ! = cmdopt . npos ) {
// value embedded in option
param = cmdopt . substr ( off + 1 ) ;
haveParam = true ;
} else if ( ! def & & + + opt < m_argc ) {
// assume next entry is parameter
param = m_argv [ opt ] ;
parsed . push_back ( m_argv [ opt ] ) ;
haveParam = true ;
} else if ( def ) {
// use default
param = def ;
haveParam = true ;
}
return parseProp ( propertyType ,
cmdopt . c_str ( ) ,
haveParam ? param . c_str ( ) : NULL ,
propname ) ;
}
2009-10-05 14:49:32 +02:00
bool Cmdline : : listPropValues ( const ConfigPropertyRegistry & validProps ,
2008-03-19 12:29:14 +01:00
const string & propName ,
const string & opt )
{
const ConfigProperty * prop = validProps . find ( propName ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
if ( ! prop & & boost : : iequals ( propName , " type " ) ) {
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL ,
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
" %s \n "
" <backend>[:<format>[:<version][!]] \n "
" legacy property, replaced by 'backend', 'databaseFormat', \n "
" 'syncFormat', 'forceSyncFormat' " ,
opt . c_str ( ) ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
return true ;
} else if ( ! prop ) {
2013-04-08 19:17:36 +02:00
SE_LOG_ERROR ( NULL , " %s: no such property " , opt . c_str ( ) ) ;
2008-03-19 12:29:14 +01:00
return false ;
} else {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
ostringstream out ;
out < < opt < < endl ;
2008-03-19 12:29:14 +01:00
string comment = prop - > getComment ( ) ;
if ( comment ! = " " ) {
list < string > commentLines ;
ConfigProperty : : splitComment ( comment , commentLines ) ;
2008-07-11 22:25:02 +02:00
BOOST_FOREACH ( const string & line , commentLines ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " " < < line < < endl ;
2008-03-19 12:29:14 +01:00
}
} else {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " no documentation available " < < endl ;
2008-03-19 12:29:14 +01:00
}
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s " , out . str ( ) . c_str ( ) ) ;
2008-03-19 12:29:14 +01:00
return true ;
}
}
2009-10-05 14:49:32 +02:00
bool Cmdline : : listProperties ( const ConfigPropertyRegistry & validProps ,
2008-03-19 12:29:14 +01:00
const string & opt )
{
// The first of several related properties has a comment.
// Remember that comment and print it as late as possible,
// that way related properties preceed their comment.
string comment ;
2011-10-19 17:15:50 +02:00
bool needComma = false ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
ostringstream out ;
2008-07-11 22:25:02 +02:00
BOOST_FOREACH ( const ConfigProperty * prop , validProps ) {
if ( ! prop - > isHidden ( ) ) {
string newComment = prop - > getComment ( ) ;
2008-03-19 12:29:14 +01:00
if ( newComment ! = " " ) {
2008-03-30 17:15:00 +02:00
if ( ! comment . empty ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < endl ;
dumpComment ( out , " " , comment ) ;
out < < endl ;
2011-10-19 17:15:50 +02:00
needComma = false ;
2008-03-30 17:15:00 +02:00
}
2008-03-19 12:29:14 +01:00
comment = newComment ;
}
2011-10-19 17:15:50 +02:00
std : : string def = prop - > getDefValue ( ) ;
if ( def . empty ( ) ) {
def = " no default " ;
}
ConfigProperty : : Sharing sharing = prop - > getSharing ( ) ;
if ( needComma ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " , " ;
2011-10-19 17:15:50 +02:00
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < boost : : join ( prop - > getNames ( ) , " = " )
2011-10-19 17:15:50 +02:00
< < " ( " < < def < < " , "
< < ConfigProperty : : sharing2str ( sharing )
< < ( prop - > isObligatory ( ) ? " , required " : " " )
< < " ) " ;
needComma = true ;
2008-03-19 12:29:14 +01:00
}
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < endl ;
dumpComment ( out , " " , comment ) ;
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s " , out . str ( ) . c_str ( ) ) ;
2008-03-19 12:29:14 +01:00
return true ;
}
2010-03-03 16:20:53 +01:00
static void findPeerProps ( FilterConfigNode : : ConfigFilter & filter ,
ConfigPropertyRegistry & registry ,
2011-01-25 11:11:53 +01:00
set < string > & peerProps )
2010-03-03 16:20:53 +01:00
{
BOOST_FOREACH ( StringPair entry , filter ) {
const ConfigProperty * prop = registry . find ( entry . first ) ;
if ( prop & &
2011-02-03 13:00:22 +01:00
prop - > getSharing ( ) = = ConfigProperty : : NO_SHARING ) {
2011-01-25 11:11:53 +01:00
peerProps . insert ( entry . first ) ;
2010-03-03 16:20:53 +01:00
}
}
}
void Cmdline : : checkForPeerProps ( )
{
2011-01-25 11:11:53 +01:00
set < string > peerProps ;
BOOST_FOREACH ( FullProps : : value_type & entry , m_props ) {
ContextProps & props = entry . second ;
2010-03-03 16:20:53 +01:00
2011-01-25 11:11:53 +01:00
findPeerProps ( props . m_syncProps , SyncConfig : : getRegistry ( ) , peerProps ) ;
BOOST_FOREACH ( SourceProps : : value_type & entry , props . m_sourceProps ) {
findPeerProps ( entry . second , SyncSourceConfig : : getRegistry ( ) , peerProps ) ;
}
}
2010-03-03 16:20:53 +01:00
if ( ! peerProps . empty ( ) ) {
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
string props = boost : : join ( peerProps , " , " ) ;
if ( props = = " forceSyncFormat, syncFormat " ) {
// special case: these two properties might have been added by the
// legacy "sync" property, which applies to both shared and unshared
// properties => cannot determine that here anymore, so ignore it
} else {
2014-04-02 14:57:56 +02:00
Exception : : throwError ( SE_HERE , string ( " per-peer (unshared) properties not allowed: " ) +
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
props ) ;
}
2010-03-03 16:20:53 +01:00
}
}
2012-09-13 18:02:07 +02:00
void Cmdline : : listDatabases ( SyncSource * source , const string & header )
2008-03-19 12:29:14 +01:00
{
2012-09-13 18:02:07 +02:00
if ( ! source ) {
// silently skip backends like the "file" backend which do not support
// listing databases and return NULL unless configured properly
return ;
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
ostringstream out ;
out < < header < < " : \n " ;
2012-03-08 11:15:22 +01:00
2012-09-13 18:02:07 +02:00
if ( source - > isInactive ( ) ) {
out < < source - > getBackend ( ) < < " : not enabled during compilation or not usable in the current environment \n " ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
} else {
2012-09-13 18:02:07 +02:00
SyncSource : : Databases databases = source - > getDatabases ( ) ;
2008-03-19 12:29:14 +01:00
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
BOOST_FOREACH ( const SyncSource : : Database & database , databases ) {
out < < " " < < database . m_name < < " ( " < < database . m_uri < < " ) " ;
if ( database . m_isDefault ) {
out < < " <default> " ;
}
2014-04-23 11:19:51 +02:00
if ( database . m_isReadOnly ) {
out < < " <read-only> " ;
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < endl ;
2008-03-30 21:08:19 +02:00
}
2008-03-19 12:29:14 +01:00
}
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s " , out . str ( ) . c_str ( ) ) ;
SE_LOG_SHOW ( NULL , " \n " ) ;
2012-09-13 18:02:07 +02:00
}
void Cmdline : : createDatabase ( SyncSource * source , const string & header )
{
if ( ! source ) {
SE_THROW ( StringPrintf ( " %s: \n cannot access databases " , header . c_str ( ) ) ) ;
return ;
}
// Only the name can be set via the command line. URI is chosen by backend.
InitStateString databaseID = source - > getDatabaseID ( ) ;
if ( ! databaseID . wasSet ( ) ) {
SE_THROW ( " The 'database' property must be set to the name of the new database " ) ;
}
SyncSource : : Database database = source - > createDatabase ( SyncSource : : Database ( databaseID , " " ) ) ;
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s: database '%s' (%s) was created. " ,
2012-09-13 18:02:07 +02:00
header . c_str ( ) ,
database . m_name . c_str ( ) ,
database . m_uri . c_str ( ) ) ;
}
void Cmdline : : removeDatabase ( SyncSource * source , const string & header )
{
if ( ! source ) {
SE_THROW ( StringPrintf ( " %s: \n cannot access databases " , header . c_str ( ) ) ) ;
return ;
}
InitStateString databaseID = source - > getDatabaseID ( ) ;
if ( ! databaseID . wasSet ( ) ) {
SE_THROW ( " The 'database' property was not set. Cowardly refusing to remove the default database. Set it to the empty string and try again if that was the intention. " ) ;
}
// determine URI
source - > open ( ) ;
SyncSource : : Database database = source - > getDatabase ( ) ;
if ( database . m_uri . empty ( ) ) {
SE_THROW ( StringPrintf ( " Cannot determine database from 'database' property value '%s'. " ,
databaseID . c_str ( ) ) ) ;
}
2013-05-24 09:42:13 +02:00
source - > deleteDatabase ( database . m_uri , SyncSource : : REMOVE_DATA_DEFAULT ) ;
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s: database '%s' (%s) was removed. " ,
2012-09-13 18:02:07 +02:00
header . c_str ( ) ,
database . m_name . c_str ( ) ,
database . m_uri . c_str ( ) ) ;
2008-03-19 12:29:14 +01:00
}
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
void Cmdline : : dumpConfigs ( const string & preamble ,
const SyncConfig : : ConfigList & servers )
2008-03-19 17:43:31 +01:00
{
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
ostringstream out ;
out < < preamble < < endl ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
BOOST_FOREACH ( const SyncConfig : : ConfigList : : value_type & server , servers ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " " < < server . first < < " = " < < server . second < < endl ;
2008-03-19 17:43:31 +01:00
}
if ( ! servers . size ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " none " < < endl ;
2008-03-19 17:43:31 +01:00
}
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s " , out . str ( ) . c_str ( ) ) ;
2008-03-19 17:43:31 +01:00
}
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
void Cmdline : : dumpConfigTemplates ( const string & preamble ,
command line: use both stdout and stderr
Traditionally, the "syncevolution" command line tool mixed its
INFO/ERROR/DEBUG messages into the normal stdout. This has the major
drawback that error messages get lost during operations like
syncevolution --export - @default addressbook | grep "John Doe"
Now anything which not the expected result of the operation is always
sent to stderr. Obviously this includes ERROR messages. INFO and DEBUG
are harder to decide. Because they usually convey meta information
about the running operation, they are also sent to stderr.
This changes the behavior of
syncevolution --run foo eds_event | less
"less" will capture only the following output:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Local data changes to be applied during synchronization:
*** eds_event ***
no changes
Synchronization successful.
Changes applied during synchronization:
+---------------|-----------------------|-----------------------|-CON-+
| | LOCAL | REMOTE | FLI |
| Source | NEW | MOD | DEL | ERR | NEW | MOD | DEL | ERR | CTS |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| eds_event | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| two-way, 0 KB sent by client, 0 KB received |
| item(s) in database backup: 2 before sync, 2 after it |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| start Wed Apr 11 14:34:11 2012, duration 0:03min |
| synchronization completed successfully |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
Data modified locally during synchronization:
*** eds_event ***
no changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To get the traditional behavior with bash or sh as shell, use
syncevolution --run foo eds_event 2>&1 | less
Some "normal" output in error messages was changed to INFO and thus
now appears on stderr after the corresponding ERROR message. Empty
lines which were used to separate different parts now also have a tag,
for the sake of consistency with the surrounding output.
The main implementation change is in LogRedirect, which now decides
whether LogStdout shall send the message to stdout or stderr. This has
the desired effect in the "syncevolution" binary, which uses
LogRedirect. Other binaries inherit the same change, although there it
usually doesn't matter.
The Cmdline unit testing mirrors this change in the way how it stores
and checks Cmdline output and also was adapted to the prefix changes.
2012-04-11 14:38:54 +02:00
const SyncConfig : : TemplateList & templates ,
bool printRank ,
Logger : : Level level )
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
{
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
ostringstream out ;
out < < preamble < < endl ;
out < < " " < < " template name " < < " = " < < " template description " ;
2010-03-03 09:24:58 +01:00
if ( printRank ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " " < < " matching score in percent (100% = exact match) " ;
2010-03-03 09:24:58 +01:00
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < endl ;
2010-03-03 09:24:58 +01:00
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
BOOST_FOREACH ( const SyncConfig : : TemplateList : : value_type server , templates ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " " < < server - > m_templateId < < " = " < < server - > m_description ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
if ( printRank ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " " < < server - > m_rank * 20 < < " % " ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < endl ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
}
if ( ! templates . size ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " none " < < endl ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
}
2013-04-08 19:17:36 +02:00
SE_LOG ( NULL , level , " %s " , out . str ( ) . c_str ( ) ) ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
}
2009-10-05 14:49:32 +02:00
void Cmdline : : dumpProperties ( const ConfigNode & configuredProps ,
2010-01-20 11:36:19 +01:00
const ConfigPropertyRegistry & allProps ,
2010-03-02 16:27:22 +01:00
int flags )
2008-03-19 12:29:14 +01:00
{
2010-01-20 11:36:19 +01:00
list < string > perPeer , perContext , global ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
ostringstream out ;
2010-01-20 11:36:19 +01:00
2008-07-11 22:25:02 +02:00
BOOST_FOREACH ( const ConfigProperty * prop , allProps ) {
2010-03-02 16:27:22 +01:00
if ( prop - > isHidden ( ) | |
( ( flags & HIDE_PER_PEER ) & &
2011-02-03 13:00:22 +01:00
prop - > getSharing ( ) = = ConfigProperty : : NO_SHARING ) ) {
2008-03-19 17:43:31 +01:00
continue ;
}
2008-03-19 12:29:14 +01:00
if ( ! m_quiet ) {
2008-07-11 22:25:02 +02:00
string comment = prop - > getComment ( ) ;
2008-03-19 15:38:19 +01:00
if ( ! comment . empty ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < endl ;
dumpComment ( out , " # " , comment ) ;
2008-03-19 15:38:19 +01:00
}
2008-03-19 12:29:14 +01:00
}
2011-11-21 16:37:53 +01:00
InitStateString value = prop - > getProperty ( configuredProps ) ;
if ( ! value . wasSet ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " # " ;
2008-03-30 23:50:51 +02:00
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < prop - > getMainName ( ) < < " = " < < value . get ( ) < < endl ;
2010-01-20 11:36:19 +01:00
list < string > * type = NULL ;
switch ( prop - > getSharing ( ) ) {
case ConfigProperty : : GLOBAL_SHARING :
type = & global ;
break ;
case ConfigProperty : : SOURCE_SET_SHARING :
type = & perContext ;
break ;
case ConfigProperty : : NO_SHARING :
type = & perPeer ;
break ;
}
if ( type ) {
configuration: added possibility to define property name aliases
The goal is to allow multiple names for properties. This will be used
to replace legacy names like "evolutionsource", but it could also be
used to allow abbreviations on the command line.
First the patch replaces the single ConfigProperty::m_name with a list
of names, of which the first one is the current name of the
property.
The name that is to be used depends on the node which is to be
manipulated: if it already has a property under an alias, that alias
is read and also written, so existing configuration continue to use
the old config name (avoids the problem of having to remove the old
name and insert the new one at the same spot in a .ini file). Old
configs continue to parse okay. Writing into node which has none of
the names set, as in migrating into a fresh config, uses the new
names.
Most of the patch deals with the removal of a single, unique name,
either by picking the name so that it matches a node, using the
default name or simply hard-coding a property name ("sync").
The command line accepts all aliases, then uses the main name for
overriding configuration options.
2011-01-18 15:18:21 +01:00
type - > push_back ( prop - > getMainName ( ) ) ;
2010-01-20 11:36:19 +01:00
}
}
2010-03-02 16:27:22 +01:00
if ( ! m_quiet & & ! ( flags & HIDE_LEGEND ) ) {
2010-01-20 11:36:19 +01:00
if ( ! perPeer . empty ( ) | |
! perContext . empty ( ) | |
! global . empty ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < endl ;
2010-01-20 11:36:19 +01:00
}
if ( ! perPeer . empty ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " # per-peer (unshared) properties: " < < boost : : join ( perPeer , " , " ) < < endl ;
2010-01-20 11:36:19 +01:00
}
if ( ! perContext . empty ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " # shared by peers in same context: " < < boost : : join ( perContext , " , " ) < < endl ;
2010-01-20 11:36:19 +01:00
}
if ( ! global . empty ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
out < < " # global properties: " < < boost : : join ( global , " , " ) < < endl ;
2010-01-20 11:36:19 +01:00
}
2008-03-19 12:29:14 +01:00
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s " , out . str ( ) . c_str ( ) ) ;
2008-03-19 12:29:14 +01:00
}
2009-10-05 14:49:32 +02:00
void Cmdline : : dumpComment ( ostream & stream ,
2008-03-19 12:29:14 +01:00
const string & prefix ,
const string & comment )
{
list < string > commentLines ;
ConfigProperty : : splitComment ( comment , commentLines ) ;
2008-07-11 22:25:02 +02:00
BOOST_FOREACH ( const string & line , commentLines ) {
stream < < prefix < < line < < endl ;
2008-03-19 12:29:14 +01:00
}
}
2009-10-05 14:49:32 +02:00
void Cmdline : : usage ( bool full , const string & error , const string & param )
2008-03-19 12:29:14 +01:00
{
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " %s " , synopsis ) ;
2008-03-19 12:29:14 +01:00
if ( full ) {
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " \n Options: \n %s " , options ) ;
2008-03-19 12:29:14 +01:00
}
if ( error ! = " " ) {
2013-04-08 19:17:36 +02:00
SE_LOG_SHOW ( NULL , " \n " ) ;
SE_LOG_ERROR ( NULL , " %s " , error . c_str ( ) ) ;
2008-03-19 12:29:14 +01:00
}
if ( param ! = " " ) {
2013-04-08 19:17:36 +02:00
SE_LOG_INFO ( NULL , " use '%s%s?' to get a list of valid parameters " ,
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
param . c_str ( ) ,
boost : : ends_with ( param , " = " ) ? " " : " " ) ;
2008-03-19 12:29:14 +01:00
}
}
2008-03-28 23:32:00 +01:00
2011-11-21 17:38:34 +01:00
bool Cmdline : : needConfigName ( )
{
if ( m_server . empty ( ) ) {
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
usage ( false , " No configuration name specified. " ) ;
2011-11-21 17:38:34 +01:00
return false ;
} else {
return true ;
}
}
2009-10-05 14:49:32 +02:00
SyncContext * Cmdline : : createSyncClient ( ) {
2009-09-14 21:54:43 +02:00
return new SyncContext ( m_server , true ) ;
2009-09-21 10:07:05 +02:00
}
2008-04-17 20:27:53 +02:00
# ifdef ENABLE_UNIT_TESTS
2008-03-28 23:32:00 +01:00
2008-03-29 18:04:26 +01:00
/** simple line-by-line diff */
static string diffStrings ( const string & lhs , const string & rhs )
{
ostringstream res ;
typedef boost : : split_iterator < string : : const_iterator > string_split_iterator ;
string_split_iterator lit =
boost : : make_split_iterator ( lhs , boost : : first_finder ( " \n " , boost : : is_iequal ( ) ) ) ;
string_split_iterator rit =
boost : : make_split_iterator ( rhs , boost : : first_finder ( " \n " , boost : : is_iequal ( ) ) ) ;
while ( lit ! = string_split_iterator ( ) & &
rit ! = string_split_iterator ( ) ) {
if ( * lit ! = * rit ) {
res < < " < " < < * lit < < endl ;
res < < " > " < < * rit < < endl ;
}
+ + lit ;
+ + rit ;
}
while ( lit ! = string_split_iterator ( ) ) {
res < < " < " < < * lit < < endl ;
+ + lit ;
}
2008-03-29 18:26:23 +01:00
while ( rit ! = string_split_iterator ( ) ) {
2008-03-29 18:04:26 +01:00
res < < " > " < < * rit < < endl ;
+ + rit ;
}
return res . str ( ) ;
}
# define CPPUNIT_ASSERT_EQUAL_DIFF( expected, actual ) \
do { \
2008-03-30 11:02:07 +02:00
string expected_ = ( expected ) ; \
string actual_ = ( actual ) ; \
if ( expected_ ! = actual_ ) { \
2008-03-29 18:04:26 +01:00
CPPUNIT_NS : : Message cpputMsg_ ( string ( " expected: \n " ) + \
2008-03-30 11:02:07 +02:00
expected_ ) ; \
2008-03-29 18:04:26 +01:00
cpputMsg_ . addDetail ( string ( " actual: \n " ) + \
2008-03-30 11:02:07 +02:00
actual_ ) ; \
2008-03-29 18:04:26 +01:00
cpputMsg_ . addDetail ( string ( " diff: \n " ) + \
2008-03-30 11:02:07 +02:00
diffStrings ( expected_ , actual_ ) ) ; \
2008-03-29 18:04:26 +01:00
CPPUNIT_NS : : Asserter : : fail ( cpputMsg_ , \
CPPUNIT_SOURCELINE ( ) ) ; \
} \
} while ( false )
2008-03-30 23:50:51 +02:00
// true if <word> =
static bool isPropAssignment ( const string & buffer ) {
2010-09-09 11:38:05 +02:00
// ignore these comments (occur in type description)
2010-07-14 08:13:57 +02:00
if ( boost : : starts_with ( buffer , " KCalExtended = " ) | |
2010-09-09 11:38:05 +02:00
boost : : starts_with ( buffer , " mkcal = " ) | |
boost : : starts_with ( buffer , " QtContacts = " ) ) {
2010-07-14 08:13:57 +02:00
return false ;
}
2008-03-30 23:50:51 +02:00
size_t start = 0 ;
while ( start < buffer . size ( ) & &
! isspace ( buffer [ start ] ) ) {
start + + ;
}
if ( start + 3 < = buffer . size ( ) & &
buffer . substr ( start , 3 ) = = " = " ) {
return true ;
} else {
return false ;
}
}
// remove pure comment lines from buffer,
2009-11-24 15:02:21 +01:00
// also empty lines,
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
// also defaultPeer and keyring (because reference properties do not include global props)
2008-03-30 13:43:36 +02:00
static string filterConfig ( const string & buffer )
{
ostringstream res ;
typedef boost : : split_iterator < string : : const_iterator > string_split_iterator ;
for ( string_split_iterator it =
boost : : make_split_iterator ( buffer , boost : : first_finder ( " \n " , boost : : is_iequal ( ) ) ) ;
it ! = string_split_iterator ( ) ;
+ + it ) {
2008-03-30 23:50:51 +02:00
string line = boost : : copy_range < string > ( * it ) ;
if ( ! line . empty ( ) & &
2009-11-24 15:02:21 +01:00
line . find ( " defaultPeer = " ) = = line . npos & &
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
line . find ( " keyring = " ) = = line . npos & &
2008-03-30 23:50:51 +02:00
( ! boost : : starts_with ( line , " # " ) | |
isPropAssignment ( line . substr ( 2 ) ) ) ) {
res < < line < < endl ;
2008-03-30 13:43:36 +02:00
}
}
return res . str ( ) ;
}
2011-05-18 17:20:56 +02:00
static string removeComments ( const string & buffer )
{
ostringstream res ;
typedef boost : : split_iterator < string : : const_iterator > string_split_iterator ;
for ( string_split_iterator it =
boost : : make_split_iterator ( buffer , boost : : first_finder ( " \n " , boost : : is_iequal ( ) ) ) ;
it ! = string_split_iterator ( ) ;
+ + it ) {
string line = boost : : copy_range < string > ( * it ) ;
if ( ! line . empty ( ) & &
! boost : : starts_with ( line , " # " ) ) {
res < < line < < endl ;
}
}
return res . str ( ) ;
}
2009-11-19 16:30:46 +01:00
static string injectValues ( const string & buffer )
{
string res = buffer ;
2011-03-23 12:14:31 +01:00
#if 0
// username/password not set in templates, only in configs created
// via the command line - not anymore, but if it ever comes back,
// here's the place for it
2009-11-19 16:30:46 +01:00
boost : : replace_first ( res ,
" # username = " ,
" username = your SyncML server account name " ) ;
boost : : replace_first ( res ,
" # password = " ,
" password = your SyncML server password " ) ;
2011-03-23 12:14:31 +01:00
# endif
2009-11-19 16:30:46 +01:00
return res ;
}
2008-03-30 17:15:00 +02:00
// remove lines indented with spaces
static string filterIndented ( const string & buffer )
{
ostringstream res ;
bool first = true ;
typedef boost : : split_iterator < string : : const_iterator > string_split_iterator ;
for ( string_split_iterator it =
boost : : make_split_iterator ( buffer , boost : : first_finder ( " \n " , boost : : is_iequal ( ) ) ) ;
it ! = string_split_iterator ( ) ;
+ + it ) {
if ( ! boost : : starts_with ( * it , " " ) ) {
if ( ! first ) {
res < < endl ;
} else {
first = false ;
}
res < < * it ;
}
}
return res . str ( ) ;
}
2009-11-24 15:02:21 +01:00
// sort lines by file, preserving order inside each line
static void sortConfig ( string & config )
{
// file name, line number, property
typedef pair < string , pair < int , string > > line_t ;
vector < line_t > lines ;
typedef boost : : split_iterator < string : : iterator > string_split_iterator ;
int linenr = 0 ;
for ( string_split_iterator it =
boost : : make_split_iterator ( config , boost : : first_finder ( " \n " , boost : : is_iequal ( ) ) ) ;
it ! = string_split_iterator ( ) ;
+ + it , + + linenr ) {
string line ( it - > begin ( ) , it - > end ( ) ) ;
if ( line . empty ( ) ) {
continue ;
}
size_t colon = line . find ( ' : ' ) ;
string prefix = line . substr ( 0 , colon ) ;
lines . push_back ( make_pair ( prefix , make_pair ( linenr , line . substr ( colon ) ) ) ) ;
}
// stable sort because of line number
sort ( lines . begin ( ) , lines . end ( ) ) ;
size_t len = config . size ( ) ;
config . resize ( 0 ) ;
config . reserve ( len ) ;
BOOST_FOREACH ( const line_t & line , lines ) {
config + = line . first ;
config + = line . second . second ;
config + = " \n " ;
}
}
// convert the internal config dump to .ini style (--print-config)
2008-03-30 13:43:36 +02:00
static string internalToIni ( const string & config )
{
ostringstream res ;
string section ;
typedef boost : : split_iterator < string : : const_iterator > string_split_iterator ;
for ( string_split_iterator it =
boost : : make_split_iterator ( config , boost : : first_finder ( " \n " , boost : : is_iequal ( ) ) ) ;
it ! = string_split_iterator ( ) ;
+ + it ) {
string line ( it - > begin ( ) , it - > end ( ) ) ;
if ( line . empty ( ) ) {
continue ;
}
size_t colon = line . find ( ' : ' ) ;
string prefix = line . substr ( 0 , colon ) ;
2009-11-24 15:02:21 +01:00
// internal values are not part of the --print-config output
2008-03-30 18:13:08 +02:00
if ( boost : : contains ( prefix , " .internal.ini " ) | |
boost : : contains ( line , " = internal value " ) ) {
2008-03-30 13:43:36 +02:00
continue ;
}
2009-11-24 15:02:21 +01:00
// --print-config also doesn't duplicate the "type" property
// => remove the shared property
if ( boost : : contains ( line , " :type = " ) & &
boost : : starts_with ( line , " sources/ " ) ) {
continue ;
}
2008-03-30 18:13:08 +02:00
// sources/<name>/config.ini or
// spds/sources/<name>/config.ini
2008-03-30 17:15:00 +02:00
size_t endslash = prefix . rfind ( ' / ' ) ;
2008-03-30 18:13:08 +02:00
if ( endslash ! = line . npos & & endslash > 1 ) {
size_t slash = prefix . rfind ( ' / ' , endslash - 1 ) ;
if ( slash ! = line . npos ) {
string newsource = prefix . substr ( slash + 1 , endslash - slash - 1 ) ;
if ( newsource ! = section & &
2009-11-24 15:02:21 +01:00
prefix . find ( " /sources/ " ) ! = prefix . npos & &
2008-03-30 18:13:08 +02:00
newsource ! = " syncml " ) {
2009-11-24 15:02:21 +01:00
res < < " [ " < < newsource < < " ] " < < endl ;
2008-03-30 18:13:08 +02:00
section = newsource ;
}
2008-03-30 13:43:36 +02:00
}
}
string assignment = line . substr ( colon + 1 ) ;
// substitude aliases with generic values
2009-06-10 14:27:16 +02:00
boost : : replace_first ( assignment , " = syncml:auth-md5 " , " = md5 " ) ;
boost : : replace_first ( assignment , " = syncml:auth-basix " , " = basic " ) ;
2008-03-30 13:43:36 +02:00
res < < assignment < < endl ;
}
return res . str ( ) ;
}
2011-05-19 11:59:02 +02:00
/** result of removeComments(filterRandomUUID(filterConfig())) for Google Calendar template/config */
2014-07-25 14:02:29 +02:00
static const std : : string google =
" syncURL = https://apidata.googleusercontent.com/caldav/v2 https://www.googleapis.com/.well-known/carddav https://www.google.com/calendar/dav \n "
2011-06-22 17:45:19 +02:00
" printChanges = 0 \n "
" dumpData = 0 \n "
2011-05-19 11:59:02 +02:00
" deviceId = fixed-devid \n "
2014-07-25 14:02:29 +02:00
" IconURI = image://themedimage/icons/services/google \n "
2011-05-19 11:59:02 +02:00
" ConsumerReady = 1 \n "
" peerType = WebDAV \n "
2014-07-25 14:02:29 +02:00
" [addressbook] \n "
" sync = two-way \n "
" backend = CardDAV \n "
2011-05-19 11:59:02 +02:00
" [calendar] \n "
" sync = two-way \n "
" backend = CalDAV \n " ;
/** result of removeComments(filterRandomUUID(filterConfig())) for Yahoo Calendar + Contacts */
static const std : : string yahoo =
2011-06-22 17:45:19 +02:00
" printChanges = 0 \n "
" dumpData = 0 \n "
2011-05-19 11:59:02 +02:00
" deviceId = fixed-devid \n "
2011-07-12 18:30:02 +02:00
" IconURI = image://themedimage/icons/services/yahoo \n "
2011-05-19 11:59:02 +02:00
" ConsumerReady = 1 \n "
" peerType = WebDAV \n "
" [addressbook] \n "
" sync = disabled \n "
" backend = CardDAV \n "
" [calendar] \n "
" sync = two-way \n "
" backend = CalDAV \n " ;
2008-03-29 18:04:26 +01:00
2013-07-26 15:56:02 +02:00
// Expected content of config.ini file depends on whether
// a keyring is enabled or not.
static const char DATABASE_PASSWORD_BAR [ ] =
# ifdef HAVE_KEYRING
// In keyring.
" databasePassword = - "
# else
// In file.
" databasePassword = bar "
# endif
;
2008-03-28 23:32:00 +01:00
/**
* Testing is based on a text representation of a directory
* hierarchy where each line is of the format
* < file path > : < line in file >
*
* The order of files is alphabetical , of lines in the file as
* in the file . Lines in the file without line break cannot
* be represented .
*
* The root of the hierarchy is not part of the representation
* itself .
*/
2009-10-05 14:49:32 +02:00
class CmdlineTest : public CppUnit : : TestFixture {
CPPUNIT_TEST_SUITE ( CmdlineTest ) ;
2008-03-28 23:32:00 +01:00
CPPUNIT_TEST ( testFramework ) ;
2008-03-29 15:16:34 +01:00
CPPUNIT_TEST ( testSetupScheduleWorld ) ;
2011-01-10 15:56:53 +01:00
CPPUNIT_TEST ( testFutureConfig ) ;
CPPUNIT_TEST ( testPeerConfigMigration ) ;
CPPUNIT_TEST ( testContextConfigMigration ) ;
2008-03-29 18:26:23 +01:00
CPPUNIT_TEST ( testSetupDefault ) ;
CPPUNIT_TEST ( testSetupRenamed ) ;
2008-03-29 18:04:26 +01:00
CPPUNIT_TEST ( testSetupFunambol ) ;
CPPUNIT_TEST ( testSetupSynthesis ) ;
2008-03-29 18:26:23 +01:00
CPPUNIT_TEST ( testPrintServers ) ;
2009-12-01 16:36:33 +01:00
CPPUNIT_TEST ( testPrintFileTemplates ) ;
2010-05-03 21:41:36 +02:00
CPPUNIT_TEST ( testPrintFileTemplatesConfig ) ;
2008-03-29 18:04:26 +01:00
CPPUNIT_TEST ( testTemplate ) ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
CPPUNIT_TEST ( testMatchTemplate ) ;
2009-12-03 16:01:32 +01:00
CPPUNIT_TEST ( testAddSource ) ;
2008-03-30 11:02:07 +02:00
CPPUNIT_TEST ( testSync ) ;
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
CPPUNIT_TEST ( testKeyring ) ;
2011-05-19 11:59:02 +02:00
CPPUNIT_TEST ( testWebDAV ) ;
2008-03-30 15:41:56 +02:00
CPPUNIT_TEST ( testConfigure ) ;
2010-09-29 15:00:16 +02:00
CPPUNIT_TEST ( testConfigureSources ) ;
2008-03-30 18:13:08 +02:00
CPPUNIT_TEST ( testOldConfigure ) ;
2008-03-30 17:15:00 +02:00
CPPUNIT_TEST ( testMigrate ) ;
2011-02-14 14:08:40 +01:00
CPPUNIT_TEST ( testMigrateContext ) ;
2011-08-19 16:19:12 +02:00
CPPUNIT_TEST ( testMigrateAutoSync ) ;
2008-03-28 23:32:00 +01:00
CPPUNIT_TEST_SUITE_END ( ) ;
2008-03-29 15:16:34 +01:00
public :
2009-10-05 14:49:32 +02:00
CmdlineTest ( ) :
2011-01-10 15:56:53 +01:00
m_testDir ( " CmdlineTest " )
2009-07-17 16:21:25 +02:00
{
}
2008-03-28 23:32:00 +01:00
2011-05-18 16:12:15 +02:00
void setUp ( )
{
rm_r ( m_testDir ) ;
mkdir_p ( m_testDir ) ;
}
2008-03-28 23:32:00 +01:00
protected :
2008-03-29 15:16:34 +01:00
/** verify that createFiles/scanFiles themselves work */
2008-03-28 23:32:00 +01:00
void testFramework ( ) {
2008-03-29 15:16:34 +01:00
const string root ( m_testDir ) ;
2008-03-28 23:32:00 +01:00
const string content ( " baz:line \n "
2008-03-29 15:16:34 +01:00
" caz/subdir:booh \n "
2008-03-30 23:50:51 +02:00
" caz/subdir2/sub:# comment \n "
" caz/subdir2/sub:# foo = bar \n "
" caz/subdir2/sub:# empty = \n "
" caz/subdir2/sub:# another comment \n "
2008-03-28 23:32:00 +01:00
" foo:bar1 \n "
2008-03-30 23:50:51 +02:00
" foo: \n "
" foo: \n "
2008-03-28 23:32:00 +01:00
" foo:bar2 \n " ) ;
2008-03-30 23:50:51 +02:00
const string filtered ( " baz:line \n "
" caz/subdir:booh \n "
" caz/subdir2/sub:# foo = bar \n "
" caz/subdir2/sub:# empty = \n "
" foo:bar1 \n "
" foo: \n "
" foo:bar2 \n " ) ;
2008-03-28 23:32:00 +01:00
createFiles ( root , content ) ;
string res = scanFiles ( root ) ;
2008-03-30 23:50:51 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( filtered , res ) ;
2008-03-28 23:32:00 +01:00
}
2008-03-30 20:02:32 +02:00
void removeRandomUUID ( string & buffer ) {
2010-02-25 17:59:51 +01:00
string uuidstr = " deviceId = syncevolution- " ;
2008-03-30 20:02:32 +02:00
size_t uuid = buffer . find ( uuidstr ) ;
CPPUNIT_ASSERT ( uuid ! = buffer . npos ) ;
size_t end = buffer . find ( " \n " , uuid + uuidstr . size ( ) ) ;
CPPUNIT_ASSERT ( end ! = buffer . npos ) ;
buffer . replace ( uuid , end - uuid , " deviceId = fixed-devid " ) ;
}
2011-05-18 17:20:56 +02:00
string filterRandomUUID ( const string & buffer ) {
string copy = buffer ;
removeRandomUUID ( copy ) ;
return copy ;
}
2008-03-29 18:04:26 +01:00
/** create new configurations */
2009-11-24 15:02:21 +01:00
void testSetupScheduleWorld ( ) { doSetupScheduleWorld ( false ) ; }
void doSetupScheduleWorld ( bool shared ) {
2008-03-29 18:04:26 +01:00
string root ;
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-29 15:16:34 +01:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
2008-03-29 18:04:26 +01:00
root = m_testDir ;
2009-11-24 15:02:21 +01:00
root + = " /syncevolution/default " ;
string peer ;
if ( shared ) {
peer = root + " /peers/scheduleworld " ;
} else {
peer = root ;
}
2008-03-30 15:11:45 +02:00
{
2009-11-24 15:02:21 +01:00
rm_r ( peer ) ;
2008-03-30 15:11:45 +02:00
TestCmdline cmdline ( " --configure " ,
" --sync-property " , " proxyHost = proxy " ,
" scheduleworld " ,
" addressbook " ,
NULL ) ;
cmdline . doit ( ) ;
string res = scanFiles ( root ) ;
2008-03-30 20:02:32 +02:00
removeRandomUUID ( res ) ;
2009-04-07 20:33:18 +02:00
string expected = ScheduleWorldConfig ( ) ;
2009-11-24 15:02:21 +01:00
sortConfig ( expected ) ;
2008-03-30 15:11:45 +02:00
boost : : replace_first ( expected ,
2008-03-30 23:50:51 +02:00
" # proxyHost = " ,
2008-03-30 15:11:45 +02:00
" proxyHost = proxy " ) ;
boost : : replace_all ( expected ,
" sync = two-way " ,
" sync = disabled " ) ;
boost : : replace_first ( expected ,
" addressbook/config.ini:sync = disabled " ,
" addressbook/config.ini:sync = two-way " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
}
{
2009-11-24 15:02:21 +01:00
rm_r ( peer ) ;
2008-03-30 15:11:45 +02:00
TestCmdline cmdline ( " --configure " ,
2008-03-30 20:02:32 +02:00
" --sync-property " , " deviceID = fixed-devid " ,
2008-03-30 15:11:45 +02:00
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
string res = scanFiles ( root ) ;
2009-11-24 15:02:21 +01:00
string expected = ScheduleWorldConfig ( ) ;
sortConfig ( expected ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
2008-03-30 15:11:45 +02:00
}
2008-03-29 15:16:34 +01:00
}
2008-03-30 23:50:51 +02:00
2011-01-10 15:56:53 +01:00
void expectTooOld ( ) {
bool caught = false ;
try {
SyncConfig config ( " scheduleworld " ) ;
} catch ( const StatusException & ex ) {
caught = true ;
if ( ex . syncMLStatus ( ) ! = STATUS_RELEASE_TOO_OLD ) {
throw ;
} else {
CPPUNIT_ASSERT_EQUAL ( StringPrintf ( " SyncEvolution %s is too old to read configuration 'scheduleworld', please upgrade SyncEvolution. " , VERSION ) ,
string ( ex . what ( ) ) ) ;
}
}
CPPUNIT_ASSERT ( caught ) ;
}
void testFutureConfig ( ) {
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
doSetupScheduleWorld ( false ) ;
// bump min/cur version to something not supported, then
// try to read => should fail
IniFileConfigNode root ( m_testDir , " /syncevolution/.internal.ini " , false ) ;
IniFileConfigNode context ( m_testDir + " /syncevolution/default " , " .internal.ini " , false ) ;
IniFileConfigNode peer ( m_testDir + " /syncevolution/default/peers/scheduleworld " , " .internal.ini " , false ) ;
root . setProperty ( " rootMinVersion " , StringPrintf ( " %d " , CONFIG_ROOT_MIN_VERSION + 1 ) ) ;
root . setProperty ( " rootCurVersion " , StringPrintf ( " %d " , CONFIG_ROOT_CUR_VERSION + 1 ) ) ;
root . flush ( ) ;
context . setProperty ( " contextMinVersion " , StringPrintf ( " %d " , CONFIG_CONTEXT_MIN_VERSION + 1 ) ) ;
context . setProperty ( " contextCurVersion " , StringPrintf ( " %d " , CONFIG_CONTEXT_CUR_VERSION + 1 ) ) ;
context . flush ( ) ;
peer . setProperty ( " peerMinVersion " , StringPrintf ( " %d " , CONFIG_PEER_MIN_VERSION + 1 ) ) ;
peer . setProperty ( " peerCurVersion " , StringPrintf ( " %d " , CONFIG_PEER_CUR_VERSION + 1 ) ) ;
peer . flush ( ) ;
expectTooOld ( ) ;
root . setProperty ( " rootMinVersion " , StringPrintf ( " %d " , CONFIG_ROOT_MIN_VERSION ) ) ;
root . flush ( ) ;
expectTooOld ( ) ;
context . setProperty ( " contextMinVersion " , StringPrintf ( " %d " , CONFIG_CONTEXT_MIN_VERSION ) ) ;
context . flush ( ) ;
expectTooOld ( ) ;
// okay now
peer . setProperty ( " peerMinVersion " , StringPrintf ( " %d " , CONFIG_PEER_MIN_VERSION ) ) ;
peer . flush ( ) ;
SyncConfig config ( " scheduleworld " ) ;
}
void expectMigration ( const std : : string & config ) {
bool caught = false ;
try {
SyncConfig c ( config ) ;
c . prepareConfigForWrite ( ) ;
} catch ( const StatusException & ex ) {
caught = true ;
if ( ex . syncMLStatus ( ) ! = STATUS_MIGRATION_NEEDED ) {
throw ;
} else {
CPPUNIT_ASSERT_EQUAL ( StringPrintf ( " Proceeding would modify config '%s' such that the "
" previous SyncEvolution release will not be able to use it. "
" Stopping now. Please explicitly acknowledge this step by "
" running the following command on the command line: "
" syncevolution --migrate '%s' " ,
config . c_str ( ) ,
config . c_str ( ) ) ,
string ( ex . what ( ) ) ) ;
}
}
CPPUNIT_ASSERT ( caught ) ;
}
void testPeerConfigMigration ( ) {
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
doSetupScheduleWorld ( false ) ;
// decrease min/cur version to something no longer supported,
// then try to write => should migrate in release mode and fail otherwise
IniFileConfigNode peer ( m_testDir + " /syncevolution/default/peers/scheduleworld " , " .internal.ini " , false ) ;
peer . setProperty ( " peerMinVersion " , StringPrintf ( " %d " , CONFIG_PEER_CUR_VERSION - 1 ) ) ;
peer . setProperty ( " peerCurVersion " , StringPrintf ( " %d " , CONFIG_PEER_CUR_VERSION - 1 ) ) ;
peer . flush ( ) ;
SyncContext : : setStableRelease ( false ) ;
expectMigration ( " scheduleworld " ) ;
SyncContext : : setStableRelease ( true ) ;
{
SyncConfig config ( " scheduleworld " ) ;
config . prepareConfigForWrite ( ) ;
}
{
TestCmdline cmdline ( " --print-servers " , NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " Configured servers: \n "
" scheduleworld = CmdlineTest/syncevolution/default/peers/scheduleworld \n "
" scheduleworld.old = CmdlineTest/syncevolution/default/peers/scheduleworld.old \n " ,
cmdline . m_out . str ( ) ) ;
}
// should be okay now
SyncContext : : setStableRelease ( false ) ;
{
SyncConfig config ( " scheduleworld " ) ;
config . prepareConfigForWrite ( ) ;
}
// do the same migration with command line
SyncContext : : setStableRelease ( false ) ;
rm_r ( m_testDir + " /syncevolution/default/peers/scheduleworld " ) ;
CPPUNIT_ASSERT_EQUAL ( 0 , rename ( ( m_testDir + " /syncevolution/default/peers/scheduleworld.old " ) . c_str ( ) ,
( m_testDir + " /syncevolution/default/peers/scheduleworld " ) . c_str ( ) ) ) ;
{
TestCmdline cmdline ( " --migrate " , " scheduleworld " , NULL ) ;
cmdline . doit ( ) ;
}
{
SyncConfig config ( " scheduleworld " ) ;
config . prepareConfigForWrite ( ) ;
}
{
TestCmdline cmdline ( " --print-servers " , NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " Configured servers: \n "
" scheduleworld = CmdlineTest/syncevolution/default/peers/scheduleworld \n "
" scheduleworld.old = CmdlineTest/syncevolution/default/peers/scheduleworld.old \n " ,
cmdline . m_out . str ( ) ) ;
}
}
void testContextConfigMigration ( ) {
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
doSetupScheduleWorld ( false ) ;
// decrease min/cur version to something no longer supported,
// then try to write => should migrate in release mode and fail otherwise
IniFileConfigNode context ( m_testDir + " /syncevolution/default " , " .internal.ini " , false ) ;
context . setProperty ( " contextMinVersion " , StringPrintf ( " %d " , CONFIG_CONTEXT_CUR_VERSION - 1 ) ) ;
context . setProperty ( " contextCurVersion " , StringPrintf ( " %d " , CONFIG_CONTEXT_CUR_VERSION - 1 ) ) ;
context . flush ( ) ;
SyncContext : : setStableRelease ( false ) ;
expectMigration ( " @default " ) ;
SyncContext : : setStableRelease ( true ) ;
{
SyncConfig config ( " @default " ) ;
config . prepareConfigForWrite ( ) ;
}
{
TestCmdline cmdline ( " --print-servers " , NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " Configured servers: \n "
" scheduleworld = CmdlineTest/syncevolution/default/peers/scheduleworld \n "
2011-02-01 22:14:22 +01:00
" scheduleworld.old@default.old = CmdlineTest/syncevolution/default.old/peers/scheduleworld.old \n " ,
2011-01-10 15:56:53 +01:00
cmdline . m_out . str ( ) ) ;
}
// should be okay now
SyncContext : : setStableRelease ( false ) ;
{
SyncConfig config ( " @default " ) ;
config . prepareConfigForWrite ( ) ;
}
// do the same migration with command line
SyncContext : : setStableRelease ( false ) ;
2011-02-01 22:14:22 +01:00
rm_r ( m_testDir + " /syncevolution/default " ) ;
CPPUNIT_ASSERT_EQUAL ( 0 , rename ( ( m_testDir + " /syncevolution/default.old/peers/scheduleworld.old " ) . c_str ( ) ,
( m_testDir + " /syncevolution/default.old/peers/scheduleworld " ) . c_str ( ) ) ) ;
CPPUNIT_ASSERT_EQUAL ( 0 , rename ( ( m_testDir + " /syncevolution/default.old " ) . c_str ( ) ,
( m_testDir + " /syncevolution/default " ) . c_str ( ) ) ) ;
2011-01-10 15:56:53 +01:00
{
TestCmdline cmdline ( " --migrate " , " @default " , NULL ) ;
cmdline . doit ( ) ;
}
{
SyncConfig config ( " @default " ) ;
config . prepareConfigForWrite ( ) ;
}
{
TestCmdline cmdline ( " --print-servers " , NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " Configured servers: \n "
" scheduleworld = CmdlineTest/syncevolution/default/peers/scheduleworld \n "
2011-02-01 22:14:22 +01:00
" scheduleworld.old@default.old = CmdlineTest/syncevolution/default.old/peers/scheduleworld.old \n " ,
2011-01-10 15:56:53 +01:00
cmdline . m_out . str ( ) ) ;
}
}
2008-03-29 18:26:23 +01:00
void testSetupDefault ( ) {
string root ;
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-29 18:26:23 +01:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
root = m_testDir ;
2009-11-24 15:02:21 +01:00
root + = " /syncevolution/default " ;
2008-03-29 18:26:23 +01:00
TestCmdline cmdline ( " --configure " ,
" --template " , " default " ,
2008-03-30 20:02:32 +02:00
" --sync-property " , " deviceID = fixed-devid " ,
2008-03-29 18:26:23 +01:00
" some-other-server " ,
NULL ) ;
cmdline . doit ( ) ;
2009-11-24 15:02:21 +01:00
string res = scanFiles ( root , " some-other-server " ) ;
2011-11-17 14:30:15 +01:00
string expected = DefaultConfig ( ) ;
2009-11-24 15:02:21 +01:00
sortConfig ( expected ) ;
2011-11-17 14:30:15 +01:00
boost : : replace_all ( expected , " /syncevolution/ " , " /some-other-server/ " ) ;
2009-11-24 15:02:21 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
2008-03-29 18:26:23 +01:00
}
2011-01-10 15:56:53 +01:00
2008-03-29 18:26:23 +01:00
void testSetupRenamed ( ) {
string root ;
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-29 18:26:23 +01:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
root = m_testDir ;
2011-02-01 15:25:01 +01:00
root + = " /syncevolution/default " ;
2008-03-29 18:26:23 +01:00
TestCmdline cmdline ( " --configure " ,
" --template " , " scheduleworld " ,
2008-03-30 20:02:32 +02:00
" --sync-property " , " deviceID = fixed-devid " ,
2008-03-29 18:26:23 +01:00
" scheduleworld2 " ,
NULL ) ;
cmdline . doit ( ) ;
2009-11-24 15:02:21 +01:00
string res = scanFiles ( root , " scheduleworld2 " ) ;
string expected = ScheduleWorldConfig ( ) ;
sortConfig ( expected ) ;
boost : : replace_all ( expected , " /scheduleworld/ " , " /scheduleworld2/ " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
2008-03-29 18:26:23 +01:00
}
2009-11-24 15:02:21 +01:00
void testSetupFunambol ( ) { doSetupFunambol ( false ) ; }
void doSetupFunambol ( bool shared ) {
2008-03-29 18:04:26 +01:00
string root ;
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-29 18:04:26 +01:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
root = m_testDir ;
2009-11-24 15:02:21 +01:00
root + = " /syncevolution/default " ;
string peer ;
if ( shared ) {
peer = root + " /peers/funambol " ;
} else {
peer = root ;
}
rm_r ( peer ) ;
2009-11-24 19:26:58 +01:00
const char * const argv_fixed [ ] = {
" --configure " ,
" --sync-property " , " deviceID = fixed-devid " ,
// templates are case-insensitive
" FunamBOL " ,
NULL
} , * const argv_shared [ ] = {
" --configure " ,
" FunamBOL " ,
NULL
} ;
TestCmdline cmdline ( shared ? argv_shared : argv_fixed ) ;
2008-03-29 18:04:26 +01:00
cmdline . doit ( ) ;
2009-11-24 15:02:21 +01:00
string res = scanFiles ( root , " funambol " ) ;
string expected = FunambolConfig ( ) ;
sortConfig ( expected ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
2008-03-29 18:04:26 +01:00
}
2009-11-24 15:02:21 +01:00
void testSetupSynthesis ( ) { doSetupSynthesis ( false ) ; }
void doSetupSynthesis ( bool shared ) {
2008-03-29 18:04:26 +01:00
string root ;
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-29 18:04:26 +01:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
root = m_testDir ;
2009-11-24 15:02:21 +01:00
root + = " /syncevolution/default " ;
string peer ;
if ( shared ) {
peer = root + " /peers/synthesis " ;
} else {
peer = root ;
}
rm_r ( peer ) ;
2009-11-24 19:26:58 +01:00
const char * const argv_fixed [ ] = {
" --configure " ,
" --sync-property " , " deviceID = fixed-devid " ,
" synthesis " ,
NULL
} , * const argv_shared [ ] = {
" --configure " ,
" synthesis " ,
NULL
} ;
TestCmdline cmdline ( shared ? argv_shared : argv_fixed ) ;
2008-03-29 18:04:26 +01:00
cmdline . doit ( ) ;
2009-11-24 15:02:21 +01:00
string res = scanFiles ( root , " synthesis " ) ;
string expected = SynthesisConfig ( ) ;
sortConfig ( expected ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
2008-03-29 18:04:26 +01:00
}
void testTemplate ( ) {
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
2008-03-29 18:04:26 +01:00
TestCmdline failure ( " --template " , NULL ) ;
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
2008-03-29 18:04:26 +01:00
CPPUNIT_ASSERT ( ! failure . m_cmdline - > parse ( ) ) ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
CPPUNIT_ASSERT_NO_THROW ( failure . expectUsageError ( " [ERROR] missing parameter for '--template' \n " ) ) ;
2008-03-29 18:04:26 +01:00
2008-03-30 15:11:45 +02:00
TestCmdline help ( " --template " , " ? " , NULL ) ;
2008-03-29 18:04:26 +01:00
help . doit ( ) ;
2011-04-20 22:02:54 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " Available configuration templates (servers): \n "
2010-03-03 09:24:58 +01:00
" template name = template description \n "
2011-04-15 08:15:19 +02:00
" eGroupware = http://www.egroupware.org \n "
2014-05-16 09:32:58 +02:00
" Funambol = https://onemediahub.com \n "
2014-07-25 14:02:29 +02:00
" Google = event and contact sync via CalDAV/CardDAV, use for the 'target-config@google' config \n "
2010-01-18 10:07:18 +01:00
" Goosync = http://www.goosync.com/ \n "
2009-04-08 16:32:05 +02:00
" Memotoo = http://www.memotoo.com \n "
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
" Mobical = https://www.everdroid.com \n "
2009-10-29 16:13:31 +01:00
" Oracle = http://www.oracle.com/technology/products/beehive/index.html \n "
2010-02-09 04:03:20 +01:00
" Ovi = http://www.ovi.com \n "
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
" ScheduleWorld = server no longer in operation \n "
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
" SyncEvolution = http://www.syncevolution.org \n "
2011-05-18 17:20:56 +02:00
" Synthesis = http://www.synthesis.ch \n "
2011-07-06 19:38:14 +02:00
" WebDAV = contact and event sync using WebDAV, use for the 'target-config@<server>' config \n "
2011-06-29 03:42:43 +02:00
" Yahoo = contact and event sync using WebDAV, use for the 'target-config@yahoo' config \n " ,
2008-03-29 18:04:26 +01:00
help . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , help . m_err . str ( ) ) ;
}
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
void testMatchTemplate ( ) {
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " testcases/templates " ) ;
2010-05-03 21:41:36 +02:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , " /dev/null " ) ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
2010-03-19 06:19:53 +01:00
TestCmdline help1 ( " --template " , " ?nokia 7210c " , NULL ) ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
help1 . doit ( ) ;
2011-04-20 22:02:54 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " Available configuration templates (clients): \n "
2010-03-04 03:26:03 +01:00
" template name = template description matching score in percent (100% = exact match) \n "
2011-04-20 18:15:07 +02:00
" Nokia_7210c = Template for Nokia S40 series Phone 100% \n "
" SyncEvolution_Client = SyncEvolution server side template 40% \n " ,
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
help1 . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , help1 . m_err . str ( ) ) ;
TestCmdline help2 ( " --template " , " ?nokia " , NULL ) ;
help2 . doit ( ) ;
2011-04-20 22:02:54 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " Available configuration templates (clients): \n "
2010-03-04 03:26:03 +01:00
" template name = template description matching score in percent (100% = exact match) \n "
2011-04-20 18:15:07 +02:00
" Nokia_7210c = Template for Nokia S40 series Phone 100% \n "
" SyncEvolution_Client = SyncEvolution server side template 40% \n " ,
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
help2 . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , help2 . m_err . str ( ) ) ;
TestCmdline help3 ( " --template " , " ?7210c " , NULL ) ;
help3 . doit ( ) ;
2011-04-20 22:02:54 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " Available configuration templates (clients): \n "
2010-03-04 03:26:03 +01:00
" template name = template description matching score in percent (100% = exact match) \n "
2011-04-20 18:15:07 +02:00
" Nokia_7210c = Template for Nokia S40 series Phone 60% \n "
" SyncEvolution_Client = SyncEvolution server side template 20% \n " ,
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
help3 . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , help3 . m_err . str ( ) ) ;
2010-03-19 06:19:53 +01:00
TestCmdline help4 ( " --template " , " ?syncevolution client " , NULL ) ;
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
help4 . doit ( ) ;
2011-04-20 22:02:54 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " Available configuration templates (clients): \n "
2010-03-04 03:26:03 +01:00
" template name = template description matching score in percent (100% = exact match) \n "
2011-04-20 18:15:07 +02:00
" SyncEvolution_Client = SyncEvolution server side template 100% \n "
" Nokia_7210c = Template for Nokia S40 series Phone 40% \n " ,
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
help4 . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , help4 . m_err . str ( ) ) ;
}
2008-03-29 18:26:23 +01:00
void testPrintServers ( ) {
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-29 18:26:23 +01:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
2009-11-24 15:02:21 +01:00
doSetupScheduleWorld ( false ) ;
doSetupSynthesis ( true ) ;
doSetupFunambol ( true ) ;
2008-03-29 18:26:23 +01:00
TestCmdline cmdline ( " --print-servers " , NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " Configured servers: \n "
2009-11-24 15:02:21 +01:00
" funambol = CmdlineTest/syncevolution/default/peers/funambol \n "
" scheduleworld = CmdlineTest/syncevolution/default/peers/scheduleworld \n "
" synthesis = CmdlineTest/syncevolution/default/peers/synthesis \n " ,
2008-03-29 18:26:23 +01:00
cmdline . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
}
2009-12-01 16:36:33 +01:00
void testPrintFileTemplates ( ) {
// use local copy of templates in build dir (no need to install)
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " ./templates " ) ;
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
2010-05-03 21:41:36 +02:00
doPrintFileTemplates ( ) ;
}
void testPrintFileTemplatesConfig ( ) {
2011-05-18 17:20:56 +02:00
// simulate reading templates from user's XDG HOME
2014-07-22 13:59:25 +02:00
CPPUNIT_ASSERT ( ! symlink ( " ../templates " , ( m_testDir + " /syncevolution-templates " ) . c_str ( ) ) ) ;
2011-05-18 17:20:56 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " /dev/null " ) ;
2010-05-03 21:41:36 +02:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
doPrintFileTemplates ( ) ;
}
void doPrintFileTemplates ( ) {
2011-05-18 17:20:56 +02:00
// Compare only the properties which are really set.
//
// note that "backend" will be take from the @default context if one
// exists, so run this before setting up Funambol below
{
2014-07-25 14:02:29 +02:00
TestCmdline cmdline ( " --print-config " , " --template " , " google " , NULL ) ;
2011-05-18 17:20:56 +02:00
cmdline . doit ( ) ;
2014-07-25 14:02:29 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( google ,
2011-05-18 17:20:56 +02:00
removeComments ( filterRandomUUID ( filterConfig ( cmdline . m_out . str ( ) ) ) ) ) ;
}
{
TestCmdline cmdline ( " --print-config " , " --template " , " yahoo " , NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( yahoo ,
removeComments ( filterRandomUUID ( filterConfig ( cmdline . m_out . str ( ) ) ) ) ) ;
}
2009-12-01 16:36:33 +01:00
testSetupFunambol ( ) ;
{
TestCmdline cmdline ( " --print-config " , " --template " , " scheduleworld " , NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
string actual = cmdline . m_out . str ( ) ;
// deviceId must be the one from Funambol
CPPUNIT_ASSERT ( boost : : contains ( actual , " deviceId = fixed-devid " ) ) ;
string filtered = injectValues ( filterConfig ( actual ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( filterConfig ( internalToIni ( ScheduleWorldConfig ( ) ) ) ,
filtered ) ;
// there should have been comments
CPPUNIT_ASSERT ( actual . size ( ) > filtered . size ( ) ) ;
}
{
TestCmdline cmdline ( " --print-config " , " funambol " , NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( filterConfig ( internalToIni ( FunambolConfig ( ) ) ) ,
injectValues ( filterConfig ( cmdline . m_out . str ( ) ) ) ) ;
}
}
2009-12-03 16:01:32 +01:00
void testAddSource ( ) {
string root ;
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2009-12-03 16:01:32 +01:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
testSetupScheduleWorld ( ) ;
root = m_testDir ;
root + = " /syncevolution/default " ;
{
TestCmdline cmdline ( " --configure " ,
2014-07-28 15:29:41 +02:00
// Intentionally use legacy parameter name here.
" --datastore-property " , " uri = dummy " ,
2009-12-03 16:01:32 +01:00
" scheduleworld " ,
" xyz " ,
NULL ) ;
cmdline . doit ( ) ;
string res = scanFiles ( root ) ;
string expected = ScheduleWorldConfig ( ) ;
expected + = " \n "
" peers/scheduleworld/sources/xyz/.internal.ini:# adminData = \n "
2010-02-15 16:50:06 +01:00
" peers/scheduleworld/sources/xyz/.internal.ini:# synthesisID = 0 \n "
2010-01-29 21:16:00 +01:00
" peers/scheduleworld/sources/xyz/config.ini:# sync = disabled \n "
2009-12-03 16:01:32 +01:00
" peers/scheduleworld/sources/xyz/config.ini:uri = dummy \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" peers/scheduleworld/sources/xyz/config.ini:# syncFormat = \n "
" peers/scheduleworld/sources/xyz/config.ini:# forceSyncFormat = 0 \n "
" sources/xyz/config.ini:# backend = select backend \n "
2011-01-18 15:33:07 +01:00
" sources/xyz/config.ini:# database = \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" sources/xyz/config.ini:# databaseFormat = \n "
2011-01-18 15:33:07 +01:00
" sources/xyz/config.ini:# databaseUser = \n "
" sources/xyz/config.ini:# databasePassword = " ;
2009-12-03 16:01:32 +01:00
sortConfig ( expected ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
}
}
2009-12-01 16:36:33 +01:00
2008-03-30 11:02:07 +02:00
void testSync ( ) {
TestCmdline failure ( " --sync " , NULL ) ;
CPPUNIT_ASSERT ( ! failure . m_cmdline - > parse ( ) ) ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
CPPUNIT_ASSERT_NO_THROW ( failure . expectUsageError ( " [ERROR] missing parameter for '--sync' \n " ) ) ;
2008-03-30 11:02:07 +02:00
TestCmdline failure2 ( " --sync " , " foo " , NULL ) ;
CPPUNIT_ASSERT ( ! failure2 . m_cmdline - > parse ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , failure2 . m_out . str ( ) ) ;
engine: local cache sync mode
This patch introduces support for true one-way syncing ("caching"):
the local datastore is meant to be an exact copy of the data on the
remote side. The assumption is that no modifications are ever made
locally outside of syncing. This is different from one-way sync modes,
which allows local changes and only temporarily disables sending them
to the remote side.
Another goal of the new mode is to avoid data writes as much as
possible.
This new mode only works on the server side of a sync, where the
engine has enough control over the data flow.
Most of the changes are in libsynthesis. SyncEvolution only needs to
enable the new mode, which is done via an extension of the "sync"
property:
- "local-cache-incremental" will do an incremental sync (if possible)
or a slow sync (otherwise). This is usually the right mode to use,
and thus has "local-cache" as alias.
- "local-cache-slow" will always do a slow sync. Useful for
debugging or after (accidentally) making changes on the server side.
An incremental sync will ignore such changes because they are not
meant to happen and thus leave client and sync out-of-sync!
Both modes are recorded in the sync report of the local side. The
target side is the client and records the normal "two-way" or "slow"
sync modes.
With the current SyncEvolution contact field list, first, middle and
last name are used to find matches during any kind of slow sync. The
organization field is ignored for matching during the initial slow
sync and used in all following ones. That's okay, the difference won't
matter in practice because the initial slow sync in PBAP caching will
be done with no local data. The test achieve the same result in both
cases by keeping the organization set in the reduced data set.
It's also okay to include the property in the comparison, because it
might help to distinguish between "John Doe" in different companies.
It might be worthwhile to add more fields as match criteria, for
example the birthday. Currently they are excluded, probably because
they are not trusted to be supported by SyncML peers. In caching mode
the situation is different, because all our data came from the peer.
The downside is that in cases where matching has to be done all the
time because change detection is not supported (PBAP), including the
birthday as criteria will cause unnecessary contact removed/added
events (and thus disk IO) when a contact was originally created
without birthday locally and then a birthday gets added on the phone.
Testing is done as part of the D-Bus testing framework, because usually
this functionality will be used as part of the D-Bus server and writing
tests in Python is easier.
A new test class "TestLocalCache" contains the new tests. They include
tests for removing extra items during a slow sync (testItemRemoval),
adding new client items under various conditions (testItemAdd*) and
updating/removing an item during incremental syncing
(testItemUpdate/Delete*). Doing these changes during a slow sync could
also be tested (not currently covered).
The tests for removing properties (testPropertyRemoval*) cover
removing almost all contact properties during an initial slow sync, a
second slow sync (which is treated differently in libsynthesis, see
merge=always and merge=slowsync), and an incremental sync.
2012-08-23 14:25:55 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " [ERROR] '--sync foo': not one of the valid values (two-way, slow, refresh-from-local, refresh-from-remote = refresh, one-way-from-local, one-way-from-remote = one-way, refresh-from-client = refresh-client, refresh-from-server = refresh-server, one-way-from-client = one-way-client, one-way-from-server = one-way-server, local-cache-slow, local-cache-incremental = local-cache, disabled = none) \n " , failure2 . m_err . str ( ) ) ;
2008-03-30 11:02:07 +02:00
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
TestCmdline failure3 ( " --sync=foo " , NULL ) ;
CPPUNIT_ASSERT ( ! failure3 . m_cmdline - > parse ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , failure3 . m_out . str ( ) ) ;
engine: local cache sync mode
This patch introduces support for true one-way syncing ("caching"):
the local datastore is meant to be an exact copy of the data on the
remote side. The assumption is that no modifications are ever made
locally outside of syncing. This is different from one-way sync modes,
which allows local changes and only temporarily disables sending them
to the remote side.
Another goal of the new mode is to avoid data writes as much as
possible.
This new mode only works on the server side of a sync, where the
engine has enough control over the data flow.
Most of the changes are in libsynthesis. SyncEvolution only needs to
enable the new mode, which is done via an extension of the "sync"
property:
- "local-cache-incremental" will do an incremental sync (if possible)
or a slow sync (otherwise). This is usually the right mode to use,
and thus has "local-cache" as alias.
- "local-cache-slow" will always do a slow sync. Useful for
debugging or after (accidentally) making changes on the server side.
An incremental sync will ignore such changes because they are not
meant to happen and thus leave client and sync out-of-sync!
Both modes are recorded in the sync report of the local side. The
target side is the client and records the normal "two-way" or "slow"
sync modes.
With the current SyncEvolution contact field list, first, middle and
last name are used to find matches during any kind of slow sync. The
organization field is ignored for matching during the initial slow
sync and used in all following ones. That's okay, the difference won't
matter in practice because the initial slow sync in PBAP caching will
be done with no local data. The test achieve the same result in both
cases by keeping the organization set in the reduced data set.
It's also okay to include the property in the comparison, because it
might help to distinguish between "John Doe" in different companies.
It might be worthwhile to add more fields as match criteria, for
example the birthday. Currently they are excluded, probably because
they are not trusted to be supported by SyncML peers. In caching mode
the situation is different, because all our data came from the peer.
The downside is that in cases where matching has to be done all the
time because change detection is not supported (PBAP), including the
birthday as criteria will cause unnecessary contact removed/added
events (and thus disk IO) when a contact was originally created
without birthday locally and then a birthday gets added on the phone.
Testing is done as part of the D-Bus testing framework, because usually
this functionality will be used as part of the D-Bus server and writing
tests in Python is easier.
A new test class "TestLocalCache" contains the new tests. They include
tests for removing extra items during a slow sync (testItemRemoval),
adding new client items under various conditions (testItemAdd*) and
updating/removing an item during incremental syncing
(testItemUpdate/Delete*). Doing these changes during a slow sync could
also be tested (not currently covered).
The tests for removing properties (testPropertyRemoval*) cover
removing almost all contact properties during an initial slow sync, a
second slow sync (which is treated differently in libsynthesis, see
merge=always and merge=slowsync), and an incremental sync.
2012-08-23 14:25:55 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " [ERROR] '--sync=foo': not one of the valid values (two-way, slow, refresh-from-local, refresh-from-remote = refresh, one-way-from-local, one-way-from-remote = one-way, refresh-from-client = refresh-client, refresh-from-server = refresh-server, one-way-from-client = one-way-client, one-way-from-server = one-way-server, local-cache-slow, local-cache-incremental = local-cache, disabled = none) \n " , failure3 . m_err . str ( ) ) ;
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
2008-03-30 15:11:45 +02:00
TestCmdline help ( " --sync " , " ? " , NULL ) ;
2008-03-30 11:02:07 +02:00
help . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " --sync \n "
2010-09-09 11:38:05 +02:00
" Requests a certain synchronization mode when initiating a sync: \n "
2011-10-26 09:13:16 +02:00
" \n "
" two-way \n "
" only send/receive changes since last sync \n "
" slow \n "
" exchange all items \n "
2011-10-24 19:52:01 +02:00
" refresh-from-remote \n "
" discard all local items and replace with \n "
" the items on the peer \n "
" refresh-from-local \n "
" discard all items on the peer and replace \n "
" with the local items \n "
" one-way-from-remote \n "
" transmit changes from peer \n "
" one-way-from-local \n "
" transmit local changes \n "
engine: local cache sync mode
This patch introduces support for true one-way syncing ("caching"):
the local datastore is meant to be an exact copy of the data on the
remote side. The assumption is that no modifications are ever made
locally outside of syncing. This is different from one-way sync modes,
which allows local changes and only temporarily disables sending them
to the remote side.
Another goal of the new mode is to avoid data writes as much as
possible.
This new mode only works on the server side of a sync, where the
engine has enough control over the data flow.
Most of the changes are in libsynthesis. SyncEvolution only needs to
enable the new mode, which is done via an extension of the "sync"
property:
- "local-cache-incremental" will do an incremental sync (if possible)
or a slow sync (otherwise). This is usually the right mode to use,
and thus has "local-cache" as alias.
- "local-cache-slow" will always do a slow sync. Useful for
debugging or after (accidentally) making changes on the server side.
An incremental sync will ignore such changes because they are not
meant to happen and thus leave client and sync out-of-sync!
Both modes are recorded in the sync report of the local side. The
target side is the client and records the normal "two-way" or "slow"
sync modes.
With the current SyncEvolution contact field list, first, middle and
last name are used to find matches during any kind of slow sync. The
organization field is ignored for matching during the initial slow
sync and used in all following ones. That's okay, the difference won't
matter in practice because the initial slow sync in PBAP caching will
be done with no local data. The test achieve the same result in both
cases by keeping the organization set in the reduced data set.
It's also okay to include the property in the comparison, because it
might help to distinguish between "John Doe" in different companies.
It might be worthwhile to add more fields as match criteria, for
example the birthday. Currently they are excluded, probably because
they are not trusted to be supported by SyncML peers. In caching mode
the situation is different, because all our data came from the peer.
The downside is that in cases where matching has to be done all the
time because change detection is not supported (PBAP), including the
birthday as criteria will cause unnecessary contact removed/added
events (and thus disk IO) when a contact was originally created
without birthday locally and then a birthday gets added on the phone.
Testing is done as part of the D-Bus testing framework, because usually
this functionality will be used as part of the D-Bus server and writing
tests in Python is easier.
A new test class "TestLocalCache" contains the new tests. They include
tests for removing extra items during a slow sync (testItemRemoval),
adding new client items under various conditions (testItemAdd*) and
updating/removing an item during incremental syncing
(testItemUpdate/Delete*). Doing these changes during a slow sync could
also be tested (not currently covered).
The tests for removing properties (testPropertyRemoval*) cover
removing almost all contact properties during an initial slow sync, a
second slow sync (which is treated differently in libsynthesis, see
merge=always and merge=slowsync), and an incremental sync.
2012-08-23 14:25:55 +02:00
" local-cache-slow (server only) \n "
" mirror remote data locally, transferring all data \n "
" local-cache-incremental (server only) \n "
" mirror remote data locally, transferring only changes; \n "
" falls back to local-cache-slow automatically if necessary \n "
" disabled (or none) \n "
2011-10-26 09:13:16 +02:00
" synchronization disabled \n "
" \n "
2011-10-24 19:52:01 +02:00
" refresh/one-way-from-server/client are also supported. Their use is \n "
" discouraged because the direction of the data transfer depends \n "
" on the role of the local side (can be server or client), which is \n "
" not always obvious. \n "
2011-10-26 09:13:16 +02:00
" \n "
2010-09-09 11:38:05 +02:00
" When accepting a sync session in a SyncML server (HTTP server), only \n "
2014-07-28 15:29:41 +02:00
" datastores with sync != disabled are made available to the client, \n "
2010-09-09 11:38:05 +02:00
" which chooses the final sync mode based on its own configuration. \n "
" When accepting a sync session in a SyncML client (local sync with \n "
" the server contacting SyncEvolution on a device), the sync mode \n "
" specified in the client is typically overriden by the server. \n " ,
2008-03-30 11:02:07 +02:00
help . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , help . m_err . str ( ) ) ;
TestCmdline filter ( " --sync " , " refresh-from-server " , NULL ) ;
CPPUNIT_ASSERT ( filter . m_cmdline - > parse ( ) ) ;
CPPUNIT_ASSERT ( ! filter . m_cmdline - > run ( ) ) ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
CPPUNIT_ASSERT_NO_THROW ( filter . expectUsageError ( " [ERROR] No configuration name specified. \n " ) ) ;
2008-03-30 11:02:07 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " sync = refresh-from-server " ,
2011-01-25 11:11:53 +01:00
string ( filter . m_cmdline - > m_props [ " " ] . m_sourceProps [ " " ] ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , string ( filter . m_cmdline - > m_props [ " " ] . m_syncProps ) ) ;
2008-03-30 11:02:07 +02:00
2014-07-28 15:29:41 +02:00
TestCmdline filter2 ( " --datastore-property " , " sync=refresh " , NULL ) ;
2008-03-30 11:02:07 +02:00
CPPUNIT_ASSERT ( filter2 . m_cmdline - > parse ( ) ) ;
CPPUNIT_ASSERT ( ! filter2 . m_cmdline - > run ( ) ) ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
CPPUNIT_ASSERT_NO_THROW ( filter2 . expectUsageError ( " [ERROR] No configuration name specified. \n " ) ) ;
2008-03-30 11:02:07 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " sync = refresh " ,
2011-01-25 11:11:53 +01:00
string ( filter2 . m_cmdline - > m_props [ " " ] . m_sourceProps [ " " ] ) ) ;
2008-03-30 11:02:07 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " " ,
2011-01-25 11:11:53 +01:00
string ( filter2 . m_cmdline - > m_props [ " " ] . m_syncProps ) ) ;
2012-04-11 10:58:51 +02:00
2014-07-28 15:29:41 +02:00
TestCmdline filter3 ( " --datastore-property " , " xyz=1 " , NULL ) ;
2012-04-11 10:58:51 +02:00
CPPUNIT_ASSERT ( ! filter3 . m_cmdline - > parse ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( string ( " " ) , filter3 . m_out . str ( ) ) ;
2014-07-28 15:29:41 +02:00
CPPUNIT_ASSERT_EQUAL ( string ( " [ERROR] '--datastore-property xyz=1': no such property \n " ) , filter3 . m_err . str ( ) ) ;
2012-04-11 10:58:51 +02:00
TestCmdline filter4 ( " xyz=1 " , NULL ) ;
CPPUNIT_ASSERT ( ! filter4 . m_cmdline - > parse ( ) ) ;
CPPUNIT_ASSERT_NO_THROW ( filter4 . expectUsageError ( " [ERROR] unrecognized property in 'xyz=1' \n " ) ) ;
TestCmdline filter5 ( " =1 " , NULL ) ;
CPPUNIT_ASSERT ( ! filter5 . m_cmdline - > parse ( ) ) ;
CPPUNIT_ASSERT_NO_THROW ( filter5 . expectUsageError ( " [ERROR] a property name must be given in '=1' \n " ) ) ;
2008-03-30 11:02:07 +02:00
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
void testKeyring ( ) {
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
rm_r ( m_testDir ) ;
{
TestCmdline cmdline ( NULL , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( false , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --keyring " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --sync-property " , " keyring=True " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " keyring=True " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --keyring=true " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --keyring=1 " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --keyring=Yes " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --keyring=false " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_FALSE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --keyring=0 " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_FALSE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --keyring=NO " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_FALSE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --keyring=GNOME " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_STRING , keyring . getValue ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " GNOME " ) , keyring . get ( ) ) ;
}
2012-06-05 14:57:32 +02:00
// Broken command line: treated like a sync, but config doesn't exist.
{
TestCmdline cmdline ( " keyring=KDE " , " @foobar " , NULL ) ;
cmdline . doit ( false ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " " ) , cmdline . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " [INFO] Configuration \" @foobar \" does not refer to a sync peer. \n [ERROR] Cannot proceed with sync without a configuration. " ) , cmdline . m_err . str ( ) ) ;
}
{
TestCmdline cmdline ( " keyring=KDE " , " nosuchpeer@foobar " , NULL ) ;
cmdline . doit ( false ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " " ) , cmdline . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " [INFO] Configuration \" nosuchpeer@foobar \" does not exist. \n [ERROR] Cannot proceed with sync without a configuration. " ) , cmdline . m_err . str ( ) ) ;
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
// empty config prop
{
TestCmdline cmdline ( " --configure " , " @default " , NULL ) ;
cmdline . doit ( ) ;
}
2012-06-05 14:57:32 +02:00
// Try broken command line again.
{
TestCmdline cmdline ( " keyring=KDE " , " @foobar " , NULL ) ;
cmdline . doit ( false ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " " ) , cmdline . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " [INFO] Configuration \" @foobar \" does not refer to a sync peer. \n [ERROR] Cannot proceed with sync without a configuration. " ) , cmdline . m_err . str ( ) ) ;
}
{
TestCmdline cmdline ( " keyring=KDE " , " nosuchpeer@foobar " , NULL ) ;
cmdline . doit ( false ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " " ) , cmdline . m_out . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " [INFO] Configuration \" nosuchpeer@foobar \" does not exist. \n [ERROR] Cannot proceed with sync without a configuration. " ) , cmdline . m_err . str ( ) ) ;
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
{
TestCmdline cmdline ( " @foobar " , NULL ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( false , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
}
// now set the value permanently
{
TestCmdline cmdline ( " --keyring " , " --configure " , " @default " , NULL ) ;
cmdline . doit ( ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
}
{
TestCmdline cmdline ( " --keyring=KDE " , " --configure " , " @default " , NULL ) ;
cmdline . doit ( ) ;
2012-06-05 14:57:32 +02:00
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_STRING , keyring . getValue ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " KDE " ) , keyring . get ( ) ) ;
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
}
2012-06-05 14:57:32 +02:00
// create by setting keyring in @default, then update;
// @default not strictly needed
rm_r ( m_testDir ) ;
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
{
2012-06-05 14:57:32 +02:00
TestCmdline cmdline ( " keyring=KDE " , " --configure " , " @default " , NULL ) ;
cmdline . doit ( ) ;
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_STRING , keyring . getValue ( ) ) ;
2012-06-05 14:57:32 +02:00
}
{
TestCmdline cmdline ( " keyring=yes " , " --configure " , " @default " , NULL ) ;
cmdline . doit ( ) ;
boost : : shared_ptr < SyncContext > context = cmdline . parse ( ) ;
CPPUNIT_ASSERT ( context ) ;
InitStateTri keyring = context - > getKeyring ( ) ;
CPPUNIT_ASSERT_EQUAL ( true , keyring . wasSet ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( InitStateTri : : VALUE_TRUE , keyring . getValue ( ) ) ;
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
}
// allow sync operation although --keyring was set
{
TestCmdline cmdline ( " keyring=GNOME " , " foobar@default " , NULL ) ;
cmdline . doit ( false ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " " ) , cmdline . m_out . str ( ) ) ;
2012-06-05 14:57:32 +02:00
CPPUNIT_ASSERT_EQUAL ( std : : string ( " [INFO] Configuration \" foobar@default \" does not exist. \n [ERROR] Cannot proceed with sync without a configuration. " ) , cmdline . m_err . str ( ) ) ;
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
}
// catch invalid "keyring" value
{
TestCmdline cmdline ( " --configure " ,
" username=foo " ,
" password=bar " ,
" syncURL=http://no.such.server " ,
" keyring=no-such-keyring " ,
" foobar@default " , NULL ) ;
cmdline . doit ( false ) ;
CPPUNIT_ASSERT_EQUAL ( std : : string ( " " ) , cmdline . m_out . str ( ) ) ;
2012-06-20 12:34:19 +02:00
CPPUNIT_ASSERT_EQUAL ( std : : string ( " [INFO] addressbook: looking for databases... \n "
" [INFO] addressbook: okay \n "
" [INFO] calendar: looking for databases... \n "
" [INFO] calendar: okay \n "
" [INFO] memo: looking for databases... \n "
" [INFO] memo: okay \n "
" [INFO] todo: looking for databases... \n "
" [INFO] todo: okay \n "
" [ERROR] Unsupported value for the \" keyring \" property, no such keyring found: no-such-keyring " ) ,
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
cmdline . m_err . str ( ) ) ;
}
}
2011-05-19 11:59:02 +02:00
void testWebDAV ( ) {
# ifdef ENABLE_DAV
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
// configure Yahoo under a different name, with explicit template selection
{
TestCmdline cmdline ( " --configure " ,
" --template " , " yahoo " ,
2011-06-29 03:42:43 +02:00
" target-config@my-yahoo " ,
2011-05-19 11:59:02 +02:00
NULL ) ;
cmdline . doit ( ) ;
}
{
2011-06-29 03:42:43 +02:00
TestCmdline cmdline ( " --print-config " , " target-config@my-yahoo " , NULL ) ;
2011-05-19 11:59:02 +02:00
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( yahoo ,
removeComments ( filterRandomUUID ( filterConfig ( cmdline . m_out . str ( ) ) ) ) ) ;
}
2014-07-25 14:02:29 +02:00
// configure Google Calendar/Contacts with template derived from config name
2011-05-19 11:59:02 +02:00
{
TestCmdline cmdline ( " --configure " ,
2014-07-25 14:02:29 +02:00
" target-config@google " ,
2011-05-19 11:59:02 +02:00
NULL ) ;
cmdline . doit ( ) ;
}
{
2014-07-25 14:02:29 +02:00
TestCmdline cmdline ( " --print-config " , " target-config@google " , NULL ) ;
2011-05-19 11:59:02 +02:00
cmdline . doit ( ) ;
2014-07-25 14:02:29 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( google ,
2011-05-19 11:59:02 +02:00
removeComments ( filterRandomUUID ( filterConfig ( cmdline . m_out . str ( ) ) ) ) ) ;
}
// test "template not found" error cases
{
TestCmdline cmdline ( " --configure " ,
" --template " , " yahooxyz " ,
2011-06-29 03:42:43 +02:00
" target-config@my-yahoo-xyz " ,
2011-05-19 11:59:02 +02:00
NULL ) ;
CPPUNIT_ASSERT ( cmdline . m_cmdline - > parse ( ) ) ;
CPPUNIT_ASSERT ( ! cmdline . m_cmdline - > run ( ) ) ;
command line: use both stdout and stderr
Traditionally, the "syncevolution" command line tool mixed its
INFO/ERROR/DEBUG messages into the normal stdout. This has the major
drawback that error messages get lost during operations like
syncevolution --export - @default addressbook | grep "John Doe"
Now anything which not the expected result of the operation is always
sent to stderr. Obviously this includes ERROR messages. INFO and DEBUG
are harder to decide. Because they usually convey meta information
about the running operation, they are also sent to stderr.
This changes the behavior of
syncevolution --run foo eds_event | less
"less" will capture only the following output:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Local data changes to be applied during synchronization:
*** eds_event ***
no changes
Synchronization successful.
Changes applied during synchronization:
+---------------|-----------------------|-----------------------|-CON-+
| | LOCAL | REMOTE | FLI |
| Source | NEW | MOD | DEL | ERR | NEW | MOD | DEL | ERR | CTS |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| eds_event | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| two-way, 0 KB sent by client, 0 KB received |
| item(s) in database backup: 2 before sync, 2 after it |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| start Wed Apr 11 14:34:11 2012, duration 0:03min |
| synchronization completed successfully |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
Data modified locally during synchronization:
*** eds_event ***
no changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To get the traditional behavior with bash or sh as shell, use
syncevolution --run foo eds_event 2>&1 | less
Some "normal" output in error messages was changed to INFO and thus
now appears on stderr after the corresponding ERROR message. Empty
lines which were used to separate different parts now also have a tag,
for the sake of consistency with the surrounding output.
The main implementation change is in LogRedirect, which now decides
whether LogStdout shall send the message to stdout or stderr. This has
the desired effect in the "syncevolution" binary, which uses
LogRedirect. Other binaries inherit the same change, although there it
usually doesn't matter.
The Cmdline unit testing mirrors this change in the way how it stores
and checks Cmdline output and also was adapted to the prefix changes.
2012-04-11 14:38:54 +02:00
static const char error [ ] = " [ERROR] No configuration template for 'yahooxyz' available. \n "
" [INFO] \n "
" [INFO] Available configuration templates (clients and servers): \n " ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
std : : string out = cmdline . m_out . str ( ) ;
std : : string err = cmdline . m_err . str ( ) ;
std : : string all = cmdline . m_all . str ( ) ;
command line: use both stdout and stderr
Traditionally, the "syncevolution" command line tool mixed its
INFO/ERROR/DEBUG messages into the normal stdout. This has the major
drawback that error messages get lost during operations like
syncevolution --export - @default addressbook | grep "John Doe"
Now anything which not the expected result of the operation is always
sent to stderr. Obviously this includes ERROR messages. INFO and DEBUG
are harder to decide. Because they usually convey meta information
about the running operation, they are also sent to stderr.
This changes the behavior of
syncevolution --run foo eds_event | less
"less" will capture only the following output:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Local data changes to be applied during synchronization:
*** eds_event ***
no changes
Synchronization successful.
Changes applied during synchronization:
+---------------|-----------------------|-----------------------|-CON-+
| | LOCAL | REMOTE | FLI |
| Source | NEW | MOD | DEL | ERR | NEW | MOD | DEL | ERR | CTS |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| eds_event | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| two-way, 0 KB sent by client, 0 KB received |
| item(s) in database backup: 2 before sync, 2 after it |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| start Wed Apr 11 14:34:11 2012, duration 0:03min |
| synchronization completed successfully |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
Data modified locally during synchronization:
*** eds_event ***
no changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To get the traditional behavior with bash or sh as shell, use
syncevolution --run foo eds_event 2>&1 | less
Some "normal" output in error messages was changed to INFO and thus
now appears on stderr after the corresponding ERROR message. Empty
lines which were used to separate different parts now also have a tag,
for the sake of consistency with the surrounding output.
The main implementation change is in LogRedirect, which now decides
whether LogStdout shall send the message to stdout or stderr. This has
the desired effect in the "syncevolution" binary, which uses
LogRedirect. Other binaries inherit the same change, although there it
usually doesn't matter.
The Cmdline unit testing mirrors this change in the way how it stores
and checks Cmdline output and also was adapted to the prefix changes.
2012-04-11 14:38:54 +02:00
CPPUNIT_ASSERT ( boost : : starts_with ( err , error ) ) ;
CPPUNIT_ASSERT ( boost : : ends_with ( err , " \n " ) ) ;
CPPUNIT_ASSERT ( ! boost : : ends_with ( err , " \n \n " ) ) ;
CPPUNIT_ASSERT_EQUAL ( string ( " " ) , out ) ;
CPPUNIT_ASSERT_EQUAL ( all , err ) ;
2011-05-19 11:59:02 +02:00
}
{
TestCmdline cmdline ( " --configure " ,
2011-06-29 03:42:43 +02:00
" target-config@foobar " ,
2011-05-19 11:59:02 +02:00
NULL ) ;
CPPUNIT_ASSERT ( cmdline . m_cmdline - > parse ( ) ) ;
CPPUNIT_ASSERT ( ! cmdline . m_cmdline - > run ( ) ) ;
command line: use both stdout and stderr
Traditionally, the "syncevolution" command line tool mixed its
INFO/ERROR/DEBUG messages into the normal stdout. This has the major
drawback that error messages get lost during operations like
syncevolution --export - @default addressbook | grep "John Doe"
Now anything which not the expected result of the operation is always
sent to stderr. Obviously this includes ERROR messages. INFO and DEBUG
are harder to decide. Because they usually convey meta information
about the running operation, they are also sent to stderr.
This changes the behavior of
syncevolution --run foo eds_event | less
"less" will capture only the following output:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Local data changes to be applied during synchronization:
*** eds_event ***
no changes
Synchronization successful.
Changes applied during synchronization:
+---------------|-----------------------|-----------------------|-CON-+
| | LOCAL | REMOTE | FLI |
| Source | NEW | MOD | DEL | ERR | NEW | MOD | DEL | ERR | CTS |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| eds_event | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| two-way, 0 KB sent by client, 0 KB received |
| item(s) in database backup: 2 before sync, 2 after it |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| start Wed Apr 11 14:34:11 2012, duration 0:03min |
| synchronization completed successfully |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
Data modified locally during synchronization:
*** eds_event ***
no changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To get the traditional behavior with bash or sh as shell, use
syncevolution --run foo eds_event 2>&1 | less
Some "normal" output in error messages was changed to INFO and thus
now appears on stderr after the corresponding ERROR message. Empty
lines which were used to separate different parts now also have a tag,
for the sake of consistency with the surrounding output.
The main implementation change is in LogRedirect, which now decides
whether LogStdout shall send the message to stdout or stderr. This has
the desired effect in the "syncevolution" binary, which uses
LogRedirect. Other binaries inherit the same change, although there it
usually doesn't matter.
The Cmdline unit testing mirrors this change in the way how it stores
and checks Cmdline output and also was adapted to the prefix changes.
2012-04-11 14:38:54 +02:00
static const char error [ ] = " [ERROR] No configuration template for 'foobar' available. \n "
" [INFO] Use '--template none' and/or specify relevant properties on the command line to create a configuration without a template. Need values for: syncURL \n "
" [INFO] \n "
" [INFO] Available configuration templates (clients and servers): \n " ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
std : : string out = cmdline . m_out . str ( ) ;
std : : string err = cmdline . m_err . str ( ) ;
std : : string all = cmdline . m_all . str ( ) ;
command line: use both stdout and stderr
Traditionally, the "syncevolution" command line tool mixed its
INFO/ERROR/DEBUG messages into the normal stdout. This has the major
drawback that error messages get lost during operations like
syncevolution --export - @default addressbook | grep "John Doe"
Now anything which not the expected result of the operation is always
sent to stderr. Obviously this includes ERROR messages. INFO and DEBUG
are harder to decide. Because they usually convey meta information
about the running operation, they are also sent to stderr.
This changes the behavior of
syncevolution --run foo eds_event | less
"less" will capture only the following output:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Local data changes to be applied during synchronization:
*** eds_event ***
no changes
Synchronization successful.
Changes applied during synchronization:
+---------------|-----------------------|-----------------------|-CON-+
| | LOCAL | REMOTE | FLI |
| Source | NEW | MOD | DEL | ERR | NEW | MOD | DEL | ERR | CTS |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| eds_event | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| two-way, 0 KB sent by client, 0 KB received |
| item(s) in database backup: 2 before sync, 2 after it |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| start Wed Apr 11 14:34:11 2012, duration 0:03min |
| synchronization completed successfully |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
Data modified locally during synchronization:
*** eds_event ***
no changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To get the traditional behavior with bash or sh as shell, use
syncevolution --run foo eds_event 2>&1 | less
Some "normal" output in error messages was changed to INFO and thus
now appears on stderr after the corresponding ERROR message. Empty
lines which were used to separate different parts now also have a tag,
for the sake of consistency with the surrounding output.
The main implementation change is in LogRedirect, which now decides
whether LogStdout shall send the message to stdout or stderr. This has
the desired effect in the "syncevolution" binary, which uses
LogRedirect. Other binaries inherit the same change, although there it
usually doesn't matter.
The Cmdline unit testing mirrors this change in the way how it stores
and checks Cmdline output and also was adapted to the prefix changes.
2012-04-11 14:38:54 +02:00
CPPUNIT_ASSERT ( boost : : starts_with ( err , error ) ) ;
CPPUNIT_ASSERT ( boost : : ends_with ( err , " \n " ) ) ;
CPPUNIT_ASSERT ( ! boost : : ends_with ( err , " \n \n " ) ) ;
CPPUNIT_ASSERT_EQUAL ( string ( " " ) , out ) ;
CPPUNIT_ASSERT_EQUAL ( err , all ) ;
2011-05-19 11:59:02 +02:00
}
# endif
}
2008-03-30 15:41:56 +02:00
void testConfigure ( ) {
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-30 15:41:56 +02:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
testSetupScheduleWorld ( ) ;
2010-03-02 16:30:10 +01:00
string expected = doConfigure ( ScheduleWorldConfig ( ) , " sources/addressbook/config.ini: " ) ;
{
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
// updating "type" for peer is mapped to updating "backend",
// "databaseFormat", "syncFormat", "forceSyncFormat"
2010-03-02 16:30:10 +01:00
TestCmdline cmdline ( " --configure " ,
2014-07-28 15:29:41 +02:00
" --datastore-property " , " addressbook/type=file:text/vcard:3.0 " ,
2011-01-25 11:11:53 +01:00
" scheduleworld " ,
2010-03-02 16:30:10 +01:00
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
boost : : replace_first ( expected ,
" backend = addressbook " ,
" backend = file " ) ;
boost : : replace_first ( expected ,
" # databaseFormat = " ,
" databaseFormat = text/vcard " ) ;
2010-03-02 16:30:10 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected ,
filterConfig ( printConfig ( " scheduleworld " ) ) ) ;
string shared = filterConfig ( printConfig ( " @default " ) ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
CPPUNIT_ASSERT ( shared . find ( " backend = file " ) ! = shared . npos ) ;
CPPUNIT_ASSERT ( shared . find ( " databaseFormat = text/vcard " ) ! = shared . npos ) ;
2010-03-02 16:30:10 +01:00
}
{
// updating type for context must not affect peer
TestCmdline cmdline ( " --configure " ,
2014-07-28 15:29:41 +02:00
" --datastore-property " , " type=file:text/x-vcard:2.1 " ,
2010-03-02 16:30:10 +01:00
" @default " , " addressbook " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
boost : : replace_first ( expected ,
" databaseFormat = text/vcard " ,
" databaseFormat = text/x-vcard " ) ;
2010-03-02 16:30:10 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected ,
filterConfig ( printConfig ( " scheduleworld " ) ) ) ;
string shared = filterConfig ( printConfig ( " @default " ) ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
CPPUNIT_ASSERT ( shared . find ( " backend = file " ) ! = shared . npos ) ;
CPPUNIT_ASSERT ( shared . find ( " databaseFormat = text/x-vcard " ) ! = shared . npos ) ;
2010-03-02 16:30:10 +01:00
}
2008-03-30 15:41:56 +02:00
2011-10-26 09:13:16 +02:00
string syncProperties ( " syncURL (no default, unshared, required) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" username (no default, unshared) \n "
2008-04-03 22:01:56 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" password (no default, unshared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" logdir (no default, shared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" loglevel (0, unshared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2012-05-22 10:05:11 +02:00
" notifyLevel (3, unshared) \n "
" \n "
2011-10-26 09:13:16 +02:00
" printChanges (TRUE, unshared) \n "
2009-04-21 11:22:32 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" dumpData (TRUE, unshared) \n "
2010-10-29 16:00:50 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" maxlogdirs (10, shared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" autoSync (0, unshared) \n "
2010-03-02 06:34:42 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" autoSyncInterval (30M, unshared) \n "
2010-03-02 06:34:42 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" autoSyncDelay (5M, unshared) \n "
2010-03-02 06:34:42 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" preventSlowSync (TRUE, unshared) \n "
2010-01-26 17:56:02 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" useProxy (FALSE, unshared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" proxyHost (no default, unshared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" proxyUsername (no default, unshared) \n "
2008-04-03 22:01:56 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" proxyPassword (no default, unshared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" clientAuthType (md5, unshared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" RetryDuration (5M, unshared) \n "
2009-09-23 15:16:42 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" RetryInterval (2M, unshared) \n "
2009-09-23 15:16:42 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" remoteIdentifier (no default, unshared) \n "
2009-11-19 16:33:33 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" PeerIsClient (FALSE, unshared) \n "
2009-11-19 16:33:33 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" SyncMLVersion (no default, unshared) \n "
2010-02-26 11:20:52 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" PeerName (no default, unshared) \n "
2010-01-13 18:05:45 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" deviceId (no default, shared) \n "
2008-03-30 20:39:15 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" remoteDeviceId (no default, unshared) \n "
2009-11-27 19:47:47 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" enableWBXML (TRUE, unshared) \n "
2009-03-17 14:16:49 +01:00
" \n "
2012-06-11 14:48:02 +02:00
" enableRefreshSync (FALSE, unshared) \n "
" \n "
2011-10-26 09:13:16 +02:00
" maxMsgSize (150000, unshared), maxObjSize (4000000, unshared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" SSLServerCertificates ( " SYNCEVOLUTION_SSL_SERVER_CERTIFICATES " , unshared) \n "
2008-04-16 22:33:38 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" SSLVerifyServer (TRUE, unshared) \n "
2008-04-16 22:33:38 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" SSLVerifyHost (TRUE, unshared) \n "
2009-04-07 20:33:18 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" WebURL (no default, unshared) \n "
2009-04-07 20:33:18 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" IconURI (no default, unshared) \n "
2009-06-29 20:32:26 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" ConsumerReady (FALSE, unshared) \n "
2009-11-13 17:25:30 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" peerType (no default, unshared) \n "
2011-05-18 17:20:56 +02:00
" \n "
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
" defaultPeer (no default, global) \n "
" \n "
" keyring (yes, global) \n " ) ;
2011-10-26 09:13:16 +02:00
string sourceProperties ( " sync (disabled, unshared, required) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" uri (no default, unshared) \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" backend (select backend, shared) \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" syncFormat (no default, unshared) \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" \n "
2011-10-26 09:13:16 +02:00
" forceSyncFormat (FALSE, unshared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" database = evolutionsource (no default, shared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" databaseFormat (no default, shared) \n "
2008-03-30 17:15:00 +02:00
" \n "
2011-10-26 09:13:16 +02:00
" databaseUser = evolutionuser (no default, shared), databasePassword = evolutionpassword (no default, shared) \n " ) ;
2008-03-30 17:15:00 +02:00
{
TestCmdline cmdline ( " --sync-property " , " ? " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( syncProperties ,
filterIndented ( cmdline . m_out . str ( ) ) ) ;
}
{
2014-07-28 15:29:41 +02:00
TestCmdline cmdline ( " --datastore-property " , " ? " ,
2008-03-30 17:15:00 +02:00
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( sourceProperties ,
filterIndented ( cmdline . m_out . str ( ) ) ) ;
}
{
2014-07-28 15:29:41 +02:00
TestCmdline cmdline ( " --datastore-property " , " ? " ,
2008-03-30 17:15:00 +02:00
" --sync-property " , " ? " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( sourceProperties + syncProperties ,
filterIndented ( cmdline . m_out . str ( ) ) ) ;
}
{
TestCmdline cmdline ( " --sync-property " , " ? " ,
2014-07-28 15:29:41 +02:00
" --datastore-property " , " ? " ,
2008-03-30 17:15:00 +02:00
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( syncProperties + sourceProperties ,
filterIndented ( cmdline . m_out . str ( ) ) ) ;
}
2011-01-25 11:11:53 +01:00
{
2014-07-28 15:29:41 +02:00
TestCmdline cmdline ( " --datastore-property " , " sync=? " ,
2011-01-25 11:11:53 +01:00
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
2014-07-28 15:29:41 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( " '--datastore-property sync=?' \n " ,
2011-01-25 11:11:53 +01:00
filterIndented ( cmdline . m_out . str ( ) ) ) ;
}
2011-02-03 14:05:16 +01:00
{
TestCmdline cmdline ( " sync=? " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " 'sync=?' \n " ,
filterIndented ( cmdline . m_out . str ( ) ) ) ;
}
{
TestCmdline cmdline ( " syncURL=? " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " 'syncURL=?' \n " ,
filterIndented ( cmdline . m_out . str ( ) ) ) ;
}
2008-03-30 18:13:08 +02:00
}
2010-09-29 15:00:16 +02:00
void testConfigureSources ( ) {
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2010-09-29 15:00:16 +02:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
// create from scratch with only addressbook configured
{
TestCmdline cmdline ( " --configure " ,
2014-07-28 15:29:41 +02:00
" --datastore-property " , " database = file://tmp/test " ,
" --datastore-property " , " type = file:text/x-vcard " ,
2010-09-29 15:00:16 +02:00
" @foobar " ,
" addressbook " ,
NULL ) ;
cmdline . doit ( ) ;
}
string root = m_testDir ;
root + = " /syncevolution/foobar " ;
string res = scanFiles ( root ) ;
removeRandomUUID ( res ) ;
string expected =
2011-01-10 15:56:53 +01:00
StringPrintf ( " .internal.ini:contextMinVersion = %d \n "
" .internal.ini:contextCurVersion = %d \n "
" config.ini:# logdir = \n "
" config.ini:# maxlogdirs = 10 \n "
" config.ini:deviceId = fixed-devid \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" sources/addressbook/config.ini:backend = file \n "
2011-01-18 15:33:07 +01:00
" sources/addressbook/config.ini:database = file://tmp/test \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" sources/addressbook/config.ini:databaseFormat = text/x-vcard \n "
2011-01-18 15:33:07 +01:00
" sources/addressbook/config.ini:# databaseUser = \n "
" sources/addressbook/config.ini:# databasePassword = \n " ,
2011-01-10 15:56:53 +01:00
CONFIG_CONTEXT_MIN_VERSION ,
CONFIG_CONTEXT_CUR_VERSION ) ;
2010-09-29 15:00:16 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
// add calendar
{
TestCmdline cmdline ( " --configure " ,
2014-07-28 15:29:41 +02:00
" --datastore-property " , " database@foobar = file://tmp/test2 " ,
" --datastore-property " , " backend = calendar " ,
2010-09-29 15:00:16 +02:00
" @foobar " ,
" calendar " ,
NULL ) ;
cmdline . doit ( ) ;
}
res = scanFiles ( root ) ;
removeRandomUUID ( res ) ;
expected + =
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" sources/calendar/config.ini:backend = calendar \n "
2011-01-18 15:33:07 +01:00
" sources/calendar/config.ini:database = file://tmp/test2 \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" sources/calendar/config.ini:# databaseFormat = \n "
2011-01-18 15:33:07 +01:00
" sources/calendar/config.ini:# databaseUser = \n "
" sources/calendar/config.ini:# databasePassword = \n " ;
2010-09-29 15:00:16 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
// add ScheduleWorld peer: must reuse existing backend settings
2010-09-29 15:00:16 +02:00
{
TestCmdline cmdline ( " --configure " ,
" scheduleworld@foobar " ,
NULL ) ;
cmdline . doit ( ) ;
}
res = scanFiles ( root ) ;
removeRandomUUID ( res ) ;
expected = ScheduleWorldConfig ( ) ;
boost : : replace_all ( expected ,
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" addressbook/config.ini:backend = addressbook " ,
" addressbook/config.ini:backend = file " ) ;
2010-09-29 15:00:16 +02:00
boost : : replace_all ( expected ,
2011-01-18 15:33:07 +01:00
" addressbook/config.ini:# database = " ,
" addressbook/config.ini:database = file://tmp/test " ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
boost : : replace_all ( expected ,
" addressbook/config.ini:# databaseFormat = " ,
" addressbook/config.ini:databaseFormat = text/x-vcard " ) ;
2010-09-29 15:00:16 +02:00
boost : : replace_all ( expected ,
2011-01-18 15:33:07 +01:00
" calendar/config.ini:# database = " ,
" calendar/config.ini:database = file://tmp/test2 " ) ;
2010-09-29 15:00:16 +02:00
sortConfig ( expected ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
2011-01-25 11:11:53 +01:00
// disable all sources except for addressbook
{
TestCmdline cmdline ( " --configure " ,
2014-07-28 15:29:41 +02:00
" --datastore-property " , " addressbook/sync=two-way " ,
" --datastore-property " , " sync=none " ,
2011-01-25 11:11:53 +01:00
" scheduleworld@foobar " ,
NULL ) ;
cmdline . doit ( ) ;
}
res = scanFiles ( root ) ;
removeRandomUUID ( res ) ;
boost : : replace_all ( expected , " sync = two-way " , " sync = disabled " ) ;
boost : : replace_first ( expected , " sync = disabled " , " sync = two-way " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , res ) ;
2011-01-28 14:35:49 +01:00
// override type in template while creating from scratch
{
TestCmdline cmdline ( " --configure " ,
" --template " , " SyncEvolution " ,
2014-07-28 15:29:41 +02:00
" --datastore-property " , " addressbook/type=file:text/vcard:3.0 " ,
" --datastore-property " , " calendar/type=file:text/calendar:2.0 " ,
2011-01-28 14:35:49 +01:00
" syncevo@syncevo " ,
NULL ) ;
cmdline . doit ( ) ;
}
string syncevoroot = m_testDir + " /syncevolution/syncevo " ;
res = scanFiles ( syncevoroot + " /sources/addressbook " ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
CPPUNIT_ASSERT ( res . find ( " backend = file \n " ) ! = res . npos ) ;
CPPUNIT_ASSERT ( res . find ( " databaseFormat = text/vcard \n " ) ! = res . npos ) ;
2011-01-28 14:35:49 +01:00
res = scanFiles ( syncevoroot + " /sources/calendar " ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
CPPUNIT_ASSERT ( res . find ( " backend = file \n " ) ! = res . npos ) ;
CPPUNIT_ASSERT ( res . find ( " databaseFormat = text/calendar \n " ) ! = res . npos ) ;
2010-09-29 15:00:16 +02:00
}
2008-03-30 18:13:08 +02:00
void testOldConfigure ( ) {
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-30 18:13:08 +02:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
string oldConfig = OldScheduleWorldConfig ( ) ;
InitList < string > props = InitList < string > ( " serverNonce " ) +
" clientNonce " +
" devInfoHash " +
2009-06-25 10:55:22 +02:00
" HashCode " +
" ConfigDate " +
2009-11-12 21:19:03 +01:00
" deviceData " +
" adminData " +
2010-02-15 16:50:06 +01:00
" synthesisID " +
2011-01-10 15:56:53 +01:00
" rootMinVersion " +
" rootCurVersion " +
" contextMinVersion " +
" contextCurVersion " +
" peerMinVersion " +
" peerCurVersion " +
2009-11-12 21:19:03 +01:00
" lastNonce " +
2008-03-30 18:13:08 +02:00
" last " ;
BOOST_FOREACH ( string & prop , props ) {
boost : : replace_all ( oldConfig ,
prop + " = " ,
prop + " = internal value " ) ;
}
rm_r ( m_testDir ) ;
createFiles ( m_testDir + " /.sync4j/evolution/scheduleworld " , oldConfig ) ;
2011-01-11 15:55:59 +01:00
// Cannot read/and write old format anymore.
SyncContext : : setStableRelease ( false ) ;
expectMigration ( " scheduleworld " ) ;
// Migrate explicitly.
{
TestCmdline cmdline ( " --migrate " , " scheduleworld " , NULL ) ;
cmdline . doit ( ) ;
}
// now test with new format
2011-01-18 14:35:13 +01:00
string expected = ScheduleWorldConfig ( ) ;
boost : : replace_first ( expected , " # ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
2011-01-18 15:33:07 +01:00
boost : : replace_first ( expected , " # database = " , " database = xyz " ) ;
boost : : replace_first ( expected , " # databaseUser = " , " databaseUser = foo " ) ;
2013-07-26 15:56:02 +02:00
boost : : replace_first ( expected , " # databasePassword = " , DATABASE_PASSWORD_BAR ) ;
2012-06-05 12:57:33 +02:00
// migrating "type" sets forceSyncFormat if not the default,
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
// and databaseFormat (if format was part of type, as for addressbook)
boost : : replace_first ( expected , " # databaseFormat = " , " databaseFormat = text/vcard " ) ;
2011-01-18 14:35:13 +01:00
doConfigure ( expected , " sources/addressbook/config.ini: " ) ;
2008-03-30 18:13:08 +02:00
}
2008-03-30 17:15:00 +02:00
2010-03-02 16:30:10 +01:00
string doConfigure ( const string & SWConfig , const string & addressbookPrefix ) {
2008-03-30 15:41:56 +02:00
string expected ;
{
TestCmdline cmdline ( " --configure " ,
2014-07-28 15:29:41 +02:00
" --datastore-property " , " sync = disabled " ,
2008-03-30 15:41:56 +02:00
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
2008-03-30 18:13:08 +02:00
expected = filterConfig ( internalToIni ( SWConfig ) ) ;
2008-03-30 15:41:56 +02:00
boost : : replace_all ( expected ,
" sync = two-way " ,
" sync = disabled " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected ,
filterConfig ( printConfig ( " scheduleworld " ) ) ) ;
}
{
TestCmdline cmdline ( " --configure " ,
2014-07-28 15:29:41 +02:00
" --datastore-property " , " sync = one-way-from-server " ,
2008-03-30 15:41:56 +02:00
" scheduleworld " ,
" addressbook " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
2008-03-30 18:13:08 +02:00
expected = SWConfig ;
2008-03-30 15:41:56 +02:00
boost : : replace_all ( expected ,
" sync = two-way " ,
" sync = disabled " ) ;
boost : : replace_first ( expected ,
2008-03-30 18:13:08 +02:00
addressbookPrefix + " sync = disabled " ,
addressbookPrefix + " sync = one-way-from-server " ) ;
2008-03-30 15:41:56 +02:00
expected = filterConfig ( internalToIni ( expected ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected ,
filterConfig ( printConfig ( " scheduleworld " ) ) ) ;
}
{
TestCmdline cmdline ( " --configure " ,
" --sync " , " two-way " ,
2014-07-28 15:29:41 +02:00
" -z " , " database=datastore " ,
2011-01-25 11:11:53 +01:00
// note priority of suffix: most specific wins
" --sync-property " , " maxlogdirs@scheduleworld@default=20 " ,
" --sync-property " , " maxlogdirs@default=10 " ,
" --sync-property " , " maxlogdirs=5 " ,
" -y " , " LOGDIR@default=logdir " ,
2008-03-30 15:41:56 +02:00
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
boost : : replace_all ( expected ,
" sync = one-way-from-server " ,
" sync = two-way " ) ;
boost : : replace_all ( expected ,
" sync = disabled " ,
" sync = two-way " ) ;
boost : : replace_all ( expected ,
2011-01-18 15:33:07 +01:00
" # database = " ,
2014-07-28 15:29:41 +02:00
" database = datastore " ) ;
2011-01-18 15:33:07 +01:00
boost : : replace_all ( expected ,
" database = xyz " ,
2014-07-28 15:29:41 +02:00
" database = datastore " ) ;
2008-03-30 15:41:56 +02:00
boost : : replace_all ( expected ,
2009-04-16 17:22:31 +02:00
" # maxlogdirs = 10 " ,
" maxlogdirs = 20 " ) ;
2008-03-30 15:41:56 +02:00
boost : : replace_all ( expected ,
2008-03-30 23:50:51 +02:00
" # logdir = " ,
2008-03-30 15:41:56 +02:00
" logdir = logdir " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected ,
filterConfig ( printConfig ( " scheduleworld " ) ) ) ;
}
2010-03-02 16:30:10 +01:00
return expected ;
2008-03-30 15:41:56 +02:00
}
2008-03-30 17:15:00 +02:00
void testMigrate ( ) {
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-30 17:15:00 +02:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
string oldRoot = m_testDir + " /.sync4j/evolution/scheduleworld " ;
2009-11-24 15:02:21 +01:00
string newRoot = m_testDir + " /syncevolution/default " ;
2008-03-30 17:15:00 +02:00
2008-03-30 18:13:08 +02:00
string oldConfig = OldScheduleWorldConfig ( ) ;
2008-03-30 17:15:00 +02:00
{
// migrate old config
createFiles ( oldRoot , oldConfig ) ;
string createdConfig = scanFiles ( oldRoot ) ;
TestCmdline cmdline ( " --migrate " ,
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
string migratedConfig = scanFiles ( newRoot ) ;
2009-11-24 15:02:21 +01:00
string expected = ScheduleWorldConfig ( ) ;
sortConfig ( expected ) ;
2011-01-17 21:48:57 +01:00
// migrating SyncEvolution < 1.2 configs sets
// ConsumerReady, to keep config visible in the updated
// sync-ui
boost : : replace_all ( expected , " # ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
2011-01-18 15:33:07 +01:00
boost : : replace_first ( expected , " # database = " , " database = xyz " ) ;
boost : : replace_first ( expected , " # databaseUser = " , " databaseUser = foo " ) ;
2013-07-26 15:56:02 +02:00
boost : : replace_first ( expected , " # databasePassword = " , DATABASE_PASSWORD_BAR ) ;
2012-06-05 12:57:33 +02:00
// migrating "type" sets forceSyncFormat if different from the "false" default
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
// and databaseFormat (if format was part of type, as for addressbook)
boost : : replace_first ( expected , " # databaseFormat = " , " databaseFormat = text/vcard " ) ;
2009-11-24 15:02:21 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , migratedConfig ) ;
2008-03-30 17:15:00 +02:00
string renamedConfig = scanFiles ( oldRoot + " .old " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( createdConfig , renamedConfig ) ;
}
{
2009-11-24 15:02:21 +01:00
// rewrite existing config with obsolete properties
// => these properties should get removed
//
// There is one limitation: shared nodes are not rewritten.
// This is acceptable.
createFiles ( newRoot + " /peers/scheduleworld " ,
2008-03-30 17:15:00 +02:00
" config.ini:# obsolete comment \n "
" config.ini:obsoleteprop = foo \n " ,
true ) ;
2009-11-24 15:02:21 +01:00
string createdConfig = scanFiles ( newRoot , " scheduleworld " ) ;
2008-03-30 17:15:00 +02:00
TestCmdline cmdline ( " --migrate " ,
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
2009-11-24 15:02:21 +01:00
string migratedConfig = scanFiles ( newRoot , " scheduleworld " ) ;
string expected = ScheduleWorldConfig ( ) ;
sortConfig ( expected ) ;
2011-01-17 21:48:57 +01:00
boost : : replace_all ( expected , " # ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
2011-01-18 15:33:07 +01:00
boost : : replace_first ( expected , " # database = " , " database = xyz " ) ;
boost : : replace_first ( expected , " # databaseUser = " , " databaseUser = foo " ) ;
2013-07-26 15:56:02 +02:00
boost : : replace_first ( expected , " # databasePassword = " , DATABASE_PASSWORD_BAR ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
boost : : replace_first ( expected , " # databaseFormat = " , " databaseFormat = text/vcard " ) ;
2009-11-24 15:02:21 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , migratedConfig ) ;
2011-08-19 16:19:12 +02:00
string renamedConfig = scanFiles ( newRoot , " scheduleworld.old.1 " ) ;
boost : : replace_first ( createdConfig , " ConsumerReady = 1 " , " ConsumerReady = 0 " ) ;
boost : : replace_all ( createdConfig , " /scheduleworld/ " , " /scheduleworld.old.1/ " ) ;
2008-03-30 17:15:00 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( createdConfig , renamedConfig ) ;
}
{
2009-11-25 15:30:07 +01:00
// migrate old config with changes and .synthesis directory, a second time
2008-03-30 17:15:00 +02:00
createFiles ( oldRoot , oldConfig ) ;
createFiles ( oldRoot ,
2009-11-25 15:30:07 +01:00
" .synthesis/dummy-file.bfi:dummy = foobar \n "
2008-03-30 17:15:00 +02:00
" spds/sources/addressbook/changes/config.txt:foo = bar \n "
" spds/sources/addressbook/changes/config.txt:foo2 = bar2 \n " ,
true ) ;
string createdConfig = scanFiles ( oldRoot ) ;
rm_r ( newRoot ) ;
TestCmdline cmdline ( " --migrate " ,
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
string migratedConfig = scanFiles ( newRoot ) ;
2011-01-10 15:56:53 +01:00
string expected = ScheduleWorldConfig ( ) ;
2009-11-24 15:02:21 +01:00
sortConfig ( expected ) ;
2011-01-17 21:48:57 +01:00
boost : : replace_all ( expected , " # ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
2011-01-18 15:33:07 +01:00
boost : : replace_first ( expected , " # database = " , " database = xyz " ) ;
boost : : replace_first ( expected , " # databaseUser = " , " databaseUser = foo " ) ;
2013-07-26 15:56:02 +02:00
boost : : replace_first ( expected , " # databasePassword = " , DATABASE_PASSWORD_BAR ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
boost : : replace_first ( expected , " # databaseFormat = " , " databaseFormat = text/vcard " ) ;
2008-03-30 17:15:00 +02:00
boost : : replace_first ( expected ,
2009-11-24 15:02:21 +01:00
" peers/scheduleworld/sources/addressbook/config.ini " ,
" peers/scheduleworld/sources/addressbook/.other.ini:foo = bar \n "
" peers/scheduleworld/sources/addressbook/.other.ini:foo2 = bar2 \n "
" peers/scheduleworld/sources/addressbook/config.ini " ) ;
2009-11-25 15:30:07 +01:00
boost : : replace_first ( expected ,
" peers/scheduleworld/config.ini " ,
" peers/scheduleworld/.synthesis/dummy-file.bfi:dummy = foobar \n "
" peers/scheduleworld/config.ini " ) ;
2008-03-30 17:15:00 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , migratedConfig ) ;
string renamedConfig = scanFiles ( oldRoot + " .old.1 " ) ;
2011-08-19 16:19:12 +02:00
boost : : replace_first ( createdConfig , " ConsumerReady = 1 " , " ConsumerReady = 0 " ) ;
2008-03-30 17:15:00 +02:00
CPPUNIT_ASSERT_EQUAL_DIFF ( createdConfig , renamedConfig ) ;
}
2009-11-25 16:10:44 +01:00
{
string otherRoot = m_testDir + " /syncevolution/other " ;
rm_r ( otherRoot ) ;
// migrate old config into non-default context
createFiles ( oldRoot , oldConfig ) ;
string createdConfig = scanFiles ( oldRoot ) ;
{
TestCmdline cmdline ( " --migrate " ,
" scheduleworld@other " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
}
string migratedConfig = scanFiles ( otherRoot ) ;
string expected = ScheduleWorldConfig ( ) ;
sortConfig ( expected ) ;
2011-01-17 21:48:57 +01:00
boost : : replace_all ( expected , " # ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
2011-01-18 15:33:07 +01:00
boost : : replace_first ( expected , " # database = " , " database = xyz " ) ;
boost : : replace_first ( expected , " # databaseUser = " , " databaseUser = foo " ) ;
2013-07-26 15:56:02 +02:00
boost : : replace_first ( expected , " # databasePassword = " , DATABASE_PASSWORD_BAR ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
boost : : replace_first ( expected , " # databaseFormat = " , " databaseFormat = text/vcard " ) ;
2009-11-25 16:10:44 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , migratedConfig ) ;
string renamedConfig = scanFiles ( oldRoot + " .old " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( createdConfig , renamedConfig ) ;
2011-01-11 17:43:23 +01:00
// migrate the migrated config again inside the "other" context,
// with no "default" context which might interfere with the tests
2011-01-17 21:48:57 +01:00
//
// ConsumerReady was set as part of previous migration,
// must be removed during migration to hide the migrated
// config from average users.
2011-01-11 17:43:23 +01:00
rm_r ( newRoot ) ;
2009-11-25 16:10:44 +01:00
{
TestCmdline cmdline ( " --migrate " ,
" scheduleworld@other " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
}
migratedConfig = scanFiles ( otherRoot , " scheduleworld " ) ;
expected = ScheduleWorldConfig ( ) ;
sortConfig ( expected ) ;
2011-01-17 21:48:57 +01:00
boost : : replace_all ( expected , " # ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
2011-01-18 15:33:07 +01:00
boost : : replace_first ( expected , " # database = " , " database = xyz " ) ;
boost : : replace_first ( expected , " # databaseUser = " , " databaseUser = foo " ) ;
2013-07-26 15:56:02 +02:00
boost : : replace_first ( expected , " # databasePassword = " , DATABASE_PASSWORD_BAR ) ;
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
boost : : replace_first ( expected , " # databaseFormat = " , " databaseFormat = text/vcard " ) ;
2009-11-25 16:10:44 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , migratedConfig ) ;
2011-08-19 16:19:12 +02:00
renamedConfig = scanFiles ( otherRoot , " scheduleworld.old.3 " ) ;
boost : : replace_all ( expected , " /scheduleworld/ " , " /scheduleworld.old.3/ " ) ;
2011-01-17 21:48:57 +01:00
boost : : replace_all ( expected , " ConsumerReady = 1 " , " ConsumerReady = 0 " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , renamedConfig ) ;
// migrate once more, this time without the explicit context in
// the config name => must not change the context, need second .old dir
{
TestCmdline cmdline ( " --migrate " ,
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
}
migratedConfig = scanFiles ( otherRoot , " scheduleworld " ) ;
2011-08-19 16:19:12 +02:00
boost : : replace_all ( expected , " /scheduleworld.old.3/ " , " /scheduleworld/ " ) ;
2011-01-17 21:48:57 +01:00
boost : : replace_all ( expected , " ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , migratedConfig ) ;
2011-08-19 16:19:12 +02:00
renamedConfig = scanFiles ( otherRoot , " scheduleworld.old.4 " ) ;
boost : : replace_all ( expected , " /scheduleworld/ " , " /scheduleworld.old.4/ " ) ;
2011-01-17 21:48:57 +01:00
boost : : replace_all ( expected , " ConsumerReady = 1 " , " ConsumerReady = 0 " ) ;
2009-11-25 16:10:44 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , renamedConfig ) ;
2011-01-11 17:43:23 +01:00
2011-01-17 21:48:57 +01:00
// remove ConsumerReady: must be remain unset when migrating
// hidden SyncEvolution >= 1.2 configs
2011-01-17 15:00:50 +01:00
{
TestCmdline cmdline ( " --configure " ,
2011-01-17 21:48:57 +01:00
" --sync-property " , " ConsumerReady=0 " ,
2011-01-17 15:00:50 +01:00
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
}
2011-01-17 21:48:57 +01:00
// migrate once more => keep ConsumerReady unset
2011-01-11 17:43:23 +01:00
{
TestCmdline cmdline ( " --migrate " ,
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
}
migratedConfig = scanFiles ( otherRoot , " scheduleworld " ) ;
2011-08-19 16:19:12 +02:00
boost : : replace_all ( expected , " /scheduleworld.old.4/ " , " /scheduleworld/ " ) ;
2011-01-11 17:43:23 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , migratedConfig ) ;
2011-08-19 16:19:12 +02:00
renamedConfig = scanFiles ( otherRoot , " scheduleworld.old.5 " ) ;
boost : : replace_all ( expected , " /scheduleworld/ " , " /scheduleworld.old.5/ " ) ;
2011-01-11 17:43:23 +01:00
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , renamedConfig ) ;
2009-11-25 16:10:44 +01:00
}
2008-03-30 17:15:00 +02:00
}
2008-03-29 15:16:34 +01:00
2011-02-14 14:08:40 +01:00
void testMigrateContext ( )
{
// Migrate context containing a peer. Must also migrate peer.
// Covers special case of inconsistent "type".
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2011-02-14 14:08:40 +01:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
string root = m_testDir + " /syncevolution/default " ;
string oldConfig =
" config.ini:logDir = none \n "
" peers/scheduleworld/config.ini:syncURL = http://sync.scheduleworld.com/funambol/ds \n "
2011-03-23 12:14:31 +01:00
" peers/scheduleworld/config.ini:# username = \n "
" peers/scheduleworld/config.ini:# password = \n "
2011-02-14 14:08:40 +01:00
" peers/scheduleworld/sources/addressbook/config.ini:sync = two-way \n "
" peers/scheduleworld/sources/addressbook/config.ini:uri = card3 \n "
" peers/scheduleworld/sources/addressbook/config.ini:type = addressbook:text/vcard \n " // correct!
" sources/addressbook/config.ini:type = calendar \n " // wrong!
" peers/funambol/config.ini:syncURL = http://sync.funambol.com/funambol/ds \n "
2011-03-23 12:14:31 +01:00
" peers/funambol/config.ini:# username = \n "
" peers/funambol/config.ini:# password = \n "
2011-02-14 14:08:40 +01:00
" peers/funambol/sources/calendar/config.ini:sync = refresh-from-server \n "
" peers/funambol/sources/calendar/config.ini:uri = cal \n "
" peers/funambol/sources/calendar/config.ini:type = calendar \n " // correct!
" peers/funambol/sources/addressbook/config.ini:# sync = disabled \n "
" peers/funambol/sources/addressbook/config.ini:type = file \n " // not used for context because source disabled
" sources/calendar/config.ini:type = memos \n " // wrong!
" peers/memotoo/config.ini:syncURL = http://sync.memotoo.com/memotoo/ds \n "
2011-03-23 12:14:31 +01:00
" peers/memotoo/config.ini:# username = \n "
" peers/memotoo/config.ini:# password = \n "
2011-02-14 14:08:40 +01:00
" peers/memotoo/sources/memo/config.ini:sync = refresh-from-client \n "
" peers/memotoo/sources/memo/config.ini:uri = cal \n "
" peers/memotoo/sources/memo/config.ini:type = memo:text/plain \n " // correct!
" sources/memo/config.ini:type = todo \n " // wrong!
;
{
createFiles ( root , oldConfig ) ;
TestCmdline cmdline ( " --migrate " ,
" memo/backend=file " , // override memo "backend" during migration
" @default " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
string migratedConfig = scanFiles ( root ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/scheduleworld/ " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " sources/addressbook/config.ini:backend = addressbook " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " sources/addressbook/config.ini:databaseFormat = text/vcard " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/scheduleworld/sources/addressbook/config.ini:syncFormat = text/vcard " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/scheduleworld/sources/addressbook/config.ini:sync = two-way " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/scheduleworld/sources/calendar/config.ini:# sync = disabled " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/scheduleworld/sources/memo/config.ini:# sync = disabled " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " sources/calendar/config.ini:backend = calendar " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " sources/calendar/config.ini:# databaseFormat = " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/funambol/sources/calendar/config.ini:# syncFormat = " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/funambol/sources/addressbook/config.ini:# sync = disabled " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/funambol/sources/calendar/config.ini:sync = refresh-from-server " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/funambol/sources/memo/config.ini:# sync = disabled " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " sources/memo/config.ini:backend = file " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " sources/memo/config.ini:databaseFormat = text/plain " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/memotoo/sources/memo/config.ini:syncFormat = text/plain " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/memotoo/sources/addressbook/config.ini:# sync = disabled " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/memotoo/sources/calendar/config.ini:# sync = disabled " ) ! = migratedConfig . npos ) ;
CPPUNIT_ASSERT ( migratedConfig . find ( " peers/memotoo/sources/memo/config.ini:sync = refresh-from-client " ) ! = migratedConfig . npos ) ;
}
}
2011-08-19 16:19:12 +02:00
void testMigrateAutoSync ( ) {
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
string oldRoot = m_testDir + " /.sync4j/evolution/scheduleworld " ;
string newRoot = m_testDir + " /syncevolution/default " ;
string oldConfig = " spds/syncml/config.txt:autoSync = 1 \n " ;
oldConfig + = OldScheduleWorldConfig ( ) ;
{
// migrate old config
createFiles ( oldRoot , oldConfig ) ;
string createdConfig = scanFiles ( oldRoot ) ;
TestCmdline cmdline ( " --migrate " ,
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
string migratedConfig = scanFiles ( newRoot ) ;
string expected = ScheduleWorldConfig ( ) ;
boost : : replace_first ( expected , " # autoSync = 0 " , " autoSync = 1 " ) ;
sortConfig ( expected ) ;
// migrating SyncEvolution < 1.2 configs sets
// ConsumerReady, to keep config visible in the updated
// sync-ui
boost : : replace_all ( expected , " # ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
boost : : replace_first ( expected , " # database = " , " database = xyz " ) ;
boost : : replace_first ( expected , " # databaseUser = " , " databaseUser = foo " ) ;
2013-07-26 15:56:02 +02:00
boost : : replace_first ( expected , " # databasePassword = " , DATABASE_PASSWORD_BAR ) ;
2012-06-05 12:57:33 +02:00
// migrating "type" sets forceSyncFormat if not already the default,
2011-08-19 16:19:12 +02:00
// and databaseFormat (if format was part of type, as for addressbook)
boost : : replace_first ( expected , " # databaseFormat = " , " databaseFormat = text/vcard " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , migratedConfig ) ;
string renamedConfig = scanFiles ( oldRoot + " .old " ) ;
// autoSync must have been unset
boost : : replace_first ( createdConfig , " :autoSync = 1 " , " :autoSync = 0 " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( createdConfig , renamedConfig ) ;
}
{
// rewrite existing config with autoSync set
string createdConfig = scanFiles ( newRoot , " scheduleworld " ) ;
TestCmdline cmdline ( " --migrate " ,
" scheduleworld " ,
NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_out . str ( ) ) ;
string migratedConfig = scanFiles ( newRoot , " scheduleworld " ) ;
string expected = ScheduleWorldConfig ( ) ;
boost : : replace_first ( expected , " # autoSync = 0 " , " autoSync = 1 " ) ;
sortConfig ( expected ) ;
boost : : replace_all ( expected , " # ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
boost : : replace_first ( expected , " # database = " , " database = xyz " ) ;
boost : : replace_first ( expected , " # databaseUser = " , " databaseUser = foo " ) ;
2013-07-26 15:56:02 +02:00
boost : : replace_first ( expected , " # databasePassword = " , DATABASE_PASSWORD_BAR ) ;
2011-08-19 16:19:12 +02:00
boost : : replace_first ( expected , " # databaseFormat = " , " databaseFormat = text/vcard " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( expected , migratedConfig ) ;
string renamedConfig = scanFiles ( newRoot , " scheduleworld.old.1 " ) ;
// autoSync must have been unset
boost : : replace_first ( createdConfig , " :autoSync = 1 " , " :autoSync = 0 " ) ;
// the scheduleworld config was consumer ready, the migrated one isn't
boost : : replace_all ( createdConfig , " ConsumerReady = 1 " , " ConsumerReady = 0 " ) ;
boost : : replace_all ( createdConfig , " /scheduleworld/ " , " /scheduleworld.old.1/ " ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( createdConfig , renamedConfig ) ;
}
}
2011-01-10 15:56:53 +01:00
const string m_testDir ;
2008-03-29 15:16:34 +01:00
2008-03-28 23:32:00 +01:00
private :
2008-03-29 15:16:34 +01:00
/**
* vararg constructor with NULL termination ,
* out and error stream into stringstream members
*/
Logging: thread-safe
Logging must be thread-safe, because the glib log callback may be
called from arbitrary threads. This becomes more important with EDS
3.8, because it shifts the execution of synchronous calls into
threads.
Thread-safe logging will also be required for running the Synthesis
engine multithreaded, to overlap SyncML client communication with
preparing the sources.
To achieve this, the core Logging module protects its global data with
a recursive mutex. A recursive mutes is used because logging calls
themselves may be recursive, so ensuring single-lock semantic would be
hard.
Ref-counted boost pointers are used to track usage of Logger
instances. This allows removal of an instance from the logging stack
while it may still be in use. Destruction then will be delayed until
the last user of the instance drops it. The instance itself must be
prepared to handle this.
The Logging mutex is available to users of the Logging module. Code
which holds the logging mutex should not lock any other mutex, to
avoid deadlocks. The new code is a bit fuzzy on that, because it calls
other modules (glib, Synthesis engine) while holding the mutex. If
that becomes a problem, then the mutex can be unlocked, at the risk of
leading to reordered log messages in different channels (see
ServerLogger).
Making all loggers follow the new rules uses different
approaches.
Loggers like the one in the local transport child which use a parent
logger and an additional ref-counted class like the D-Bus helper keep
a weak reference to the helper and lock it before use. If it is gone
already, the second logging part is skipped. This is the recommended
approach.
In cases where introducing ref-counting for the second class would
have been too intrusive (Server and SessionHelper), a fake
boost::shared_ptr without a destructor is used as an intermediate step
towards the recommended approach. To avoid race conditions while the
instance these fake pointers refer to destructs, an explicit
"remove()" method is necessary which must hold the Logging
mutex. Using the potentially removed pointer must do the same. Such
fake ref-counted Loggers cannot be used as parent logger of other
loggers, because then remove() would not be able to drop the last
reference to the fake boost::shared_ptr.
Loggers with fake boost::shared_ptr must keep a strong reference,
because no-one else does. The goal is to turn this into weak
references eventually.
LogDir must protect concurrent access to m_report and the Synthesis
engine.
The LogRedirectLogger assumes that it is still the active logger while
disabling itself. The remove() callback method will always be invoked
before removing a logger from the stack.
2013-04-09 21:32:35 +02:00
class TestCmdline : public Logger {
2009-11-24 19:26:58 +01:00
void init ( ) {
Logging: thread-safe
Logging must be thread-safe, because the glib log callback may be
called from arbitrary threads. This becomes more important with EDS
3.8, because it shifts the execution of synchronous calls into
threads.
Thread-safe logging will also be required for running the Synthesis
engine multithreaded, to overlap SyncML client communication with
preparing the sources.
To achieve this, the core Logging module protects its global data with
a recursive mutex. A recursive mutes is used because logging calls
themselves may be recursive, so ensuring single-lock semantic would be
hard.
Ref-counted boost pointers are used to track usage of Logger
instances. This allows removal of an instance from the logging stack
while it may still be in use. Destruction then will be delayed until
the last user of the instance drops it. The instance itself must be
prepared to handle this.
The Logging mutex is available to users of the Logging module. Code
which holds the logging mutex should not lock any other mutex, to
avoid deadlocks. The new code is a bit fuzzy on that, because it calls
other modules (glib, Synthesis engine) while holding the mutex. If
that becomes a problem, then the mutex can be unlocked, at the risk of
leading to reordered log messages in different channels (see
ServerLogger).
Making all loggers follow the new rules uses different
approaches.
Loggers like the one in the local transport child which use a parent
logger and an additional ref-counted class like the D-Bus helper keep
a weak reference to the helper and lock it before use. If it is gone
already, the second logging part is skipped. This is the recommended
approach.
In cases where introducing ref-counting for the second class would
have been too intrusive (Server and SessionHelper), a fake
boost::shared_ptr without a destructor is used as an intermediate step
towards the recommended approach. To avoid race conditions while the
instance these fake pointers refer to destructs, an explicit
"remove()" method is necessary which must hold the Logging
mutex. Using the potentially removed pointer must do the same. Such
fake ref-counted Loggers cannot be used as parent logger of other
loggers, because then remove() would not be able to drop the last
reference to the fake boost::shared_ptr.
Loggers with fake boost::shared_ptr must keep a strong reference,
because no-one else does. The goal is to turn this into weak
references eventually.
LogDir must protect concurrent access to m_report and the Synthesis
engine.
The LogRedirectLogger assumes that it is still the active logger while
disabling itself. The remove() callback method will always be invoked
before removing a logger from the stack.
2013-04-09 21:32:35 +02:00
addLogger ( boost : : shared_ptr < Logger > ( this , NopDestructor ( ) ) ) ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
2009-11-24 19:26:58 +01:00
m_argv . reset ( new const char * [ m_argvstr . size ( ) + 1 ] ) ;
m_argv [ 0 ] = " client-test " ;
for ( size_t index = 0 ;
index < m_argvstr . size ( ) ;
+ + index ) {
m_argv [ index + 1 ] = m_argvstr [ index ] . c_str ( ) ;
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
m_cmdline . set ( new KeyringSyncCmdline ( m_argvstr . size ( ) + 1 , m_argv . get ( ) ) , " cmdline " ) ;
2009-11-24 19:26:58 +01:00
}
2008-03-29 15:16:34 +01:00
public :
TestCmdline ( const char * arg , . . . ) {
va_list argList ;
va_start ( argList , arg ) ;
for ( const char * curr = arg ;
curr ;
curr = va_arg ( argList , const char * ) ) {
m_argvstr . push_back ( curr ) ;
}
va_end ( argList ) ;
2009-11-24 19:26:58 +01:00
init ( ) ;
}
2008-03-29 15:16:34 +01:00
2009-11-24 19:26:58 +01:00
TestCmdline ( const char * const argv [ ] ) {
for ( int i = 0 ; argv [ i ] ; i + + ) {
m_argvstr . push_back ( argv [ i ] ) ;
2008-03-29 15:16:34 +01:00
}
2009-11-24 19:26:58 +01:00
init ( ) ;
2008-03-29 15:16:34 +01:00
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
~ TestCmdline ( ) {
Logging: thread-safe
Logging must be thread-safe, because the glib log callback may be
called from arbitrary threads. This becomes more important with EDS
3.8, because it shifts the execution of synchronous calls into
threads.
Thread-safe logging will also be required for running the Synthesis
engine multithreaded, to overlap SyncML client communication with
preparing the sources.
To achieve this, the core Logging module protects its global data with
a recursive mutex. A recursive mutes is used because logging calls
themselves may be recursive, so ensuring single-lock semantic would be
hard.
Ref-counted boost pointers are used to track usage of Logger
instances. This allows removal of an instance from the logging stack
while it may still be in use. Destruction then will be delayed until
the last user of the instance drops it. The instance itself must be
prepared to handle this.
The Logging mutex is available to users of the Logging module. Code
which holds the logging mutex should not lock any other mutex, to
avoid deadlocks. The new code is a bit fuzzy on that, because it calls
other modules (glib, Synthesis engine) while holding the mutex. If
that becomes a problem, then the mutex can be unlocked, at the risk of
leading to reordered log messages in different channels (see
ServerLogger).
Making all loggers follow the new rules uses different
approaches.
Loggers like the one in the local transport child which use a parent
logger and an additional ref-counted class like the D-Bus helper keep
a weak reference to the helper and lock it before use. If it is gone
already, the second logging part is skipped. This is the recommended
approach.
In cases where introducing ref-counting for the second class would
have been too intrusive (Server and SessionHelper), a fake
boost::shared_ptr without a destructor is used as an intermediate step
towards the recommended approach. To avoid race conditions while the
instance these fake pointers refer to destructs, an explicit
"remove()" method is necessary which must hold the Logging
mutex. Using the potentially removed pointer must do the same. Such
fake ref-counted Loggers cannot be used as parent logger of other
loggers, because then remove() would not be able to drop the last
reference to the fake boost::shared_ptr.
Loggers with fake boost::shared_ptr must keep a strong reference,
because no-one else does. The goal is to turn this into weak
references eventually.
LogDir must protect concurrent access to m_report and the Synthesis
engine.
The LogRedirectLogger assumes that it is still the active logger while
disabling itself. The remove() callback method will always be invoked
before removing a logger from the stack.
2013-04-09 21:32:35 +02:00
removeLogger ( this ) ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
}
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
boost : : shared_ptr < SyncContext > parse ( )
{
if ( ! m_cmdline - > parse ( ) ) {
return boost : : shared_ptr < SyncContext > ( ) ;
}
boost : : shared_ptr < SyncContext > context ( new SyncContext ( m_cmdline - > m_server ) ) ;
context - > setConfigFilter ( true , " " , m_cmdline - > m_props . createSyncFilter ( m_cmdline - > m_server ) ) ;
return context ;
}
2011-11-21 17:38:34 +01:00
void doit ( bool expectSuccess = true ) {
bool success = false ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
m_out . str ( " " ) ;
m_err . str ( " " ) ;
2011-11-21 17:38:34 +01:00
// emulates syncevolution.cpp exception handling
try {
success = m_cmdline - > parse ( ) & &
m_cmdline - > run ( ) ;
} catch ( const std : : exception & ex ) {
m_err < < " [ERROR] " < < ex . what ( ) ;
} catch ( . . . ) {
std : : string explanation ;
Exception : : handle ( explanation ) ;
m_err < < " [ERROR] " < < explanation ;
}
if ( expectSuccess & & m_err . str ( ) . size ( ) ) {
2010-03-26 09:53:27 +01:00
m_out < < endl < < m_err . str ( ) ;
2008-03-29 15:16:34 +01:00
}
2011-11-21 17:38:34 +01:00
CPPUNIT_ASSERT_MESSAGE ( m_out . str ( ) , success = = expectSuccess ) ;
2008-03-29 15:16:34 +01:00
}
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
/** verify that Cmdline::usage() produced a short usage info followed by a specific error message */
void expectUsageError ( const std : : string & error )
{
// expect short usage info as normal output
std : : string out = m_out . str ( ) ;
std : : string err = m_err . str ( ) ;
std : : string all = m_all . str ( ) ;
2012-09-13 18:02:07 +02:00
CPPUNIT_ASSERT ( boost : : starts_with ( out , " List and manipulate databases: \n " ) ) ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
CPPUNIT_ASSERT ( out . find ( " \n Options: \n " ) = = std : : string : : npos ) ;
CPPUNIT_ASSERT ( boost : : ends_with ( out ,
" Remove item(s): \n "
2014-07-28 15:29:41 +02:00
" syncevolution --delete-items [--] <config> <store> (<luid> ... | '*') \n \n " ) ) ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
// exact error message
CPPUNIT_ASSERT_EQUAL ( error , err ) ;
// also check order
CPPUNIT_ASSERT_EQUAL_DIFF ( out + err , all ) ;
}
// separate streams for normal messages and error messages
2008-03-29 15:16:34 +01:00
ostringstream m_out , m_err ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
// combined stream with all messages
ostringstream m_all ;
2009-10-05 14:49:32 +02:00
cxxptr < Cmdline > m_cmdline ;
2008-03-29 15:16:34 +01:00
private :
vector < string > m_argvstr ;
boost : : scoped_array < const char * > m_argv ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
/** capture output produced while test ran */
2013-04-08 20:10:31 +02:00
void messagev ( const MessageOptions & options ,
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
const char * format ,
va_list args )
{
2013-04-08 20:10:31 +02:00
Level level = options . m_level ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
if ( level < = INFO ) {
command line: use both stdout and stderr
Traditionally, the "syncevolution" command line tool mixed its
INFO/ERROR/DEBUG messages into the normal stdout. This has the major
drawback that error messages get lost during operations like
syncevolution --export - @default addressbook | grep "John Doe"
Now anything which not the expected result of the operation is always
sent to stderr. Obviously this includes ERROR messages. INFO and DEBUG
are harder to decide. Because they usually convey meta information
about the running operation, they are also sent to stderr.
This changes the behavior of
syncevolution --run foo eds_event | less
"less" will capture only the following output:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Local data changes to be applied during synchronization:
*** eds_event ***
no changes
Synchronization successful.
Changes applied during synchronization:
+---------------|-----------------------|-----------------------|-CON-+
| | LOCAL | REMOTE | FLI |
| Source | NEW | MOD | DEL | ERR | NEW | MOD | DEL | ERR | CTS |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| eds_event | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| two-way, 0 KB sent by client, 0 KB received |
| item(s) in database backup: 2 before sync, 2 after it |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| start Wed Apr 11 14:34:11 2012, duration 0:03min |
| synchronization completed successfully |
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
Data modified locally during synchronization:
*** eds_event ***
no changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To get the traditional behavior with bash or sh as shell, use
syncevolution --run foo eds_event 2>&1 | less
Some "normal" output in error messages was changed to INFO and thus
now appears on stderr after the corresponding ERROR message. Empty
lines which were used to separate different parts now also have a tag,
for the sake of consistency with the surrounding output.
The main implementation change is in LogRedirect, which now decides
whether LogStdout shall send the message to stdout or stderr. This has
the desired effect in the "syncevolution" binary, which uses
LogRedirect. Other binaries inherit the same change, although there it
usually doesn't matter.
The Cmdline unit testing mirrors this change in the way how it stores
and checks Cmdline output and also was adapted to the prefix changes.
2012-04-11 14:38:54 +02:00
ostringstream & out = level ! = SHOW ? m_err : m_out ;
command line: cleaned up output
The user-visible part of this change is that command line output now
uses the same [ERROR/INFO] prefixes like the rest of SyncEvolution,
instead of "Error:". Several messages were split into [ERROR] and
[INFO] parts on seperate lines. Multi-line messages with such a prefix
now have the prefix at the start of each line. Full sentences start
with captital letters.
All usage errors related to the synopsis of the command line now
include the synopsis, without the detailed documentation of all
options. Some of those errors dumped the full documentation, which was
way too much information and pushed the actual synopsis off the
screen. Some other errors did not include usage information at all.
All output still goes to stdout, stderr is not used at all. Should be
changed in a seperate patch, because currently error messages during
operations like "--export -" get mixed with the result of the
operation.
Technically the output handling was simplified. All output is printed
via the logging system, instead of using a mixture of logging and
streaming into std::cout. The advantage is that it will be easier to
redirect all regular output inside the syncevo-dbus-helper to the
parent. In particular, the following code could be removed:
- the somewhat hacky std::streambuf->logging bridge code (CmdlineStreamBuf)
- SyncContext set/getOutput()
- ostream constructor parameters for Cmdline and derived classes
The new code uses SE_LOG_SHOW() to produce output without prefix. Each
call ends at the next line, regardless whether the string ends in a
newline or not. The LoggerStdout was adapted to behave according to
that expectation, and it inserts the line prefix at the start of each
line - probably didn't matter before, because hardly any (no?!)
message had line breaks.
Because of this implicit newline in the logging code, some newlines
become redundant; SE_LOG_SHOW("") is used to insert an empty line
where needed. Calls to the logging system are minimized if possible by
assembling output in buffers first, to reduce overhead and to adhere
to the "one call per message" guideline.
Testing was adapted accordingly. It's a bit stricter now, too, because
it checks the entire error output instead of just the last line. The
previous use of Cmdline ostreams to capture output from the class was
replaced with loggers which hook into the logging system while the
test runs and store the output. Same with SyncContext testing.
Conflicts:
src/dbus/server/cmdline-wrapper.h
2012-04-11 10:22:57 +02:00
std : : string str = StringPrintfV ( format , args ) ;
if ( level ! = SHOW ) {
out < < " [ " < < levelToStr ( level ) < < " ] " ;
m_all < < " [ " < < levelToStr ( level ) < < " ] " ;
}
out < < str ;
m_all < < str ;
if ( ! boost : : ends_with ( str , " \n " ) ) {
out < < std : : endl ;
m_all < < std : : endl ;
}
}
}
2008-03-29 15:16:34 +01:00
} ;
2011-11-17 14:30:15 +01:00
string DefaultConfig ( ) {
string config = ScheduleWorldConfig ( ) ;
boost : : replace_first ( config ,
" syncURL = http://sync.scheduleworld.com/funambol/ds " ,
" syncURL = http://yourserver:port " ) ;
boost : : replace_first ( config , " http://www.scheduleworld.com " , " http://www.syncevolution.org " ) ;
boost : : replace_all ( config , " ScheduleWorld " , " SyncEvolution " ) ;
boost : : replace_all ( config , " scheduleworld " , " syncevolution " ) ;
boost : : replace_first ( config , " PeerName = SyncEvolution " , " # PeerName = " ) ;
boost : : replace_first ( config , " # ConsumerReady = 0 " , " ConsumerReady = 1 " ) ;
boost : : replace_first ( config , " uri = card3 " , " uri = addressbook " ) ;
boost : : replace_first ( config , " uri = cal2 " , " uri = calendar " ) ;
boost : : replace_first ( config , " uri = task2 " , " uri = todo " ) ;
boost : : replace_first ( config , " uri = note " , " uri = memo " ) ;
boost : : replace_first ( config , " syncFormat = text/vcard " , " # syncFormat = " ) ;
return config ;
}
2011-01-10 15:56:53 +01:00
string ScheduleWorldConfig ( int contextMinVersion = CONFIG_CONTEXT_MIN_VERSION ,
int contextCurVersion = CONFIG_CONTEXT_CUR_VERSION ,
int peerMinVersion = CONFIG_PEER_MIN_VERSION ,
int peerCurVersion = CONFIG_PEER_CUR_VERSION ) {
// properties sorted by the order in which they are defined
// in the sync and sync source property registry
string config =
StringPrintf ( " peers/scheduleworld/.internal.ini:peerMinVersion = %d \n "
" peers/scheduleworld/.internal.ini:peerCurVersion = %d \n "
" peers/scheduleworld/.internal.ini:# HashCode = 0 \n "
" peers/scheduleworld/.internal.ini:# ConfigDate = \n "
" peers/scheduleworld/.internal.ini:# lastNonce = \n "
" peers/scheduleworld/.internal.ini:# deviceData = \n "
2011-04-20 18:13:16 +02:00
" peers/scheduleworld/.internal.ini:# webDAVCredentialsOkay = 0 \n "
2011-01-10 15:56:53 +01:00
" peers/scheduleworld/config.ini:syncURL = http://sync.scheduleworld.com/funambol/ds \n "
2011-03-23 12:14:31 +01:00
" peers/scheduleworld/config.ini:# username = \n "
" peers/scheduleworld/config.ini:# password = \n "
2011-01-10 15:56:53 +01:00
" .internal.ini:contextMinVersion = %d \n "
" .internal.ini:contextCurVersion = %d \n "
" config.ini:# logdir = \n "
" peers/scheduleworld/config.ini:# loglevel = 0 \n "
2012-05-22 10:05:11 +02:00
" peers/scheduleworld/config.ini:# notifyLevel = 3 \n "
2011-01-10 15:56:53 +01:00
" peers/scheduleworld/config.ini:# printChanges = 1 \n "
" peers/scheduleworld/config.ini:# dumpData = 1 \n "
" config.ini:# maxlogdirs = 10 \n "
" peers/scheduleworld/config.ini:# autoSync = 0 \n "
" peers/scheduleworld/config.ini:# autoSyncInterval = 30M \n "
" peers/scheduleworld/config.ini:# autoSyncDelay = 5M \n "
" peers/scheduleworld/config.ini:# preventSlowSync = 1 \n "
" peers/scheduleworld/config.ini:# useProxy = 0 \n "
" peers/scheduleworld/config.ini:# proxyHost = \n "
" peers/scheduleworld/config.ini:# proxyUsername = \n "
" peers/scheduleworld/config.ini:# proxyPassword = \n "
" peers/scheduleworld/config.ini:# clientAuthType = md5 \n "
" peers/scheduleworld/config.ini:# RetryDuration = 5M \n "
" peers/scheduleworld/config.ini:# RetryInterval = 2M \n "
" peers/scheduleworld/config.ini:# remoteIdentifier = \n "
" peers/scheduleworld/config.ini:# PeerIsClient = 0 \n "
" peers/scheduleworld/config.ini:# SyncMLVersion = \n "
2011-06-29 03:38:38 +02:00
" peers/scheduleworld/config.ini:PeerName = ScheduleWorld \n "
2011-01-10 15:56:53 +01:00
" config.ini:deviceId = fixed-devid \n " /* this is not the default! */
" peers/scheduleworld/config.ini:# remoteDeviceId = \n "
" peers/scheduleworld/config.ini:# enableWBXML = 1 \n "
2012-06-11 14:48:02 +02:00
" peers/scheduleworld/config.ini:# enableRefreshSync = 0 \n "
2011-01-10 15:56:53 +01:00
" peers/scheduleworld/config.ini:# maxMsgSize = 150000 \n "
" peers/scheduleworld/config.ini:# maxObjSize = 4000000 \n "
" peers/scheduleworld/config.ini:# SSLServerCertificates = \n "
" peers/scheduleworld/config.ini:# SSLVerifyServer = 1 \n "
" peers/scheduleworld/config.ini:# SSLVerifyHost = 1 \n "
" peers/scheduleworld/config.ini:WebURL = http://www.scheduleworld.com \n "
2011-07-12 18:30:02 +02:00
" peers/scheduleworld/config.ini:IconURI = image://themedimage/icons/services/scheduleworld \n "
2011-01-10 15:56:53 +01:00
" peers/scheduleworld/config.ini:# ConsumerReady = 0 \n "
2011-05-18 17:20:56 +02:00
" peers/scheduleworld/config.ini:# peerType = \n "
2011-01-10 15:56:53 +01:00
" peers/scheduleworld/sources/addressbook/.internal.ini:# adminData = \n "
" peers/scheduleworld/sources/addressbook/.internal.ini:# synthesisID = 0 \n "
" peers/scheduleworld/sources/addressbook/config.ini:sync = two-way \n "
" peers/scheduleworld/sources/addressbook/config.ini:uri = card3 \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" sources/addressbook/config.ini:backend = addressbook \n "
" peers/scheduleworld/sources/addressbook/config.ini:syncFormat = text/vcard \n "
" peers/scheduleworld/sources/addressbook/config.ini:# forceSyncFormat = 0 \n "
" sources/addressbook/config.ini:# database = \n "
" sources/addressbook/config.ini:# databaseFormat = \n "
2011-01-18 15:33:07 +01:00
" sources/addressbook/config.ini:# databaseUser = \n "
" sources/addressbook/config.ini:# databasePassword = \n "
2011-01-10 15:56:53 +01:00
" peers/scheduleworld/sources/calendar/.internal.ini:# adminData = \n "
" peers/scheduleworld/sources/calendar/.internal.ini:# synthesisID = 0 \n "
" peers/scheduleworld/sources/calendar/config.ini:sync = two-way \n "
" peers/scheduleworld/sources/calendar/config.ini:uri = cal2 \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" sources/calendar/config.ini:backend = calendar \n "
" peers/scheduleworld/sources/calendar/config.ini:# syncFormat = \n "
" peers/scheduleworld/sources/calendar/config.ini:# forceSyncFormat = 0 \n "
" sources/calendar/config.ini:# database = \n "
" sources/calendar/config.ini:# databaseFormat = \n "
2011-01-18 15:33:07 +01:00
" sources/calendar/config.ini:# databaseUser = \n "
" sources/calendar/config.ini:# databasePassword = \n "
2011-01-10 15:56:53 +01:00
" peers/scheduleworld/sources/memo/.internal.ini:# adminData = \n "
" peers/scheduleworld/sources/memo/.internal.ini:# synthesisID = 0 \n "
" peers/scheduleworld/sources/memo/config.ini:sync = two-way \n "
" peers/scheduleworld/sources/memo/config.ini:uri = note \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" sources/memo/config.ini:backend = memo \n "
" peers/scheduleworld/sources/memo/config.ini:# syncFormat = \n "
" peers/scheduleworld/sources/memo/config.ini:# forceSyncFormat = 0 \n "
" sources/memo/config.ini:# database = \n "
" sources/memo/config.ini:# databaseFormat = \n "
2011-01-18 15:33:07 +01:00
" sources/memo/config.ini:# databaseUser = \n "
" sources/memo/config.ini:# databasePassword = \n "
2011-01-10 15:56:53 +01:00
" peers/scheduleworld/sources/todo/.internal.ini:# adminData = \n "
" peers/scheduleworld/sources/todo/.internal.ini:# synthesisID = 0 \n "
" peers/scheduleworld/sources/todo/config.ini:sync = two-way \n "
" peers/scheduleworld/sources/todo/config.ini:uri = task2 \n "
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" sources/todo/config.ini:backend = todo \n "
" peers/scheduleworld/sources/todo/config.ini:# syncFormat = \n "
" peers/scheduleworld/sources/todo/config.ini:# forceSyncFormat = 0 \n "
" sources/todo/config.ini:# database = \n "
" sources/todo/config.ini:# databaseFormat = \n "
2011-01-18 15:33:07 +01:00
" sources/todo/config.ini:# databaseUser = \n "
" sources/todo/config.ini:# databasePassword = " ,
2011-01-10 15:56:53 +01:00
peerMinVersion , peerCurVersion ,
contextMinVersion , contextCurVersion ) ;
# ifdef ENABLE_LIBSOUP
// path to SSL certificates has to be set only for libsoup
boost : : replace_first ( config ,
" SSLServerCertificates = " ,
" SSLServerCertificates = /etc/ssl/certs/ca-certificates.crt:/etc/pki/tls/certs/ca-bundle.crt:/usr/share/ssl/certs/ca-bundle.crt " ) ;
# endif
2009-04-07 20:33:18 +02:00
2009-12-01 16:36:33 +01:00
#if 0
// Currently we don't have an icon for ScheduleWorld. If we
// had (MB #2062) one, then this code would ensure that the
// reference config also has the right path for it.
const char * templateDir = getenv ( " SYNCEVOLUTION_TEMPLATE_DIR " ) ;
if ( ! templateDir ) {
templateDir = TEMPLATE_DIR ;
}
if ( isDir ( string ( templateDir ) + " /ScheduleWorld " ) ) {
2009-04-07 20:33:18 +02:00
boost : : replace_all ( config ,
" # IconURI = " ,
2009-12-01 16:36:33 +01:00
string ( " IconURI = file:// " ) + templateDir + " /ScheduleWorld/icon.png " ) ;
2009-04-07 20:33:18 +02:00
}
2009-12-01 16:36:33 +01:00
# endif
2009-04-07 20:33:18 +02:00
return config ;
2008-03-30 18:13:08 +02:00
}
string OldScheduleWorldConfig ( ) {
2009-11-24 15:02:21 +01:00
// old style paths
string oldConfig =
" spds/syncml/config.txt:syncURL = http://sync.scheduleworld.com/funambol/ds \n "
2011-03-23 12:14:31 +01:00
" spds/syncml/config.txt:# username = \n "
" spds/syncml/config.txt:# password = \n "
2009-11-24 15:02:21 +01:00
" spds/syncml/config.txt:# logdir = \n "
" spds/syncml/config.txt:# loglevel = 0 \n "
2012-05-22 10:05:11 +02:00
" spds/syncml/config.txt:# notifyLevel = 3 \n "
2009-11-24 15:02:21 +01:00
" spds/syncml/config.txt:# printChanges = 1 \n "
2010-10-29 16:00:50 +02:00
" spds/syncml/config.txt:# dumpData = 1 \n "
2009-11-24 15:02:21 +01:00
" spds/syncml/config.txt:# maxlogdirs = 10 \n "
2010-03-02 06:34:42 +01:00
" spds/syncml/config.txt:# autoSync = 0 \n "
2010-03-22 17:45:03 +01:00
" spds/syncml/config.txt:# autoSyncInterval = 30M \n "
" spds/syncml/config.txt:# autoSyncDelay = 5M \n "
2010-02-25 17:59:51 +01:00
" spds/syncml/config.txt:# preventSlowSync = 1 \n "
2009-11-24 15:02:21 +01:00
" spds/syncml/config.txt:# useProxy = 0 \n "
" spds/syncml/config.txt:# proxyHost = \n "
" spds/syncml/config.txt:# proxyUsername = \n "
" spds/syncml/config.txt:# proxyPassword = \n "
" spds/syncml/config.txt:# clientAuthType = md5 \n "
2010-03-22 17:45:03 +01:00
" spds/syncml/config.txt:# RetryDuration = 5M \n "
2010-04-19 13:56:07 +02:00
" spds/syncml/config.txt:# RetryInterval = 2M \n "
2009-11-24 15:02:21 +01:00
" spds/syncml/config.txt:# remoteIdentifier = \n "
" spds/syncml/config.txt:# PeerIsClient = 0 \n "
2010-02-26 11:20:52 +01:00
" spds/syncml/config.txt:# SyncMLVersion = \n "
2011-06-29 03:38:38 +02:00
" spds/syncml/config.txt:PeerName = ScheduleWorld \n "
2009-11-24 15:02:21 +01:00
" spds/syncml/config.txt:deviceId = fixed-devid \n " /* this is not the default! */
2009-11-27 19:47:47 +01:00
" spds/syncml/config.txt:# remoteDeviceId = \n "
2009-11-24 15:02:21 +01:00
" spds/syncml/config.txt:# enableWBXML = 1 \n "
2012-06-11 14:48:02 +02:00
" spds/syncml/config.txt:# enableRefreshSync = 0 \n "
2010-02-25 17:59:51 +01:00
" spds/syncml/config.txt:# maxMsgSize = 150000 \n "
2009-11-24 15:02:21 +01:00
" spds/syncml/config.txt:# maxObjSize = 4000000 \n "
# ifdef ENABLE_LIBSOUP
// path to SSL certificates is only set for libsoup
" spds/syncml/config.txt:# SSLServerCertificates = /etc/ssl/certs/ca-certificates.crt:/etc/pki/tls/certs/ca-bundle.crt:/usr/share/ssl/certs/ca-bundle.crt \n "
# else
" spds/syncml/config.txt:# SSLServerCertificates = \n "
# endif
" spds/syncml/config.txt:# SSLVerifyServer = 1 \n "
" spds/syncml/config.txt:# SSLVerifyHost = 1 \n "
2010-01-19 19:17:31 +01:00
" spds/syncml/config.txt:WebURL = http://www.scheduleworld.com \n "
2011-07-12 18:30:02 +02:00
" spds/syncml/config.txt:IconURI = image://themedimage/icons/services/scheduleworld \n "
2010-12-14 14:29:00 +01:00
" spds/syncml/config.txt:# ConsumerReady = 0 \n "
2009-11-24 15:02:21 +01:00
" spds/sources/addressbook/config.txt:sync = two-way \n "
" spds/sources/addressbook/config.txt:type = addressbook:text/vcard \n "
2011-01-18 15:33:07 +01:00
" spds/sources/addressbook/config.txt:evolutionsource = xyz \n "
2009-11-24 15:02:21 +01:00
" spds/sources/addressbook/config.txt:uri = card3 \n "
2011-01-18 15:33:07 +01:00
" spds/sources/addressbook/config.txt:evolutionuser = foo \n "
" spds/sources/addressbook/config.txt:evolutionpassword = bar \n "
2009-11-24 15:02:21 +01:00
" spds/sources/calendar/config.txt:sync = two-way \n "
" spds/sources/calendar/config.txt:type = calendar \n "
2011-01-18 15:33:07 +01:00
" spds/sources/calendar/config.txt:# database = \n "
2009-11-24 15:02:21 +01:00
" spds/sources/calendar/config.txt:uri = cal2 \n "
" spds/sources/calendar/config.txt:# evolutionuser = \n "
" spds/sources/calendar/config.txt:# evolutionpassword = \n "
" spds/sources/memo/config.txt:sync = two-way \n "
" spds/sources/memo/config.txt:type = memo \n "
2011-01-18 15:33:07 +01:00
" spds/sources/memo/config.txt:# database = \n "
2009-11-24 15:02:21 +01:00
" spds/sources/memo/config.txt:uri = note \n "
" spds/sources/memo/config.txt:# evolutionuser = \n "
" spds/sources/memo/config.txt:# evolutionpassword = \n "
" spds/sources/todo/config.txt:sync = two-way \n "
" spds/sources/todo/config.txt:type = todo \n "
2011-01-18 15:33:07 +01:00
" spds/sources/todo/config.txt:# database = \n "
2009-11-24 15:02:21 +01:00
" spds/sources/todo/config.txt:uri = task2 \n "
" spds/sources/todo/config.txt:# evolutionuser = \n "
" spds/sources/todo/config.txt:# evolutionpassword = \n " ;
2008-03-30 18:13:08 +02:00
return oldConfig ;
}
2008-03-30 13:43:36 +02:00
string FunambolConfig ( ) {
2011-01-10 15:56:53 +01:00
string config = ScheduleWorldConfig ( ) ;
2009-11-24 15:02:21 +01:00
boost : : replace_all ( config , " /scheduleworld/ " , " /funambol/ " ) ;
2011-06-29 03:38:38 +02:00
boost : : replace_all ( config , " PeerName = ScheduleWorld " , " PeerName = Funambol " ) ;
2008-03-30 13:43:36 +02:00
boost : : replace_first ( config ,
2008-06-28 15:27:07 +02:00
" syncURL = http://sync.scheduleworld.com/funambol/ds " ,
2014-05-16 09:32:58 +02:00
" syncURL = https://onemediahub.com/sync " ) ;
2008-03-30 13:43:36 +02:00
2009-04-07 20:33:18 +02:00
boost : : replace_first ( config ,
2010-01-18 21:58:31 +01:00
" WebURL = http://www.scheduleworld.com " ,
2014-05-16 09:32:58 +02:00
" WebURL = https://onemediahub.com " ) ;
2009-04-07 20:33:18 +02:00
2011-07-12 18:30:02 +02:00
boost : : replace_first ( config ,
" IconURI = image://themedimage/icons/services/scheduleworld " ,
" IconURI = image://themedimage/icons/services/funambol " ) ;
2010-12-14 14:29:00 +01:00
boost : : replace_first ( config ,
" # ConsumerReady = 0 " ,
" ConsumerReady = 1 " ) ;
2009-06-25 11:06:07 +02:00
boost : : replace_first ( config ,
" # enableWBXML = 1 " ,
" enableWBXML = 0 " ) ;
2012-06-11 14:48:02 +02:00
boost : : replace_first ( config ,
" # enableRefreshSync = 0 " ,
" enableRefreshSync = 1 " ) ;
2010-04-19 13:56:07 +02:00
boost : : replace_first ( config ,
" # RetryInterval = 2M " ,
" RetryInterval = 0 " ) ;
2008-03-30 13:43:36 +02:00
boost : : replace_first ( config ,
" addressbook/config.ini:uri = card3 " ,
" addressbook/config.ini:uri = card " ) ;
2009-11-24 15:02:21 +01:00
boost : : replace_all ( config ,
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" addressbook/config.ini:syncFormat = text/vcard " ,
" addressbook/config.ini:# syncFormat = " ) ;
2008-03-30 13:43:36 +02:00
boost : : replace_first ( config ,
2008-06-12 20:55:01 +02:00
" calendar/config.ini:uri = cal2 " ,
2008-03-30 13:43:36 +02:00
" calendar/config.ini:uri = event " ) ;
2009-11-24 15:02:21 +01:00
boost : : replace_all ( config ,
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" calendar/config.ini:# syncFormat = " ,
" calendar/config.ini:syncFormat = text/calendar " ) ;
boost : : replace_all ( config ,
" calendar/config.ini:# forceSyncFormat = 0 " ,
" calendar/config.ini:forceSyncFormat = 1 " ) ;
2008-03-30 13:43:36 +02:00
boost : : replace_first ( config ,
" todo/config.ini:uri = task2 " ,
" todo/config.ini:uri = task " ) ;
2009-11-24 15:02:21 +01:00
boost : : replace_all ( config ,
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" todo/config.ini:# syncFormat = " ,
" todo/config.ini:syncFormat = text/calendar " ) ;
boost : : replace_all ( config ,
" todo/config.ini:# forceSyncFormat = 0 " ,
" todo/config.ini:forceSyncFormat = 1 " ) ;
2008-03-30 13:43:36 +02:00
return config ;
}
string SynthesisConfig ( ) {
2011-01-10 15:56:53 +01:00
string config = ScheduleWorldConfig ( ) ;
2009-11-24 15:02:21 +01:00
boost : : replace_all ( config , " /scheduleworld/ " , " /synthesis/ " ) ;
2011-06-29 03:38:38 +02:00
boost : : replace_all ( config , " PeerName = ScheduleWorld " , " PeerName = Synthesis " ) ;
2009-11-24 15:02:21 +01:00
2008-03-30 13:43:36 +02:00
boost : : replace_first ( config ,
2008-06-28 15:27:07 +02:00
" syncURL = http://sync.scheduleworld.com/funambol/ds " ,
2008-03-30 13:43:36 +02:00
" syncURL = http://www.synthesis.ch/sync " ) ;
2009-04-07 20:33:18 +02:00
boost : : replace_first ( config ,
2010-01-18 21:58:31 +01:00
" WebURL = http://www.scheduleworld.com " ,
2011-07-12 18:30:02 +02:00
" WebURL = http://www.synthesis.ch " ) ;
boost : : replace_first ( config ,
" IconURI = image://themedimage/icons/services/scheduleworld " ,
" IconURI = image://themedimage/icons/services/synthesis " ) ;
2009-04-07 20:33:18 +02:00
2008-03-30 13:43:36 +02:00
boost : : replace_first ( config ,
" addressbook/config.ini:uri = card3 " ,
" addressbook/config.ini:uri = contacts " ) ;
2009-11-24 15:02:21 +01:00
boost : : replace_all ( config ,
config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).
This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format
With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.
Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.
The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.
The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.
Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.
Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
instead of the long "Files in one directory", which is now an alias
(used to be the other way around); done because "type = file"
was expanded to the long name, which was a bit unexpected and showed
how unintuitive the long name is
Internal changes:
- getMimeVersion() is still present, although it hasn't been used
for a long time; FileSyncSource::getMimeVersion() now derives
the version from the supported Mime types, in case that the
function will be needed again in the future
- setSourceType() with string as argument was replaced with one
taking a SourceType instance; to emulate the old behavior if
desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
like SourceBackendConfigProperty can generate content at runtime
(a recent commit broke that feature)
- File templates were stripped down to the essential properties,
with "type" replaced by the per-peer "syncFormat". "type" would
still have been accepted (so it is not necessary to adapt
syncevo-phone-config right away), but has the original
disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:17:24 +01:00
" addressbook/config.ini:syncFormat = text/vcard " ,
" addressbook/config.ini:# syncFormat = " ) ;
2008-03-30 13:43:36 +02:00
boost : : replace_first ( config ,
2008-06-12 20:55:01 +02:00
" calendar/config.ini:uri = cal2 " ,
2008-03-30 13:43:36 +02:00
" calendar/config.ini:uri = events " ) ;
boost : : replace_first ( config ,
" calendar/config.ini:sync = two-way " ,
" calendar/config.ini:sync = disabled " ) ;
boost : : replace_first ( config ,
" memo/config.ini:uri = note " ,
" memo/config.ini:uri = notes " ) ;
boost : : replace_first ( config ,
" todo/config.ini:uri = task2 " ,
" todo/config.ini:uri = tasks " ) ;
boost : : replace_first ( config ,
" todo/config.ini:sync = two-way " ,
" todo/config.ini:sync = disabled " ) ;
return config ;
2010-01-29 20:28:24 +01:00
}
2008-03-29 15:16:34 +01:00
2008-03-28 23:32:00 +01:00
/** create directory hierarchy, overwriting previous content */
2008-03-30 17:15:00 +02:00
void createFiles ( const string & root , const string & content , bool append = false ) {
if ( ! append ) {
rm_r ( root ) ;
}
2008-03-28 23:32:00 +01:00
size_t start = 0 ;
ofstream out ;
string outname ;
out . exceptions ( ios_base : : badbit | ios_base : : failbit ) ;
while ( start < content . size ( ) ) {
size_t delim = content . find ( ' : ' , start ) ;
size_t end = content . find ( ' \n ' , start ) ;
if ( delim = = content . npos | |
end = = content . npos ) {
// invalid content ?!
break ;
}
string newname = content . substr ( start , delim - start ) ;
string line = content . substr ( delim + 1 , end - delim - 1 ) ;
if ( newname ! = outname ) {
if ( out . is_open ( ) ) {
out . close ( ) ;
}
string fullpath = root + " / " + newname ;
size_t fileoff = fullpath . rfind ( ' / ' ) ;
mkdir_p ( fullpath . substr ( 0 , fileoff ) ) ;
2008-03-30 17:15:00 +02:00
out . open ( fullpath . c_str ( ) ,
2011-08-19 16:19:12 +02:00
append ? ( ios_base : : out | ios_base : : ate | ios_base : : app ) : ( ios_base : : out | ios_base : : trunc ) ) ;
2008-03-28 23:32:00 +01:00
outname = newname ;
}
out < < line < < endl ;
start = end + 1 ;
}
}
2009-11-24 15:02:21 +01:00
/** turn directory hierarchy into string
*
* @ param root root path in file system
* @ param peer if non - empty , then ignore all < root > / peers / < foo > directories
* where < foo > ! = peer
* @ param onlyProps ignore lines which are comments
*/
string scanFiles ( const string & root , const string & peer = " " , bool onlyProps = true ) {
2008-03-28 23:32:00 +01:00
ostringstream out ;
2009-11-24 15:02:21 +01:00
scanFiles ( root , " " , peer , out , onlyProps ) ;
2008-03-28 23:32:00 +01:00
return out . str ( ) ;
}
2008-03-30 23:50:51 +02:00
2009-11-24 15:02:21 +01:00
void scanFiles ( const string & root , const string & dir , const string & peer , ostringstream & out , bool onlyProps ) {
2008-03-29 15:16:34 +01:00
string newroot = root ;
newroot + = " / " ;
newroot + = dir ;
ReadDir readDir ( newroot ) ;
2008-03-28 23:32:00 +01:00
sort ( readDir . begin ( ) , readDir . end ( ) ) ;
2008-07-11 22:25:02 +02:00
BOOST_FOREACH ( const string & entry , readDir ) {
if ( isDir ( newroot + " / " + entry ) ) {
2009-11-24 15:02:21 +01:00
if ( boost : : ends_with ( newroot , " /peers " ) & &
! peer . empty ( ) & &
entry ! = peer ) {
// skip different peer directory
continue ;
} else {
scanFiles ( root , dir + ( dir . empty ( ) ? " " : " / " ) + entry , peer , out , onlyProps ) ;
}
2008-03-29 15:16:34 +01:00
} else {
ifstream in ;
in . exceptions ( ios_base : : badbit /* failbit must not trigger exception because is set when reaching eof ?! */ ) ;
2008-07-11 22:25:02 +02:00
in . open ( ( newroot + " / " + entry ) . c_str ( ) ) ;
2008-03-29 15:16:34 +01:00
string line ;
while ( ! in . eof ( ) ) {
getline ( in , line ) ;
if ( ( line . size ( ) | | ! in . eof ( ) ) & &
( ! onlyProps | |
2008-03-30 23:50:51 +02:00
( boost : : starts_with ( line , " # " ) ?
isPropAssignment ( line . substr ( 2 ) ) :
! line . empty ( ) ) ) ) {
2008-03-29 15:16:34 +01:00
if ( dir . size ( ) ) {
out < < dir < < " / " ;
}
2008-07-11 22:25:02 +02:00
out < < entry < < " : " ;
2008-03-29 15:16:34 +01:00
out < < line < < ' \n ' ;
2008-03-28 23:32:00 +01:00
}
}
}
}
}
2008-03-30 15:41:56 +02:00
string printConfig ( const string & server ) {
configuration: removed builtin templates
The code for builtin templates had side effects, like always adding
all four standard sources to a template, even if the template itself
didn't have all of them defined. It also hid the problem that listing
templates didn't work for templates on disk.
Another benefit is that template files can be packaged separately. By
choosing the packages which are to be installed, a distributor of
SyncEvolution (like MeeGo) can choose which services to offer by
default.
Therefore this patch removes the "builtin templates" feature, which
was only useful in unusual use cases anyway (for example, single-binary
distribution).
Because there are no more default values for source properties, all
templates must specify the "backend" explicitly. syncevo-phone-config
was adapted accordingly, and also updated to use the current names of
the properties in the process.
As part of moving the templates into separate files, some of them
were cleaned up:
- Mobical: now points to Everdroid, its new name
- Google, Ovi: SSL verification is always enabled in the templates;
the workaround for old libsoup should no longer be
necessary for most users
- Google: renamed to "Google_Contacts", with "Google" as alias,
because there will be two Google templates soon
- Scheduleworld: use "server no longer in operation" instead of
an invalid URL
The finger print match had a special case for "default". The exact
intention of that is unknown. Perhaps it was meant to give that
template a boost when it wouldn't match the string that is getting
searched for at all.
But it had the effect that an exact match when searching for the
"default" template was not found and thus that template couldn't be
used in the command line after moving it from builtin to external.
Removed the complete check.
2011-05-18 14:11:54 +02:00
ScopedEnvChange templates ( " SYNCEVOLUTION_TEMPLATE_DIR " , " templates " ) ;
2008-03-30 15:41:56 +02:00
ScopedEnvChange xdg ( " XDG_CONFIG_HOME " , m_testDir ) ;
ScopedEnvChange home ( " HOME " , m_testDir ) ;
TestCmdline cmdline ( " --print-config " , server . c_str ( ) , NULL ) ;
cmdline . doit ( ) ;
CPPUNIT_ASSERT_EQUAL_DIFF ( " " , cmdline . m_err . str ( ) ) ;
return cmdline . m_out . str ( ) ;
}
2008-03-28 23:32:00 +01:00
} ;
2009-10-05 14:49:32 +02:00
SYNCEVOLUTION_TEST_SUITE_REGISTRATION ( CmdlineTest ) ;
2008-03-28 23:32:00 +01:00
# endif // ENABLE_UNIT_TESTS
2009-10-02 17:23:53 +02:00
SE_END_CXX