Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 202974 | Differences between
and this patch

Collapse All | Expand All

(-)work/kitchensync-3.5.8/kitchensync.old/configure.in.bot (-2 / +2 lines)
Lines 1-7 Link Here
1
if test "$HAVE_OPENSYNC" = 0 -o "$HAVE_OPENSYNC_ENGINE" = 0; then
1
if test "$HAVE_OPENSYNC" = 0; then
2
	echo ""
2
	echo ""
3
	echo "You're missing a compatible version of libopensync."
3
	echo "You're missing a compatible version of libopensync."
4
        echo "Version 0.19 or greater is needed."
4
        echo "Version 0.31 or greater is needed."
5
	echo "kitchensync will not be built."
5
	echo "kitchensync will not be built."
6
	echo ""
6
	echo ""
7
	all_tests=bad
7
	all_tests=bad
(-)work/kitchensync-3.5.8/kitchensync.old/configure.in.in (-5 / +3 lines)
Lines 29-37 Link Here
29
29
30
30
31
HAVE_OPENSYNC=0
31
HAVE_OPENSYNC=0
32
HAVE_OPENSYNC_ENGINE=0
32
PKG_CHECK_MODULES(OPENSYNC, opensync-1.0 >= 0.33, HAVE_OPENSYNC=1,HAVE_OPENSYNC=0)
33
PKG_CHECK_MODULES(OPENSYNC, opensync-1.0 >= 0.19, HAVE_OPENSYNC=1,HAVE_OPENSYNC=0)
34
PKG_CHECK_MODULES(OPENSYNCENGINE, osengine-1.0 >= 0.19, HAVE_OPENSYNC_ENGINE=1, HAVE_OPENSYNC_ENGINE=0)
35
PKG_CHECK_MODULES(LIBXML,   libxml-2.0, , HAVE_OPENSYNC=0)
33
PKG_CHECK_MODULES(LIBXML,   libxml-2.0, , HAVE_OPENSYNC=0)
36
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6, , HAVE_OPENSYNC=0)
34
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6, , HAVE_OPENSYNC=0)
37
35
Lines 52-60 Link Here
52
AC_SUBST(OPENSYNC_HEADERDIR)
50
AC_SUBST(OPENSYNC_HEADERDIR)
53
51
54
dnl Check if we can compile KitchenSync
52
dnl Check if we can compile KitchenSync
55
AM_CONDITIONAL(compile_kitchensync, test "$HAVE_OPENSYNC" = 1 -a "$HAVE_OPENSYNC_ENGINE" = 1)
53
AM_CONDITIONAL(compile_kitchensync, test "$HAVE_OPENSYNC" = 1)
56
54
57
if test "$HAVE_OPENSYNC" = 1 -a "$HAVE_OPENSYNC_ENGINE" = 1 ; then
55
if test "$HAVE_OPENSYNC" = 1; then
58
    AC_MSG_RESULT([found])
56
    AC_MSG_RESULT([found])
59
else
57
else
60
    AC_MSG_RESULT([not found])
58
    AC_MSG_RESULT([not found])
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/callbackhandler.cpp (-11 / +12 lines)
Lines 19-30 Link Here
19
    Boston, MA 02110-1301, USA.
19
    Boston, MA 02110-1301, USA.
20
*/
20
*/
21
21
22
#include <osengine/engine.h>
22
#include <opensync/opensync.h>
23
23
#include <opensync/opensync-engine.h>
24
#include <libqopensync/engine.h>
25
24
26
#include <qapplication.h>
25
#include <qapplication.h>
27
26
27
#include "engine.h"
28
28
#include "callbackhandler.h"
29
#include "callbackhandler.h"
29
30
30
using namespace QSync;
31
using namespace QSync;
Lines 111-121 Link Here
111
{
112
{
112
  mEngine = engine;
113
  mEngine = engine;
113
114
114
  osengine_set_conflict_callback( engine->mEngine, &conflict_callback, this );
115
  osync_engine_set_conflict_callback( engine->mEngine, &conflict_callback, this );
115
  osengine_set_changestatus_callback( engine->mEngine, &change_callback, this );
116
  osync_engine_set_changestatus_callback( engine->mEngine, &change_callback, this );
116
  osengine_set_mappingstatus_callback( engine->mEngine, &mapping_callback, this );
117
  osync_engine_set_mappingstatus_callback( engine->mEngine, &mapping_callback, this );
117
  osengine_set_enginestatus_callback( engine->mEngine, &engine_callback, this );
118
  osync_engine_set_enginestatus_callback( engine->mEngine, &engine_callback, this );
118
  osengine_set_memberstatus_callback( engine->mEngine, &member_callback, this );
119
  osync_engine_set_memberstatus_callback( engine->mEngine, &member_callback, this );
119
}
120
}
120
121
121
Engine* CallbackHandler::engine() const
122
Engine* CallbackHandler::engine() const
Lines 143-149 Link Here
143
  }
144
  }
144
}
145
}
145
146
146
void CallbackHandler::conflict_callback( OSyncEngine *engine, OSyncMapping *omapping, void *data )
147
void CallbackHandler::conflict_callback( OSyncEngine *engine, OSyncMappingEngine *omapping, void *data )
147
{
148
{
148
  SyncMapping mapping( omapping, engine );
149
  SyncMapping mapping( omapping, engine );
149
150
Lines 152-158 Link Here
152
  QApplication::postEvent( handler, new ConflictEvent( mapping ) );
153
  QApplication::postEvent( handler, new ConflictEvent( mapping ) );
153
}
154
}
154
155
155
void CallbackHandler::change_callback( OSyncEngine*, OSyncChangeUpdate *update, void *data )
156
void CallbackHandler::change_callback( OSyncChangeUpdate *update, void *data )
156
{
157
{
157
  SyncChangeUpdate change( update );
158
  SyncChangeUpdate change( update );
158
159
Lines 170-176 Link Here
170
  QApplication::postEvent( handler, new MappingEvent( mapping ) );
171
  QApplication::postEvent( handler, new MappingEvent( mapping ) );
171
}
172
}
172
173
173
void CallbackHandler::engine_callback( OSyncEngine*, OSyncEngineUpdate *update, void *data )
174
void CallbackHandler::engine_callback( OSyncEngineUpdate *update, void *data )
174
{
175
{
175
  SyncEngineUpdate engine( update );
176
  SyncEngineUpdate engine( update );
176
177
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/callbackhandler.h (-3 / +3 lines)
Lines 76-85 Link Here
76
    class EngineEvent;
76
    class EngineEvent;
77
    class MemberEvent;
77
    class MemberEvent;
78
78
79
    static void conflict_callback( OSyncEngine*, OSyncMapping*, void* );
79
    static void conflict_callback( OSyncEngine*, OSyncMappingEngine*, void* );
80
    static void change_callback( OSyncEngine*, OSyncChangeUpdate*, void* );
80
    static void change_callback( OSyncChangeUpdate*, void* );
81
    static void mapping_callback( OSyncMappingUpdate*, void* );
81
    static void mapping_callback( OSyncMappingUpdate*, void* );
82
    static void engine_callback( OSyncEngine*, OSyncEngineUpdate*, void* );
82
    static void engine_callback( OSyncEngineUpdate*, void* );
83
    static void member_callback( OSyncMemberUpdate*, void* );
83
    static void member_callback( OSyncMemberUpdate*, void* );
84
84
85
    Engine* mEngine;
85
    Engine* mEngine;
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/conversion.cpp (-6 / +11 lines)
Lines 20-25 Link Here
20
*/
20
*/
21
21
22
#include <opensync/opensync.h>
22
#include <opensync/opensync.h>
23
#include <opensync/opensync-format.h>
23
24
24
#include "conversion.h"
25
#include "conversion.h"
25
26
Lines 43-58 Link Here
43
{
44
{
44
  Q_ASSERT( mEnvironment );
45
  Q_ASSERT( mEnvironment );
45
46
46
  OSyncFormatEnv *formatEnv = osync_conv_env_new( mEnvironment );
47
  OSyncError *error = NULL;
48
  OSyncFormatEnv *formatEnv = osync_format_env_new( &error );
47
  Q_ASSERT( formatEnv );
49
  Q_ASSERT( formatEnv );
48
50
51
  osync_format_env_load_plugins(formatEnv, NULL, &error);
52
49
  QStringList types;	
53
  QStringList types;	
50
  for ( int i = 0; i < osync_conv_num_objtypes( formatEnv ); i++ ) {
51
    OSyncObjType *type = osync_conv_nth_objtype( formatEnv, i );
52
    types.append( QString::fromUtf8( osync_objtype_get_name( type ) ) );
53
  }
54
54
55
  osync_conv_env_free( formatEnv );
55
  for (int i = 0; i < osync_format_env_num_objformats(formatEnv); i++) {
56
    OSyncObjFormat *format = osync_format_env_nth_objformat(formatEnv, i);
57
    types.append( QString::fromUtf8( osync_objformat_get_objtype(format) ) );
58
 }
59
60
  osync_format_env_free( formatEnv );
56
61
57
  return types;
62
  return types;
58
}
63
}
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/conversion.h (-3 / +3 lines)
Lines 24-36 Link Here
24
24
25
#include <qstringlist.h>
25
#include <qstringlist.h>
26
26
27
class OSyncEnv;
27
class OSyncGroupEnv;
28
28
29
namespace QSync {
29
namespace QSync {
30
30
31
class Conversion
31
class Conversion
32
{
32
{
33
  friend class Environment;
33
  friend class PluginEnv;
34
34
35
  public:
35
  public:
36
    Conversion();
36
    Conversion();
Lines 47-53 Link Here
47
    QStringList objectTypes() const;
47
    QStringList objectTypes() const;
48
48
49
  private:
49
  private:
50
    OSyncEnv *mEnvironment;
50
    OSyncGroupEnv *mGroupEnv;
51
};
51
};
52
52
53
}
53
}
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/engine.cpp (-7 / +33 lines)
Lines 20-26 Link Here
20
*/
20
*/
21
21
22
#include <opensync/opensync.h>
22
#include <opensync/opensync.h>
23
#include <osengine/engine.h>
23
#include <opensync/opensync-engine.h>
24
25
#include "group.h"
26
#include "member.h"
27
#include "result.h"
24
28
25
#include "engine.h"
29
#include "engine.h"
26
30
Lines 29-47 Link Here
29
Engine::Engine( const Group &group )
33
Engine::Engine( const Group &group )
30
{
34
{
31
  OSyncError *error = 0;
35
  OSyncError *error = 0;
32
  mEngine = osengine_new( group.mGroup, &error );
36
  mEngine = osync_engine_new( group.mGroup, &error );
33
}
37
}
34
38
35
Engine::~Engine()
39
Engine::~Engine()
36
{
40
{
37
  osengine_free( mEngine );
41
  osync_engine_unref( mEngine );
38
  mEngine = 0;
42
  mEngine = 0;
39
}
43
}
40
44
41
Result Engine::initialize()
45
Result Engine::initialize()
42
{
46
{
47
  Q_ASSERT( mEngine );
48
43
  OSyncError *error = 0;
49
  OSyncError *error = 0;
44
  if ( !osengine_init( mEngine, &error ) )
50
  if ( !osync_engine_initialize	( mEngine, &error ) )
45
    return Result( &error );
51
    return Result( &error );
46
  else
52
  else
47
    return Result();
53
    return Result();
Lines 49-61 Link Here
49
55
50
void Engine::finalize()
56
void Engine::finalize()
51
{
57
{
52
  osengine_finalize( mEngine );
58
  Q_ASSERT( mEngine );
59
60
  OSyncError *error = 0;
61
  osync_engine_finalize( mEngine , &error );
53
}
62
}
54
63
55
Result Engine::synchronize()
64
Result Engine::synchronize()
56
{
65
{
66
  Q_ASSERT( mEngine );
67
57
  OSyncError *error = 0;
68
  OSyncError *error = 0;
58
  if ( !osengine_synchronize( mEngine, &error ) )
69
  if ( !osync_engine_synchronize( mEngine, &error ) )
70
    return Result( &error );
71
  else
72
    return Result();
73
}
74
75
Result Engine::discover( const Member &member )
76
{
77
  Q_ASSERT( mEngine );
78
79
  OSyncError *error = 0;
80
  if ( !osync_engine_discover_and_block( mEngine, member.mMember, &error ) )
59
    return Result( &error );
81
    return Result( &error );
60
  else
82
  else
61
    return Result();
83
    return Result();
Lines 63-67 Link Here
63
85
64
void Engine::abort()
86
void Engine::abort()
65
{
87
{
66
  osengine_abort( mEngine );
88
  Q_ASSERT( mEngine );
89
90
// TODO
91
//  osync_engine_abort( mEngine );
67
}
92
}
93
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/engine.h (-2 / +9 lines)
Lines 22-33 Link Here
22
#ifndef QSYNC_ENGINE_H
22
#ifndef QSYNC_ENGINE_H
23
#define QSYNC_ENGINE_H
23
#define QSYNC_ENGINE_H
24
24
25
#include <libqopensync/group.h>
26
27
class OSyncEngine;
25
class OSyncEngine;
28
26
29
namespace QSync {
27
namespace QSync {
30
28
29
class Group;
30
class Member;
31
class Result;
32
31
class Engine
33
class Engine
32
{
34
{
33
  friend class CallbackHandler;
35
  friend class CallbackHandler;
Lines 59-64 Link Here
59
    Result synchronize();
61
    Result synchronize();
60
62
61
    /**
63
    /**
64
      Starts the discover process for a certain member.
65
     */
66
    Result discover( const Member &member );
67
68
    /**
62
      Stops the synchronization process.
69
      Stops the synchronization process.
63
     */
70
     */
64
    void abort();
71
    void abort();
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/environment.cpp (-172 lines)
Lines 1-172 Link Here
1
/*
2
    This file is part of libqopensync.
3
4
    Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
6
    This library is free software; you can redistribute it and/or
7
    modify it under the terms of the GNU Library General Public
8
    License as published by the Free Software Foundation; either
9
    version 2 of the License, or (at your option) any later version.
10
11
    This library is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
    Library General Public License for more details.
15
16
    You should have received a copy of the GNU Library General Public License
17
    along with this library; see the file COPYING.LIB.  If not, write to
18
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
    Boston, MA 02110-1301, USA.
20
*/
21
22
#include "environment.h"
23
24
#include <opensync/opensync.h>
25
26
using namespace QSync;
27
28
Environment::Environment()
29
{
30
  mEnvironment = osync_env_new();
31
}
32
33
Environment::~Environment()
34
{
35
  osync_env_free( mEnvironment );
36
}
37
38
Environment::GroupIterator Environment::groupBegin()
39
{
40
  GroupIterator it( this );
41
  it.mPos = 0;
42
43
  return it;
44
}
45
46
Environment::GroupIterator Environment::groupEnd()
47
{
48
  GroupIterator it( this );
49
  it.mPos = groupCount();
50
51
  return it;
52
}
53
54
Environment::PluginIterator Environment::pluginBegin()
55
{
56
  PluginIterator it( this );
57
  it.mPos = 0;
58
59
  return it;
60
}
61
62
Environment::PluginIterator Environment::pluginEnd()
63
{
64
  PluginIterator it( this );
65
  it.mPos = pluginCount();
66
67
  return it;
68
}
69
70
Result Environment::initialize()
71
{
72
  OSyncError *error = 0;
73
  if ( !osync_env_initialize( mEnvironment, &error ) )
74
    return Result( &error );
75
  else
76
    return Result();
77
}
78
79
Result Environment::finalize()
80
{
81
  OSyncError *error = 0;
82
  if ( !osync_env_finalize( mEnvironment, &error ) )
83
    return Result( &error);
84
  else
85
    return Result();
86
}
87
88
int Environment::groupCount() const
89
{
90
  return osync_env_num_groups( mEnvironment );
91
}
92
93
Group Environment::groupAt( int pos ) const
94
{
95
  Group group;
96
97
  if ( pos < 0 || pos >= groupCount() )
98
    return group;
99
100
  OSyncGroup *ogroup = osync_env_nth_group( mEnvironment, pos );
101
  group.mGroup = ogroup;
102
103
  return group;
104
}
105
106
Group Environment::groupByName( const QString &name ) const
107
{
108
  Group group;
109
110
  OSyncGroup *ogroup = osync_env_find_group( mEnvironment, name.latin1() );
111
  if ( ogroup )
112
    group.mGroup = ogroup;
113
114
  return group;
115
}
116
117
Group Environment::addGroup()
118
{
119
  Group group;
120
121
  OSyncGroup *ogroup = osync_group_new( mEnvironment );
122
  if ( ogroup )
123
    group.mGroup = ogroup;
124
125
  return group;
126
}
127
128
Result Environment::removeGroup( const Group &group )
129
{
130
  OSyncError *error = 0;
131
  if ( !osync_group_delete( group.mGroup, &error ) )
132
    return Result( &error );
133
  else
134
    return Result();
135
}
136
137
int Environment::pluginCount() const
138
{
139
  return osync_env_num_plugins( mEnvironment );
140
}
141
142
Plugin Environment::pluginAt( int pos ) const
143
{
144
  Plugin plugin;
145
146
  if ( pos < 0 || pos >= pluginCount() )
147
    return plugin;
148
149
  OSyncPlugin *oplugin = osync_env_nth_plugin( mEnvironment, pos );
150
  plugin.mPlugin = oplugin;
151
152
  return plugin;
153
}
154
155
Plugin Environment::pluginByName( const QString &name ) const
156
{
157
  Plugin plugin;
158
159
  OSyncPlugin *oplugin = osync_env_find_plugin( mEnvironment, name.latin1() );
160
  if ( oplugin )
161
    plugin.mPlugin = oplugin;
162
163
  return plugin;
164
}
165
166
Conversion Environment::conversion() const
167
{
168
  Conversion conversion;
169
  conversion.mEnvironment = mEnvironment;
170
171
  return conversion;
172
}
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/environment.h (-199 lines)
Lines 1-199 Link Here
1
/*
2
    This file is part of libqopensync.
3
4
    Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
6
    This library is free software; you can redistribute it and/or
7
    modify it under the terms of the GNU Library General Public
8
    License as published by the Free Software Foundation; either
9
    version 2 of the License, or (at your option) any later version.
10
11
    This library is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
    Library General Public License for more details.
15
16
    You should have received a copy of the GNU Library General Public License
17
    along with this library; see the file COPYING.LIB.  If not, write to
18
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
    Boston, MA 02110-1301, USA.
20
*/
21
22
#ifndef OSYNC_ENVIRONMENT_H
23
#define OSYNC_ENVIRONMENT_H
24
25
#include <qstring.h>
26
27
#include <libqopensync/group.h>
28
#include <libqopensync/plugin.h>
29
#include <libqopensync/result.h>
30
#include <libqopensync/conversion.h>
31
32
struct OSyncEnv;
33
34
namespace QSync {
35
36
class Environment
37
{
38
  public:
39
    Environment();
40
    ~Environment();
41
42
    class GroupIterator
43
    {
44
      friend class Environment;
45
46
      public:
47
        GroupIterator( Environment *environment )
48
          : mEnvironment( environment ), mPos( -1 )
49
        {
50
        }
51
52
        GroupIterator( const GroupIterator &it )
53
        {
54
          mEnvironment = it.mEnvironment;
55
          mPos = it.mPos;
56
        }
57
58
        Group operator*() 
59
        {
60
          return mEnvironment->groupAt( mPos );
61
        }
62
63
        GroupIterator &operator++() { mPos++; return *this; }
64
        GroupIterator &operator++( int ) { mPos++; return *this; }
65
        GroupIterator &operator--() { mPos--; return *this; }
66
        GroupIterator &operator--( int ) { mPos--; return *this; }
67
        bool operator==( const GroupIterator &it ) { return mEnvironment == it.mEnvironment && mPos == it.mPos; }
68
        bool operator!=( const GroupIterator &it ) { return mEnvironment == it.mEnvironment && mPos != it.mPos; }
69
70
      private:
71
        Environment *mEnvironment;
72
        int mPos;
73
    };
74
75
    class PluginIterator
76
    {
77
      friend class Environment;
78
79
      public:
80
        PluginIterator( Environment *environment )
81
          : mEnvironment( environment ), mPos( -1 )
82
        {
83
        }
84
85
        PluginIterator( const PluginIterator &it )
86
        {
87
          mEnvironment = it.mEnvironment;
88
          mPos = it.mPos;
89
        }
90
91
        Plugin operator*() 
92
        {
93
          return mEnvironment->pluginAt( mPos );
94
        }
95
96
        PluginIterator &operator++() { mPos++; return *this; }
97
        PluginIterator &operator++( int ) { mPos++; return *this; }
98
        PluginIterator &operator--() { mPos--; return *this; }
99
        PluginIterator &operator--( int ) { mPos--; return *this; }
100
        bool operator==( const PluginIterator &it ) { return mEnvironment == it.mEnvironment && mPos == it.mPos; }
101
        bool operator!=( const PluginIterator &it ) { return mEnvironment == it.mEnvironment && mPos != it.mPos; }
102
103
      private:
104
        Environment *mEnvironment;
105
        int mPos;
106
    };
107
108
    /**
109
      Returns an iterator pointing to the first item in the group list.
110
      This iterator equals groupEnd() if the group list is empty.
111
     */
112
    GroupIterator groupBegin();
113
114
    /**
115
      Returns an iterator pointing past the last item in the group list.
116
      This iterator equals groupBegin() if the group list is empty.
117
     */
118
    GroupIterator groupEnd();
119
120
    /**
121
      Returns an iterator pointing to the first item in the plugin list.
122
      This iterator equals pluginEnd() if the group list is empty.
123
     */
124
    PluginIterator pluginBegin();
125
126
    /**
127
      Returns an iterator pointing past the last item in the plugin list.
128
      This iterator equals pluginBegin() if the plugin list is empty.
129
     */
130
    PluginIterator pluginEnd();
131
132
    /**
133
      Initializes the environment ( e.g. loads the groups and plugins ).
134
      Has to be called before the groups or plugins can be accessed.
135
     */
136
    Result initialize();
137
138
    /**
139
      Finalizes the environment ( e.g. unloads the groups and plugins ).
140
      Should be the last call before the object is deleted.
141
     */
142
    Result finalize();
143
144
    /**
145
      Returns the number of groups.
146
     */
147
    int groupCount() const;
148
149
    /**
150
      Returns the group at position @param pos.
151
     */
152
    Group groupAt( int pos ) const;
153
154
    /**
155
      Returns a group by name or an invalid group when the group with this
156
      name doesn't exists.
157
     */
158
    Group groupByName( const QString &name ) const;
159
160
    /**
161
      Adds a new group to the environment.
162
163
      @returns the new group.
164
     */
165
    Group addGroup();
166
167
    /**
168
      Removes a group from the environment.
169
     */
170
    Result removeGroup( const Group &group );
171
172
    /**
173
      Returns the number of plugins.
174
     */
175
    int pluginCount() const;
176
177
    /**
178
      Returns the plugin at position @param pos.
179
     */
180
    Plugin pluginAt( int pos ) const;
181
182
    /**
183
      Returns a plugin by name or an invalid plugin when the plugin with this
184
      name doesn't exists.
185
     */
186
    Plugin pluginByName( const QString &name ) const;
187
188
    /**
189
      Returns the conversion object of this environment.
190
     */
191
    Conversion conversion() const;
192
193
  private:
194
    OSyncEnv *mEnvironment;
195
};
196
197
}
198
199
#endif
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/filter.cpp (+1 lines)
Lines 20-25 Link Here
20
*/
20
*/
21
21
22
#include <opensync/opensync.h>
22
#include <opensync/opensync.h>
23
#include <opensync/opensync-format.h>
23
24
24
#include "filter.h"
25
#include "filter.h"
25
26
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/group.cpp (-99 / +44 lines)
Lines 25-110 Link Here
25
/** hack includes **/
25
/** hack includes **/
26
26
27
#include <opensync/opensync.h>
27
#include <opensync/opensync.h>
28
#include <opensync/opensync-group.h>
28
29
29
#include "conversion.h"
30
#include "conversion.h"
31
#include "filter.h"
32
#include "member.h"
33
#include "plugin.h"
34
#include "result.h"
35
30
#include "group.h"
36
#include "group.h"
31
37
32
using namespace QSync;
38
using namespace QSync;
33
39
34
/**
35
  This class is a quick hack for OpenSync 0.19 and 0.20 because
36
  the engine doesn't stores the filter settings itself when calling
37
  osync_group_set_objtype_enabled(), so we have to store it for every
38
  group in a separated config file. This class encapsulates it.
39
 */
40
GroupConfig::GroupConfig()
41
  : mGroup( 0 )
42
{
43
}
44
45
QStringList GroupConfig::activeObjectTypes() const
46
{
47
  Q_ASSERT( mGroup );
48
49
  const QString fileName = QString( "%1/filter.conf" ).arg( osync_group_get_configdir( mGroup ) );
50
51
  QFile file( fileName );
52
  if ( !file.open( IO_ReadOnly ) )
53
    return QStringList();
54
55
  QDomDocument document;
56
57
  QString message;
58
  if ( !document.setContent( &file, &message ) ) {
59
    qDebug( "Error on loading %s: %s", fileName.latin1(), message.latin1() );
60
    return QStringList();
61
  }
62
  file.close();
63
64
  QStringList objectTypes;
65
66
  QDomElement element = document.documentElement();
67
  QDomNode node = element.firstChild();
68
  while ( !node.isNull() ) {
69
    QDomElement childElement = node.toElement();
70
    if ( !childElement.isNull() )
71
      objectTypes.append( childElement.tagName() );
72
73
    node = node.nextSibling();
74
  }
75
76
  return objectTypes;
77
}
78
79
void GroupConfig::setActiveObjectTypes( const QStringList &objectTypes )
80
{
81
  Q_ASSERT( mGroup );
82
83
  QDomDocument document( "Filter" );
84
  document.appendChild( document.createProcessingInstruction(
85
                        "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
86
87
  QDomElement element = document.createElement( "filter" );
88
  document.appendChild( element );
89
90
  for ( uint i = 0; i < objectTypes.count(); ++i ) {
91
    QDomElement entry = document.createElement( objectTypes[ i ] );
92
    element.appendChild( entry );
93
  }
94
95
  const QString fileName = QString( "%1/filter.conf" ).arg( osync_group_get_configdir( mGroup ) );
96
97
  QFile file( fileName );
98
  if ( !file.open( IO_WriteOnly ) )
99
    return;
100
101
  QTextStream s( &file );
102
  s.setEncoding( QTextStream::UnicodeUTF8 );
103
  s << document.toString();
104
  file.close();
105
}
106
107
108
Group::Group()
40
Group::Group()
109
  : mGroup( 0 )
41
  : mGroup( 0 )
110
{
42
{
Lines 119-140 Link Here
119
  return ( mGroup != 0 );
51
  return ( mGroup != 0 );
120
}
52
}
121
53
122
Group::Iterator Group::begin()
123
{
124
  Iterator it( this );
125
  it.mPos = 0;
126
127
  return it;
128
}
129
130
Group::Iterator Group::end()
131
{
132
  Iterator it( this );
133
  it.mPos = memberCount();
134
135
  return it;
136
}
137
138
void Group::setName( const QString &name )
54
void Group::setName( const QString &name )
139
{
55
{
140
  Q_ASSERT( mGroup );
56
  Q_ASSERT( mGroup );
Lines 188-205 Link Here
188
  }
104
  }
189
}
105
}
190
106
191
void Group::unlock( bool removeFile )
107
void Group::unlock()
192
{
108
{
193
  Q_ASSERT( mGroup );
109
  Q_ASSERT( mGroup );
194
110
195
  osync_group_unlock( mGroup, removeFile );
111
  osync_group_unlock( mGroup );
196
}
112
}
197
113
198
Member Group::addMember()
114
Member Group::addMember( const QSync::Plugin &plugin )
199
{
115
{
200
  Q_ASSERT( mGroup );
116
  Q_ASSERT( mGroup );
201
117
202
  OSyncMember *omember = osync_member_new( mGroup );
118
  OSyncError *error = 0;
119
120
  OSyncMember *omember = osync_member_new( &error );
121
  osync_group_add_member( mGroup, omember );
122
  osync_member_set_pluginname( omember, plugin.name().utf8() );
203
123
204
  Member member;
124
  Member member;
205
  member.mMember = omember;
125
  member.mMember = omember;
Lines 269-274 Link Here
269
    return Result();
189
    return Result();
270
}
190
}
271
191
192
void Group::setUseMerger( bool use )
193
{
194
  Q_ASSERT( mGroup );
195
  osync_group_set_merger_enabled( mGroup, use );
196
}
197
198
bool Group::useMerger() const
199
{
200
  Q_ASSERT( mGroup );
201
  return osync_group_get_merger_enabled( mGroup );
202
}
203
204
void Group::setUseConverter( bool use )
205
{
206
  Q_ASSERT( mGroup );
207
  osync_group_set_converter_enabled( mGroup, use );
208
}
209
210
bool Group::useConverter() const
211
{
212
  Q_ASSERT( mGroup );
213
  return osync_group_get_converter_enabled( mGroup );
214
}
215
272
void Group::setObjectTypeEnabled( const QString &objectType, bool enabled )
216
void Group::setObjectTypeEnabled( const QString &objectType, bool enabled )
273
{
217
{
274
  Q_ASSERT( mGroup );
218
  Q_ASSERT( mGroup );
Lines 281-292 Link Here
281
  return osync_group_objtype_enabled( mGroup, objectType.utf8() );
225
  return osync_group_objtype_enabled( mGroup, objectType.utf8() );
282
}
226
}
283
227
284
GroupConfig Group::config() const
228
Result Group::cleanup() const
285
{
229
{
286
  Q_ASSERT( mGroup );
230
  Q_ASSERT( mGroup );
287
231
288
  GroupConfig config;
232
  OSyncError *error = 0;
289
  config.mGroup = mGroup;
233
  if ( !osync_group_delete( mGroup, &error ) )
290
234
    return Result( &error );
291
  return config;
235
  else
236
    return Result();
292
}
237
}
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/groupenv.cpp (+121 lines)
Line 0 Link Here
1
/*
2
    This file is part of libqopensync.
3
4
    Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
6
    This library is free software; you can redistribute it and/or
7
    modify it under the terms of the GNU Library General Public
8
    License as published by the Free Software Foundation; either
9
    version 2 of the License, or (at your option) any later version.
10
11
    This library is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
    Library General Public License for more details.
15
16
    You should have received a copy of the GNU Library General Public License
17
    along with this library; see the file COPYING.LIB.  If not, write to
18
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
    Boston, MA 02110-1301, USA.
20
*/
21
22
#include <opensync/opensync.h>
23
#include <opensync/opensync-group.h>
24
25
#include "group.h"
26
#include "result.h"
27
28
#include "groupenv.h"
29
30
using namespace QSync;
31
32
GroupEnv::GroupEnv()
33
{
34
  OSyncError *error = 0;
35
  mGroupEnv = osync_group_env_new( &error );
36
}
37
38
GroupEnv::~GroupEnv()
39
{
40
  osync_group_env_free( mGroupEnv );
41
}
42
43
Result GroupEnv::initialize()
44
{
45
  Q_ASSERT( mGroupEnv );
46
47
  OSyncError *error = 0;
48
  if ( !osync_group_env_load_groups( mGroupEnv, NULL, &error ) )
49
    return Result( &error );
50
  else
51
    return Result();
52
}
53
54
void GroupEnv::finalize()
55
{
56
}
57
58
int GroupEnv::groupCount() const
59
{
60
  Q_ASSERT( mGroupEnv );
61
62
  return osync_group_env_num_groups( mGroupEnv );
63
}
64
65
Group GroupEnv::groupAt( int pos ) const
66
{
67
  Q_ASSERT( mGroupEnv );
68
69
  Group group;
70
71
  if ( pos < 0 || pos >= groupCount() )
72
    return group;
73
74
  OSyncGroup *ogroup = osync_group_env_nth_group( mGroupEnv, pos );
75
  group.mGroup = ogroup;
76
77
  return group;
78
}
79
80
Group GroupEnv::groupByName( const QString &name ) const
81
{
82
  Q_ASSERT( mGroupEnv );
83
84
  Group group;
85
86
  OSyncGroup *ogroup = osync_group_env_find_group( mGroupEnv, name.latin1() );
87
  if ( ogroup )
88
    group.mGroup = ogroup;
89
90
  return group;
91
}
92
93
Group GroupEnv::addGroup( const QString &name )
94
{
95
  Q_ASSERT( mGroupEnv );
96
97
  Group group;
98
  OSyncError *error = 0;
99
100
  OSyncGroup *ogroup = osync_group_new( &error );
101
  if ( ogroup )
102
    group.mGroup = ogroup;
103
104
  group.setName( name );
105
106
  if ( !osync_group_env_add_group( mGroupEnv, ogroup, &error ) ) {
107
    Result res( &error );
108
    qDebug( "Error on adding group: %s", res.message().latin1() );
109
  }
110
111
  return group;
112
}
113
114
void GroupEnv::removeGroup( const Group &group )
115
{
116
  Q_ASSERT( mGroupEnv );
117
118
  group.cleanup();
119
120
  osync_group_env_remove_group( mGroupEnv, group.mGroup );
121
}
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/groupenv.h (+86 lines)
Line 0 Link Here
1
/*
2
    This file is part of libqopensync.
3
4
    Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
6
    This library is free software; you can redistribute it and/or
7
    modify it under the terms of the GNU Library General Public
8
    License as published by the Free Software Foundation; either
9
    version 2 of the License, or (at your option) any later version.
10
11
    This library is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
    Library General Public License for more details.
15
16
    You should have received a copy of the GNU Library General Public License
17
    along with this library; see the file COPYING.LIB.  If not, write to
18
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
    Boston, MA 02110-1301, USA.
20
*/
21
22
#ifndef OSYNC_GROUPENV_H
23
#define OSYNC_GROUPENV_H
24
25
#include <qstring.h>
26
27
struct OSyncGroupEnv;
28
29
namespace QSync {
30
31
class Group;
32
class Result;
33
34
class GroupEnv
35
{
36
  public:
37
    GroupEnv();
38
    ~GroupEnv();
39
40
    /**
41
      Initializes the environment ( e.g. loads the groups and plugins ).
42
      Has to be called before the groups or plugins can be accessed.
43
     */
44
    Result initialize();
45
46
    /**
47
      Finalizes the environment ( e.g. unloads the groups and plugins ).
48
      Should be the last call before the object is deleted.
49
     */
50
    void finalize();
51
52
    /**
53
      Returns the number of groups.
54
     */
55
    int groupCount() const;
56
57
    /**
58
      Returns the group at position @param pos.
59
     */
60
    Group groupAt( int pos ) const;
61
62
    /**
63
      Returns a group by name or an invalid group when the group with this
64
      name doesn't exists.
65
     */
66
    Group groupByName( const QString &name ) const;
67
68
    /**
69
      Adds a new group to the environment.
70
71
      @returns the new group.
72
     */
73
    Group addGroup( const QString &name );
74
75
    /**
76
      Removes a group from the environment.
77
     */
78
    void removeGroup( const Group &group );
79
80
  private:
81
    OSyncGroupEnv *mGroupEnv;
82
};
83
84
}
85
86
#endif
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/group.h (-73 / +31 lines)
Lines 25-59 Link Here
25
#include <qdatetime.h>
25
#include <qdatetime.h>
26
#include <qstringlist.h>
26
#include <qstringlist.h>
27
27
28
#include <libqopensync/filter.h>
29
#include <libqopensync/member.h>
30
31
class OSyncGroup;
28
class OSyncGroup;
32
29
33
namespace QSync {
30
namespace QSync {
34
31
32
class Filter;
33
class Member;
34
class Plugin;
35
class Result;
36
35
/**
37
/**
36
  @internal
38
  @internal
37
 */
39
 */
38
class GroupConfig
39
{
40
  friend class Group;
41
42
  public:
43
    GroupConfig();
44
45
    QStringList activeObjectTypes() const;
46
    void setActiveObjectTypes( const QStringList &objectTypes );
47
48
  private:
49
    OSyncGroup *mGroup;
50
};
51
52
53
class Group
40
class Group
54
{
41
{
55
  friend class Engine;
42
  friend class Engine;
56
  friend class Environment;
43
  friend class GroupEnv;
57
44
58
  public:
45
  public:
59
    enum LockType
46
    enum LockType
Lines 71-121 Link Here
71
     */
58
     */
72
    bool isValid() const;
59
    bool isValid() const;
73
60
74
    class Iterator
75
    {
76
      friend class Group;
77
78
      public:
79
        Iterator( Group *group )
80
          : mGroup( group ), mPos( -1 )
81
        {
82
        }
83
84
        Iterator( const Iterator &it )
85
        {
86
          mGroup = it.mGroup;
87
          mPos = it.mPos;
88
        }
89
90
        Member operator*() 
91
        {
92
          return mGroup->memberAt( mPos );
93
        }
94
95
        Iterator &operator++() { mPos++; return *this; }
96
        Iterator &operator++( int ) { mPos++; return *this; }
97
        Iterator &operator--() { mPos--; return *this; }
98
        Iterator &operator--( int ) { mPos--; return *this; }
99
        bool operator==( const Iterator &it ) { return mGroup == it.mGroup && mPos == it.mPos; }
100
        bool operator!=( const Iterator &it ) { return mGroup == it.mGroup && mPos != it.mPos; }
101
102
      private:
103
        Group *mGroup;
104
        int mPos;
105
    };
106
107
    /**
108
      Returns an iterator pointing to the first item in the member list.
109
      This iterator equals end() if the member list is empty.
110
     */
111
    Iterator begin();
112
113
    /**
114
      Returns an iterator pointing past the last item in the member list.
115
      This iterator equals begin() if the member list is empty.
116
     */
117
    Iterator end();
118
119
    /**
61
    /**
120
      Sets the name of the group.
62
      Sets the name of the group.
121
     */
63
     */
Lines 145-161 Link Here
145
87
146
    /**
88
    /**
147
      Unlocks the group.
89
      Unlocks the group.
148
149
      @param removeFile Whether the lock file shall be removed.
150
     */
90
     */
151
    void unlock( bool removeFile = true );
91
    void unlock();
152
92
153
    /**
93
    /**
154
      Adds a new member to the group.
94
      Adds a new member to the group.
155
95
156
      @returns the new member.
96
      @returns the new member.
157
     */
97
     */
158
    Member addMember();
98
    Member addMember( const QSync::Plugin &plugin );
159
99
160
    /**
100
    /**
161
      Removes a member from the group.
101
      Removes a member from the group.
Lines 195-213 Link Here
195
    bool isObjectTypeEnabled( const QString &objectType ) const;
135
    bool isObjectTypeEnabled( const QString &objectType ) const;
196
136
197
    /**
137
    /**
198
      Saves the configuration to hard disc.
138
      Sets whether this group uses the merger for synchronization.
199
     */
139
     */
200
    Result save();
140
    void setUseMerger( bool use );
201
141
202
    /**
142
    /**
203
      Returns the config object of this group.
143
      Returns whether this group uses the merger for synchronization.
144
     */
145
    bool useMerger() const;
204
146
205
      Note: This method is only available for OpenSync 0.19 and 0.20.
147
    /**
148
      Sets whether this group uses the converter for synchronization.
206
     */
149
     */
207
    GroupConfig config() const;
150
    void setUseConverter( bool use );
151
152
    /**
153
      Returns whether this group uses the converter for synchronization.
154
     */
155
    bool useConverter() const;
156
157
    /**
158
      Saves the configuration to hard disc.
159
     */
160
    Result save();
208
161
209
    bool operator==( const Group &group ) const { return mGroup == group.mGroup; }
162
    bool operator==( const Group &group ) const { return mGroup == group.mGroup; }
210
163
164
    /**
165
      Removes all group configurations from the hard disc.
166
     */
167
    Result cleanup() const;
168
211
  private:
169
  private:
212
    OSyncGroup *mGroup;
170
    OSyncGroup *mGroup;
213
};
171
};
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/Makefile.am (-4 / +8 lines)
Lines 2-17 Link Here
2
           -I$(top_srcdir)/kitchensync \
2
           -I$(top_srcdir)/kitchensync \
3
           -I$(top_srcdir) \
3
           -I$(top_srcdir) \
4
           $(OPENSYNC_CFLAGS) \
4
           $(OPENSYNC_CFLAGS) \
5
           $(OPENSYNCENGINE_CFLAGS) \
5
           $(GLIB_CFLAGS) \
6
           $(all_includes)
6
           $(all_includes)
7
7
8
lib_LTLIBRARIES = libqopensync.la
8
lib_LTLIBRARIES = libqopensync.la
9
9
10
libqopensync_la_SOURCES = callbackhandler.cpp conversion.cpp engine.cpp environment.cpp filter.cpp group.cpp \
10
libqopensync_la_SOURCES = callbackhandler.cpp engine.cpp groupenv.cpp pluginenv.cpp filter.cpp group.cpp \
11
	member.cpp plugin.cpp result.cpp syncmapping.cpp syncupdates.cpp \
11
	member.cpp plugin.cpp result.cpp syncmapping.cpp syncupdates.cpp \
12
	syncchange.cpp
12
	syncchange.cpp
13
libqopensync_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
13
14
libqopensync_la_LIBADD = $(LIB_KDEUI) $(OPENSYNC_LIBS) $(OPENSYNCENGINE_LIBS)
14
# FIXME: -no-undefined break the build for some unkown reason - libopensync broken?!
15
#libqopensync_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
16
libqopensync_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
17
libqopensync_la_LIBADD = $(LIB_KDEUI) $(OPENSYNC_LIBS)
18
15
19
16
METASOURCES = AUTO
20
METASOURCES = AUTO
17
21
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/member.cpp (-51 / +22 lines)
Lines 20-27 Link Here
20
*/
20
*/
21
21
22
#include <opensync/opensync.h>
22
#include <opensync/opensync.h>
23
#include <opensync/opensync-group.h>
24
23
#include <stdlib.h>
25
#include <stdlib.h>
24
26
27
#include "result.h"
28
25
#include "member.h"
29
#include "member.h"
26
30
27
using namespace QSync;
31
using namespace QSync;
Lines 42-50 Link Here
42
  if ( !mMember )
46
  if ( !mMember )
43
    return false;
47
    return false;
44
48
45
  if ( !osync_member_instance_plugin( mMember, pluginName().utf8(), &error ) ) {
49
  if ( !osync_member_load( mMember, configurationDirectory().utf8(), &error ) ) {
46
    qDebug( "Plugin %s is not valid: %s", pluginName().latin1(), osync_error_print( &error ) );
50
    qDebug( "Plugin %s is not valid: %s", pluginName().latin1(), osync_error_print( &error ) );
47
    osync_error_free( &error );
51
    osync_error_unref( &error );
48
    return false;
52
    return false;
49
  }
53
  }
50
54
Lines 65-83 Link Here
65
  return QString::fromLatin1( osync_member_get_pluginname( mMember ) );
69
  return QString::fromLatin1( osync_member_get_pluginname( mMember ) );
66
}
70
}
67
71
68
Plugin Member::plugin() const
69
{
70
  Q_ASSERT( mMember );
71
72
  Plugin plugin;
73
74
  OSyncPlugin *oplugin = osync_member_get_plugin( mMember );
75
  if ( oplugin )
76
    plugin.mPlugin = oplugin;
77
78
  return plugin;
79
}
80
81
int Member::id() const
72
int Member::id() const
82
{
73
{
83
  Q_ASSERT( mMember );
74
  Q_ASSERT( mMember );
Lines 103-129 Link Here
103
{
94
{
104
  Q_ASSERT( mMember );
95
  Q_ASSERT( mMember );
105
96
106
  osync_member_set_config( mMember, configurationData.data(), configurationData.size() );
97
  osync_member_set_config( mMember, configurationData.data() );
107
}
98
}
108
99
109
Result Member::configuration( QByteArray &configurationData, bool useDefault )
100
Result Member::configuration( QByteArray &configurationData, bool useDefault )
110
{
101
{
111
  Q_ASSERT( mMember );
102
  Q_ASSERT( mMember );
112
103
113
  char *data;
104
  const char *data;
114
  int size;
105
  int size = 0;
115
106
116
  OSyncError *error = 0;
107
  OSyncError *error = 0;
117
  osync_bool ok = false;
118
  if ( useDefault )
108
  if ( useDefault )
119
    ok = osync_member_get_config_or_default( mMember, &data, &size, &error );
109
    data = osync_member_get_config_or_default( mMember, &error );
120
  else
110
  else
121
    ok = osync_member_get_config( mMember, &data, &size, &error );
111
    data = osync_member_get_config( mMember, &error );
122
112
123
  if ( !ok ) {
113
114
  if ( !data ) {
124
    return Result( &error );
115
    return Result( &error );
125
  } else {
116
  } else {
126
    configurationData.resize( size );
117
    size = strlen(data);
118
    configurationData.resize( size );	  
127
    memcpy( configurationData.data(), data, size );
119
    memcpy( configurationData.data(), data, size );
128
120
129
    return Result();
121
    return Result();
Lines 141-150 Link Here
141
    return Result();
133
    return Result();
142
}
134
}
143
135
144
Result Member::instance( const Plugin &plugin )
136
Result Member::instance()
145
{
137
{
146
  OSyncError *error = 0;
138
  OSyncError *error = 0;
147
  if ( !osync_member_instance_plugin( mMember, plugin.name().utf8(), &error ) )
139
  if ( !osync_member_load( mMember, configurationDirectory().utf8(), &error ) )
148
    return Result( &error );
140
    return Result( &error );
149
  else
141
  else
150
    return Result();
142
    return Result();
Lines 155-188 Link Here
155
  return mMember == member.mMember;
147
  return mMember == member.mMember;
156
}
148
}
157
149
158
QString Member::scanDevices( const QString &query )
150
Result Member::cleanup() const
159
{
160
  Q_ASSERT( mMember );
161
162
  OSyncError *error = 0;
163
  char *data = (char*)osync_member_call_plugin( mMember, "scan_devices", const_cast<char*>( query.utf8().data() ), &error );
164
  if ( error != 0 ) {
165
    osync_error_free( &error );
166
    return QString();
167
  } else {
168
    QString xml = QString::fromUtf8( data );
169
    free( data );
170
    return xml;
171
  }
172
}
173
174
bool Member::testConnection( const QString &configuration )
175
{
151
{
176
  Q_ASSERT( mMember );
152
  Q_ASSERT( mMember );
177
153
178
  OSyncError *error = 0;
154
  OSyncError *error = 0;
179
  int *result = (int*)osync_member_call_plugin( mMember, "test_connection", const_cast<char*>( configuration.utf8().data() ), &error );
155
  if ( !osync_member_delete( mMember, &error ) )
180
  if ( error != 0 ) {
156
    return Result( &error );
181
    osync_error_free( &error );
157
  else
182
    return false;
158
    return Result();
183
  } else {
184
    bool value = ( *result == 1 ? true : false );
185
    free( result );
186
    return value;
187
  }
188
}
159
}
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/member.h (-9 / +12 lines)
Lines 22-40 Link Here
22
#ifndef QSYNC_MEMBER_H
22
#ifndef QSYNC_MEMBER_H
23
#define QSYNC_MEMBER_H
23
#define QSYNC_MEMBER_H
24
24
25
#include <libqopensync/plugin.h>
25
#include <qstring.h>
26
#include <libqopensync/result.h>
27
#include <libqopensync/plugin.h>
28
26
29
class OSyncMember;
27
class OSyncMember;
30
28
31
namespace QSync {
29
namespace QSync {
32
30
31
class Result;
32
33
class Member
33
class Member
34
{
34
{
35
  friend class Group;
35
  friend class Group;
36
  friend class Engine;
36
  friend class SyncChange;
37
  friend class SyncChange;
37
  friend class SyncMemberUpdate;
38
  friend class SyncMemberUpdate;
39
  friend class SyncChangeUpdate;
38
40
39
  public:
41
  public:
40
    Member();
42
    Member();
Lines 56-66 Link Here
56
    QString pluginName() const;
58
    QString pluginName() const;
57
59
58
    /**
60
    /**
59
      Returns the plugin, the member belongs to.
60
     */
61
    Plugin plugin() const;
62
63
    /**
64
      Returns the id of the plugin.
61
      Returns the id of the plugin.
65
    */
62
    */
66
    int id() const;
63
    int id() const;
Lines 102-108 Link Here
102
    /**
99
    /**
103
      Make this member an instance of the given plugin.
100
      Make this member an instance of the given plugin.
104
    */
101
    */
105
    Result instance( const Plugin & );
102
    Result instance();
106
103
107
    bool operator==( const Member& ) const;
104
    bool operator==( const Member& ) const;
108
105
Lines 119-124 Link Here
119
     */
116
     */
120
    bool testConnection( const QString &configuration );
117
    bool testConnection( const QString &configuration );
121
118
119
120
    /**
121
     * Deletes the member's information from the hard disc.
122
     */
123
    Result cleanup() const;
124
122
  private:
125
  private:
123
    OSyncMember *mMember;
126
    OSyncMember *mMember;
124
};
127
};
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/plugin.cpp (+1 lines)
Lines 20-25 Link Here
20
*/
20
*/
21
21
22
#include <opensync/opensync.h>
22
#include <opensync/opensync.h>
23
#include <opensync/opensync-plugin.h>
23
24
24
#include "plugin.h"
25
#include "plugin.h"
25
26
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/pluginenv.cpp (+96 lines)
Line 0 Link Here
1
/*
2
    This file is part of libqopensync.
3
4
    Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
    Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
6
7
    This library is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU Library General Public
9
    License as published by the Free Software Foundation; either
10
    version 2 of the License, or (at your option) any later version.
11
12
    This library is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
    Library General Public License for more details.
16
17
    You should have received a copy of the GNU Library General Public License
18
    along with this library; see the file COPYING.LIB.  If not, write to
19
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
    Boston, MA 02110-1301, USA.
21
*/
22
23
#include <opensync/opensync.h>
24
#include <opensync/opensync-plugin.h>
25
26
#include "plugin.h"
27
#include "result.h"
28
29
#include "pluginenv.h"
30
31
using namespace QSync;
32
33
PluginEnv::PluginEnv()
34
{
35
  OSyncError *error = 0;
36
  mPluginEnv = osync_plugin_env_new( &error );
37
}
38
39
PluginEnv::~PluginEnv()
40
{
41
  osync_plugin_env_free( mPluginEnv );
42
}
43
44
Result PluginEnv::initialize()
45
{
46
  OSyncError *error = 0;
47
  if ( !osync_plugin_env_load( mPluginEnv, NULL, &error ) )
48
    return Result( &error );
49
  else
50
    return Result();
51
}
52
53
Result PluginEnv::finalize()
54
{
55
  osync_plugin_env_free( mPluginEnv ); 
56
  return Result();
57
}
58
59
int PluginEnv::pluginCount() const
60
{
61
  return osync_plugin_env_num_plugins( mPluginEnv );
62
}
63
64
Plugin PluginEnv::pluginAt( int pos ) const
65
{
66
  Plugin plugin;
67
68
  if ( pos < 0 || pos >= pluginCount() )
69
    return plugin;
70
71
  OSyncPlugin *oplugin = osync_plugin_env_nth_plugin( mPluginEnv, pos );
72
  plugin.mPlugin = oplugin;
73
74
  return plugin;
75
}
76
77
Plugin PluginEnv::pluginByName( const QString &name ) const
78
{
79
  Plugin plugin;
80
81
  OSyncPlugin *oplugin = osync_plugin_env_find_plugin( mPluginEnv, name.latin1() );
82
  if ( oplugin )
83
    plugin.mPlugin = oplugin;
84
85
  return plugin;
86
}
87
88
/*
89
Conversion PluginEnv::conversion() const
90
{
91
  Conversion conversion;
92
  conversion.mPluginEnv = mPluginEnv;
93
94
  return conversion;
95
}
96
*/
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/pluginenv.h (+80 lines)
Line 0 Link Here
1
/*
2
    This file is part of libqopensync.
3
4
    Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
    Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
6
7
    This library is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU Library General Public
9
    License as published by the Free Software Foundation; either
10
    version 2 of the License, or (at your option) any later version.
11
12
    This library is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
    Library General Public License for more details.
16
17
    You should have received a copy of the GNU Library General Public License
18
    along with this library; see the file COPYING.LIB.  If not, write to
19
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
    Boston, MA 02110-1301, USA.
21
*/
22
23
#ifndef OSYNC_PLUGINENV_H
24
#define OSYNC_PLUGINENV_H
25
26
#include <qstring.h>
27
28
struct OSyncPluginEnv;
29
30
namespace QSync {
31
32
class Plugin;
33
class Result;
34
35
class PluginEnv
36
{
37
  public:
38
    PluginEnv();
39
    ~PluginEnv();
40
41
    /**
42
      Initializes the environment ( e.g. loads the groups and plugins ).
43
      Has to be called before the groups or plugins can be accessed.
44
     */
45
    Result initialize();
46
47
    /**
48
      Finalizes the environment ( e.g. unloads the groups and plugins ).
49
      Should be the last call before the object is deleted.
50
     */
51
    Result finalize();
52
53
    /**
54
      Returns the number of plugins.
55
     */
56
    int pluginCount() const;
57
58
    /**
59
      Returns the plugin at position @param pos.
60
     */
61
    Plugin pluginAt( int pos ) const;
62
63
    /**
64
      Returns a plugin by name or an invalid plugin when the plugin with this
65
      name doesn't exists.
66
     */
67
    Plugin pluginByName( const QString &name ) const;
68
69
    /**
70
      Returns the conversion object of this environment.
71
     */
72
//    Conversion conversion() const;
73
74
  private:
75
    OSyncPluginEnv *mPluginEnv;
76
};
77
78
}
79
80
#endif
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/plugin.h (-1 / +1 lines)
Lines 30-36 Link Here
30
30
31
class Plugin
31
class Plugin
32
{
32
{
33
  friend class Environment;
33
  friend class PluginEnv;
34
  friend class Member;
34
  friend class Member;
35
35
36
  public:
36
  public:
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/result.cpp (-1 / +1 lines)
Lines 100-106 Link Here
100
  mMessage = QString::fromUtf8( osync_error_print( error ) );
100
  mMessage = QString::fromUtf8( osync_error_print( error ) );
101
101
102
  if ( deleteError )
102
  if ( deleteError )
103
    osync_error_free( error );
103
    osync_error_unref( error );
104
}
104
}
105
105
106
Result::~Result()
106
Result::~Result()
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/syncchange.cpp (-17 / +34 lines)
Lines 19-26 Link Here
19
    Boston, MA 02110-1301, USA.
19
    Boston, MA 02110-1301, USA.
20
*/
20
*/
21
21
22
#include <stdlib.h>
23
22
#include <opensync/file.h>
24
#include <opensync/file.h>
25
23
#include <opensync/opensync.h>
26
#include <opensync/opensync.h>
27
#include <opensync/opensync-data.h>
28
#include <opensync/opensync-format.h>
24
29
25
#include "syncchange.h"
30
#include "syncchange.h"
26
31
Lines 64-102 Link Here
64
  return QString::fromUtf8( osync_change_get_hash( mSyncChange ) );
69
  return QString::fromUtf8( osync_change_get_hash( mSyncChange ) );
65
}
70
}
66
71
67
void SyncChange::setData( const QString &data )
72
void SyncChange::setData( const QString &data , OSyncObjFormat *format )
68
{
73
{
69
  osync_change_set_data( mSyncChange, const_cast<char*>( data.utf8().data() ), data.utf8().size(), true );
74
  OSyncError *error = 0;	
75
76
  OSyncData *odata = osync_data_new( const_cast<char*>( data.utf8().data() ), data.utf8().size(), format, &error );
77
  osync_change_set_data( mSyncChange, odata );
70
}
78
}
71
79
72
QString SyncChange::data() const
80
QString SyncChange::data() const
73
{
81
{
74
  int size = osync_change_get_datasize( mSyncChange );
82
  char *buf;
83
  unsigned int size;
84
85
  OSyncData *data = osync_change_get_data( mSyncChange );
86
87
  osync_data_get_data( data, &buf, &size );
75
88
76
  QString content;
89
  QString content;
77
  if ( objectFormatName() == "file" ) {
90
  if ( objectFormatName() == "file" ) {
78
    fileFormat *format = (fileFormat*)osync_change_get_data( mSyncChange );
91
    OSyncFileFormat *format = (OSyncFileFormat*) buf;
79
    if ( format )
92
    if ( format )
80
      content = QString::fromUtf8( format->data, format->size );
93
      content = QString::fromUtf8( format->data, format->size );
81
  } else
94
  } else
82
    content = QString::fromUtf8( osync_change_get_data( mSyncChange ), size );
95
    content = QString::fromUtf8( buf, size );
96
97
  free( buf );
83
98
84
  return content;
99
  return content;
85
}
100
}
86
101
87
bool SyncChange::hasData() const
102
bool SyncChange::hasData() const
88
{
103
{
89
  return osync_change_has_data( mSyncChange );
104
  return osync_data_has_data( osync_change_get_data( mSyncChange ) );
90
}
105
}
91
106
92
QString SyncChange::objectFormatName() const
107
QString SyncChange::objectFormatName() const
93
{
108
{
94
  OSyncObjFormat *format = osync_change_get_objformat( mSyncChange );
109
  OSyncObjFormat *format = osync_data_get_objformat( osync_change_get_data( mSyncChange ) );
95
  Q_ASSERT( format );
110
  Q_ASSERT( format );
96
111
97
  return QString::fromUtf8( osync_objformat_get_name( format ) );
112
  return QString::fromUtf8( osync_objformat_get_name( format ) );
98
}
113
}
99
114
115
/*
100
Member SyncChange::member() const
116
Member SyncChange::member() const
101
{
117
{
102
  OSyncMember *omember = osync_change_get_member( mSyncChange );
118
  OSyncMember *omember = osync_change_get_member( mSyncChange );
Lines 106-111 Link Here
106
122
107
  return m;
123
  return m;
108
}
124
}
125
*/
109
126
110
void SyncChange::setChangeType( Type changeType )
127
void SyncChange::setChangeType( Type changeType )
111
{
128
{
Lines 113-132 Link Here
113
130
114
  switch ( changeType ) {
131
  switch ( changeType ) {
115
    case AddedChange:
132
    case AddedChange:
116
      ochangeType = CHANGE_ADDED;
133
      ochangeType = OSYNC_CHANGE_TYPE_ADDED;
117
      break;
134
      break;
118
    case UnmodifiedChange:
135
    case UnmodifiedChange:
119
      ochangeType = CHANGE_UNMODIFIED;
136
      ochangeType = OSYNC_CHANGE_TYPE_UNMODIFIED;
120
      break;
137
      break;
121
    case DeletedChange:
138
    case DeletedChange:
122
      ochangeType = CHANGE_DELETED;
139
      ochangeType = OSYNC_CHANGE_TYPE_DELETED;
123
      break;
140
      break;
124
    case ModifiedChange:
141
    case ModifiedChange:
125
      ochangeType = CHANGE_MODIFIED;
142
      ochangeType = OSYNC_CHANGE_TYPE_MODIFIED;
126
      break;
143
      break;
127
    case UnknownChange:
144
    case UnknownChange:
128
    default:
145
    default:
129
      ochangeType = CHANGE_UNKNOWN;
146
      ochangeType = OSYNC_CHANGE_TYPE_UNKNOWN;
130
      break;
147
      break;
131
  }
148
  }
132
149
Lines 138-156 Link Here
138
  OSyncChangeType ochangeType = osync_change_get_changetype( mSyncChange );
155
  OSyncChangeType ochangeType = osync_change_get_changetype( mSyncChange );
139
156
140
  switch ( ochangeType ) {
157
  switch ( ochangeType ) {
141
    case CHANGE_ADDED:
158
    case OSYNC_CHANGE_TYPE_ADDED:
142
      return AddedChange;
159
      return AddedChange;
143
      break;
160
      break;
144
    case CHANGE_UNMODIFIED:
161
    case OSYNC_CHANGE_TYPE_UNMODIFIED:
145
      return UnmodifiedChange;
162
      return UnmodifiedChange;
146
      break;
163
      break;
147
    case CHANGE_DELETED:
164
    case OSYNC_CHANGE_TYPE_DELETED:
148
      return DeletedChange;
165
      return DeletedChange;
149
      break;
166
      break;
150
    case CHANGE_MODIFIED:
167
    case OSYNC_CHANGE_TYPE_MODIFIED:
151
      return ModifiedChange;
168
      return ModifiedChange;
152
      break;
169
      break;
153
    case CHANGE_UNKNOWN:
170
    case OSYNC_CHANGE_TYPE_UNKNOWN:
154
    default:
171
    default:
155
      return UnknownChange;
172
      return UnknownChange;
156
      break;
173
      break;
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/syncchange.h (-2 / +3 lines)
Lines 25-30 Link Here
25
#include <libqopensync/member.h>
25
#include <libqopensync/member.h>
26
26
27
class OSyncChange;
27
class OSyncChange;
28
class OSyncObjFormat;
28
29
29
namespace QSync {
30
namespace QSync {
30
31
Lines 74-80 Link Here
74
    /**
75
    /**
75
      Sets the data provided by the plugin.
76
      Sets the data provided by the plugin.
76
     */
77
     */
77
    void setData( const QString &data );
78
    void setData( const QString &data, OSyncObjFormat *format );
78
79
79
    /**
80
    /**
80
      Returns the data provided by the plugin.
81
      Returns the data provided by the plugin.
Lines 94-100 Link Here
94
    /**
95
    /**
95
      Returns the parent member of this change.
96
      Returns the parent member of this change.
96
     */
97
     */
97
    Member member() const;
98
//    Member member() const;
98
99
99
    /**
100
    /**
100
      Sets the change type.
101
      Sets the change type.
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/syncmapping.cpp (-18 / +25 lines)
Lines 20-38 Link Here
20
*/
20
*/
21
21
22
#include <qstring.h>
22
#include <qstring.h>
23
#include <osengine/engine.h>
23
#include <opensync/opensync.h>
24
#include <opensync/opensync-engine.h>
24
25
25
#include "syncmapping.h"
26
#include "syncmapping.h"
26
27
27
using namespace QSync;
28
using namespace QSync;
28
29
29
SyncMapping::SyncMapping()
30
SyncMapping::SyncMapping()
30
  : mEngine( 0 ), mMapping( 0 )
31
  : mEngine( 0 ), mMappingEngine( 0 )
31
{
32
{
32
}
33
}
33
34
34
SyncMapping::SyncMapping( OSyncMapping *mapping, OSyncEngine *engine )
35
SyncMapping::SyncMapping( OSyncMappingEngine *mapping, OSyncEngine *engine )
35
  : mEngine( engine ), mMapping( mapping )
36
  : mEngine( engine ), mMappingEngine( mapping )
36
{
37
{
37
}
38
}
38
39
Lines 42-99 Link Here
42
43
43
bool SyncMapping::isValid() const
44
bool SyncMapping::isValid() const
44
{
45
{
45
  return ( mEngine != 0 && mMapping != 0 );
46
  return ( mEngine != 0 && mMappingEngine != 0 );
46
}
47
}
47
48
49
/*
48
long long SyncMapping::id() const
50
long long SyncMapping::id() const
49
{
51
{
50
  Q_ASSERT( mMapping );
52
  Q_ASSERT( mMappingEngine );
51
53
52
  return osengine_mapping_get_id( mMapping );
54
  return osync_mapping_engine_get_id( mMappingEngine );
53
}
55
}
56
*/
54
57
55
void SyncMapping::duplicate()
58
void SyncMapping::duplicate()
56
{
59
{
57
  Q_ASSERT( mEngine );
60
  Q_ASSERT( mEngine );
58
  Q_ASSERT( mMapping );
61
  Q_ASSERT( mMappingEngine );
62
63
  OSyncError *error = 0;
59
64
60
  osengine_mapping_duplicate( mEngine, mMapping );
65
  osync_mapping_engine_duplicate( mMappingEngine, &error );
61
}
66
}
62
67
63
void SyncMapping::solve( const SyncChange &change )
68
void SyncMapping::solve( const SyncChange &change )
64
{
69
{
65
  Q_ASSERT( mEngine );
70
  Q_ASSERT( mEngine );
66
  Q_ASSERT( mMapping );
71
  Q_ASSERT( mMappingEngine );
67
  Q_ASSERT( change.isValid() );
72
  Q_ASSERT( change.isValid() );
68
73
69
  osengine_mapping_solve( mEngine, mMapping, change.mSyncChange );
74
  OSyncError *error = 0;
75
76
  osync_mapping_engine_solve( mMappingEngine, change.mSyncChange, &error );
70
}
77
}
71
78
72
void SyncMapping::ignore()
79
void SyncMapping::ignore()
73
{
80
{
74
  Q_ASSERT( mEngine );
81
  Q_ASSERT( mEngine );
75
  Q_ASSERT( mMapping );
82
  Q_ASSERT( mMappingEngine );
76
83
77
  //TODO: error should be returned as Result
84
  //TODO: error should be returned as Result
78
  OSyncError *error = 0;
85
  OSyncError *error = 0;
79
  osengine_mapping_ignore_conflict( mEngine, mMapping, &error );
86
  osync_mapping_engine_ignore( mMappingEngine, &error );
80
}
87
}
81
88
82
int SyncMapping::changesCount() const
89
int SyncMapping::changesCount() const
83
{
90
{
84
  Q_ASSERT( mMapping );
91
  Q_ASSERT( mMappingEngine );
85
92
86
  return osengine_mapping_num_changes( mMapping );
93
  return osync_mapping_engine_num_changes( mMappingEngine );
87
}
94
}
88
95
89
SyncChange SyncMapping::changeAt( int pos )
96
SyncChange SyncMapping::changeAt( int pos )
90
{
97
{
91
  Q_ASSERT( mMapping );
98
  Q_ASSERT( mMappingEngine );
92
99
93
  if ( pos < 0 || pos >= osengine_mapping_num_changes( mMapping ) )
100
  if ( pos < 0 || pos >= osync_mapping_engine_num_changes( mMappingEngine ) )
94
    return SyncChange();
101
    return SyncChange();
95
102
96
  OSyncChange *ochange = osengine_mapping_nth_change( mMapping, pos );
103
  OSyncChange *ochange = osync_mapping_engine_nth_change( mMappingEngine, pos );
97
104
98
  return SyncChange( ochange );
105
  return SyncChange( ochange );
99
}
106
}
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/syncmapping.h (-3 / +3 lines)
Lines 25-31 Link Here
25
#include <libqopensync/syncchange.h>
25
#include <libqopensync/syncchange.h>
26
26
27
class OSyncEngine;
27
class OSyncEngine;
28
class OSyncMapping;
28
class OSyncMappingEngine;
29
29
30
namespace QSync {
30
namespace QSync {
31
31
Lines 35-41 Link Here
35
35
36
  public:
36
  public:
37
    SyncMapping();
37
    SyncMapping();
38
    SyncMapping( OSyncMapping*, OSyncEngine* );
38
    SyncMapping( OSyncMappingEngine*, OSyncEngine* );
39
    ~SyncMapping();
39
    ~SyncMapping();
40
40
41
    bool isValid() const;
41
    bool isValid() const;
Lines 51-57 Link Here
51
51
52
  private:
52
  private:
53
    OSyncEngine *mEngine;
53
    OSyncEngine *mEngine;
54
    OSyncMapping *mMapping;
54
    OSyncMappingEngine *mMappingEngine;
55
};
55
};
56
56
57
}
57
}
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/syncupdates.cpp (-54 / +48 lines)
Lines 19-25 Link Here
19
    Boston, MA 02110-1301, USA.
19
    Boston, MA 02110-1301, USA.
20
*/
20
*/
21
21
22
#include <osengine/engine.h>
22
#include <opensync/opensync.h>
23
#include <opensync/opensync-engine.h>
23
24
24
#include "syncupdates.h"
25
#include "syncupdates.h"
25
26
Lines 32-63 Link Here
32
SyncMemberUpdate::SyncMemberUpdate( OSyncMemberUpdate *update )
33
SyncMemberUpdate::SyncMemberUpdate( OSyncMemberUpdate *update )
33
{
34
{
34
  switch ( update->type ) {
35
  switch ( update->type ) {
35
    case MEMBER_CONNECTED:
36
    case OSYNC_CLIENT_EVENT_CONNECTED:
36
      mType = Connected;
37
      mType = Connected;
37
      break;
38
      break;
38
    case MEMBER_SENT_CHANGES:
39
    case OSYNC_CLIENT_EVENT_DISCONNECTED:
39
      mType = SentChanges;
40
      break;
41
    case MEMBER_COMMITTED_ALL:
42
      mType = CommittedAll;
43
      break;
44
    case MEMBER_DISCONNECTED:
45
      mType = Disconnected;
40
      mType = Disconnected;
46
      break;
41
      break;
47
    case MEMBER_CONNECT_ERROR:
42
    case OSYNC_CLIENT_EVENT_READ:
48
      mType = ConnectError;
43
      mType = Read; 
49
      break;
44
      break;
50
    case MEMBER_GET_CHANGES_ERROR:
45
    case OSYNC_CLIENT_EVENT_WRITTEN:
51
      mType = GetChangesError;
46
      mType = Written;
52
      break;
47
      break;
53
    case MEMBER_COMMITTED_ALL_ERROR:
48
    case OSYNC_CLIENT_EVENT_SYNC_DONE:
54
      mType = CommittedAllError;
49
      mType = SyncDone;
55
      break;
50
      break;
56
    case MEMBER_SYNC_DONE_ERROR:
51
    case OSYNC_CLIENT_EVENT_DISCOVERED:
57
      mType = SyncDoneError;
52
      mType = Discovered;
58
      break;
53
      break;
59
    case MEMBER_DISCONNECT_ERROR:
54
    case OSYNC_CLIENT_EVENT_ERROR:
60
      mType = DisconnectedError;
55
      mType = Error;
61
      break;
56
      break;
62
  }
57
  }
63
58
Lines 94-113 Link Here
94
SyncChangeUpdate::SyncChangeUpdate( OSyncChangeUpdate *update )
89
SyncChangeUpdate::SyncChangeUpdate( OSyncChangeUpdate *update )
95
{
90
{
96
  switch ( update->type ) {
91
  switch ( update->type ) {
97
    case CHANGE_RECEIVED:
92
    case OSYNC_CHANGE_EVENT_READ:
98
      mType = Received;
93
      mType = Read;
99
      break;
100
    case CHANGE_RECEIVED_INFO:
101
      mType = ReceivedInfo;
102
      break;
94
      break;
103
    case CHANGE_SENT:
95
    case OSYNC_CHANGE_EVENT_WRITTEN:
104
      mType = Sent;
96
      mType = Written;
105
      break;
97
      break;
106
    case CHANGE_WRITE_ERROR:
98
    case OSYNC_CHANGE_EVENT_ERROR:
107
      mType = WriteError;
99
      mType = Error;
108
      break;
109
    case CHANGE_RECV_ERROR:
110
      mType = ReceiveError;
111
      break;
100
      break;
112
  }
101
  }
113
102
Lines 115-121 Link Here
115
    mResult = Result( &(update->error) );
104
    mResult = Result( &(update->error) );
116
105
117
  mChange = SyncChange( update->change );
106
  mChange = SyncChange( update->change );
118
  mMemberId = update->member_id;
107
  mMember.mMember = update->member;
119
  mMappingId = update->mapping_id;
108
  mMappingId = update->mapping_id;
120
}
109
}
121
110
Lines 138-146 Link Here
138
  return mChange;
127
  return mChange;
139
}
128
}
140
129
141
int SyncChangeUpdate::memberId() const
130
Member SyncChangeUpdate::member() const
142
{
131
{
143
  return mMemberId;
132
  return mMember;
144
}
133
}
145
134
146
int SyncChangeUpdate::mappingId() const
135
int SyncChangeUpdate::mappingId() const
Lines 155-168 Link Here
155
SyncMappingUpdate::SyncMappingUpdate( OSyncMappingUpdate *update, OSyncEngine *engine )
144
SyncMappingUpdate::SyncMappingUpdate( OSyncMappingUpdate *update, OSyncEngine *engine )
156
{
145
{
157
  switch ( update->type ) {
146
  switch ( update->type ) {
158
    case MAPPING_SOLVED:
147
    case OSYNC_MAPPING_EVENT_SOLVED:
159
      mType = Solved;
148
      mType = Solved;
160
      break;
149
      break;
161
    case MAPPING_SYNCED:
150
//    case OSYNC_MAPPING_EVENT_SYNCED:
162
      mType = Synced;
151
  //    mType = Synced;
163
      break;
152
    //  break;
164
    case MAPPING_WRITE_ERROR:
153
    case OSYNC_MAPPING_EVENT_ERROR:
165
      mType = WriteError;
154
      mType = Error;
166
      break;
155
      break;
167
  }
156
  }
168
157
Lines 171-177 Link Here
171
160
172
  mWinner = update->winner;
161
  mWinner = update->winner;
173
  mMapping.mEngine = engine;
162
  mMapping.mEngine = engine;
174
  mMapping.mMapping = update->mapping;
163
164
  // TODO PORTING
165
//  mMapping.mMapping = update->mapping;
175
}
166
}
176
167
177
SyncMappingUpdate::~SyncMappingUpdate()
168
SyncMappingUpdate::~SyncMappingUpdate()
Lines 205-234 Link Here
205
SyncEngineUpdate::SyncEngineUpdate( OSyncEngineUpdate *update )
196
SyncEngineUpdate::SyncEngineUpdate( OSyncEngineUpdate *update )
206
{
197
{
207
  switch ( update->type ) {
198
  switch ( update->type ) {
208
    case ENG_ENDPHASE_CON:
199
    case OSYNC_ENGINE_EVENT_CONNECTED:
209
      mType = EndPhaseConnected;
200
      mType = Connected;
210
      break;
201
      break;
211
    case ENG_ENDPHASE_READ:
202
    case OSYNC_ENGINE_EVENT_READ:
212
      mType = EndPhaseRead;
203
      mType = Read;
213
      break;
204
      break;
214
    case ENG_ENDPHASE_WRITE:
205
    case OSYNC_ENGINE_EVENT_WRITTEN:
215
      mType = EndPhaseWrite;
206
      mType = Written;
216
      break;
207
      break;
217
    case ENG_ENDPHASE_DISCON:
208
    case OSYNC_ENGINE_EVENT_DISCONNECTED: 
218
      mType = EndPhaseDisconnected;
209
      mType = Disconnected;
219
      break;
210
      break;
220
    case ENG_ERROR:
211
    case OSYNC_ENGINE_EVENT_ERROR:
221
      mType = Error;
212
      mType = Error;
222
      break;
213
      break;
223
    case ENG_SYNC_SUCCESSFULL:
214
    case OSYNC_ENGINE_EVENT_SUCCESSFUL:
224
      mType = SyncSuccessfull;
215
      mType = SyncSuccessful;
225
      break;
216
      break;
226
    case ENG_PREV_UNCLEAN:
217
    case OSYNC_ENGINE_EVENT_PREV_UNCLEAN:
227
      mType = PrevUnclean;
218
      mType = PrevUnclean;
228
      break;
219
      break;
229
    case ENG_END_CONFLICTS:
220
    case OSYNC_ENGINE_EVENT_END_CONFLICTS:
230
      mType = EndConflicts;
221
      mType = EndConflicts;
231
      break;
222
      break;
223
    case OSYNC_ENGINE_EVENT_SYNC_DONE:
224
      mType = SyncDone;
225
      break;
232
  }
226
  }
233
227
234
  if ( update->error )
228
  if ( update->error )
(-)work/kitchensync-3.5.8/kitchensync.old/libqopensync/syncupdates.h (-22 / +19 lines)
Lines 42-55 Link Here
42
  public:
42
  public:
43
    enum Type {
43
    enum Type {
44
      Connected,
44
      Connected,
45
      SentChanges,
46
      CommittedAll,
47
      Disconnected,
45
      Disconnected,
48
      ConnectError,
46
      Read,
49
      GetChangesError,
47
      Written,
50
      CommittedAllError,
48
      SyncDone,
51
      SyncDoneError,
49
      Discovered,
52
      DisconnectedError
50
      Error
53
    };
51
    };
54
52
55
    SyncMemberUpdate();
53
    SyncMemberUpdate();
Lines 72-82 Link Here
72
70
73
  public:
71
  public:
74
    enum Type {
72
    enum Type {
75
      Received = 1,
73
      Read = 1,
76
      ReceivedInfo,
74
      Written,
77
      Sent,
75
      Error
78
      WriteError,
79
      ReceiveError
80
    };
76
    };
81
77
82
    SyncChangeUpdate();
78
    SyncChangeUpdate();
Lines 86-99 Link Here
86
    Type type() const;
82
    Type type() const;
87
    Result result() const;
83
    Result result() const;
88
    SyncChange change() const;
84
    SyncChange change() const;
89
    int memberId() const;
85
    Member member() const;
90
    int mappingId() const;
86
    int mappingId() const;
91
87
92
  private:
88
  private:
93
    Type mType;
89
    Type mType;
94
    Result mResult;
90
    Result mResult;
95
    SyncChange mChange;
91
    SyncChange mChange;
96
    int mMemberId;
92
    Member mMember;
97
    int mMappingId;
93
    int mMappingId;
98
};
94
};
99
95
Lines 104-111 Link Here
104
  public:
100
  public:
105
    enum Type {
101
    enum Type {
106
      Solved = 1,
102
      Solved = 1,
107
      Synced,
103
      //Synced,
108
      WriteError
104
      Error
109
    };
105
    };
110
106
111
    SyncMappingUpdate();
107
    SyncMappingUpdate();
Lines 130-143 Link Here
130
126
131
  public:
127
  public:
132
    enum Type {
128
    enum Type {
133
      EndPhaseConnected = 1,
129
      Connected = 1,
134
      EndPhaseRead,
130
      Read,
135
      EndPhaseWrite,
131
      Written,
136
      EndPhaseDisconnected,
132
      Disconnected,
137
      Error,
133
      Error,
138
      SyncSuccessfull,
134
      SyncSuccessful,
139
      PrevUnclean,
135
      PrevUnclean,
140
      EndConflicts
136
      EndConflicts,
137
      SyncDone
141
    };
138
    };
142
139
143
    SyncEngineUpdate();
140
    SyncEngineUpdate();
(-)work/kitchensync-3.5.8/kitchensync.old/src/configguifile.cpp (-14 / +26 lines)
Lines 55-67 Link Here
55
  QDomDocument doc;
55
  QDomDocument doc;
56
  doc.setContent( xml );
56
  doc.setContent( xml );
57
  QDomElement docElement = doc.documentElement();
57
  QDomElement docElement = doc.documentElement();
58
  QDomNode n;
58
59
  for( n = docElement.firstChild(); !n.isNull(); n = n.nextSibling() ) {
59
  QDomNode node;
60
    QDomElement e = n.toElement();
60
  for ( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
61
    if ( e.tagName() == "path" ) {
61
    QDomElement e = node.toElement();
62
      mFilename->setURL( e.text() );
62
    if ( e.tagName() == "directory" ) {
63
    } else if ( e.tagName() == "recursive" ) {
63
      QDomNode subNode;
64
      mRecursive->setChecked( e.text() == "TRUE" );
64
      for ( subNode = e.firstChild(); !subNode.isNull(); subNode = subNode.nextSibling() ) {
65
        QDomElement subElement = subNode.toElement();
66
        if ( subElement.tagName() == "path" ) {
67
          mFilename->setURL( subElement.text() );
68
        } else if ( subElement.tagName() == "recursive" ) {
69
          mRecursive->setChecked( subElement.text() == "TRUE" );
70
        }
71
      }
65
    }
72
    }
66
  }
73
  }
67
}
74
}
Lines 69-81 Link Here
69
QString ConfigGuiFile::save() const
76
QString ConfigGuiFile::save() const
70
{
77
{
71
  QString xml;
78
  QString xml;
72
  xml = "<config>";
79
  xml = "<config>\n";
73
  xml += "<path>" + mFilename->url() + "</path>";
80
  xml += "  <directory>\n";
74
  xml += "<recursive>";
81
  xml += "    <path>" + mFilename->url() + "</path>\n";
75
  if ( mRecursive->isChecked() ) xml += "TRUE";
82
  xml += "    <objtype>data</objtype>\n";
76
  else xml += "FALSE";
83
  xml += "    <recursive>";
77
  xml += "</recursive>";
84
  if ( mRecursive->isChecked() )
78
  xml += "</config>";
85
    xml += "TRUE";
86
  else
87
    xml += "FALSE";
88
  xml += "</recursive>\n";
89
  xml += "  </directory>\n";
90
  xml += "</config>\n";
79
91
80
  return xml;
92
  return xml;
81
}
93
}
(-)work/kitchensync-3.5.8/kitchensync.old/src/configguisyncmlhttp.cpp (-2 / +2 lines)
Lines 121-127 Link Here
121
  mGridLayout->addWidget( label, 5, 0 );
121
  mGridLayout->addWidget( label, 5, 0 );
122
122
123
  mRecvLimit = new QSpinBox( optionWidget );
123
  mRecvLimit = new QSpinBox( optionWidget );
124
  mRecvLimit->setMinValue( 1 );
124
  mRecvLimit->setMinValue( 0 );
125
  mRecvLimit->setMaxValue( 65536 );
125
  mRecvLimit->setMaxValue( 65536 );
126
  mGridLayout->addWidget( mRecvLimit, 5, 1 );
126
  mGridLayout->addWidget( mRecvLimit, 5, 1 );
127
127
Lines 130-136 Link Here
130
  mGridLayout->addWidget( label, 6, 0 );
130
  mGridLayout->addWidget( label, 6, 0 );
131
131
132
  mMaxObjSize = new QSpinBox( optionWidget );
132
  mMaxObjSize = new QSpinBox( optionWidget );
133
  mMaxObjSize->setMinValue( 1 );
133
  mMaxObjSize->setMinValue( 0 );
134
  mMaxObjSize->setMaxValue( 65536 );
134
  mMaxObjSize->setMaxValue( 65536 );
135
  mGridLayout->addWidget( mMaxObjSize, 6, 1 );
135
  mGridLayout->addWidget( mMaxObjSize, 6, 1 );
136
136
(-)work/kitchensync-3.5.8/kitchensync.old/src/configguisyncmlobex.cpp (-2 / +2 lines)
Lines 153-159 Link Here
153
  mGridLayout->addWidget( label, 14, 0 );
153
  mGridLayout->addWidget( label, 14, 0 );
154
154
155
  mRecvLimit = new QSpinBox( optionsWidget );
155
  mRecvLimit = new QSpinBox( optionsWidget );
156
  mRecvLimit->setMinValue( 1 );
156
  mRecvLimit->setMinValue( 0 );
157
  mRecvLimit->setMaxValue( 65536 );
157
  mRecvLimit->setMaxValue( 65536 );
158
  mGridLayout->addWidget( mRecvLimit, 14, 1 );
158
  mGridLayout->addWidget( mRecvLimit, 14, 1 );
159
159
Lines 162-168 Link Here
162
  mGridLayout->addWidget( label, 15, 0 );
162
  mGridLayout->addWidget( label, 15, 0 );
163
163
164
  mMaxObjSize = new QSpinBox( optionsWidget );
164
  mMaxObjSize = new QSpinBox( optionsWidget );
165
  mMaxObjSize->setMinValue( 1 );
165
  mMaxObjSize->setMinValue( 0 );
166
  mMaxObjSize->setMaxValue( 65536 );
166
  mMaxObjSize->setMaxValue( 65536 );
167
  mGridLayout->addWidget( mMaxObjSize, 15, 1 );
167
  mGridLayout->addWidget( mMaxObjSize, 15, 1 );
168
168
(-)work/kitchensync-3.5.8/kitchensync.old/src/groupconfigcommon.cpp (-7 / +14 lines)
Lines 30-43 Link Here
30
#include <qcheckbox.h>
30
#include <qcheckbox.h>
31
31
32
#include <libqopensync/group.h>
32
#include <libqopensync/group.h>
33
#include <libqopensync/conversion.h>
33
//#include <libqopensync/conversion.h>
34
#include <libqopensync/environment.h>
35
34
36
#include "syncprocess.h"
35
#include "syncprocess.h"
37
#include "syncprocessmanager.h"
36
#include "syncprocessmanager.h"
38
37
39
#include "groupconfigcommon.h"
38
#include "groupconfigcommon.h"
40
39
40
// TODO: port ObjectTypeSelector to ported solution of Conversation class
41
#if 0
41
ObjectTypeSelector::ObjectTypeSelector( QWidget *parent )
42
ObjectTypeSelector::ObjectTypeSelector( QWidget *parent )
42
  : QWidget( parent )
43
  : QWidget( parent )
43
{
44
{
Lines 124-129 Link Here
124
  QSync::GroupConfig config = group.config();
125
  QSync::GroupConfig config = group.config();
125
  config.setActiveObjectTypes( objectTypes );
126
  config.setActiveObjectTypes( objectTypes );
126
}
127
}
128
#endif
127
129
128
GroupConfigCommon::GroupConfigCommon( QWidget *parent )
130
GroupConfigCommon::GroupConfigCommon( QWidget *parent )
129
  : QWidget( parent )
131
  : QWidget( parent )
Lines 135-144 Link Here
135
  mGroupName = new KLineEdit( this );
137
  mGroupName = new KLineEdit( this );
136
  layout->addWidget( mGroupName, 0, 1 );
138
  layout->addWidget( mGroupName, 0, 1 );
137
139
138
  layout->addWidget( new QLabel( i18n( "Object Types to be Synchronized:"), this ), 1, 0, Qt::AlignTop );
140
  //layout->addWidget( new QLabel( i18n( "Object Types to be Synchronized:"), this ), 1, 0, Qt::AlignTop );
139
141
140
  mObjectTypeSelector = new ObjectTypeSelector( this );
142
  // TODO port ObjectTypeSelector class..
141
  layout->addWidget( mObjectTypeSelector, 1, 1 );
143
  //mObjectTypeSelector = new ObjectTypeSelector( this );
144
  //layout->addWidget( mObjectTypeSelector, 1, 1 );
142
145
143
  layout->setRowStretch( 2, 1 );
146
  layout->setRowStretch( 2, 1 );
144
}
147
}
Lines 148-158 Link Here
148
  mSyncProcess = syncProcess;
151
  mSyncProcess = syncProcess;
149
152
150
  mGroupName->setText( mSyncProcess->group().name() );
153
  mGroupName->setText( mSyncProcess->group().name() );
151
  mObjectTypeSelector->load( mSyncProcess->group() );
154
155
  // TODO port ObjectTypeSelector class..
156
  //mObjectTypeSelector->load( mSyncProcess->group() );
152
}
157
}
153
158
154
void GroupConfigCommon::save()
159
void GroupConfigCommon::save()
155
{
160
{
156
  mSyncProcess->group().setName( mGroupName->text() );
161
  mSyncProcess->group().setName( mGroupName->text() );
157
  mObjectTypeSelector->save( mSyncProcess->group() );
162
163
  // TODO port ObjectTypeSelector class..
164
  //mObjectTypeSelector->save( mSyncProcess->group() );
158
}
165
}
(-)work/kitchensync-3.5.8/kitchensync.old/src/groupconfigcommon.h (-1 / +4 lines)
Lines 30-35 Link Here
30
class SyncProcess;
30
class SyncProcess;
31
class QCheckBox;
31
class QCheckBox;
32
32
33
//TODO: Conversation needs to be ported before...
34
#if 0
33
class ObjectTypeSelector : public QWidget
35
class ObjectTypeSelector : public QWidget
34
{
36
{
35
  public:
37
  public:
Lines 41-46 Link Here
41
  private:
43
  private:
42
    QMap<QString,QCheckBox *> mObjectTypeChecks;
44
    QMap<QString,QCheckBox *> mObjectTypeChecks;
43
};
45
};
46
#endif
44
47
45
class GroupConfigCommon : public QWidget
48
class GroupConfigCommon : public QWidget
46
{
49
{
Lines 52-58 Link Here
52
55
53
  private:
56
  private:
54
    KLineEdit *mGroupName;
57
    KLineEdit *mGroupName;
55
    ObjectTypeSelector *mObjectTypeSelector;
58
  //  ObjectTypeSelector *mObjectTypeSelector;
56
59
57
    SyncProcess *mSyncProcess;
60
    SyncProcess *mSyncProcess;
58
};
61
};
(-)work/kitchensync-3.5.8/kitchensync.old/src/groupconfig.cpp (-17 / +41 lines)
Lines 27-34 Link Here
27
#include "syncprocess.h"
27
#include "syncprocess.h"
28
#include "syncprocessmanager.h"
28
#include "syncprocessmanager.h"
29
29
30
#include <libqopensync/engine.h>
30
#include <libqopensync/group.h>
31
#include <libqopensync/group.h>
31
#include <libqopensync/plugin.h>
32
#include <libqopensync/plugin.h>
33
#include <libqopensync/result.h>
32
34
33
#include <kdialog.h>
35
#include <kdialog.h>
34
#include <kiconloader.h>
36
#include <kiconloader.h>
Lines 40-45 Link Here
40
#include <qlabel.h>
42
#include <qlabel.h>
41
#include <qlayout.h>
43
#include <qlayout.h>
42
#include <qpushbutton.h>
44
#include <qpushbutton.h>
45
#include <qtimer.h>
43
46
44
GroupConfig::GroupConfig( QWidget *parent )
47
GroupConfig::GroupConfig( QWidget *parent )
45
  : QWidget( parent )
48
  : QWidget( parent )
Lines 84-97 Link Here
84
  mMemberView = new KJanusWidget( this, 0, KJanusWidget::IconList );
87
  mMemberView = new KJanusWidget( this, 0, KJanusWidget::IconList );
85
  topLayout->addWidget( mMemberView );
88
  topLayout->addWidget( mMemberView );
86
89
87
  QBoxLayout *buttonLayout = new QHBoxLayout( topLayout );
88
89
  QPushButton *addButton = new QPushButton( i18n("Add Member..."), this );
90
  connect( addButton, SIGNAL( clicked() ), SLOT( addMember() ) );
91
  buttonLayout->addWidget( addButton );
92
93
  buttonLayout->addStretch( 1 );
94
95
  icon = KGlobal::iconLoader()->loadIcon( "bookmark", KIcon::Desktop );
90
  icon = KGlobal::iconLoader()->loadIcon( "bookmark", KIcon::Desktop );
96
  QFrame *page = mMemberView->addPage( i18n("Group"),
91
  QFrame *page = mMemberView->addPage( i18n("Group"),
97
    i18n("General Group Settings"), icon );
92
    i18n("General Group Settings"), icon );
Lines 99-104 Link Here
99
94
100
  mCommonConfig = new GroupConfigCommon( page );
95
  mCommonConfig = new GroupConfigCommon( page );
101
  pageLayout->addWidget( mCommonConfig );
96
  pageLayout->addWidget( mCommonConfig );
97
98
  connect( mMemberView, SIGNAL( aboutToShowPage( QWidget* ) ), SLOT( memberWidgetSelected( QWidget* ) ) );
102
}
99
}
103
100
104
void GroupConfig::setSyncProcess( SyncProcess *process )
101
void GroupConfig::setSyncProcess( SyncProcess *process )
Lines 113-121 Link Here
113
110
114
void GroupConfig::updateMembers()
111
void GroupConfig::updateMembers()
115
{
112
{
116
  QValueList<MemberConfig *>::ConstIterator memberIt;
113
  QMap<QWidget*, MemberConfig *>::ConstIterator memberIt;
117
  for ( memberIt = mMemberConfigs.begin(); memberIt != mMemberConfigs.end(); ++memberIt )
114
  for ( memberIt = mMemberConfigs.begin(); memberIt != mMemberConfigs.end(); ++memberIt )
118
    (*memberIt)->saveData();
115
    memberIt.data()->saveData();
119
116
120
  QValueList<QFrame *>::ConstIterator it2;
117
  QValueList<QFrame *>::ConstIterator it2;
121
  for ( it2 = mConfigPages.begin(); it2 != mConfigPages.end(); ++it2 ) {
118
  for ( it2 = mConfigPages.begin(); it2 != mConfigPages.end(); ++it2 ) {
Lines 125-134 Link Here
125
  mConfigPages.clear();
122
  mConfigPages.clear();
126
  mMemberConfigs.clear();
123
  mMemberConfigs.clear();
127
124
128
  QSync::Group group = mProcess->group();
125
  const QSync::Group group = mProcess->group();
129
  QSync::Group::Iterator it( group.begin() );
126
  for ( int i = 0; i < group.memberCount(); ++i ) {
130
  for ( ; it != group.end(); ++it ) {
127
    QSync::Member member = group.memberAt( i );
131
    QSync::Member member = *it;
132
    MemberInfo mi( member );
128
    MemberInfo mi( member );
133
    QFrame *page = mMemberView->addPage( mi.name(), 
129
    QFrame *page = mMemberView->addPage( mi.name(), 
134
      QString( "%1 (%2)" ).arg( mi.name() ).arg(member.pluginName()), mi.desktopIcon() );
130
      QString( "%1 (%2)" ).arg( mi.name() ).arg(member.pluginName()), mi.desktopIcon() );
Lines 137-143 Link Here
137
    mConfigPages.append( page );
133
    mConfigPages.append( page );
138
134
139
    MemberConfig *memberConfig = new MemberConfig( page, member );
135
    MemberConfig *memberConfig = new MemberConfig( page, member );
140
    mMemberConfigs.append( memberConfig );
136
    mMemberConfigs.insert( page, memberConfig );
141
    pageLayout->addWidget( memberConfig );
137
    pageLayout->addWidget( memberConfig );
142
138
143
    memberConfig->loadData();
139
    memberConfig->loadData();
Lines 148-162 Link Here
148
{
144
{
149
  mProcess->group().save();
145
  mProcess->group().save();
150
146
151
  QValueList<MemberConfig *>::ConstIterator it;
147
  QMap<QWidget*, MemberConfig*>::ConstIterator it;
152
  for ( it = mMemberConfigs.begin(); it != mMemberConfigs.end(); ++it )
148
  for ( it = mMemberConfigs.begin(); it != mMemberConfigs.end(); ++it )
153
    (*it)->saveData();
149
    it.data()->saveData();
154
150
155
  mCommonConfig->save();
151
  mCommonConfig->save();
156
152
153
  const QSync::Group group = mProcess->group();
154
  for ( int i = 0; i < group.memberCount(); ++i ) {
155
    const QSync::Member member = group.memberAt( i );
156
    mProcess->engine()->discover( member );
157
  }
158
157
  mProcess->reinitEngine();
159
  mProcess->reinitEngine();
158
}
160
}
159
161
162
void GroupConfig::memberWidgetSelected( QWidget *wdg )
163
{
164
  /**
165
   * Emit 'true' whenever a real member widget is selected by the
166
   * user.
167
   */
168
  emit memberSelected( wdg != mCommonConfig->parentWidget() );
169
}
170
160
void GroupConfig::addMember()
171
void GroupConfig::addMember()
161
{
172
{
162
  QSync::Plugin plugin = PluginPickerDialog::getPlugin( this );
173
  QSync::Plugin plugin = PluginPickerDialog::getPlugin( this );
Lines 176-179 Link Here
176
  }
187
  }
177
}
188
}
178
189
190
void GroupConfig::removeMember()
191
{
192
  QWidget *selectedWidget = mMemberView->pageWidget( mMemberView->activePageIndex() );
193
  if ( selectedWidget && mMemberConfigs.contains( selectedWidget ) ) {
194
    MemberConfig *config = mMemberConfigs[ selectedWidget ];
195
196
    SyncProcessManager::self()->removeMember( mProcess, config->member() );
197
    mMemberConfigs.remove( selectedWidget );
198
199
    QTimer::singleShot( 0, this, SLOT( updateMembers() ) );
200
  }
201
}
202
179
#include "groupconfig.moc"
203
#include "groupconfig.moc"
(-)work/kitchensync-3.5.8/kitchensync.old/src/groupconfigdialog.cpp (-1 / +23 lines)
Lines 28-34 Link Here
28
28
29
GroupConfigDialog::GroupConfigDialog( QWidget *parent, SyncProcess *process )
29
GroupConfigDialog::GroupConfigDialog( QWidget *parent, SyncProcess *process )
30
  : KDialogBase( parent, 0, true, i18n("Configure Synchronization Group"),
30
  : KDialogBase( parent, 0, true, i18n("Configure Synchronization Group"),
31
     Ok )
31
     Ok | User1 | User2, Ok )
32
{
32
{
33
  QFrame *topFrame = makeMainWidget();
33
  QFrame *topFrame = makeMainWidget();
34
34
Lines 40-45 Link Here
40
  mConfigWidget->setSyncProcess( process );
40
  mConfigWidget->setSyncProcess( process );
41
41
42
  setInitialSize( configDialogSize( "size_groupconfigdialog" ) );
42
  setInitialSize( configDialogSize( "size_groupconfigdialog" ) );
43
44
  enableButton( User1, false );
45
  setButtonText( User1, i18n( "Remove Member" ) );
46
47
  connect( mConfigWidget, SIGNAL( memberSelected( bool ) ), SLOT( memberSelected( bool ) ) );
48
49
  setButtonText( User2, i18n("Add Member...") );
43
}
50
}
44
51
45
GroupConfigDialog::~GroupConfigDialog()
52
GroupConfigDialog::~GroupConfigDialog()
Lines 54-57 Link Here
54
  accept();
61
  accept();
55
}
62
}
56
63
64
void GroupConfigDialog::slotUser1()
65
{
66
  mConfigWidget->removeMember();
67
}
68
69
void GroupConfigDialog::slotUser2()
70
{
71
  mConfigWidget->addMember();
72
}
73
74
void GroupConfigDialog::memberSelected( bool selected )
75
{
76
  enableButton( User1, selected );
77
}
78
57
#include "groupconfigdialog.moc"
79
#include "groupconfigdialog.moc"
(-)work/kitchensync-3.5.8/kitchensync.old/src/groupconfigdialog.h (+5 lines)
Lines 35-40 Link Here
35
35
36
  protected slots:
36
  protected slots:
37
    void slotOk();
37
    void slotOk();
38
    void slotUser1();
39
    void slotUser2();
40
41
  private slots:
42
    void memberSelected( bool );
38
43
39
  private:
44
  private:
40
    GroupConfig *mConfigWidget;
45
    GroupConfig *mConfigWidget;
(-)work/kitchensync-3.5.8/kitchensync.old/src/groupconfig.h (-4 / +11 lines)
Lines 40-51 Link Here
40
40
41
    void setSyncProcess( SyncProcess *process );
41
    void setSyncProcess( SyncProcess *process );
42
42
43
    void saveConfig();
44
45
  public slots:
46
    void addMember();
47
    void removeMember();
48
43
    void updateMembers();
49
    void updateMembers();
44
50
45
    void saveConfig();
51
  signals:
52
    void memberSelected( bool );
46
53
47
  protected slots:
54
  protected slots:
48
    void addMember();
55
    void memberWidgetSelected( QWidget* );
49
56
50
  private:
57
  private:
51
    QLabel *mNameLabel;
58
    QLabel *mNameLabel;
Lines 55-62 Link Here
55
    SyncProcess *mProcess;
62
    SyncProcess *mProcess;
56
63
57
    GroupConfigCommon *mCommonConfig;
64
    GroupConfigCommon *mCommonConfig;
58
    QValueList<MemberConfig *> mMemberConfigs;
65
    QMap<QWidget*, MemberConfig*> mMemberConfigs;
59
    QValueList<QFrame *> mConfigPages;
66
    QValueList<QFrame*> mConfigPages;
60
};
67
};
61
68
62
#endif
69
#endif
(-)work/kitchensync-3.5.8/kitchensync.old/src/groupitem.cpp (-40 / +31 lines)
Lines 33-38 Link Here
33
#include <qprogressbar.h>
33
#include <qprogressbar.h>
34
#include <qvbox.h>
34
#include <qvbox.h>
35
35
36
#include <libqopensync/plugin.h>
37
#include <libqopensync/pluginenv.h>
38
36
#include "memberinfo.h"
39
#include "memberinfo.h"
37
#include "multiconflictdialog.h"
40
#include "multiconflictdialog.h"
38
#include "singleconflictdialog.h"
41
#include "singleconflictdialog.h"
Lines 150-161 Link Here
150
  mProgressBar->reset();
153
  mProgressBar->reset();
151
  mProgressBar->hide();
154
  mProgressBar->hide();
152
155
153
  QSync::Group group = mSyncProcess->group();
156
  const QSync::Group group = mSyncProcess->group();
154
  QSync::Group::Iterator memberIt( group.begin() );
157
  for ( int i = 0; i < group.memberCount(); ++i ) {
155
  QSync::Group::Iterator memberEndIt( group.end() );
158
    MemberItem *item = new MemberItem( mBox, mSyncProcess, group.memberAt( i ) );
156
157
  for ( ; memberIt != memberEndIt; ++memberIt ) {
158
    MemberItem *item = new MemberItem( mBox, mSyncProcess, *memberIt );
159
    item->show();
159
    item->show();
160
    item->setStatusMessage( i18n( "Ready" ) );
160
    item->setStatusMessage( i18n( "Ready" ) );
161
    mMemberItems.append( item );
161
    mMemberItems.append( item );
Lines 187-200 Link Here
187
void GroupItem::change( const QSync::SyncChangeUpdate &update )
187
void GroupItem::change( const QSync::SyncChangeUpdate &update )
188
{
188
{
189
  switch ( update.type() ) {
189
  switch ( update.type() ) {
190
    case QSync::SyncChangeUpdate::Received:
190
    case QSync::SyncChangeUpdate::Read:
191
      mProcessedItems++;
191
      mProcessedItems++;
192
      mStatus->setText( i18n( "%1 entries read" ).arg( mProcessedItems ) );
192
      mStatus->setText( i18n( "%1 entries read" ).arg( mProcessedItems ) );
193
      break;
193
      break;
194
    case QSync::SyncChangeUpdate::ReceivedInfo:
194
    case QSync::SyncChangeUpdate::Written:
195
      mStatus->setText( i18n( "Receive information" ) );
196
      break;
197
    case QSync::SyncChangeUpdate::Sent:
198
      mProcessedItems--;
195
      mProcessedItems--;
199
      mStatus->setText( i18n( "%1 entries written" ).arg( mMaxProcessedItems - mProcessedItems ) );
196
      mStatus->setText( i18n( "%1 entries written" ).arg( mMaxProcessedItems - mProcessedItems ) );
200
197
Lines 211-221 Link Here
211
        mProgressBar->setProgress( 100 - progress );
208
        mProgressBar->setProgress( 100 - progress );
212
      }
209
      }
213
      break;
210
      break;
214
    case QSync::SyncChangeUpdate::WriteError:
211
    case QSync::SyncChangeUpdate::Error:
215
      mStatus->setText( i18n( "Error" ) );
216
      KPassivePopup::message( update.result().message(), this );
217
      break;
218
    case QSync::SyncChangeUpdate::ReceiveError:
219
      mStatus->setText( i18n( "Error" ) );
212
      mStatus->setText( i18n( "Error" ) );
220
      KPassivePopup::message( update.result().message(), this );
213
      KPassivePopup::message( update.result().message(), this );
221
      break;
214
      break;
Lines 232-252 Link Here
232
void GroupItem::engine( const QSync::SyncEngineUpdate &update )
225
void GroupItem::engine( const QSync::SyncEngineUpdate &update )
233
{
226
{
234
  switch ( update.type() ) {
227
  switch ( update.type() ) {
235
    case QSync::SyncEngineUpdate::EndPhaseConnected:
228
    case QSync::SyncEngineUpdate::Connected:
236
      mStatus->setText( i18n( "Connected" ) );
229
      mStatus->setText( i18n( "Connected" ) );
237
      mProgressBar->setProgress( 0 );
230
      mProgressBar->setProgress( 0 );
238
      mSynchronizing = true;
231
      mSynchronizing = true;
239
      mSyncAction->setText( "Abort Synchronization" );
232
      mSyncAction->setText( "Abort Synchronization" );
240
      break;
233
      break;
241
    case QSync::SyncEngineUpdate::EndPhaseRead:
234
    case QSync::SyncEngineUpdate::Read:
242
      mStatus->setText( i18n( "Data read" ) );
235
      mStatus->setText( i18n( "Data read" ) );
243
      break;
236
      break;
244
    case QSync::SyncEngineUpdate::EndPhaseWrite:
237
    case QSync::SyncEngineUpdate::Written:
245
      mStatus->setText( i18n( "Data written" ) );
238
      mStatus->setText( i18n( "Data written" ) );
246
      mProgressBar->setProgress( 100 );
239
      mProgressBar->setProgress( 100 );
247
      mProcessedItems = mMaxProcessedItems = 0;
240
      mProcessedItems = mMaxProcessedItems = 0;
248
      break;
241
      break;
249
    case QSync::SyncEngineUpdate::EndPhaseDisconnected:
242
    case QSync::SyncEngineUpdate::Disconnected:
250
      mStatus->setText( i18n( "Disconnected" ) );
243
      mStatus->setText( i18n( "Disconnected" ) );
251
      break;
244
      break;
252
    case QSync::SyncEngineUpdate::Error:
245
    case QSync::SyncEngineUpdate::Error:
Lines 257-263 Link Here
257
      mSynchronizing = false;
250
      mSynchronizing = false;
258
      mSyncAction->setText( i18n( "Synchronize Now" ) );
251
      mSyncAction->setText( i18n( "Synchronize Now" ) );
259
      break;
252
      break;
260
    case QSync::SyncEngineUpdate::SyncSuccessfull:
253
    case QSync::SyncEngineUpdate::SyncSuccessful:
261
      mStatus->setText( i18n( "Successfully synchronized" ) );
254
      mStatus->setText( i18n( "Successfully synchronized" ) );
262
      mSyncProcess->group().setLastSynchronization( QDateTime::currentDateTime() );
255
      mSyncProcess->group().setLastSynchronization( QDateTime::currentDateTime() );
263
      mSyncProcess->group().save();
256
      mSyncProcess->group().save();
Lines 288-315 Link Here
288
        case QSync::SyncMemberUpdate::Connected:
281
        case QSync::SyncMemberUpdate::Connected:
289
          (*it)->setStatusMessage( i18n( "Connected" ) );
282
          (*it)->setStatusMessage( i18n( "Connected" ) );
290
          break;
283
          break;
291
        case QSync::SyncMemberUpdate::SentChanges:
284
        case QSync::SyncMemberUpdate::Read:
292
          (*it)->setStatusMessage( i18n( "Changes read" ) );
285
          (*it)->setStatusMessage( i18n( "Changes read" ) );
293
          break;
286
          break;
294
        case QSync::SyncMemberUpdate::CommittedAll:
287
        case QSync::SyncMemberUpdate::Written:
295
          (*it)->setStatusMessage( i18n( "Changes written" ) );
288
          (*it)->setStatusMessage( i18n( "Changes written" ) );
296
          break;
289
          break;
297
        case QSync::SyncMemberUpdate::Disconnected:
290
        case QSync::SyncMemberUpdate::Disconnected:
298
          (*it)->setStatusMessage( i18n( "Disconnected" ) );
291
          (*it)->setStatusMessage( i18n( "Disconnected" ) );
299
          break;
292
          break;
300
        case QSync::SyncMemberUpdate::ConnectError:
293
        case QSync::SyncMemberUpdate::SyncDone:
301
          (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
294
          (*it)->setStatusMessage( i18n( "Synchronization done" ) );
302
          break;
295
          break;
303
        case QSync::SyncMemberUpdate::GetChangesError:
296
        case QSync::SyncMemberUpdate::Discovered:
304
          (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
297
          (*it)->setStatusMessage( i18n( "Discovered" ) );
305
          break;
298
          break;
306
        case QSync::SyncMemberUpdate::CommittedAllError:
299
        case QSync::SyncMemberUpdate::Error:
307
          (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
308
          break;
309
        case QSync::SyncMemberUpdate::SyncDoneError:
310
          (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
311
          break;
312
        case QSync::SyncMemberUpdate::DisconnectedError:
313
          (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
300
          (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
314
          break;
301
          break;
315
        default:
302
        default:
Lines 352-362 Link Here
352
  QFont boldFont;
339
  QFont boldFont;
353
  boldFont.setBold( true );
340
  boldFont.setBold( true );
354
341
355
  MemberInfo mi( member );
342
  const MemberInfo mi( member );
356
343
  const QPixmap icon = mi.smallIcon();
357
  QPixmap icon = mi.smallIcon();
358
359
  QSync::Plugin plugin = member.plugin();
360
344
361
  QVBoxLayout *layout = new QVBoxLayout( this );
345
  QVBoxLayout *layout = new QVBoxLayout( this );
362
346
Lines 378-384 Link Here
378
  mStatus = new QLabel( box );
362
  mStatus = new QLabel( box );
379
363
380
  mMemberName->setText( member.name() );
364
  mMemberName->setText( member.name() );
381
  mDescription->setText( plugin.longName() );
365
366
  const QSync::PluginEnv *env = SyncProcessManager::self()->pluginEnv();
367
  const QSync::Plugin plugin = env->pluginByName( member.pluginName() );
368
369
  if ( plugin.isValid() )
370
    mDescription->setText( plugin.longName() );
371
  else
372
    mDescription->setText( i18n("Plugin \"%1\" can't get initialized!").arg( member.pluginName() ) );
382
}
373
}
383
374
384
void MemberItem::setStatusMessage( const QString &msg )
375
void MemberItem::setStatusMessage( const QString &msg )
(-)work/kitchensync-3.5.8/kitchensync.old/src/kitchensync.desktop (+1 lines)
Lines 2-7 Link Here
2
Encoding=UTF-8
2
Encoding=UTF-8
3
Name=KitchenSync
3
Name=KitchenSync
4
Name[pt]=KitchenSyncFilter
4
Name[pt]=KitchenSyncFilter
5
Name[pt_BR]=KitchenSyncFilter
5
Name[sv]=Kitchensync
6
Name[sv]=Kitchensync
6
GenericName=Synchronization
7
GenericName=Synchronization
7
GenericName[af]=Sinkronisasie
8
GenericName[af]=Sinkronisasie
(-)work/kitchensync-3.5.8/kitchensync.old/src/mainwidget.cpp (-10 / +10 lines)
Lines 26-32 Link Here
26
#include "syncprocess.h"
26
#include "syncprocess.h"
27
#include "syncprocessmanager.h"
27
#include "syncprocessmanager.h"
28
28
29
#include <libqopensync/environment.h>
29
#include <libqopensync/result.h>
30
30
31
#include <kaboutdata.h>
31
#include <kaboutdata.h>
32
#include <kaction.h>
32
#include <kaction.h>
Lines 46-58 Link Here
46
  initGUI();
46
  initGUI();
47
  initActions();
47
  initActions();
48
48
49
  /** apply object type filter hack **/
50
  int count = SyncProcessManager::self()->count();
51
  for ( int i = 0; i < count; ++i ) {
52
    SyncProcessManager::self()->at( i )->applyObjectTypeFilter();
53
  }
54
  /** apply object type filter hack **/
55
56
  mGroupView->updateView();
49
  mGroupView->updateView();
57
50
58
  connect( SyncProcessManager::self(), SIGNAL( changed() ),
51
  connect( SyncProcessManager::self(), SIGNAL( changed() ),
Lines 125-136 Link Here
125
{
118
{
126
  bool ok;
119
  bool ok;
127
  QString name = KInputDialog::getText( i18n("Create Synchronization Group"),
120
  QString name = KInputDialog::getText( i18n("Create Synchronization Group"),
128
    i18n("Name for new synchronization group."), QString::null, &ok, this );
121
    i18n("Name for new synchronization group."), i18n( "Default" ), &ok, this );
129
  if ( ok ) {
122
  if ( ok ) {
123
    SyncProcess *process = SyncProcessManager::self()->byGroupName( name );
124
    if ( process ) {
125
      KMessageBox::error( this, i18n( "A group with the same name exists already.\nPlease choose another name." ),
126
                          i18n( "Duplicated Group Name" ) );
127
      return;
128
    }
129
130
    SyncProcessManager::self()->addGroup( name );
130
    SyncProcessManager::self()->addGroup( name );
131
    enableActions();
131
    enableActions();
132
132
133
    SyncProcess *process = SyncProcessManager::self()->byGroupName( name );
133
    process = SyncProcessManager::self()->byGroupName( name );
134
    if ( process )
134
    if ( process )
135
      editGroup( process );
135
      editGroup( process );
136
  }
136
  }
(-)work/kitchensync-3.5.8/kitchensync.old/src/Makefile.am (-1 / +1 lines)
Lines 24-30 Link Here
24
                            pluginpicker.cpp configgui.cpp configguiblank.cpp configguifile.cpp \
24
                            pluginpicker.cpp configgui.cpp configguiblank.cpp configguifile.cpp \
25
                            memberinfo.cpp groupconfigcommon.cpp kwidgetlist.cpp \
25
                            memberinfo.cpp groupconfigcommon.cpp kwidgetlist.cpp \
26
                            configguipalm.cpp conflictdialog.cpp singleconflictdialog.cpp \
26
                            configguipalm.cpp conflictdialog.cpp singleconflictdialog.cpp \
27
                            addresseediffalgo.cpp calendardiffalgo.cpp \
27
                            addresseediffalgo.cpp calendardiffalgo.cpp xmldiffalgo.cpp \
28
                            htmldiffalgodisplay.cpp genericdiffalgo.cpp multiconflictdialog.cpp \
28
                            htmldiffalgodisplay.cpp genericdiffalgo.cpp multiconflictdialog.cpp \
29
                            configguiirmc.cpp \
29
                            configguiirmc.cpp \
30
                            configguisyncmlobex.cpp configguisyncmlhttp.cpp configguiopie.cpp  \
30
                            configguisyncmlobex.cpp configguisyncmlhttp.cpp configguiopie.cpp  \
(-)work/kitchensync-3.5.8/kitchensync.old/src/memberconfig.cpp (-3 / +8 lines)
Lines 23-28 Link Here
23
#include "configgui.h"
23
#include "configgui.h"
24
#include "memberinfo.h"
24
#include "memberinfo.h"
25
25
26
#include <libqopensync/result.h>
27
26
#include <klocale.h>
28
#include <klocale.h>
27
#include <kmessagebox.h>
29
#include <kmessagebox.h>
28
30
Lines 67-79 Link Here
67
  if ( txt.isEmpty() ) {
69
  if ( txt.isEmpty() ) {
68
    KMessageBox::sorry( this, i18n("Configuration of %1 is empty.").arg( mMember.pluginName() ) );
70
    KMessageBox::sorry( this, i18n("Configuration of %1 is empty.").arg( mMember.pluginName() ) );
69
  } else {
71
  } else {
70
    QByteArray cfg = txt.utf8();
72
    mMember.setConfiguration( txt.utf8() );
71
    cfg.truncate(cfg.size() - 1); /* discard NUL terminator */
72
    mMember.setConfiguration( cfg );
73
    mMember.setName( mGui->instanceName() );
73
    mMember.setName( mGui->instanceName() );
74
    // TODO: Check for save() error.
74
    // TODO: Check for save() error.
75
    mMember.save();
75
    mMember.save();
76
  }
76
  }
77
}
77
}
78
78
79
QSync::Member MemberConfig::member() const
80
{
81
  return mMember;
82
}
83
79
#include "memberconfig.moc"
84
#include "memberconfig.moc"
(-)work/kitchensync-3.5.8/kitchensync.old/src/memberconfig.h (+2 lines)
Lines 38-43 Link Here
38
    void loadData();
38
    void loadData();
39
    void saveData();
39
    void saveData();
40
40
41
    QSync::Member member() const;
42
41
  private:
43
  private:
42
    QSync::Member mMember;
44
    QSync::Member mMember;
43
45
(-)work/kitchensync-3.5.8/kitchensync.old/src/multiconflictdialog.cpp (-2 / +4 lines)
Lines 39-46 Link Here
39
    {
39
    {
40
      QGridLayout *layout = new QGridLayout( this, 2, 1, KDialog::marginHint(), KDialog::spacingHint() );
40
      QGridLayout *layout = new QGridLayout( this, 2, 1, KDialog::marginHint(), KDialog::spacingHint() );
41
41
42
      MemberInfo mi( change.member() );
42
      // TODO change doesn't contain member as struct member .. use SyncMapping to determine the correct member.
43
      layout->addWidget( new QLabel( mi.name(), this ), 0, 0 );
43
      //MemberInfo mi( change.member() );
44
      //layout->addWidget( new QLabel( mi.name(), this ), 0, 0 );
45
      layout->addWidget( new QLabel( "PORTING TODO", this ), 0, 0 );
44
46
45
      QString type;
47
      QString type;
46
      switch ( change.changeType() ) {
48
      switch ( change.changeType() ) {
(-)work/kitchensync-3.5.8/kitchensync.old/src/pluginpicker.cpp (-6 / +8 lines)
Lines 24-30 Link Here
24
#include "memberinfo.h"
24
#include "memberinfo.h"
25
#include "syncprocessmanager.h"
25
#include "syncprocessmanager.h"
26
26
27
#include <libqopensync/environment.h>
27
#include <libqopensync/pluginenv.h>
28
28
29
#include <kdialog.h>
29
#include <kdialog.h>
30
#include <kglobal.h>
30
#include <kglobal.h>
Lines 77-88 Link Here
77
{
77
{
78
  mPluginList->clear();
78
  mPluginList->clear();
79
79
80
  QSync::Environment *env = SyncProcessManager::self()->environment();
80
  const QSync::PluginEnv *env = SyncProcessManager::self()->pluginEnv();
81
82
  for ( int i = 0; i < env->pluginCount(); ++i ) {
83
    QSync::Plugin plugin = env->pluginAt( i );
84
85
    if ( plugin.isValid() )
86
      mPluginList->appendItem( new PluginItem( mPluginList, plugin ) );
81
87
82
  QSync::Environment::PluginIterator it( env->pluginBegin() );
83
  for( ; it != env->pluginEnd(); ++it ) {
84
    QSync::Plugin plugin = *it;
85
    mPluginList->appendItem( new PluginItem( mPluginList, plugin ) );
86
  }
88
  }
87
}
89
}
88
90
(-)work/kitchensync-3.5.8/kitchensync.old/src/singleconflictdialog.cpp (-3 / +11 lines)
Lines 27-32 Link Here
27
27
28
#include "addresseediffalgo.h"
28
#include "addresseediffalgo.h"
29
#include "genericdiffalgo.h"
29
#include "genericdiffalgo.h"
30
#include "xmldiffalgo.h"
30
#include "htmldiffalgodisplay.h"
31
#include "htmldiffalgodisplay.h"
31
#include "memberinfo.h"
32
#include "memberinfo.h"
32
33
Lines 43-58 Link Here
43
44
44
  if ( format == "file" ) {
45
  if ( format == "file" ) {
45
    mDiffAlgo = new KSync::GenericDiffAlgo( leftChange.data(), rightChange.data() );
46
    mDiffAlgo = new KSync::GenericDiffAlgo( leftChange.data(), rightChange.data() );
46
  } else if ( format == "vcard" ) {
47
  } else if ( format == "vcard21" || format == "vcard30" ) {
47
  } else if ( format == "calendar" ) {
48
  } else if ( format == "xml-contact" ) {
49
    mDiffAlgo = new KSync::AddresseeDiffAlgo( leftChange.data(), rightChange.data() );
48
    mDiffAlgo = new KSync::AddresseeDiffAlgo( leftChange.data(), rightChange.data() );
49
  } else if ( format == "calendar" ) {
50
  } else if ( format == "xmlformat-contact" || format == "xmlformat-note"
51
	   || format == "xmlformat-event" || format == "xmlformat-todo") { 
52
    mDiffAlgo = new KSync::XmlDiffAlgo( leftChange.data(), rightChange.data() );
50
  }
53
  }
51
54
55
// TODO: SyncChange doesn't have member as struct member anymore ...
56
// Use SyncMapping to determine the member .. see msynctool for example implementation of conlicthandler
57
#if 0  
52
  MemberInfo miLeft( leftChange.member() );
58
  MemberInfo miLeft( leftChange.member() );
53
  mDiffAlgoDisplay->setLeftSourceTitle( miLeft.name() );
59
  mDiffAlgoDisplay->setLeftSourceTitle( miLeft.name() );
54
  MemberInfo miRight( rightChange.member() );
60
  MemberInfo miRight( rightChange.member() );
55
  mDiffAlgoDisplay->setRightSourceTitle( miRight.name() );
61
  mDiffAlgoDisplay->setRightSourceTitle( miRight.name() );
62
#endif  
56
63
57
  if ( mDiffAlgo ) {
64
  if ( mDiffAlgo ) {
58
    mDiffAlgo->addDisplay( mDiffAlgoDisplay );
65
    mDiffAlgo->addDisplay( mDiffAlgoDisplay );
Lines 99-104 Link Here
99
  QGridLayout *layout = new QGridLayout( this, 3, 4, KDialog::marginHint(), KDialog::spacingHint() );
106
  QGridLayout *layout = new QGridLayout( this, 3, 4, KDialog::marginHint(), KDialog::spacingHint() );
100
107
101
  layout->addMultiCellWidget( new QLabel( i18n( "A conflict has appeared, please solve it manually." ), this ), 0, 0, 0, 3 );
108
  layout->addMultiCellWidget( new QLabel( i18n( "A conflict has appeared, please solve it manually." ), this ), 0, 0, 0, 3 );
109
102
  mDiffAlgoDisplay = new KSync::HTMLDiffAlgoDisplay( this );
110
  mDiffAlgoDisplay = new KSync::HTMLDiffAlgoDisplay( this );
103
111
104
  layout->addMultiCellWidget( mDiffAlgoDisplay, 1, 1, 0, 3 );
112
  layout->addMultiCellWidget( mDiffAlgoDisplay, 1, 1, 0, 3 );
(-)work/kitchensync-3.5.8/kitchensync.old/src/syncprocess.cpp (-27 / +16 lines)
Lines 19-28 Link Here
19
*/
19
*/
20
20
21
#include <libqopensync/engine.h>
21
#include <libqopensync/engine.h>
22
#include <libqopensync/environment.h>
22
#include <libqopensync/member.h>
23
#include <libqopensync/result.h>
23
24
24
#include <kdebug.h>
25
#include <kdebug.h>
25
#include <klocale.h>
26
#include <klocale.h>
27
#include <kmessagebox.h>
26
28
27
#include "syncprocess.h"
29
#include "syncprocess.h"
28
#include "syncprocessmanager.h"
30
#include "syncprocessmanager.h"
Lines 60-67 Link Here
60
62
61
QSync::Result SyncProcess::addMember( const QSync::Plugin &plugin )
63
QSync::Result SyncProcess::addMember( const QSync::Plugin &plugin )
62
{
64
{
63
  QSync::Member member = mGroup.addMember();
65
  QSync::Member member = mGroup.addMember( plugin );
64
  QSync::Result result = member.instance( plugin );
66
  QSync::Result result = member.instance();
65
67
66
  if ( !result.isError() )
68
  if ( !result.isError() )
67
    mGroup.save();
69
    mGroup.save();
Lines 69-108 Link Here
69
  return result;
71
  return result;
70
}
72
}
71
73
74
void SyncProcess::removeMember( const QSync::Member &member )
75
{
76
  member.cleanup();
77
  mGroup.removeMember( member );
78
  mGroup.save();
79
}
80
72
void SyncProcess::reinitEngine()
81
void SyncProcess::reinitEngine()
73
{
82
{
74
  mEngine->finalize();
83
  mEngine->finalize();
75
  delete mEngine;
84
  delete mEngine;
76
  mEngine = new QSync::Engine( mGroup );
85
  mEngine = new QSync::Engine( mGroup );
77
  Result result = mEngine->initialize();
86
  Result result = mEngine->initialize();
78
  if ( result.isError() )
87
  if ( result.isError() ) {
79
    kdDebug() << "SyncProcess::reinitEngine: " << result.message() << endl;
88
    kdDebug() << "SyncProcess::reinitEngine: " << result.message() << endl;
89
    KMessageBox::error( 0, i18n("Error initializing Synchronization Engine for group \"%1\":\n %2")
90
		    .arg( mGroup.name() ).arg( result.message() ) );
80
91
81
  applyObjectTypeFilter();
92
  }
82
93
83
  emit engineChanged( mEngine );
94
  emit engineChanged( mEngine );
84
}
95
}
85
96
86
void SyncProcess::applyObjectTypeFilter()
87
{
88
  const QSync::Conversion conversion = SyncProcessManager::self()->environment()->conversion();
89
  const QStringList objectTypes = conversion.objectTypes();
90
  const QStringList activeObjectTypes = mGroup.config().activeObjectTypes();
91
92
  for ( uint i = 0; i < objectTypes.count(); ++i ) {
93
    if ( activeObjectTypes.contains( objectTypes[ i ] ) ) {
94
      kdDebug() << "Enabled object type: " <<  objectTypes[ i ] << endl;
95
      /*
96
       * This is not required. Also this lead to filtering problems when sync with "file-sync".
97
       * Uncomment this line again when OpenSync is fixed!
98
       *
99
       * mGroup.setObjectTypeEnabled( objectTypes[ i ], true );
100
       */
101
    } else {
102
      kdDebug() << "Disabled object type: " <<  objectTypes[ i ] << endl;
103
      mGroup.setObjectTypeEnabled( objectTypes[ i ], false );
104
    }
105
  }
106
}
107
108
#include "syncprocess.moc"
97
#include "syncprocess.moc"
(-)work/kitchensync-3.5.8/kitchensync.old/src/syncprocess.h (-3 / +1 lines)
Lines 44-55 Link Here
44
    QString memberStatus( const QSync::Member &member ) const;
44
    QString memberStatus( const QSync::Member &member ) const;
45
45
46
    QSync::Result addMember( const QSync::Plugin &plugin );
46
    QSync::Result addMember( const QSync::Plugin &plugin );
47
    void removeMember( const QSync::Member &member );
47
48
48
    void reinitEngine();
49
    void reinitEngine();
49
50
50
    /** apply object type filter hack **/
51
    void applyObjectTypeFilter();
52
53
  signals:
51
  signals:
54
    /**
52
    /**
55
      This signal is emitted whenever the engine has changed ( reinitialized ).
53
      This signal is emitted whenever the engine has changed ( reinitialized ).
(-)work/kitchensync-3.5.8/kitchensync.old/src/syncprocessmanager.cpp (-14 / +34 lines)
Lines 23-29 Link Here
23
23
24
#include "syncprocess.h"
24
#include "syncprocess.h"
25
25
26
#include <libqopensync/environment.h>
26
#include <libqopensync/groupenv.h>
27
#include <libqopensync/member.h>
28
#include <libqopensync/pluginenv.h>
29
#include <libqopensync/result.h>
27
30
28
#include <kstaticdeleter.h>
31
#include <kstaticdeleter.h>
29
#include <kmessagebox.h>
32
#include <kmessagebox.h>
Lines 43-56 Link Here
43
46
44
SyncProcessManager::SyncProcessManager()
47
SyncProcessManager::SyncProcessManager()
45
{
48
{
46
  mEnvironment = new QSync::Environment;
49
  mGroupEnv = new QSync::GroupEnv;
47
  QSync::Result result = mEnvironment->initialize();
50
  QSync::Result result = mGroupEnv->initialize();
48
  if ( result.isError() ) {
51
  if ( result.isError() ) {
49
    KMessageBox::error( 0, i18n("Error initializing OpenSync.\n%1")
52
    KMessageBox::error( 0, i18n("Error initializing OpenSync.\n%1")
50
      .arg( result.message() ) );
53
      .arg( result.message() ) );
51
  } else {
54
  } else {
52
    init( mEnvironment );
55
    initGroup( mGroupEnv );
53
  }
56
  }
57
58
  mPluginEnv = new QSync::PluginEnv;
59
  result = mPluginEnv->initialize();
60
  if ( result.isError() ) {
61
    KMessageBox::error( 0, i18n("Error initializing OpenSync.\n%1")
62
      .arg( result.message() ) );
63
  } else {
64
//    initPlugin( mPluginEnv );
65
  }
66
54
}
67
}
55
68
56
SyncProcessManager::~SyncProcessManager()
69
SyncProcessManager::~SyncProcessManager()
Lines 61-68 Link Here
61
74
62
  mProcesses.clear();
75
  mProcesses.clear();
63
76
64
  mEnvironment->finalize();
77
  mGroupEnv->finalize();
65
  delete mEnvironment;
78
  delete mGroupEnv;
66
}
79
}
67
80
68
int SyncProcessManager::count() const
81
int SyncProcessManager::count() const
Lines 102-109 Link Here
102
{
115
{
103
  SyncProcess* process = byGroupName( name );
116
  SyncProcess* process = byGroupName( name );
104
  if ( !process ) {
117
  if ( !process ) {
105
    QSync::Group group = mEnvironment->addGroup();
118
    QSync::Group group = mGroupEnv->addGroup( name );
106
    group.setName( name );
107
    group.save();
119
    group.save();
108
120
109
    mProcesses.append( new SyncProcess( group ) );
121
    mProcesses.append( new SyncProcess( group ) );
Lines 120-141 Link Here
120
    const QSync::Group group = syncProcess->group();
132
    const QSync::Group group = syncProcess->group();
121
    delete syncProcess;
133
    delete syncProcess;
122
134
123
    mEnvironment->removeGroup( group );
135
    mGroupEnv->removeGroup( group );
124
136
125
    emit changed();
137
    emit changed();
126
  }
138
  }
127
}
139
}
128
140
129
void SyncProcessManager::init( QSync::Environment *environment )
141
void SyncProcessManager::initGroup( QSync::GroupEnv *groupEnv )
130
{
142
{
131
  QSync::Environment::GroupIterator it( environment->groupBegin() );
143
  for ( int i = 0; i < groupEnv->groupCount(); ++i ) {
132
  for ( ; it != environment->groupEnd(); ++it ) {
133
    /**
144
    /**
134
     * We check whether the group is valid before we append them
145
     * We check whether the group is valid before we append them
135
     * to mProcesses. That avoids crashes if the plugin of one of
146
     * to mProcesses. That avoids crashes if the plugin of one of
136
     * the members isn't loaded (e.g. not installed).
147
     * the members isn't loaded (e.g. not installed).
137
     */
148
     */
138
    const QSync::Group group = *it;
149
    const QSync::Group group = groupEnv->groupAt( i );
139
    int count = group.memberCount();
150
    int count = group.memberCount();
140
151
141
    bool isValid = true;
152
    bool isValid = true;
Lines 149-155 Link Here
149
    }
160
    }
150
161
151
    if ( isValid )
162
    if ( isValid )
152
      mProcesses.append( new SyncProcess( *it ) );
163
      mProcesses.append( new SyncProcess( group ) );
153
  }
164
  }
154
165
155
  emit changed();
166
  emit changed();
Lines 169-172 Link Here
169
  return result;
180
  return result;
170
}
181
}
171
182
183
void SyncProcessManager::removeMember( SyncProcess *process, const QSync::Member &member )
184
{
185
  Q_ASSERT( process );
186
187
  process->removeMember( member );
188
  process->group().save();
189
  emit syncProcessChanged( process );
190
}
191
172
#include "syncprocessmanager.moc"
192
#include "syncprocessmanager.moc"
(-)work/kitchensync-3.5.8/kitchensync.old/src/syncprocessmanager.h (-5 / +18 lines)
Lines 26-32 Link Here
26
#include <libqopensync/group.h>
26
#include <libqopensync/group.h>
27
27
28
namespace QSync {
28
namespace QSync {
29
class Environment;
29
class GroupEnv;
30
class PluginEnv;
30
}
31
}
31
32
32
class SyncProcess;
33
class SyncProcess;
Lines 43-51 Link Here
43
    ~SyncProcessManager();
44
    ~SyncProcessManager();
44
45
45
    /**
46
    /**
46
      Return OpenSync Environment.
47
      Return OpenSync GroupEnv.
47
    */
48
    */
48
    QSync::Environment *environment() const { return mEnvironment; }
49
    QSync::GroupEnv *groupEnv() const { return mGroupEnv; }
50
51
    /**
52
      Return OpenSync PluginEnv.
53
    */
54
    QSync::PluginEnv *pluginEnv() const { return mPluginEnv; }
49
55
50
    /**
56
    /**
51
      Returns the number of SyncProcesses.
57
      Returns the number of SyncProcesses.
Lines 82-87 Link Here
82
     */
88
     */
83
    QSync::Result addMember( SyncProcess *process, const QSync::Plugin &plugin );
89
    QSync::Result addMember( SyncProcess *process, const QSync::Plugin &plugin );
84
90
91
    /**
92
      Removes the @param member from the group of @param process.
93
     */
94
    void removeMember( SyncProcess *process, const QSync::Member &member );
95
85
  signals:
96
  signals:
86
    void changed();
97
    void changed();
87
    void syncProcessChanged( SyncProcess *process );
98
    void syncProcessChanged( SyncProcess *process );
Lines 89-98 Link Here
89
  private:
100
  private:
90
    SyncProcessManager();
101
    SyncProcessManager();
91
102
92
    void init( QSync::Environment *environment );
103
    void initGroup( QSync::GroupEnv *groupEnv );
104
//    void initPlugin( QSync::PluginEnv *pluginEnv );
93
105
94
    QValueList<SyncProcess*> mProcesses;
106
    QValueList<SyncProcess*> mProcesses;
95
    QSync::Environment *mEnvironment;
107
    QSync::GroupEnv *mGroupEnv;
108
    QSync::PluginEnv *mPluginEnv;
96
109
97
    static SyncProcessManager *mSelf;
110
    static SyncProcessManager *mSelf;
98
};
111
};
(-)work/kitchensync-3.5.8/kitchensync.old/src/xmldiffalgo.cpp (+166 lines)
Line 0 Link Here
1
/*
2
    This file is part of KitchenSync.
3
4
    Copyright (c) 2006 Daniel Gollub <dgollub@suse.de> 
5
6
    This program is free software; you can redistribute it and/or
7
    modify it under the terms of the GNU Library General Public
8
    License as published by the Free Software Foundation; either
9
    version 2 of the License, or (at your option) any later version.
10
11
    This library is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
    Library General Public License for more details.
15
16
    You should have received a copy of the GNU Library General Public License
17
    along with this library; see the file COPYING.LIB.  If not, write to
18
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
    Boston, MA 02110-1301, USA.
20
*/
21
22
#include "xmldiffalgo.h"
23
24
#include <kdebug.h>
25
26
using namespace KSync;
27
28
#ifndef KDE_USE_FINAL
29
// With --enable-final, we get the (identical) compareString from
30
// addresseediffalgo.cpp
31
//
32
static bool compareString( const QString &left, const QString &right )
33
{
34
  if ( left.isEmpty() && right.isEmpty() )
35
    return true;
36
  else
37
    return left == right;
38
}
39
#endif
40
41
XmlDiffAlgo::XmlDiffAlgo( const QString &leftXml, const QString &rightXml )
42
{
43
  kdDebug() << __func__ << " " << __LINE__ << endl;
44
45
  mLeftXml.setContent( leftXml );
46
  mRightXml.setContent( rightXml );
47
48
}
49
50
XmlDiffAlgo::XmlDiffAlgo( const QDomDocument &leftXml, const QDomDocument &rightXml )
51
  : mLeftXml( leftXml ), mRightXml( rightXml )
52
{
53
  kdDebug() << __func__ << " " << __LINE__ << endl;
54
}
55
56
void XmlDiffAlgo::appendSingleNodes(QDomElement &element, bool isLeft)
57
{
58
  QDomNode node;
59
60
  for ( node = element.firstChild(); !node.isNull(); node = node.nextSibling() ) {
61
    QDomElement child = node.toElement();
62
63
    if (isLeft)
64
      additionalLeftField( node.nodeName(), child.text() );
65
    else
66
      additionalRightField( node.nodeName(), child.text() );
67
  }
68
69
}
70
71
void XmlDiffAlgo::appendConflictNodes(QDomElement &leftElement, QDomElement &rightElement)
72
{
73
  QDomNode left, right;
74
  QDomElement leftChild, rightChild;
75
76
  for ( left = leftElement.firstChild(); !left.isNull(); left = left.nextSibling() ) {
77
    leftChild = left.toElement();
78
79
    for ( right = rightElement.firstChild(); !right.isNull(); right = right.nextSibling() ) {
80
      rightChild = right.toElement();
81
82
      if ( leftChild.tagName() != rightChild.tagName() )
83
        continue;
84
85
      if (leftChild.text().isEmpty() || rightChild.text().isEmpty())
86
        continue;
87
88
      QString id = leftChild.tagName();
89
      if (id == "Content")
90
        id = left.parentNode().nodeName();
91
92
      conflictField( id, leftChild.text(), rightChild.text() );
93
94
      left.parentNode().removeChild( left );
95
      left = leftElement.firstChild();
96
97
      right.parentNode().removeChild( right );
98
      right = rightElement.firstChild();
99
100
    }
101
  }
102
}
103
104
void XmlDiffAlgo::compareNode(QDomElement &leftElement, QDomElement &rightElement)
105
{
106
  QDomNode left, right;
107
  QDomElement leftChild, rightChild;
108
  QDomNodeList nlist;
109
top:;
110
111
  for ( left = leftElement.firstChild(); !left.isNull(); left = left.nextSibling() ) {
112
    leftChild = left.toElement();
113
114
    for ( right = rightElement.firstChild(); !right.isNull(); right = right.nextSibling() ) {
115
      rightChild = right.toElement();
116
117
      if (leftChild.tagName() != rightChild.tagName())
118
        continue;
119
120
      if ( left.childNodes().count() > 1 && right.childNodes().count() > 1 ) {
121
        compareNode( leftChild, rightChild );
122
123
        if ( !left.hasChildNodes() && !right.hasChildNodes() ) {
124
          left.parentNode().removeChild( left );
125
          right.parentNode().removeChild( right );
126
          goto top;
127
        }
128
129
        break;
130
      }
131
132
      if ( leftChild.text() == rightChild.text() ) {
133
        QString id = leftChild.tagName();
134
135
        if ( id == "Content" )
136
          id = left.parentNode().nodeName(); 
137
 
138
	if ( id != "Type" )
139
          //matchingField( id, leftChild.text(), rightChild.text() );
140
141
        left.parentNode().removeChild( left );
142
        right.parentNode().removeChild( right );
143
        goto top;
144
      }
145
    }
146
  }
147
148
  appendConflictNodes(rightElement, leftElement);
149
150
  appendSingleNodes(rightElement, false);
151
  appendSingleNodes(leftElement, true);
152
}
153
154
void XmlDiffAlgo::run()
155
{
156
  kdDebug() << __func__ << endl;	
157
  begin();
158
159
  QDomElement leftElement = mLeftXml.documentElement();
160
  QDomElement rightElement = mRightXml.documentElement();
161
162
  compareNode( leftElement, rightElement );
163
164
  end();
165
}
166
(-)work/kitchensync-3.5.8/kitchensync.old/src/xmldiffalgo.h (+54 lines)
Line 0 Link Here
1
/*
2
    This file is part of KitchenSync 
3
4
    Copyright (c) 2006 Daniel Gollub <dgollub@suse.de>
5
6
    This program is free software; you can redistribute it and/or
7
    modify it under the terms of the GNU Library General Public
8
    License as published by the Free Software Foundation; either
9
    version 2 of the License, or (at your option) any later version.
10
11
    This library is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
    Library General Public License for more details.
15
16
    You should have received a copy of the GNU Library General Public License
17
    along with this library; see the file COPYING.LIB.  If not, write to
18
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
    Boston, MA 02110-1301, USA.
20
*/
21
22
#ifndef KSYNC_XMLDIFFALGO_H
23
#define KSYNC_XMLDIFFALGO_H
24
25
#include <qdom.h>
26
27
#include <libkdepim/diffalgo.h>
28
29
using namespace KPIM;
30
31
namespace KSync {
32
33
class XmlDiffAlgo : public DiffAlgo
34
{
35
  public:
36
    XmlDiffAlgo( const QString &leftXml, const QString &rightXml );
37
    XmlDiffAlgo( const QDomDocument &leftXml, const QDomDocument &rightXml );
38
39
    void run();
40
41
  private:
42
    void appendConflictNodes(QDomElement &leftElement, QDomElement &rightElement);
43
    void appendSingleNodes(QDomElement &element, bool isLeft);
44
45
46
    void compareNode(QDomElement &leftElement, QDomElement &rightElement);
47
48
    QDomDocument mLeftXml;
49
    QDomDocument mRightXml;
50
};
51
52
}
53
54
#endif

Return to bug 202974