This addresses two different warnings from Fedora Rawhide:
/srv/runtests/work/sources/syncevolution/src/syncevo/SyncContext.cpp: In member function 'std::string SyncEvo::XMLFiles::get(SyncEvo::XMLFiles::Category)':
/srv/runtests/work/sources/syncevolution/src/syncevo/SyncContext.cpp:2390:28: error: loop variable 'entry' of type 'const StringPair&' {aka 'const std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&'} binds to a temporary constructed from type 'std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >' [-Werror=range-loop-construct]
2390 | for (const StringPair &entry: m_files[category]) {
| ^~~~~
/srv/runtests/work/sources/syncevolution/src/syncevo/SyncContext.cpp:2390:28: note: use non-reference type 'const StringPair' {aka 'const std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >'} to make the copy explicit or 'const std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&' to prevent copying
This fails because StringPair has non-const members. By using "auto",
we get rid of the need to define and pick exactly the right type.
/srv/runtests/work/sources/syncevolution/src/syncevo/SyncConfig.cpp: In member function 'void SyncEvo::SyncConfig::removeSyncSource(const string&)':
/srv/runtests/work/sources/syncevolution/src/syncevo/SyncConfig.cpp:2552:36: error: loop variable 'peer' creates a copy from type 'const string' {aka 'const std::__cxx11::basic_string<char>'} [-Werror=range-loop-construct]
2552 | for (const std::string peer: m_tree->getChildren(m_contextPath + "/peers")) {
| ^~~~
/srv/runtests/work/sources/syncevolution/src/syncevo/SyncConfig.cpp:2552:36: note: use reference type to prevent copying
2552 | for (const std::string peer: m_tree->getChildren(m_contextPath + "/peers")) {
| ^~~~
| &
We could have used "auto" also instead of "std::string", but here it
doesn't save that much typing and is more readable. We just have to
use a reference.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Some older version of libsecret.h lacked `extern "C"`. Adding
that manually now causes compile errors on Fedora Rawhide and thus
has to be removed:
/usr/include/c++/11/type_traits:480:3: error: template with C linkage
480 | template<typename _Tp>
| ^~~~~~~~
/srv/runtests/work/sources/syncevolution/src/backends/gnome/GNOMEPlatform.cpp:24:1: note: 'extern "C"' linkage started here
24 | extern "C" {
| ^~~~~~~~~~
In file included from /usr/include/glib-2.0/glib/gmacros.h:241,
from /usr/lib64/glib-2.0/include/glibconfig.h:9,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/libsecret-1/libsecret/secret.h:18,
from /srv/runtests/work/sources/syncevolution/src/backends/gnome/GNOMEPlatform.cpp:25:
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Developed originally by Milan Crha for Fedora, copied and updated
by Patrick Ohly.
From Milan:
There are going to be made huge libecal API changes, as huge as it
deserved a version bump from 1.2 to 2.0, and together with it a small
libebook API changes, most likely being part of the evolution-data-
server 3.33.2 release, which is planned for May 20. More about this can
be found here:
https://mail.gnome.org/archives/desktop-devel-list/2019-April/msg00016.html
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Having to specify the type of an iterator is annoying and does not
really add clarity to the code. With C++11 we can use "auto"
instead and in some cases remove helper typedefs.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
NULL is ambiguous (can be integer and pointer) and using it as
terminator for vararg list of pointers without explicit casting to a
pointer was downright incorrect. nullptr fixes that.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Several headers were no longer needed resp. could be replaced by more
specific ones like noncopyable.hpp.
boost::assign mostly can be replaced with initialization lists and
boost::tuple with std::tuple.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
This allows us to get rid of an external dependency. Mostly std::regex
works, but there are limitations that have to be worked around:
- no multiline support in C++11
- conversion of groups to non-string types has to be done manually
While at it, use raw strings to get rid of excessive backslash
escaping.
pcrecpp::StringPiece was used as a general-purpose utility class. Now
we have our own implementation.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
std::unique_ptr usually can be used instead. std::vector also works
for arrays and even has a data() method as part of the official API in
C++11.
For historic reasons, the functions creating SyncSources returned
plain pointers. We are breaking the API now, so we might as well fix
that.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
We can use std::shared_ptr and std::function instead now.
Lambdas are usually a better alternative to boost/std::bind. The
downside is the need to explicitly specify parameters completely. When
inlining callbacks entirely with lambdas, duplication of that
parameter list can be avoided.
Whenever possible, use std::make_shared to construct objects that are
tracked by std::shared_ptr.
Some objects need a std::weak_ptr during object destruction. For that
we have to use our own implementation of std::enable_shared_from_this,
with a matching creator function. The additional benefit is that we
can get rid of explicit static "create" methods by making that create
function a friend.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
boost/foreach.hpp is no longer needed, range-based loops work
the same. With some helpers, even reverse iteration and
boost::make_split_iterator() can be handled the same way.
"auto" makes it possible to avoid explicitly spelling out the
expected type.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Lambdas without variable capture are guaranteed to be compatible with
plain C functions, so we can use them as callbacks. That keeps the
code closer together and avoids having to declare helper methods as
part of the public class.
In some cases the static method is the actual code, in which case only
"nothrow()" gets replaced with "noexcept" because it's cleaner and to
mark that the code was looked at and intentionally left as-is.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
By specifying the list of signal types as template parameters
it becomes possible to use a single implementation. Lambdas
can replace explicit callback methods.
The reimplementation is more flexible and does not enforce
the use of a boost::function. This matches how connectSignal()
was used in practice. Thanks to universal references, the boost::bind
instances get moved directly into the allocated instances that are
attached to the signal handler.
The downside is that the call syntax changes slightly, because
partially specifying template parameters does not work.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Using templates with a varying number of types allows removing
duplicated code for the different cases.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
The code becomes a lot more readable. One can also set breakpoints
inside the callbacks.
Exception handling in GRunInMain() is better now, with the ability to
rethrow arbitrary exceptions thanks to std::exception_ptr.
Only some usage of boost::lambda in the Akonadi backend remains.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
set/getenv() are not thread-safe, and a recent bug report via private
email shows that this does cause segfaults:
Thread 4 (Thread 19251):
....
Thread 1 (Thread 19311):
...
In this case, DLT was used and the setenv call was setting the
LIBSYNTHESIS_<context> variables.
The solution is to avoid setenv() in code which might run in parallel
to other threads:
- DLT-related variables are set at the beginning of
syncevo-dbus-server startup which then gets inherited
by syncevo-dbus-helper and in the environment prepared
for syncevo-local-sync (because the latter might run with
a different log level)
- the default for SYNCEVOLUTION_PBAP_SYNC is now "incremental"
everywhere and SyncContext is told about the special
mode where it needs to keep photo data differently, i.e. setting
SYNCEVOLUTION_PBAP_SYNC in dbus-sync.cpp for PBAP syncing is
no longer necessary
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Dropping the pcrecpp build hacks in the nightly testing showed that
the flags for normal linking and compilation were missing.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Recent EDS started to exhibit race conditions when opening a database (for
example, https://bugzilla.gnome.org/show_bug.cgi?id=791306). Opening was
already tried again for a certain known error in some old EDS version. Now it
is tried five times with a delay of one second for all errors.
The advantage is that this does not depend on accurately detecting the race
condition error.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
When libcurl was selected instead of libsoup, compilation failed
because the necessary header file was missing and the direct assignment
of a plain pointer to the shared_ptr failed.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Suppressing the warning for all code hid the deprecation warning
about auto_ptr, which is something that should have been fixed
before.
Now only some code still suppresses the warning (GTK UI, Akonadi)
because there is no time to also update and test that part.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
This allows us to get rid of deprecated function calls. We no longer
need to set a default proxy either, the newer libsoup does that itself
by default
(https://developer.gnome.org/libsoup/stable/libsoup-session-porting.html).
Not mentioned in the porting guide is that the based soup session now
has a 60s timeout by default. We don't want to time out.
We also need to quit the event loop explicitly when timing out. Somehow
that wasn't necessary before.
When using the generic SoupSession, it is no longer guaranteed that canceling
an operation invokes the callbacks before returning. Therefore we have to be
prepared for callbacks occuring after destructing the SoupTransportAgent. This
is achieved by storing all SoupTransportAgent in a boost::shared_ptr and
letting the instance know about that with a weak_ptr, which then can be used
by the callbacks.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
auto_ptr has been deprecated for a while now. unique_ptr can
be taken for granted now, so use that instead.
GDBusMessage requires a custom deleter. Not sure how auto_ptr
handled that before.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Sometimes GNOME keyring and libsecret fail to set up the right temporary keys
(https://bugzilla.gnome.org/show_bug.cgi?id=778357). This has been fixed
upstream, but still breaks with the distros used by the automated testing
occassionally.
Retrying the operations after disconnecting from the server is an attempt
to recover from this sporadic error.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
The GNOME keyring library has been obsoleted for a long time now,
long enough that the replacement libsecret is available on all
supported distros. Therefore we can switch unconditionally.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
libical v3 removes some deprecated functions (like icaltime_from_timet)
and removes the "is_utc" member from icaltimetype. The replacement
code works with old and new libical and thus needs no ifdefs.
However, that struct is part of the ABI, which impacts the tricks that
syncevolution.org binaries use to get built against libical v2 and then
run with more recent libs like libical v3.
Depending on the platform ABI, it may still be okay, because the calling code
in SyncEvolution reserves and copies enough bytes for the icaltimetype
instances and because that code never directly accesses any member (is_date,
is_daylight, zone) whose offset changes.
Original author: Milan Crha <mcrha@redhat.com>
Slightly modified it so that icaltime_t.zone is not set.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
The account data was unreferenced once too often, or rather, a suitable ref
count increase was missing. A debug build of glib detects that ("GLib:
g_variant_unref: assertion 'value->ref_count > 0' failed"), but without that
check the code might also crash.
Prevents the wallet backend from crashing SyncEvolution when
enabled. Functionality not really tested, though.
PIM backend had compile problems when enabled.
When a backend is inactive, it is meant to ignore generic types like
"calendar". The idea behind that is that typically users install or
compile just the backends they want, and then ask for the "calendar"
backend using the generic sync templates or instructions.
When adding the TDEPIM calendar backend, that broke because it also
instantiated itself for those terms when active. The other TDEPIM
backends already did this as intended.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
The latest activesyncd contains GSettings schema files
which get installed by the top-level makefile, therefore
we have to install everything.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
The *Register.cpp files and everything they include must compile
without hard dependencies on header files which are TDE specific,
so add some ifdefs. Compiling with TDE backends disabled broke
because of this.
When enabled (untested!), it is unclear how some of these *Register.cpp
could have worked without including the header file that defines the
class they instantiate. Added the necessary includes.
A closing } was missing (found by cppcheck, which tests all variations
of the code, not just those currently enabled).
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
syncevolution.org binaries are now getting compiled on Ubuntu Trusty and thus
no longer support distros with older EDS. The code should still compile
against older EDS (for example, for Maemo), but that is not getting tested
anymore.
This allows removing the dynamic linker hacks related to older libraries,
which was only used in those binaries. Instead, backends using libical or EDS
get compiled on Ubuntu Trusty and then the soname of those libs get patched to
make the backend module usable in combination with a different set of
libs. That patching is part of a script maintained in the syncevolution.org
build infrastructure.
This approach was already used before to generate different EDS backends
for EDS versions with the newer EClient API, because that turned out to be
easier than the dynamic loading approach. It works because none of the methods
used by SyncEvolution changed their ABI, only some other parts of the
libraries did. Should there ever be a situation again that cannot be handled
like this, then backends might also get compiled on different distros than
Ubuntu Trusty (however, that may lead to problems due to the libstdc++ ABI
changes - to be decided...).
libical still requires one special hack: system time zone loading in
libical v1 (and only in that version, v2 has builtin support again) must
be overridden such that time zones are generated with rules instead
of transitions because that is more compatible with the peers that
SyncEvolution exchanges data with.
That hack now relies on overriding the two relevant functions inside the main
binaries (has to be there, otherwise libical still ends up calling its own
internal implementation). The overriding code is in
libsyncevo-icaltz-util.so.0 and depends on libical.so.1. If
libsyncevo-icaltz-util.so.0 can be loaded, the wrappers in the main binary use
it, otherwise they fall through to the code from the current libical.so, which
then should be libical.so.2 or more recent.
This hack is active by default when libical v1 is detected during configuration.
Recent shells filter out environment variables that are not valid shell
variables, so for example,
SYNCEVOLUTION_FILE_SOURCE_DELAY_OPEN_addressbook-slow-server did not get
passed through to syncevo-dbus-server because of the hyphen. As a result, the
tests became unreliable (non-deterministic timing) or outright failed.
Now we ensure that these variables are valid also in a shell and in addition,
make the test stricter such that it detects when the file backend did not
wait.
Extracting a meaningful description of each item from the Synthesis
engine when updating and adding items is easy to do for items of
certain known types (contacts and calendar items) and arguably an
improvement; in particular it makes tests like
TestCmdline.testSyncOutput more realistic.
When sending an access token with insufficient scope (for example,
because the Ubuntu Online Accounts service definition was incomplete,
as documented in FDO #86824), Google responds with a 403 "service
denied" error.
Neon (arguably correctly) treats this as a permanent error and not
as a transient authentication error. Google should better send
a 401 error.
To activate the 401 error handling in SyncEvolution, detect this
special case and turn the general SE_ERROR error into SE_AUTH.
The Ubuntu Online Accounts signon backend complained about
invalid "username" content with an error message containing "sso",
the string used for gSSO.
Define these magic strings once and then use only the defines.
Use the information contained in the AgAuthData object to decide which
authentication method is being used.
Move the common authentication code into a private authenticate()
method.
[PO: fixed g_variant_builder_end() mem leak]
[PO: avoid issue found via cppcheck: returning std::string::c_str() in
a method returning a std::string forces a string copy, which is
inefficient.]
[PO: UiPolicy was not set because of an invalid g_variant_builder_add()
"sv" parameter.]
Instead of passing the session data and the mechanism, pass the full
AgAuthData object to the SignonAuthProvider constructor.
This object can be used to build the session data without converting all
dictionaries to and from GHashTable.
[PO: fixed g_variant_builder_end() mem leak]
[PO: ForceTokenRefresh was not set because of an invalid g_variant_builder_add()
"sv" parameter.]
It's not sync-evolution task to complete the account creation; in those
platforms where this backend is deployed (Ubuntu, Elementary, KDE) the
account should already be created with a proper SignonIdentity attached
to it.