Commit Graph

20 Commits

Author SHA1 Message Date
Milan Crha 75dff12823 Python2 -> Python3
Originally developed by Milan Crha for Fedora, copied from there
by Patrick Ohly.
2020-08-09 16:31:32 +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 bd32d1faa9 syncevo-phone-config: set consumerReady in output (BMC #3803)
None of the config templates added to the wiki contain the "consumerReady"
flag. Therefore they don't show up in the sync-ui once a user follows the
instructions for downloading them.

The tool now adds the flag automatically, because a user who downloads
the template does so in order to use it, regardless whether it is
ready or not (which we haven't defined anyway for phones).
2010-08-27 13:30:05 +02:00
Zhu, Yongsheng b58e7bc751 syncevo-phone-config: generate correct config for 'calendar+todo' (MBC#1197)
When combining calendar and todo into one source, phone config has
2 problems:
1) don't generate correct 'evolutionsource=calendar,todo' for the source
2) It should disable 'calendar' and 'todo' sources instead of 'calendar+
todo'. It's an obvious bug.
Now the tool can generate correct config for Nokia 7210c.
2010-05-18 13:53:16 +08:00
Patrick Ohly e29bf278eb syncevo-phone-config: handle phones with no calendar or no todo (MBC #1847)
The Sony Ericsson W595 only support contacts and events, but no tasks.
That triggered an access to a "NoneType" for the task config. Need to
check not only for existance of key, but also for real value.
2010-05-07 14:05:42 +02:00
Patrick Ohly be78d802a8 syncevo-phone-config: add "forced types" to tested configs (MBC #1197)
Types like "text/calendar" are implicitly turned into
"text/x-vcalendar" inside SyncEvolution when asking the phone to
sync. Forcing the type leads to a different SAN message and thus
is worth testing.

Forcing legacy types also leads to a slightly different sync session:
the SAN is the same as without forcing the type, but then we send
simpler CtCap information. This might make a difference when a phone
stumbles over too complex CtCap. But because such a phone should
work when disabling CtCap altogether, the forced legacy types are
not tested separately (would increase overall number of test cases).

Using --advanced with a --type for which no test data exists now fails
with an error instead of silently using empty items.
2010-04-28 08:06:57 +02:00
Patrick Ohly 8a23af0acb syncevo-phone-config: avoid referencing invalid config (MBC #1197)
The code which set remoteIdentifier and SyncMLVersion in the template
copied from a "config" variable which was not set if a) not creating
a config earlier or b) the last source had no working config.

Case b actually occurred when running against a MeeGo netbook, which
has no "memo" database.

The fix is simple: only copy the values when at least one source has
them.
2010-04-28 08:06:57 +02:00
Chen Congwu b5138faee1 syncevo-phone-config: some syntax fixes 2010-04-28 08:06:57 +02:00
Patrick Ohly b2bd8ff35d syncevo-phone-config: fix combined calendar detection for Nokia phones?! (MBC #1197)
After thinking some more about this, I think the current version of
the script will fail to detect combined calendar+todo for Nokias,
because of the changed order of URIs that we test. I think Nokia
phones ignore the URI that we send to it and then decides on the data
store entirely based on the data type. That way the first URIs for
calendar and todo are accepted ("Calendar" and "Task"), which breaks
the "URI equal" comparison.

The fix should be simple - test the calendar URIs first when testing
todos, as it was done before my last commit.
2010-04-28 08:06:57 +02:00
Patrick Ohly 07e74b9996 syncevo-phone-config: reimplemented template generation and calendar+todo detection (MBC #1197)
--combined-calendar-task was broken: because "calendar+todo" was
tested with only an event, the test always passed when using the
settings for events, even if tasks cannot be exchanged using those
settings. If it had worked and had been essential to get correct
results, the option should have been enabled by default.

The new implementation of combined calendar+todo storage works
differently, without increasing the number of tests that need to
be run when searching for complete settings:
- detect settings for "calendar" using VEVENT as test data
- detect settings for "todo" using VTODO as test data
- if uri identical, configure a "calendar+todo" source instead of
  separate "calendar" and "todo"

Note that this hasn't been tested yet.

The --combined-calendar-task option is thus obsolete and was removed.

The template generation was rewritten and now prints the template
to stdout. While doing this, some more changes were made:
- "type" is always set, even if using default data formats,
  because "default" data formats are a bit underspecified and it
  is better to be explicit about what worked
- previously, "type" did not distinguish between events and tasks
  because it omitted the "calendar:" and "todo:" type part
- the template is printed if and only if --advanced is enabled,
  because only then is the result reliable; disabling it makes
  little sense when printing to stdout, so --create-template was
  removed

The generated config is no longer derived from the 'Nokia 7210c'
template. Instead the "SyncEvolution Client" template is used, because
it does not contain a potentially unused "calendar+todo" source.
The same fix for missing "calendar/todo" in "type" also had to
be applied to to the created config.

The syncevo-phone-config tool used source names that differed from the
syncevolution command line, for example "contact" was used instead of
"addressbook". This was not only making the code more complex (it had
two different ways to map "contact" to "addressbook"), it was also
exposed to users via the --source option. Now the same
addressbook/calendar/memo/todo names as in the rest of the
SyncEvolution command line are used.

This patch also includes quite a bit of code, language and output
cleanup. The code still isn't as pythonic as it could be, though.
2010-04-28 08:06:57 +02:00
Patrick Ohly ea3fafe99c syncevo-phone-config: let CTRL-C really abort syncevolution (MBC #1197)
The signal handler in syncevolution interpret CTRL-C as suspend
request. When invoked by syncevo-phone-config, that is not what is
intended by the user and usually had the effect that a sync session
failed without flagging the abort request, thus keeping the script
running.

This patch adds SYNCEVOLUTION_NO_SYNC_SIGNALS, which prevents
installing the signal handlers, and uses that in the script.
As a result, CTRL-C leads to "aborted prematurely", for which
a test was added earlier.

Because syncevolution has to do no cleanup work, aborting it
like this is okay.
2010-04-28 08:06:57 +02:00
Patrick Ohly f0af60b6a8 syncevo-phone-config: use -v for minimal information about tested config, -v -v for full output (MBC #1197)
It was hard to tell what was being tested. Previously one only had
the choice between very verbose debugging output and minimal
progress information.

This patch turns -v into a counter that can be repeated on the command
line. -v now adds the config to the progress message, still using one
line per test. -v -v is the complete debug output.
2010-04-28 08:06:57 +02:00
Patrick Ohly 92a7d791be syncevo-phone-config: avoid writing in user's .config while testing (MBC #1197)
Using a fixed, unique config name and a @test-phone context was meant
to avoid conflicts with user data, but that still has drawbacks:
- extra clean up code necessary
- cannot run multiple syncevo-phone-config calls in parallel

A better solution is to set XDG_CONFIG_HOME to the temporary directory.
That way we can leave the last test config in place, for review by the
user or a developer.

Another advantage is that it is safe to run without daemon mode, because
there really isn't any overlap left with the normal sync system. Not
using daemon mode
- has less overhead (no D-Bus involved)
- is easier to debug
- does not interfer with other, normal sync sessions

The patch renames the "syncevo" variable to ensure that all references
to it were updated. "syncevoCmd" is also a bit easier to search for.
2010-04-28 08:06:57 +02:00
Patrick Ohly 1ece0e2109 syncevo-phone-config: avoid deprecated popen2, check for fatal status (MBC #1197)
Invoking "find" via popen2 is not particularly efficient. It also
triggers deprecation warnings. Better use native Python facilities,
like file pattern matching via glob. This is also shorter.

Instead of using an ad-hoc parser for the file, better use ConfigParser.
Some utility class is needed to massage our file content into shape
for it, because ConfigParser expects sections, which we don't write.

While we are at it, also check for premature exit of syncevolution.
The most likely reason for that is "killall -9 syncevolution", which
is currently the most reliable way to kill it because CTRL-C is not
always checked (needs to be fixed, though). Another reason are
fatal bugs in the binary, which should also abort testing.
2010-04-28 08:06:57 +02:00
Patrick Ohly 3ccdc3c97b syncevo-phone-config: fixed mkdir (MBC #1197)
A mkdir invocation failed because of a missing -p parameter.
Not sure whether creating the directory was really necessary,
but when the script does it, it should at least do it right.

This patch also switches to native Python functions instead of
invoking the "rm" and "mkdir" shell commands.
2010-04-28 08:06:57 +02:00
Patrick Ohly 79fbb7f683 syncevo-phone-config: do not hide command line errors (MBC #1197)
In non-verbose mode, 2>/dev/null hid errors, including errors
caused by the script itself which need to be fixed (like a missing
"-p" for mkdir). Better show errors in all cases. Because syncevolution
itself prints to stdout, this does not produce more output in
non-verbose mode either.
2010-04-28 08:06:56 +02:00
Patrick Ohly 83abbb96b1 syncevo-phone-config: fixed Python syntax errors
First, the "tempfile" variable clashed with the global tempfile module
and later was expected to be called "testfile". "tmpdir" is a better
description, because it is not the name of a file.

Second, the testConfig and testResult variables must explicitly
set as global variables. Variable assignments are local by default
in Python. Declaring the variables first is not strictly necessary,
but done to be consistent with other global variables.
2010-04-28 08:06:56 +02:00
Chen Congwu 6549757434 phone-config-tool: setting test data and test result temp dir (MB#9862) 2010-04-20 09:27:06 +02:00
Chen Congwu 6e69e6a129 config-phone: interrupt handling 2010-04-19 11:35:40 +02:00
Chen Congwu 1022e21494 Test tools: automatically detection working configuration for a phone (MB#9862)
This is a python script that tries with all possible configuration
combinations for a phone, once found the corresponding configuration and
the configuration template can be generated.
The script is installed as 'syncevo-phone-config'
2010-04-19 11:35:40 +02:00