Commit graph

150 commits

Author SHA1 Message Date
Patrick Ohly 5c27f81d5f testing: adapted Cmdline tests to revised config descriptions
Formatting was changed and a new warning was inserte for "sync".
(cherry picked from commit bb222f236a)
2011-11-18 15:15:35 +00:00
Patrick Ohly 13b89e2224 documentation: added glossary and command line conventions sections, improved listing of properties
The README.rst now introduces some terms in a glossary directly after
the synopsis. The way how config, sources and properties are used on
the command line are also defined first in their own section, instead
of introducing that further down as part of the options.

The output of "--sync/source-property ?" was changed:
- now it includes information about aliases, default values
  and sharing state (useful by itself)
- follows reStructured Text format and thus can be embedded
  directly inside the README.rst

The Makefile rules for that will be committed in the next patch
(must be done differently on syncevolution-1-2 and master branch,
whereas this commit applies cleanly to both).
2011-10-24 20:04:36 +02:00
Patrick Ohly 0b8a15362f command line: also check password for --import/export/delete-items and the source (BMC #21311, #22937)
The previous commit 7411f7e had the password check in the code branch
for --print-items. --import/export/delete-items still had the same
problem. Moved the code.

Source passwords must also be checked, in case that "backendPassword"
is set. Added.
2011-09-14 15:07:31 +02:00
Patrick Ohly a8effb21b8 config migration: avoid name conflicts and auto syncing of old configs (BMC #22691)
When (auto-)migrating a config, it was possible that a name for the
peer, say foo.old, was chosen for the renamed config although there
was already such a config, for example foo.old in ~/.sync4j. Besides
being confusing for users, this also led to a bug in the code where it
copied from the older config with the foo.old name.

Found when adding unit testing of migrating configs with auto syncing,
because then the content of the migrated config mattered.

The main problem fixed in this commit is the disabling of auto syncing
in the old config. Done similar to ConsumerRead, by reading/writing
the .ini (resp. .txt) file directly.
2011-08-19 16:19:12 +02:00
Salvatore Iovene 7411f7e8e3 Fixes BMC#21311 - item operations: authentication problem for WebDAV when using keyring
Use checkPassword() before trying to --print-items. This will either
prompt for the password at command line, or ask it from the keyring
if --keyring is specified (or if using the dbus server).
2011-08-05 14:37:41 +02:00
Salvatore Iovene 10418e133a Cmdline.cpp: we don't need *both* gnome-keyring and kwallet to store the pwd. 2011-08-05 14:37:41 +02:00
Patrick Ohly 84eb04d291 config templates: added IconURI to all templates (BMC #20750)
Most of the selected theme icons don't exist, so adding these values
only provides the possibility to add icons later on.

For Google Contacts, the existing gmail icon is used as a short-term
solution until the theme gets a proper google-contacts icon.
2011-07-12 18:30:02 +02:00
Patrick Ohly 3d20ede9a6 templates: added generic WebDAV template
In contrast to the Yahoo template, this one doesn't mention
a specific service and enables both contact and calendar sync.
To be used with a service that supports auto-discovery.
2011-07-06 19:47:07 +02:00
Patrick Ohly 8032247a5a local sync: renamed "source-config" to "target-config"
As discussed on the mailing list, "source-config" is ambiguous because
the "addressbook/calendar/..." configs are also called "source
configs".

Now the naming is "sync" config (for the config with syncURL=local://,
because it is used for syncing) and "target" config (because it is
used as target in a sync config's syncURL).

Rejected:
"local" config - because the databases are not necessarily local
"source" config - see above
"client" or "server" config - because both sides might use local data
                              and/or client/server could refer to the role
                              of the peer or the SyncML client/server model
                              used internally
2011-06-28 18:42:43 -07:00
Patrick Ohly 34e6667e14 templates: Add PeerName field, part II
The Funambol template hadn't been updated and the command line
tests failed because the didn't expect the PeerName to be set.

The normalization of "= F" to "= 0" broke the "= Funambol" peer name.
Doesn't seem to server any useful purpose anymore, so removed.
2011-06-28 18:38:38 -07:00
Patrick Ohly 528f8ef5a8 WebDAV templates: avoid complete data dump
Each sync involving WebDAV did a complete data dump (dumpData) and
showed differences (printChanges) for the WebDAV side of the sync.
This could be used to restore the WebDAV server after a sync, but it
seems a bit excessive and not useful for most users because the same
is also done on the local side of the sync.

Therefore this patch sets these two options to off in the
configuration templates.
2011-06-24 17:09:18 +02:00
Patrick Ohly aa7321e6b4 Google template: fixed Cmdline test
Adding the IconURI broke the SyncEvo::CmdlineTest::testPrintFileTemplates test.
Test had to be adapted to the modified template content.
2011-06-24 17:09:17 +02:00
Patrick Ohly 10109fd208 WebDAV + command line: simplify creation of source-config@yahoo|google-calendar
This patch teaches the command line how to infer the right template
for a source-config@<something> config creation:
   syncevolution --configure source-config@google-calendar

For this particular example, "google-calendar" must match the "Google
Calendar" fingerprint in the template. Spaces, hyphen and underscores
are now all considered equal in TemplateConfig::fingerprintMatch().

Also added CmdlineTest::testWebDAV unit test. The test can only run if
WebDAV support is enabled, because otherwise the
backend=CardDAV/CalDAV would be rejected.
2011-06-08 12:19:51 +02:00
Patrick Ohly 33f0c9c3f6 WebDAV: added templates for Yahoo and Google
This patch introduces the new "peerType" property which marks
templates and configs as something that can be used for the
'source-config@<target>' configs necessary for local sync.

Only "WebDAV" is used. If peerType is not set, the template or config
is traditional SyncML.

This patch also adds two templates, one for Google Calendar and one
for Yahoo CardDAV and CalDAV. Because Yahoo CardDAV is unreliable,
it is not enabled.
2011-06-08 12:19:51 +02:00
Patrick Ohly bfb7a85f84 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-06-08 12:19:51 +02:00
Patrick Ohly c72ca29f5c Cmdline: better error reporting when unit tests fail
Better check error message before return code. That way
a non-zero error is visible in the output instead of
only the failed run check.

Calling doit() would be shorter, but hide the actual location
of the failure.
2011-06-08 12:19:51 +02:00
Patrick Ohly f04988de68 Cmdline: cleaned up unit testing
Moved removal and creation of the test directory (= "CmdlineTest")
into the test setup method. That way all tests are guaranteed to
start in a clean state, without having to duplicate that all over
the place.

Motivated by the observation that at least one test didn't have the
necessary cleanup, which caused a failure when creating more
templates.
2011-06-08 12:19:51 +02:00
Patrick Ohly fa237c72cd templates: listing templates only showed builtin templates
"syncevolution --templates ?" only showed builtin templates
because the scanning for template on disk was called without
any match definition => empty results, only builtin templates
used as fallback.
2011-05-18 10:04:49 +02:00
Patrick Ohly b6861ed768 nightly testing: renamed ical20/itodo20/vcard30/text, removed vcard21 from Evolution backend (BMC #14972)
The distinction between vcard21 and vcard30 became mute in the Evolution
backend a while ago. Both tests ended up using the vCard 3.0 Evolution
tests data and the default uri for each server. This patch removes
the vCard 2.1 special case.

It also renames the tests and test data to reflect that they always
were Evolution specific. The new naming convention, also applied
to file, QtContacts, KCalExtended, XMLRPC, Maemo and Akonadi backends, is
now <backend>_contact/event/task/memo, with eds/file/qt/kcal/maemo/kde
as backend names.

The reasoning is:
- results in unique string (in particular no overlap with
  backend type names), easier to search for
- underscore already used before (in contrast to hyphen)
- no plural-s to keep the name shorter

The Akonadi backend should be using its own test data instead of
the Evolution ones.
2011-05-05 20:15:55 +08:00
Patrick Ohly d2e70d93e5 command line: an invalid --template parameter did not always trigger an error
Specifying an invalid template name continued with an empty template
if enough properties were specified. That's not correct and leads
to unexpected results:
- peerIsClient might have been part of the desired template.
- Set of sources to be created is defined by template.

Now an error is printed for this case.
2011-04-20 22:11:36 +02:00
Patrick Ohly 98c98fa29a command line: avoid spaces in the handles of template names
The device templates contained spaces ("Nokia N900", for example),
which was hard to use on the command line and in scripts. Now
an underscore is used instead of spaces.
2011-04-20 18:15:07 +02:00
Patrick Ohly 118662a301 WebDAV: always register our special property
This is a better fix for the webDAVCredentialsOkay property
registration: always do it, regardless whether the backend is enabled,
because then the config migration code will always know about it.

Also fixed automated testing to include that property.
2011-04-20 18:13:16 +02:00
Patrick Ohly 87b4a063a3 command line: better error message when checking sources, avoid "list"
The command line instantiated sources with the name "list" (cut-and-paste
error?) instead of using the proper name. As a result, error messages
created by these sources didn't refer back to the configuration. Now
the real name is used.
2011-04-19 13:48:13 +02:00
Patrick Ohly bb5c1ac39b SyncSource config: grant sources read/write access to context
The intention always was that backends may add their own
properties. For sync properties this seemed less relevant,
so sources only got read access to it.

But the WebDAV backends run with their own "source-config" context
and now need read/write access to store information that is
shared between all sources.

Therefore this patch removes the "const" qualifier from SyncConfig.
2011-04-15 13:26:55 +02:00
Patrick Ohly 31e286059b eGroupware: added template (BMC #15992)
The problem with eGroupware is that it doesn't have one fixed syncURL.
Users of the template must remember to change it. To make this more
obvious, it is set to http://set.your.domain.here/rpc.php

The failure to fix the URL is leading to fairly obvious network
errors.

Various people have reported success with eGroupware, the latest
one here: http://www.ruinelli.ch/how-to-sync-egroupware-with-a-tablet-n900-with-syncevolution
Therefore it makes sense to also mark this template as "consumerReady"
and have it shown in the sync UI.
2011-04-15 08:15:19 +02:00
Dinesh ab25aef728 command line + syncevo-dbus-server: added support for KWallet
Currently not enabled in compilation by default. If KWallet support is
enabled, it will check whether KDE is running and otherwise fall back
to GNOME keyring.
2011-04-13 10:34:13 +02:00
Patrick Ohly 21dd62cd71 command line: relaxed checking of config creation (BMC #14805)
SyncEvolution used to insist on having a template when creating a
config from scratch. This was meant to address typos like "--configure
sheduleworld".  But when the command line contains enough information,
no template is needed.

The same logic was applied to configuring a source: if a source was not
among those defined by the template, configuring it was rejected as a
typo.

With this patch, there are two ways around these checks:
- --template none and/or
- specifying required properties on the command line

This patch also removes the special cases for "your SyncML server
account name/password". Username/password aren't always needed
(previous patch), nor are they always for a SyncML server anymore.
2011-03-23 12:14:31 +01:00
Patrick Ohly 21084cb470 command line: fix issue with configuring a peer multiple times
This patch fixes a problem that occured if:
* a peer was configured with a ifferently named template (--configure --template foo bar)
* and there was a config foo@xyz.

Then the nonsense error message "ERROR: template foo must not specify a context."
was printed (nonsense because "foo" does not specify a context) and the operation
failed.

The root cause was that SyncConfig::normalizeConfigString() expanded
the "foo" string to "foo@xyz" (desired when "foo" is a shorthand for
an existing config). This behavior now can be turned off with a
flag. The patch does that by replacing the bool parameter with a bit
field.
2011-03-02 11:20:27 +01:00
Patrick Ohly da7f503bee Memotoo: use vCard 3.0
When SyncEvolution prefers vCard 3.0, additional properties like
NICKNAME work with Memotoo. This patch a) makes that the default
syncFormat in the Memotoo template and b) automatically sets it
in the "addressbook" source of all migrated configs which sync
with Memotoo (detected based on the syncURL).

The automatic config rewriting is possible because users upgrading
from the previous stable SyncEvolution release need to migrate their
configs anyway. Normally SyncEvolution does not modify configs like
this.
2011-03-02 11:05:18 +01:00
Patrick Ohly ed64a3f067 config migration: handle inconsistent old config (type mismatch!)
If the context "type" was wrong and only the peer "type" was right,
the old config was usable for syncing. It seems that the "Memotoo"
template created such broken configs. After migration, the wrong
backend was selected based on the context's broken "type", thus
breaking syncing.

This patch fixes that problem by overriding the context "type" with
the corresponding values from one peer which has the source enabled.
The rationale is that this peer used to work and should be kept
working.

There's still a chance that different peers had different backends
configured, which is neither checked nor detected at the moment.
2011-02-14 14:39:58 +01:00
Patrick Ohly 720a194e66 command line: fixed printing of sources (BMC #13301)
After the removal of the "type" property, listing of sources broke
because the command kind code kept setting that to select a backend.
Fixed by parsing the type and setting "backend" and "databaseFormat"
instead.
2011-02-08 09:46:58 +01:00
Patrick Ohly cf23b4e912 command line: --sync/source-property keyword optional
Just saying "foo = bar" is enough now. --sync-property and
--source-property are still accepted, in case that "foo" ever becomes
ambiguous (not the case right now).
2011-02-03 14:05:16 +01:00
Patrick Ohly 664a1e54a5 ConfigProperty: removed the SHARED_AND_UNSHARED hack
After removing the "type" property there is no longer any property
which is both shared and unshared. Removing the dead code.
2011-02-03 13:00:22 +01:00
Patrick Ohly 388f72b369 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:59:02 +01:00
Patrick Ohly f6c151b26c SyncConfig + command line: enabled migration of config contexts
Because of the shared source property name changes
(evolutionsource/user/password -> database*), mixing old and new
configs inside the same context is not possible. Bumped
CONFIG_CONTEXT_MIN_VERSION and CONFIG_CONTEXT_CUR_VERSION to reflect
that and added the necessary code for migrating a context and all
peers inside it.

This is triggered by a) an automatic config migration in release mode
and b) an explicit --migrate of *any peer inside the context* or of
the context itself.
2011-02-01 22:14:22 +01:00
Patrick Ohly 2229146e1a merge: refactoring 2011-02-01 16:32:22 +01:00
Patrick Ohly 34437d77cb command line: refactored migrate/configure code
No functional changes. Splitting out some code should make it easier
to migrate contexts.
2011-02-01 16:04:04 +01:00
Patrick Ohly 706b667c6a Cmdline test: test wasn't independent of others
CmdlineTest::testSetupRenamed failed when the config dir wasn't in
the expected state, because it wasn't cleared properly.
2011-02-01 15:25:01 +01:00
Patrick Ohly 07390794c9 command line: --remove was broken by recent commit
--remove sanity check had the logic for "has properties" inverted,
which prevented running the operation *unless* a property was given.
2011-01-31 11:34:46 +01:00
Patrick Ohly 19d0ad900c command line: per-source source properties ("addressbook/...") were ignored when creating from scratch
When creating a config from scratch, the command line source properties
applying to the default source set in the template were ignored. That's
because createFilters() needs to know about all active sources, otherwise
it won't create the filters for them.
2011-01-28 14:35:49 +01:00
Patrick Ohly 5f504e7312 Cmdline tests: show error output in CPPUnit exception
When running a command line failed, an assertion was raised without
ever showing the error output of the failed command line. Now it is
included as message text in the CPPUNIT_ASSERT_MESSAGE() exception.
2011-01-28 14:34:45 +01:00
Patrick Ohly acac1c28d8 command line: fixed the "source props set, no sources selected" case
If --source-property was set while syncing, the intention was to only
apply (and thus potentially enable) the filter to active sources. If
no sources where specified on the command line, then the code looked
at the config to build that list.

That code must have been broken for a long time, because it had a ==
"disabled" check instead of != "disabled", thus enabling exactly the
wrong sources. Fixed.

Probably not relevant for old releases because it only applied to cases
where no source filter was set. That additional shortcut check was
removed when rewriting the property filters, so now it was found.
2011-01-25 12:01:01 +01:00
Patrick Ohly 74cd593111 command line: complain about invalid "<source>/" prefix in sync props 2011-01-25 11:45:28 +01:00
Patrick Ohly dfb5cc5a09 local sync: override properties per config
Now the @context or @peer@context suffix in sync and source properties
on the command line can be used to configure both sides of the sync
differently.
2011-01-25 11:38:49 +01:00
Patrick Ohly 16bf21f53e command line: specify properties per source and config
The new format of the property name in --sync-property is:
  <name>[@<context>|@<peer>@<context>]

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

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

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

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

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

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

SyncConfig itself still only stores the filters which apply to it, not
the full set of overrides that the Cmdline has in its m_props. The
advantage is that the API remains the same (no change needed or done
in the syncevo-dbus-server). The disadvantage is that in a local
sync, no information is available about the properties applying to the
target context - probably needs to change.
2011-01-25 11:11:53 +01:00
Patrick Ohly 3cfc889178 configuration: renamed evolutionsource->database, evolutionuser/password->evolutionUser/Password
This renames the legacy "evolutionsource/user/password" properties to
"database" and "databaseUser/Password". The justification is that
these properties are also used outside of the Evolution backends.

The change can be done now because the on-disk format has to be
changed anyway in a backward-incompatible way.

The CmdlineTest::testOldConfigure test covers reading an old-style
config.
2011-01-18 16:16:52 +01:00
Patrick Ohly a6c245580c 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
Patrick Ohly a61b8590f3 backend API cleanup: removal of "const char *" return types
SyncConfig inherited "const char *" from the Funambol C++ API and some
other methods used the same approach for efficient access to plain
strings. However, this has the disadvantage that dynamically generated
strings cannot be returned. SyncConfig had to use an awkward
workaround with a local string cache.

This patch converts most of that code to a normal std::string return
value and removes the string cache.

Out-of-tree backends must be adapted, otherwise they won't compile.
2011-01-18 15:15:09 +01:00
Patrick Ohly 549e1d69a8 nightly testing: fix for CmdlineTest::testOldConfigure
The previous commit broke the test because now ConsumerReady is
set after migration.
2011-01-18 14:35:13 +01:00
Patrick Ohly cc90383f13 config migration: special handling for config visibility of <1.2 configs
SyncEvolution < 1.2 considered all existing configurations
user-visible in UIs, therefore the ConsumerReady flags was not always
set (done by sync-ui, not done by command line).

In order to keep such old configs visible even when the updated
sync-ui (and soon Genesis) check the flag, the syncevo-dbus-server
transparently adds the flag when it finds a config written by
SyncEvolution < 1.2.

The Cmdline.cpp migration code does the same when rewriting such and
old config for read/write use.
2011-01-17 21:48:57 +01:00