Commit graph

56 commits

Author SHA1 Message Date
Patrick Ohly
88f35083a5 syncevo-dbus-server: fix for handling of active session
The logic for creating a shared_ptr for the active session
was flawed: it assumed that the session must be owned by
a client, which is not true if some other entity (like
a Connection) owns it.

As a result of this flaw, DBusServer::m_syncSession wasn't
set when running a sync via the Connection API, which
crashed when the Connection destructed itself and the
session while some of the session code was still active.

Fixed by keeping both a plain pointer (for the case when
the weak_ptr doesn't provide it anymore while shutting
itself down) and a weak_ptr (which avoids searching for
the shared_ptr).
2009-10-07 18:11:48 +02:00
Patrick Ohly
a3d85c4bba syncevo-dbus-server: implemented Session.Sync() parameter handling
The Session.Sync() parameters are a special case of temporarily
overriding the source properties of all or some sources. This
patch uses the new per-source config filters to transfer the
parameters to the core sync engine.

This patch also introduces Session members for temporary config
changes, which is another way of setting these and other parameters.
These Session members must be set in SetConfig(temporary=true) calls
(not done yet).
2009-10-07 18:10:06 +02:00
Patrick Ohly
d8283ba873 sync source handling: implemented per-source property filtering, Cmdline uses it
Selecting active sources during a sync or status check was done with a
combination of setting a sync mode via a source config filter and
setting a list of active sources. Now the SyncConfig supports a source
filter which is applied to all sources and source filters for each
source. The latter override the former.

This is powerful enough to start syncs with full control over which
sources are active in which mode, as described in the new D-Bus API.
As part of this patch, the command line semantic is implemented
entirely using a combination of different source filters.
2009-10-07 18:10:00 +02:00
Patrick Ohly
4ac0e355c9 syncevo-dbus-server: implemented Session.Sync() and sync status/progress
The Session keeps the sync progress and status in the format expected
by the D-Bus interface. That way it is available without the corresponding
sync engine.

To run a sync, the Session.Sync() method creates a DBusSync, derived
from SyncContext. With an eye towards peer-to-peer sync the
new class and member are named just "sync" instead of using the too
specific "client". When that instance is ready, the g_main_loop_run()
call in DBusServer::run() is stopped and DBusServer::run() hands
over control to Session::run().

That call transfers control to SyncContext::sync(), which
retains control as long as the sync runs. Occassionally (via
progress calls) control is returned temporarily. These calls could be used
to check for D-Bus requests, but currently that is only done when
the sync blocks while transferring messages, by configuring the
SoupTransportAgent to use the same GMainLoop as the D-Bus binding.

The implementation of the D-Bus interface is still very much incomplete.
All of the missing bits and pieces are marked as TODO in the source.
2009-10-07 18:08:35 +02:00
Patrick Ohly
bf2954e5d2 syncevo-dbus-server: added stubs for Server/Session.GetConfig/GetReports()
Both methods are to be implemented inside the ReadOperations
class, which has the server configuration name as sole data item.
The Server methods are provided by glue code which instantiates
a ReadOperations object and calls the real methods.

From a C++ class design perspective the Server glue methods
should be declared static and the ReadOperations methods as const.
However, both qualifiers are not currently supported by the C++
binding.
2009-10-07 18:04:59 +02:00
Patrick Ohly
ec185613ec syncevo-dbus-server: moved to gdbus with C++ bridge
This is basically a rewrite from scratch, targeting the revised D-Bus
API. The core infrastructure for handling client requests is in place,
including the work queue for sessions and unexpected disconnects.
Many of the related D-Bus methods (Server.Connect(),
Server.StartSession(), Connection.Close(), Session.Close()) are
implemented.

Rudimentary testing is done with the test/dbus-server-connect.py
script.
2009-10-07 18:03:16 +02:00
Patrick Ohly
7e4eb2e93d more classes renamed
EvolutionSyncConfig => SyncConfig
SyncEvolutionException => Exception
EvolutionUnref* => Unref*
2009-10-06 17:22:47 +02:00
Patrick Ohly
71fbf32c94 files and classes renamed, include statements cleaned up
The intention is to get rid of the historic and inconsistent
naming of some classes and their corresponding files:
* EvolutionSyncClient = class derived from Funambol's SyncClient,
* SyncEvolutionConfig = SyncEvolution's config

With the strict 'namespace SyncEvo' and the syncevo/ path prefix for
most header files it is no longer necessary to have "SyncEvolution" or
"Evolution" in the names. This patch thus renames as follows:
  EvolutionSyncClient => SyncContext
  EvolutionSmartPtr => SmartPtr
  SyncEvolutionCmdline => Cmdline
  SyncEvolutionConfig => SyncConfig
  SyncEvolutionUtil => util

The former EvolutionSyncClient always had a role that went beyond just
running a sync, for example it also provided config access. With the
upcoming server support it also won't be just a client. Thus the new
name "SyncContext".

The 'syncevo/' prefix is used throughout the code now.

removed whenever the prefix made it clear that the file belongs
to SyncEvolution. This helps finding incorrect include paths.

Quotes should be used exclusively for SyncEvolution files which don't
have a specific prefix yet (test.h, config.h) to help identifying
them.
2009-10-05 14:49:32 +02:00
Patrick Ohly
d5961f8d8f 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-26 15:41:51 +02:00
Jussi Kukkonen
93731226b9 dbus server: copy template configuration in a sane way
All calls to syncevo_get_server_config() resulted in
EvolutionSyncConfig.copy() call, which can be expensive.
There is no reason to copy except when copying from a
template.

Fixes #5021
2009-08-12 10:34:39 +03:00
Patrick Ohly
c37ac407e0 compiler error: constness and strstr (Bugzilla #5061)
With g++ 4.4.1 (?) on Fedora 11 there's an error message
about the "server = strstr(...)" assignment. I suspect that
strstr() is overloaded and returns a const pointer for its
const argument.

"const char *server" should fix that problem.
2009-08-05 12:00:27 +02:00
Patrick Ohly
19db86bea6 D-Bus server: added dbus_g_thread_init()
According to the D-Bus glib docs, this function must be called
once at program startup. It didn't seem to matter that it wasn't
called, or it was called indirectly. In any case, better call it.
2009-07-30 17:19:32 +02:00
Patrick Ohly
023e5e4c7c D-Bus server: avoid potential crash in type handling (Bugzilla #4921)
dbus_g_type_get_struct() was called without the terminating G_TYPE_INVALID,
causing random (or rather, in my debug build, constant) glib CRITICAL
warnings and crashes.
2009-07-30 16:24:26 +02:00
Jussi Kukkonen
1df11d6f42 dbus: handle errors correctly when getting config
in dbus server syncevo_get_server_config() and
syncevo_get_template_config() did not set a return variable
to NULL when returning error. The client checked for non-NULLness
even on errors, however.... Both issues fixed.

Fixes #4556
2009-07-21 13:14:41 +02:00
Jussi Kukkonen
dc750a5fa8 use ConsumerReady flag in dbus api and UI
support isConsumerReady in dbus api (GetServers, GetTemplates
and also in the options in GetServerConfig). Use the flag in
sync-ui to hide non-ready templates.

Fix #3336
2009-07-09 10:40:00 +02:00
Patrick Ohly
f4e267aa51 compile error: GNOME keyring 2.24 misses extern "C"
Got an undefined reference to C++ GNOME keyring functions
which in reality should have been plain C functions. Reason
was that /usr/include/gnome-keyring-1/gnome-keyring.h (from 2.24.1)
didn't have an 'extern "C"' declarations.

Adding those in our source code fixed that and should be safe,
because double nesting of it is safe and the header is
unlikely to contain real C++ declarations.
2009-06-24 16:14:13 +02:00
Jussi Kukkonen
20e2ba2b88 dbus client, server: remove scheme from keyring urls
save server url in gnome-keyring without uri scheme. Also
add checks for url correctness in client.
2009-06-16 15:05:55 +03:00
Jussi Kukkonen
c67e296ac5 dbus client: make sure password is "-" in config
password in config file must be "-" so SyncClient:AskPassword()
gets called (which uses gnome-keyring in syncevo-dbus-server).

Also remove protocol key from gnome-keyring calls.
lease enter the commit message for your changes. Lines starting
2009-06-02 14:06:03 +03:00
Jussi Kukkonen
a18a00f0cc dbus service: remove 'need-password' signal
emitting "need-password" over D-Bus was not implemented and
was never a good solution anyway. Current options are:
 * use passwords saved in SyncEvolution config
 * use a supported keyring system (now gnome-keyring)

Setting a password over D-Bus when saving a server with
SetServerconfig does work, but the password is not given in
GetServerConfig.
2009-05-29 12:46:40 +03:00
Jussi Kukkonen
cd6446e984 dbus service/client: add gnome-keyring support
The GTK+/Moblin UI now only uses gnome-keyring.
D-Bus service supports it but it is not required.

I think I will remove the authentication over dbus altogether,
it's just a bad idea. Then choices would be:
* authentication saved in config files, not changeable via dbus
* authentication via supported keyring methods
  (currently gnome-keyring)
2009-05-29 10:38:14 +03:00
Jussi Kukkonen
7001704b9b dbus service: don't abort on Sync() exception 2009-05-14 11:21:46 +03:00
Jussi Kukkonen
24715a1ae2 dbus client/service: hide non--supported sources
Add a source option  that tells whether source is
supported locally.
Don't show or enable unsupported sources in main window
Don't include unsupported sources in sync

Fixes #1977
2009-05-13 19:32:40 +03:00
Jussi Kukkonen
10f21f5cff dbus service/client: fix DBus error handling
server did not call dbus_g_error_domain_register() so
the remote exception names weren't transmitted.

Fixes #2067
2009-05-13 19:32:40 +03:00
Patrick Ohly
c4a605d3cc added missing copyright and license headers 2009-05-11 16:31:17 +02:00
Jussi Kukkonen
3869951cb4 dbus service: remember to init GLib threads 2009-05-11 10:50:59 +03:00
Jussi Kukkonen
3b63988257 dbus client: shutdown after client inactivity
currently delay is 120 seconds
2009-04-27 10:42:19 +03:00
Jussi Kukkonen
98a02241bc dbus client: stop leaking memory on every dbus callback 2009-04-27 10:42:19 +03:00
Jussi Kukkonen
a09ce3d9ca support sync reports in dbus api, use GetSyncReports in ui 2009-04-27 10:42:19 +03:00
Jussi Kukkonen
df2648d770 dbus service: add support for per-source syncmode 2009-04-21 13:37:11 +03:00
Jussi Kukkonen
2baee1ba6d dbus client: support removing services 2009-04-16 18:16:49 +03:00
Jussi Kukkonen
c3c3b76687 dbus service & client: support webURL and iconURI
Due to a git mishap this commit has two commits worth of changes:
* use webURL in service list linkbuttons, use iconURI in main window
  and service list.
* Improve n window and service list layout
2009-04-08 13:49:13 +03:00
Jussi Kukkonen
d960fc131e Merge branch 'dbus' into ui 2009-04-07 21:33:54 +03:00
Jussi Kukkonen
ef14cbe22a dbus service: bug fixes, add error codes 2009-04-07 21:31:09 +03:00
Jussi Kukkonen
b8fa1233ad dbus service: add GetTemplateConfig method 2009-04-07 13:29:12 +03:00
Jussi Kukkonen
88fa7b83fe dbus service: add GetTemplateConfig method 2009-04-07 10:16:07 +03:00
Jussi Kukkonen
b445c72f8d Merge branch 'ui-patrick' into ui 2009-04-06 22:56:19 +03:00
Jussi Kukkonen
ec8dbe1c0d Merge branch 'dbus' into ui 2009-04-06 22:46:22 +03:00
Jussi Kukkonen
e0e90abf50 dbus service: use Progress signal to return Syncevolution return code 2009-04-06 22:45:21 +03:00
Jussi Kukkonen
1d69f0763e dbus client: add sync mode support to client
server side isn't implemented yet
2009-04-06 21:11:22 +03:00
Patrick Ohly
ecb2bba7e3 fixed compiler warnings (unused variables, printf formatting, ...) 2009-04-06 19:13:05 +02:00
Jussi Kukkonen
67b5f84c3f dbus service: copy template if config does not exist yet 2009-04-06 18:20:31 +03:00
Jussi Kukkonen
b5f706970e dbus service: implement SetServerConfig 2009-04-06 14:34:57 +03:00
Jussi Kukkonen
3f96c221b0 dbus service: send password in options as well 2009-04-05 11:46:44 +03:00
Jussi Kukkonen
645e4901c4 dbus service: make GetServers signature like GetTemplates
this makes more sense even if we might never use the
note (config file path) on servers
2009-04-05 01:41:16 +03:00
Jussi Kukkonen
a564a0f075 dbus service: add GetTemplates 2009-04-04 23:39:11 +03:00
Jussi Kukkonen
7960724ec2 dbus service: fix option handling bug
also remove debug purpose  g_main_loop_quit()
2009-04-02 20:37:00 +03:00
Jussi Kukkonen
6fbab79477 dbus service: fix possible crasher on sync abort 2009-04-02 20:37:00 +03:00
Jussi Kukkonen
b9c31b8434 dbus service: handle suspend request 2009-04-02 20:36:59 +03:00
Jussi Kukkonen
32d06790ae dbus service: remove separate SourceProgress signal
A single progress signal is fine -- the progress event types
are unique
2009-04-02 20:36:59 +03:00
Jussi Kukkonen
d7857a51ca dbus service: fix broken progress emission 2009-04-02 20:36:59 +03:00