Commit graph

829 commits

Author SHA1 Message Date
Patrick Ohly bf14e33977 C++: better types for loop variables
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>
2021-02-06 06:39:12 -08:00
Patrick Ohly e132410296 gnome: remove libsecret include hack
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>
2021-02-06 06:28:52 -08:00
Patrick Ohly 0a64fbadcc akonadi: avoid link error on Fedora Rawhide
At least on Fedora Rawhide -lkdeui and -lkdecore
are not found and not needed.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
2021-02-06 06:27:30 -08:00
Patrick Ohly 64c62b53b4 tde: fix "make dist" issue
"make dist" tries to include all source files in the archive, which
does not work for the generated files.
2020-12-18 08:14:41 -08:00
deloptes 57d357afee tdepim: various changes
Submitted by deloptes via private email.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
2020-12-06 11:25:57 +01:00
Patrick Ohly 051b8ac8d2 EDS: avoid dead code warnings when disabled 2020-12-05 21:28:08 +01:00
Milan Crha edb458dfcb EDS: EDS 3.33.2, libecal 2.0 support
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly e88bfa6214 C++: automatically determine iterator types
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 85edb458f4 util.h: remove unused ToString()
It pulled sstream into many compilation units.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
2020-12-05 21:28:08 +01:00
Patrick Ohly b8cbd5358f C++: avoid NULL
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 74f0d01f33 C++: remove more boost headers (tuple, assign, utility)
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly ae4969cfa3 C++: replace pcrecpp with std::regex
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 6217ba0bd1 C++: avoid boost::scope_ptr/array and plain pointers
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 2fa3c3335a C++: replace boost::shared_ptr, boost::function, boost::bind
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly d0c08bf0dd C++: avoid "using namespace std"
It saved some typing, but isn't good style.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
2020-12-05 21:28:08 +01:00
Patrick Ohly bce7526da1 C++: simpler for loops
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 623397c674 C++: lambdas instead of static methods
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 39bf3f1291 C++: variadic connectSignal()
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 3729a239fc C++: variadic templates in D-Bus bindings
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 8713809b35 C++: use lambdas instead of boost::lambda, std::exception_ptr
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 55cb5ad46f sync: avoid setenv()
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 3cd62b3e41 signon: fix pcrecpp build flags
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>
2020-12-05 21:28:08 +01:00
Patrick Ohly 3afdbaf651 EDS: more generic open retry handling
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>
2018-01-09 07:53:28 -08:00
Patrick Ohly 2747426b7c oauth2.cpp: fix usage of curl
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>
2018-01-09 07:53:27 -08:00
Patrick Ohly 1126b65b6a autotools: be more selective about suppressing deprecation warnings
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>
2018-01-09 07:53:27 -08:00
Patrick Ohly 0db56499c2 SoupTransportAgent: require libsoup 2.42, no deprecated methods
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>
2018-01-09 07:53:27 -08:00
Patrick Ohly 88619eb58c C++: replace auto_ptr with unique_ptr
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>
2018-01-03 10:39:51 +01:00
Patrick Ohly 62387107f9 TDEPIMNotesSource.h: remove unused kn_dcop
It's a local variable in the implementation. Found with cppcheck.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
2018-01-03 10:39:50 +01:00
Patrick Ohly 3325aebbff GNOME: retry keyring operations
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>
2018-01-03 10:39:50 +01:00
Patrick Ohly 7b7660af60 GNOME: replace gnome-keyring with libsecret (FDO #104219)
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>
2018-01-03 10:39:34 +01:00
Patrick Ohly d5ecc1b468 libical: support libical v3 (FDO #104220)
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>
2018-01-03 10:39:13 +01:00
Patrick Ohly 451440bd54 TDE: fix compile issue
When the TDE notes backend was disabled, the code didn't compile
because the SE_END_CXX wasn't nested properly inside the ifdef/endif.
2016-11-04 03:06:02 -07:00
Patrick Ohly 5937277102 SignonAuthProvider: fix ref counting issue
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.
2016-11-03 00:50:26 -07:00
deloptes 7f3ec05c05 TDE: various fixes
Prevents the wallet backend from crashing SyncEvolution when
enabled. Functionality not really tested, though.

PIM backend had compile problems when enabled.
2016-11-03 00:36:32 -07:00
SyncEvolution Nightly Testing 46a81a3cb8 Merge remote-tracking branch 'origin/for-master/tde' into nightly 2016-10-13 05:07:07 -07:00
Patrick Ohly 7d06fd2869 TDEPIMCalendarSourceRegister.cpp: only grab generic types when active
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>
2016-10-09 23:20:16 -07:00
Patrick Ohly 30d42f88ca activesync: fix packaging of activesyncd (FDO #98014)
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>
2016-10-07 15:25:38 +02:00
Patrick Ohly e05817a492 tdepim: fix build issues
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>
2016-10-07 15:17:41 +02:00
deloptes 160b1f5e60 tde, tdepim: adapt to TDE 14.1
The notes API changed in TDE 14.1. Also includes several other
enhancements (error checking, testing).
2016-09-26 21:14:58 +02:00
deloptes cb34f4972b tde, tdepim: backend for the TDE desktop (FDO #97780)
This is the code for TDE < 14.1.
2016-09-26 21:07:55 +02:00
Patrick Ohly 90a4758ce1 PbapSyncSource.cpp.rej: remove from repo
Was accidentally added, does not belong into git repo.
Reported by Tino Mettler.
2016-09-26 12:58:27 +02:00
Patrick Ohly 426ec3543a syncevolution.org: compile on Ubuntu Trusty, libical v1/v2 compatibility
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.
2016-09-26 12:58:26 +02:00
Patrick Ohly 941774a1d1 D-Bus testing: fix slowing down file sources
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.
2016-09-26 12:58:26 +02:00
Patrick Ohly 1385ac43fb file backend: log item manipulation
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.
2015-06-01 14:23:46 +02:00
Niels Ole Salscheider cd93586d0b Use ${PKG_CONFIG} instead of pkg-config.
This fixes the build on Exherbo that only has prefixed versions of pkg-config.
2015-04-17 10:41:44 +02:00
Patrick Ohly 84a30285a9 WebDAV: handle 403 during Google OAuth authentication
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.
2015-03-03 10:44:03 +01:00
Patrick Ohly d84f323398 signon: ensure consistent use of "username" provider prefix
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.
2015-03-03 10:44:03 +01:00
Alberto Mardegan 9acfd11de7 signon-accounts: implement getCredentials
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.]
2015-03-03 10:43:26 +01:00
Alberto Mardegan c58ed9ff59 signon-accounts: pass the AgAuthData to the SignonAuthProvider
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.]
2015-03-03 10:41:52 +01:00
Alberto Mardegan 382c81e70f signon-accounts: do not create identities on the fly
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.
2015-03-03 10:30:53 +01:00