summaryrefslogtreecommitdiffstats
path: root/kitchensync/src
diff options
context:
space:
mode:
Diffstat (limited to 'kitchensync/src')
-rw-r--r--kitchensync/src/Makefile.am2
-rw-r--r--kitchensync/src/configguifile.cpp40
-rw-r--r--kitchensync/src/configguisyncmlhttp.cpp4
-rw-r--r--kitchensync/src/configguisyncmlobex.cpp4
-rw-r--r--kitchensync/src/groupconfig.cpp58
-rw-r--r--kitchensync/src/groupconfig.h15
-rw-r--r--kitchensync/src/groupconfigcommon.cpp21
-rw-r--r--kitchensync/src/groupconfigcommon.h7
-rw-r--r--kitchensync/src/groupconfigdialog.cpp24
-rw-r--r--kitchensync/src/groupconfigdialog.h5
-rw-r--r--kitchensync/src/groupitem.cpp71
-rw-r--r--kitchensync/src/mainwidget.cpp20
-rw-r--r--kitchensync/src/memberconfig.cpp11
-rw-r--r--kitchensync/src/memberconfig.h2
-rw-r--r--kitchensync/src/multiconflictdialog.cpp6
-rw-r--r--kitchensync/src/pluginpicker.cpp14
-rw-r--r--kitchensync/src/singleconflictdialog.cpp14
-rw-r--r--kitchensync/src/syncprocess.cpp43
-rw-r--r--kitchensync/src/syncprocess.h4
-rw-r--r--kitchensync/src/syncprocessmanager.cpp48
-rw-r--r--kitchensync/src/syncprocessmanager.h23
-rw-r--r--kitchensync/src/xmldiffalgo.cpp166
-rw-r--r--kitchensync/src/xmldiffalgo.h54
23 files changed, 493 insertions, 163 deletions
diff --git a/kitchensync/src/Makefile.am b/kitchensync/src/Makefile.am
index 7f94fc173..6527084cc 100644
--- a/kitchensync/src/Makefile.am
+++ b/kitchensync/src/Makefile.am
@@ -24,7 +24,7 @@ libkitchensync_la_SOURCES = aboutpage.cpp mainwidget.cpp groupconfigdialog.cpp \
pluginpicker.cpp configgui.cpp configguiblank.cpp configguifile.cpp \
memberinfo.cpp groupconfigcommon.cpp kwidgetlist.cpp \
configguipalm.cpp conflictdialog.cpp singleconflictdialog.cpp \
- addresseediffalgo.cpp calendardiffalgo.cpp \
+ addresseediffalgo.cpp calendardiffalgo.cpp xmldiffalgo.cpp \
htmldiffalgodisplay.cpp genericdiffalgo.cpp multiconflictdialog.cpp \
configguiirmc.cpp \
configguisyncmlobex.cpp configguisyncmlhttp.cpp configguiopie.cpp \
diff --git a/kitchensync/src/configguifile.cpp b/kitchensync/src/configguifile.cpp
index 6a8b0402c..a0c6a596d 100644
--- a/kitchensync/src/configguifile.cpp
+++ b/kitchensync/src/configguifile.cpp
@@ -55,13 +55,20 @@ void ConfigGuiFile::load( const TQString &xml )
TQDomDocument doc;
doc.setContent( xml );
TQDomElement docElement = doc.documentElement();
- TQDomNode n;
- for( n = docElement.firstChild(); !n.isNull(); n = n.nextSibling() ) {
- TQDomElement e = n.toElement();
- if ( e.tagName() == "path" ) {
- mFilename->setURL( e.text() );
- } else if ( e.tagName() == "recursive" ) {
- mRecursive->setChecked( e.text() == "TRUE" );
+
+ TQDomNode node;
+ for ( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
+ TQDomElement e = node.toElement();
+ if ( e.tagName() == "directory" ) {
+ TQDomNode subNode;
+ for ( subNode = e.firstChild(); !subNode.isNull(); subNode = subNode.nextSibling() ) {
+ TQDomElement subElement = subNode.toElement();
+ if ( subElement.tagName() == "path" ) {
+ mFilename->setURL( subElement.text() );
+ } else if ( subElement.tagName() == "recursive" ) {
+ mRecursive->setChecked( subElement.text() == "TRUE" );
+ }
+ }
}
}
}
@@ -69,13 +76,18 @@ void ConfigGuiFile::load( const TQString &xml )
TQString ConfigGuiFile::save() const
{
TQString xml;
- xml = "<config>";
- xml += "<path>" + mFilename->url() + "</path>";
- xml += "<recursive>";
- if ( mRecursive->isChecked() ) xml += "TRUE";
- else xml += "FALSE";
- xml += "</recursive>";
- xml += "</config>";
+ xml = "<config>\n";
+ xml += " <directory>\n";
+ xml += " <path>" + mFilename->url() + "</path>\n";
+ xml += " <objtype>data</objtype>\n";
+ xml += " <recursive>";
+ if ( mRecursive->isChecked() )
+ xml += "TRUE";
+ else
+ xml += "FALSE";
+ xml += "</recursive>\n";
+ xml += " </directory>\n";
+ xml += "</config>\n";
return xml;
}
diff --git a/kitchensync/src/configguisyncmlhttp.cpp b/kitchensync/src/configguisyncmlhttp.cpp
index 26a8c2241..b07111675 100644
--- a/kitchensync/src/configguisyncmlhttp.cpp
+++ b/kitchensync/src/configguisyncmlhttp.cpp
@@ -121,7 +121,7 @@ ConfigGuiSyncmlHttp::ConfigGuiSyncmlHttp( const QSync::Member &member, TQWidget
mGridLayout->addWidget( label, 5, 0 );
mRecvLimit = new TQSpinBox( optionWidget );
- mRecvLimit->setMinValue( 1 );
+ mRecvLimit->setMinValue( 0 );
mRecvLimit->setMaxValue( 65536 );
mGridLayout->addWidget( mRecvLimit, 5, 1 );
@@ -130,7 +130,7 @@ ConfigGuiSyncmlHttp::ConfigGuiSyncmlHttp( const QSync::Member &member, TQWidget
mGridLayout->addWidget( label, 6, 0 );
mMaxObjSize = new TQSpinBox( optionWidget );
- mMaxObjSize->setMinValue( 1 );
+ mMaxObjSize->setMinValue( 0 );
mMaxObjSize->setMaxValue( 65536 );
mGridLayout->addWidget( mMaxObjSize, 6, 1 );
diff --git a/kitchensync/src/configguisyncmlobex.cpp b/kitchensync/src/configguisyncmlobex.cpp
index 372cf9261..ea952ef4a 100644
--- a/kitchensync/src/configguisyncmlobex.cpp
+++ b/kitchensync/src/configguisyncmlobex.cpp
@@ -153,7 +153,7 @@ ConfigGuiSyncmlObex::ConfigGuiSyncmlObex( const QSync::Member &member, TQWidget
mGridLayout->addWidget( label, 14, 0 );
mRecvLimit = new TQSpinBox( optionsWidget );
- mRecvLimit->setMinValue( 1 );
+ mRecvLimit->setMinValue( 0 );
mRecvLimit->setMaxValue( 65536 );
mGridLayout->addWidget( mRecvLimit, 14, 1 );
@@ -162,7 +162,7 @@ ConfigGuiSyncmlObex::ConfigGuiSyncmlObex( const QSync::Member &member, TQWidget
mGridLayout->addWidget( label, 15, 0 );
mMaxObjSize = new TQSpinBox( optionsWidget );
- mMaxObjSize->setMinValue( 1 );
+ mMaxObjSize->setMinValue( 0 );
mMaxObjSize->setMaxValue( 65536 );
mGridLayout->addWidget( mMaxObjSize, 15, 1 );
diff --git a/kitchensync/src/groupconfig.cpp b/kitchensync/src/groupconfig.cpp
index cfedcbfad..7e0af734a 100644
--- a/kitchensync/src/groupconfig.cpp
+++ b/kitchensync/src/groupconfig.cpp
@@ -27,8 +27,10 @@
#include "syncprocess.h"
#include "syncprocessmanager.h"
+#include <libqopensync/engine.h>
#include <libqopensync/group.h>
#include <libqopensync/plugin.h>
+#include <libqopensync/result.h>
#include <kdialog.h>
#include <kiconloader.h>
@@ -40,6 +42,7 @@
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqpushbutton.h>
+#include <tqtimer.h>
GroupConfig::GroupConfig( TQWidget *parent )
: TQWidget( parent )
@@ -84,14 +87,6 @@ GroupConfig::GroupConfig( TQWidget *parent )
mMemberView = new KJanusWidget( this, 0, KJanusWidget::IconList );
topLayout->addWidget( mMemberView );
- TQBoxLayout *buttonLayout = new TQHBoxLayout( topLayout );
-
- TQPushButton *addButton = new TQPushButton( i18n("Add Member..."), this );
- connect( addButton, TQT_SIGNAL( clicked() ), TQT_SLOT( addMember() ) );
- buttonLayout->addWidget( addButton );
-
- buttonLayout->addStretch( 1 );
-
icon = KGlobal::iconLoader()->loadIcon( "bookmark", KIcon::Desktop );
TQFrame *page = mMemberView->addPage( i18n("Group"),
i18n("General Group Settings"), icon );
@@ -99,6 +94,8 @@ GroupConfig::GroupConfig( TQWidget *parent )
mCommonConfig = new GroupConfigCommon( page );
pageLayout->addWidget( mCommonConfig );
+
+ connect( mMemberView, TQT_SIGNAL( aboutToShowPage( TQWidget* ) ), TQT_SLOT( memberWidgetSelected( TQWidget* ) ) );
}
void GroupConfig::setSyncProcess( SyncProcess *process )
@@ -113,9 +110,9 @@ void GroupConfig::setSyncProcess( SyncProcess *process )
void GroupConfig::updateMembers()
{
- TQValueList<MemberConfig *>::ConstIterator memberIt;
+ TQMap<TQWidget*, MemberConfig *>::ConstIterator memberIt;
for ( memberIt = mMemberConfigs.begin(); memberIt != mMemberConfigs.end(); ++memberIt )
- (*memberIt)->saveData();
+ memberIt.data()->saveData();
TQValueList<TQFrame *>::ConstIterator it2;
for ( it2 = mConfigPages.begin(); it2 != mConfigPages.end(); ++it2 ) {
@@ -125,10 +122,9 @@ void GroupConfig::updateMembers()
mConfigPages.clear();
mMemberConfigs.clear();
- QSync::Group group = mProcess->group();
- QSync::Group::Iterator it( group.begin() );
- for ( ; it != group.end(); ++it ) {
- QSync::Member member = *it;
+ const QSync::Group group = mProcess->group();
+ for ( int i = 0; i < group.memberCount(); ++i ) {
+ QSync::Member member = group.memberAt( i );
MemberInfo mi( member );
TQFrame *page = mMemberView->addPage( mi.name(),
TQString( "%1 (%2)" ).arg( mi.name() ).arg(member.pluginName()), mi.desktopIcon() );
@@ -137,7 +133,7 @@ void GroupConfig::updateMembers()
mConfigPages.append( page );
MemberConfig *memberConfig = new MemberConfig( page, member );
- mMemberConfigs.append( memberConfig );
+ mMemberConfigs.insert( page, memberConfig );
pageLayout->addWidget( memberConfig );
memberConfig->loadData();
@@ -148,15 +144,30 @@ void GroupConfig::saveConfig()
{
mProcess->group().save();
- TQValueList<MemberConfig *>::ConstIterator it;
+ TQMap<TQWidget*, MemberConfig*>::ConstIterator it;
for ( it = mMemberConfigs.begin(); it != mMemberConfigs.end(); ++it )
- (*it)->saveData();
+ it.data()->saveData();
mCommonConfig->save();
+ const QSync::Group group = mProcess->group();
+ for ( int i = 0; i < group.memberCount(); ++i ) {
+ const QSync::Member member = group.memberAt( i );
+ mProcess->engine()->discover( member );
+ }
+
mProcess->reinitEngine();
}
+void GroupConfig::memberWidgetSelected( TQWidget *wdg )
+{
+ /**
+ * Emit 'true' whenever a real member widget is selected by the
+ * user.
+ */
+ emit memberSelected( wdg != mCommonConfig->parentWidget() );
+}
+
void GroupConfig::addMember()
{
QSync::Plugin plugin = PluginPickerDialog::getPlugin( this );
@@ -176,4 +187,17 @@ void GroupConfig::addMember()
}
}
+void GroupConfig::removeMember()
+{
+ TQWidget *selectedWidget = mMemberView->pageWidget( mMemberView->activePageIndex() );
+ if ( selectedWidget && mMemberConfigs.contains( selectedWidget ) ) {
+ MemberConfig *config = mMemberConfigs[ selectedWidget ];
+
+ SyncProcessManager::self()->removeMember( mProcess, config->member() );
+ mMemberConfigs.remove( selectedWidget );
+
+ TQTimer::singleShot( 0, this, TQT_SLOT( updateMembers() ) );
+ }
+}
+
#include "groupconfig.moc"
diff --git a/kitchensync/src/groupconfig.h b/kitchensync/src/groupconfig.h
index 8dc300b6b..4deb8f255 100644
--- a/kitchensync/src/groupconfig.h
+++ b/kitchensync/src/groupconfig.h
@@ -40,12 +40,19 @@ class GroupConfig : public QWidget
void setSyncProcess( SyncProcess *process );
+ void saveConfig();
+
+ public slots:
+ void addMember();
+ void removeMember();
+
void updateMembers();
- void saveConfig();
+ signals:
+ void memberSelected( bool );
protected slots:
- void addMember();
+ void memberWidgetSelected( TQWidget* );
private:
TQLabel *mNameLabel;
@@ -55,8 +62,8 @@ class GroupConfig : public QWidget
SyncProcess *mProcess;
GroupConfigCommon *mCommonConfig;
- TQValueList<MemberConfig *> mMemberConfigs;
- TQValueList<TQFrame *> mConfigPages;
+ TQMap<TQWidget*, MemberConfig*> mMemberConfigs;
+ TQValueList<TQFrame*> mConfigPages;
};
#endif
diff --git a/kitchensync/src/groupconfigcommon.cpp b/kitchensync/src/groupconfigcommon.cpp
index 9f629c4d2..360746893 100644
--- a/kitchensync/src/groupconfigcommon.cpp
+++ b/kitchensync/src/groupconfigcommon.cpp
@@ -30,14 +30,15 @@
#include <tqcheckbox.h>
#include <libqopensync/group.h>
-#include <libqopensync/conversion.h>
-#include <libqopensync/environment.h>
+//#include <libqopensync/conversion.h>
#include "syncprocess.h"
#include "syncprocessmanager.h"
#include "groupconfigcommon.h"
+// TODO: port ObjectTypeSelector to ported solution of Conversation class
+#if 0
ObjectTypeSelector::ObjectTypeSelector( TQWidget *parent )
: TQWidget( parent )
{
@@ -124,6 +125,7 @@ void ObjectTypeSelector::save( QSync::Group group )
QSync::GroupConfig config = group.config();
config.setActiveObjectTypes( objectTypes );
}
+#endif
GroupConfigCommon::GroupConfigCommon( TQWidget *parent )
: TQWidget( parent )
@@ -135,10 +137,11 @@ GroupConfigCommon::GroupConfigCommon( TQWidget *parent )
mGroupName = new KLineEdit( this );
layout->addWidget( mGroupName, 0, 1 );
- layout->addWidget( new TQLabel( i18n( "Object Types to be Synchronized:"), this ), 1, 0, Qt::AlignTop );
+ //layout->addWidget( new TQLabel( i18n( "Object Types to be Synchronized:"), this ), 1, 0, Qt::AlignTop );
- mObjectTypeSelector = new ObjectTypeSelector( this );
- layout->addWidget( mObjectTypeSelector, 1, 1 );
+ // TODO port ObjectTypeSelector class..
+ //mObjectTypeSelector = new ObjectTypeSelector( this );
+ //layout->addWidget( mObjectTypeSelector, 1, 1 );
layout->setRowStretch( 2, 1 );
}
@@ -148,11 +151,15 @@ void GroupConfigCommon::setSyncProcess( SyncProcess *syncProcess )
mSyncProcess = syncProcess;
mGroupName->setText( mSyncProcess->group().name() );
- mObjectTypeSelector->load( mSyncProcess->group() );
+
+ // TODO port ObjectTypeSelector class..
+ //mObjectTypeSelector->load( mSyncProcess->group() );
}
void GroupConfigCommon::save()
{
mSyncProcess->group().setName( mGroupName->text() );
- mObjectTypeSelector->save( mSyncProcess->group() );
+
+ // TODO port ObjectTypeSelector class..
+ //mObjectTypeSelector->save( mSyncProcess->group() );
}
diff --git a/kitchensync/src/groupconfigcommon.h b/kitchensync/src/groupconfigcommon.h
index a953607fe..15ec5e5ab 100644
--- a/kitchensync/src/groupconfigcommon.h
+++ b/kitchensync/src/groupconfigcommon.h
@@ -30,7 +30,9 @@ class KLineEdit;
class SyncProcess;
class TQCheckBox;
-class ObjectTypeSelector : public QWidget
+//TODO: Conversation needs to be ported before...
+#if 0
+class ObjectTypeSelector : public TQWidget
{
public:
ObjectTypeSelector( TQWidget *parent );
@@ -41,6 +43,7 @@ class ObjectTypeSelector : public QWidget
private:
TQMap<TQString,TQCheckBox *> mObjectTypeChecks;
};
+#endif
class GroupConfigCommon : public QWidget
{
@@ -52,7 +55,7 @@ class GroupConfigCommon : public QWidget
private:
KLineEdit *mGroupName;
- ObjectTypeSelector *mObjectTypeSelector;
+ // ObjectTypeSelector *mObjectTypeSelector;
SyncProcess *mSyncProcess;
};
diff --git a/kitchensync/src/groupconfigdialog.cpp b/kitchensync/src/groupconfigdialog.cpp
index 4d8be65d0..d0b5894f9 100644
--- a/kitchensync/src/groupconfigdialog.cpp
+++ b/kitchensync/src/groupconfigdialog.cpp
@@ -28,7 +28,7 @@
GroupConfigDialog::GroupConfigDialog( TQWidget *parent, SyncProcess *process )
: KDialogBase( parent, 0, true, i18n("Configure Synchronization Group"),
- Ok )
+ Ok | User1 | User2, Ok )
{
TQFrame *topFrame = makeMainWidget();
@@ -40,6 +40,13 @@ GroupConfigDialog::GroupConfigDialog( TQWidget *parent, SyncProcess *process )
mConfigWidget->setSyncProcess( process );
setInitialSize( configDialogSize( "size_groupconfigdialog" ) );
+
+ enableButton( User1, false );
+ setButtonText( User1, i18n( "Remove Member" ) );
+
+ connect( mConfigWidget, TQT_SIGNAL( memberSelected( bool ) ), TQT_SLOT( memberSelected( bool ) ) );
+
+ setButtonText( User2, i18n("Add Member...") );
}
GroupConfigDialog::~GroupConfigDialog()
@@ -54,4 +61,19 @@ void GroupConfigDialog::slotOk()
accept();
}
+void GroupConfigDialog::slotUser1()
+{
+ mConfigWidget->removeMember();
+}
+
+void GroupConfigDialog::slotUser2()
+{
+ mConfigWidget->addMember();
+}
+
+void GroupConfigDialog::memberSelected( bool selected )
+{
+ enableButton( User1, selected );
+}
+
#include "groupconfigdialog.moc"
diff --git a/kitchensync/src/groupconfigdialog.h b/kitchensync/src/groupconfigdialog.h
index 5fd70884f..8dde4da77 100644
--- a/kitchensync/src/groupconfigdialog.h
+++ b/kitchensync/src/groupconfigdialog.h
@@ -35,6 +35,11 @@ class GroupConfigDialog : public KDialogBase
protected slots:
void slotOk();
+ void slotUser1();
+ void slotUser2();
+
+ private slots:
+ void memberSelected( bool );
private:
GroupConfig *mConfigWidget;
diff --git a/kitchensync/src/groupitem.cpp b/kitchensync/src/groupitem.cpp
index 784991c6f..fe4b2fdcd 100644
--- a/kitchensync/src/groupitem.cpp
+++ b/kitchensync/src/groupitem.cpp
@@ -33,6 +33,9 @@
#include <tqprogressbar.h>
#include <tqvbox.h>
+#include <libqopensync/plugin.h>
+#include <libqopensync/pluginenv.h>
+
#include "memberinfo.h"
#include "multiconflictdialog.h"
#include "singleconflictdialog.h"
@@ -150,12 +153,9 @@ void GroupItem::update()
mProgressBar->reset();
mProgressBar->hide();
- QSync::Group group = mSyncProcess->group();
- QSync::Group::Iterator memberIt( group.begin() );
- QSync::Group::Iterator memberEndIt( group.end() );
-
- for ( ; memberIt != memberEndIt; ++memberIt ) {
- MemberItem *item = new MemberItem( mBox, mSyncProcess, *memberIt );
+ const QSync::Group group = mSyncProcess->group();
+ for ( int i = 0; i < group.memberCount(); ++i ) {
+ MemberItem *item = new MemberItem( mBox, mSyncProcess, group.memberAt( i ) );
item->show();
item->setStatusMessage( i18n( "Ready" ) );
mMemberItems.append( item );
@@ -187,14 +187,11 @@ void GroupItem::conflict( QSync::SyncMapping mapping )
void GroupItem::change( const QSync::SyncChangeUpdate &update )
{
switch ( update.type() ) {
- case QSync::SyncChangeUpdate::Received:
+ case QSync::SyncChangeUpdate::Read:
mProcessedItems++;
mStatus->setText( i18n( "%1 entries read" ).arg( mProcessedItems ) );
break;
- case QSync::SyncChangeUpdate::ReceivedInfo:
- mStatus->setText( i18n( "Receive information" ) );
- break;
- case QSync::SyncChangeUpdate::Sent:
+ case QSync::SyncChangeUpdate::Written:
mProcessedItems--;
mStatus->setText( i18n( "%1 entries written" ).arg( mMaxProcessedItems - mProcessedItems ) );
@@ -211,11 +208,7 @@ void GroupItem::change( const QSync::SyncChangeUpdate &update )
mProgressBar->setProgress( 100 - progress );
}
break;
- case QSync::SyncChangeUpdate::WriteError:
- mStatus->setText( i18n( "Error" ) );
- KPassivePopup::message( update.result().message(), this );
- break;
- case QSync::SyncChangeUpdate::ReceiveError:
+ case QSync::SyncChangeUpdate::Error:
mStatus->setText( i18n( "Error" ) );
KPassivePopup::message( update.result().message(), this );
break;
@@ -232,21 +225,21 @@ void GroupItem::mapping( const QSync::SyncMappingUpdate& )
void GroupItem::engine( const QSync::SyncEngineUpdate &update )
{
switch ( update.type() ) {
- case QSync::SyncEngineUpdate::EndPhaseConnected:
+ case QSync::SyncEngineUpdate::Connected:
mStatus->setText( i18n( "Connected" ) );
mProgressBar->setProgress( 0 );
mSynchronizing = true;
mSyncAction->setText( "Abort Synchronization" );
break;
- case QSync::SyncEngineUpdate::EndPhaseRead:
+ case QSync::SyncEngineUpdate::Read:
mStatus->setText( i18n( "Data read" ) );
break;
- case QSync::SyncEngineUpdate::EndPhaseWrite:
+ case QSync::SyncEngineUpdate::Written:
mStatus->setText( i18n( "Data written" ) );
mProgressBar->setProgress( 100 );
mProcessedItems = mMaxProcessedItems = 0;
break;
- case QSync::SyncEngineUpdate::EndPhaseDisconnected:
+ case QSync::SyncEngineUpdate::Disconnected:
mStatus->setText( i18n( "Disconnected" ) );
break;
case QSync::SyncEngineUpdate::Error:
@@ -257,7 +250,7 @@ void GroupItem::engine( const QSync::SyncEngineUpdate &update )
mSynchronizing = false;
mSyncAction->setText( i18n( "Synchronize Now" ) );
break;
- case QSync::SyncEngineUpdate::SyncSuccessfull:
+ case QSync::SyncEngineUpdate::SyncSuccessful:
mStatus->setText( i18n( "Successfully synchronized" ) );
mSyncProcess->group().setLastSynchronization( TQDateTime::currentDateTime() );
mSyncProcess->group().save();
@@ -288,28 +281,22 @@ void GroupItem::member( const QSync::SyncMemberUpdate &update )
case QSync::SyncMemberUpdate::Connected:
(*it)->setStatusMessage( i18n( "Connected" ) );
break;
- case QSync::SyncMemberUpdate::SentChanges:
+ case QSync::SyncMemberUpdate::Read:
(*it)->setStatusMessage( i18n( "Changes read" ) );
break;
- case QSync::SyncMemberUpdate::CommittedAll:
+ case QSync::SyncMemberUpdate::Written:
(*it)->setStatusMessage( i18n( "Changes written" ) );
break;
case QSync::SyncMemberUpdate::Disconnected:
(*it)->setStatusMessage( i18n( "Disconnected" ) );
break;
- case QSync::SyncMemberUpdate::ConnectError:
- (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
+ case QSync::SyncMemberUpdate::SyncDone:
+ (*it)->setStatusMessage( i18n( "Synchronization done" ) );
break;
- case QSync::SyncMemberUpdate::GetChangesError:
- (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
+ case QSync::SyncMemberUpdate::Discovered:
+ (*it)->setStatusMessage( i18n( "Discovered" ) );
break;
- case QSync::SyncMemberUpdate::CommittedAllError:
- (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
- break;
- case QSync::SyncMemberUpdate::SyncDoneError:
- (*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
- break;
- case QSync::SyncMemberUpdate::DisconnectedError:
+ case QSync::SyncMemberUpdate::Error:
(*it)->setStatusMessage( i18n( "Error: %1" ).arg( update.result().message() ) );
break;
default:
@@ -352,11 +339,8 @@ MemberItem::MemberItem( TQWidget *parent, SyncProcess *process,
TQFont boldFont;
boldFont.setBold( true );
- MemberInfo mi( member );
-
- TQPixmap icon = mi.smallIcon();
-
- QSync::Plugin plugin = member.plugin();
+ const MemberInfo mi( member );
+ const TQPixmap icon = mi.smallIcon();
TQVBoxLayout *layout = new TQVBoxLayout( this );
@@ -378,7 +362,14 @@ MemberItem::MemberItem( TQWidget *parent, SyncProcess *process,
mStatus = new TQLabel( box );
mMemberName->setText( member.name() );
- mDescription->setText( plugin.longName() );
+
+ const QSync::PluginEnv *env = SyncProcessManager::self()->pluginEnv();
+ const QSync::Plugin plugin = env->pluginByName( member.pluginName() );
+
+ if ( plugin.isValid() )
+ mDescription->setText( plugin.longName() );
+ else
+ mDescription->setText( i18n("Plugin \"%1\" can't get initialized!").arg( member.pluginName() ) );
}
void MemberItem::setStatusMessage( const TQString &msg )
diff --git a/kitchensync/src/mainwidget.cpp b/kitchensync/src/mainwidget.cpp
index d04542f9d..02b279b3e 100644
--- a/kitchensync/src/mainwidget.cpp
+++ b/kitchensync/src/mainwidget.cpp
@@ -26,7 +26,7 @@
#include "syncprocess.h"
#include "syncprocessmanager.h"
-#include <libqopensync/environment.h>
+#include <libqopensync/result.h>
#include <kaboutdata.h>
#include <kaction.h>
@@ -46,13 +46,6 @@ MainWidget::MainWidget( KXMLGUIClient *guiClient, TQWidget *widget, const char *
initGUI();
initActions();
- /** apply object type filter hack **/
- int count = SyncProcessManager::self()->count();
- for ( int i = 0; i < count; ++i ) {
- SyncProcessManager::self()->at( i )->applyObjectTypeFilter();
- }
- /** apply object type filter hack **/
-
mGroupView->updateView();
connect( SyncProcessManager::self(), TQT_SIGNAL( changed() ),
@@ -125,12 +118,19 @@ void MainWidget::addGroup()
{
bool ok;
TQString name = KInputDialog::getText( i18n("Create Synchronization Group"),
- i18n("Name for new synchronization group."), TQString::null, &ok, this );
+ i18n("Name for new synchronization group."), i18n( "Default" ), &ok, this );
if ( ok ) {
+ SyncProcess *process = SyncProcessManager::self()->byGroupName( name );
+ if ( process ) {
+ KMessageBox::error( this, i18n( "A group with the same name exists already.\nPlease choose another name." ),
+ i18n( "Duplicated Group Name" ) );
+ return;
+ }
+
SyncProcessManager::self()->addGroup( name );
enableActions();
- SyncProcess *process = SyncProcessManager::self()->byGroupName( name );
+ process = SyncProcessManager::self()->byGroupName( name );
if ( process )
editGroup( process );
}
diff --git a/kitchensync/src/memberconfig.cpp b/kitchensync/src/memberconfig.cpp
index 37755a504..d3d08a63b 100644
--- a/kitchensync/src/memberconfig.cpp
+++ b/kitchensync/src/memberconfig.cpp
@@ -23,6 +23,8 @@
#include "configgui.h"
#include "memberinfo.h"
+#include <libqopensync/result.h>
+
#include <klocale.h>
#include <kmessagebox.h>
@@ -67,13 +69,16 @@ void MemberConfig::saveData()
if ( txt.isEmpty() ) {
KMessageBox::sorry( this, i18n("Configuration of %1 is empty.").arg( mMember.pluginName() ) );
} else {
- TQByteArray cfg = txt.utf8();
- cfg.truncate(cfg.size() - 1); /* discard NUL terminator */
- mMember.setConfiguration( cfg );
+ mMember.setConfiguration( txt.utf8() );
mMember.setName( mGui->instanceName() );
// TODO: Check for save() error.
mMember.save();
}
}
+QSync::Member MemberConfig::member() const
+{
+ return mMember;
+}
+
#include "memberconfig.moc"
diff --git a/kitchensync/src/memberconfig.h b/kitchensync/src/memberconfig.h
index c6457972d..b2a3569d4 100644
--- a/kitchensync/src/memberconfig.h
+++ b/kitchensync/src/memberconfig.h
@@ -38,6 +38,8 @@ class MemberConfig : public QWidget
void loadData();
void saveData();
+ QSync::Member member() const;
+
private:
QSync::Member mMember;
diff --git a/kitchensync/src/multiconflictdialog.cpp b/kitchensync/src/multiconflictdialog.cpp
index 7d7805c42..88d42d3b3 100644
--- a/kitchensync/src/multiconflictdialog.cpp
+++ b/kitchensync/src/multiconflictdialog.cpp
@@ -39,8 +39,10 @@ class ChangeItem : public KWidgetListItem
{
TQGridLayout *layout = new TQGridLayout( this, 2, 1, KDialog::marginHint(), KDialog::spacingHint() );
- MemberInfo mi( change.member() );
- layout->addWidget( new TQLabel( mi.name(), this ), 0, 0 );
+ // TODO change doesn't contain member as struct member .. use SyncMapping to determine the correct member.
+ //MemberInfo mi( change.member() );
+ //layout->addWidget( new TQLabel( mi.name(), this ), 0, 0 );
+ layout->addWidget( new TQLabel( "PORTING TODO", this ), 0, 0 );
TQString type;
switch ( change.changeType() ) {
diff --git a/kitchensync/src/pluginpicker.cpp b/kitchensync/src/pluginpicker.cpp
index d981599bd..5dda30bfe 100644
--- a/kitchensync/src/pluginpicker.cpp
+++ b/kitchensync/src/pluginpicker.cpp
@@ -24,7 +24,7 @@
#include "memberinfo.h"
#include "syncprocessmanager.h"
-#include <libqopensync/environment.h>
+#include <libqopensync/pluginenv.h>
#include <kdialog.h>
#include <kglobal.h>
@@ -77,12 +77,14 @@ void PluginPicker::updatePluginList()
{
mPluginList->clear();
- QSync::Environment *env = SyncProcessManager::self()->environment();
+ const QSync::PluginEnv *env = SyncProcessManager::self()->pluginEnv();
+
+ for ( int i = 0; i < env->pluginCount(); ++i ) {
+ QSync::Plugin plugin = env->pluginAt( i );
+
+ if ( plugin.isValid() )
+ mPluginList->appendItem( new PluginItem( mPluginList, plugin ) );
- QSync::Environment::PluginIterator it( env->pluginBegin() );
- for( ; it != env->pluginEnd(); ++it ) {
- QSync::Plugin plugin = *it;
- mPluginList->appendItem( new PluginItem( mPluginList, plugin ) );
}
}
diff --git a/kitchensync/src/singleconflictdialog.cpp b/kitchensync/src/singleconflictdialog.cpp
index 8975b6f98..121ec50cb 100644
--- a/kitchensync/src/singleconflictdialog.cpp
+++ b/kitchensync/src/singleconflictdialog.cpp
@@ -27,6 +27,7 @@
#include "addresseediffalgo.h"
#include "genericdiffalgo.h"
+#include "xmldiffalgo.h"
#include "htmldiffalgodisplay.h"
#include "memberinfo.h"
@@ -43,16 +44,22 @@ SingleConflictDialog::SingleConflictDialog( QSync::SyncMapping &mapping, TQWidge
if ( format == "file" ) {
mDiffAlgo = new KSync::GenericDiffAlgo( leftChange.data(), rightChange.data() );
- } else if ( format == "vcard" ) {
- } else if ( format == "calendar" ) {
- } else if ( format == "xml-contact" ) {
+ } else if ( format == "vcard21" || format == "vcard30" ) {
mDiffAlgo = new KSync::AddresseeDiffAlgo( leftChange.data(), rightChange.data() );
+ } else if ( format == "calendar" ) {
+ } else if ( format == "xmlformat-contact" || format == "xmlformat-note"
+ || format == "xmlformat-event" || format == "xmlformat-todo") {
+ mDiffAlgo = new KSync::XmlDiffAlgo( leftChange.data(), rightChange.data() );
}
+// TODO: SyncChange doesn't have member as struct member anymore ...
+// Use SyncMapping to determine the member .. see msynctool for example implementation of conlicthandler
+#if 0
MemberInfo miLeft( leftChange.member() );
mDiffAlgoDisplay->setLeftSourceTitle( miLeft.name() );
MemberInfo miRight( rightChange.member() );
mDiffAlgoDisplay->setRightSourceTitle( miRight.name() );
+#endif
if ( mDiffAlgo ) {
mDiffAlgo->addDisplay( mDiffAlgoDisplay );
@@ -99,6 +106,7 @@ void SingleConflictDialog::initGUI()
TQGridLayout *layout = new TQGridLayout( this, 3, 4, KDialog::marginHint(), KDialog::spacingHint() );
layout->addMultiCellWidget( new TQLabel( i18n( "A conflict has appeared, please solve it manually." ), this ), 0, 0, 0, 3 );
+
mDiffAlgoDisplay = new KSync::HTMLDiffAlgoDisplay( this );
layout->addMultiCellWidget( mDiffAlgoDisplay, 1, 1, 0, 3 );
diff --git a/kitchensync/src/syncprocess.cpp b/kitchensync/src/syncprocess.cpp
index 60310b803..2ff93bcd4 100644
--- a/kitchensync/src/syncprocess.cpp
+++ b/kitchensync/src/syncprocess.cpp
@@ -19,10 +19,12 @@
*/
#include <libqopensync/engine.h>
-#include <libqopensync/environment.h>
+#include <libqopensync/member.h>
+#include <libqopensync/result.h>
#include <kdebug.h>
#include <klocale.h>
+#include <kmessagebox.h>
#include "syncprocess.h"
#include "syncprocessmanager.h"
@@ -60,8 +62,8 @@ TQString SyncProcess::memberStatus( const QSync::Member& ) const
QSync::Result SyncProcess::addMember( const QSync::Plugin &plugin )
{
- QSync::Member member = mGroup.addMember();
- QSync::Result result = member.instance( plugin );
+ QSync::Member member = mGroup.addMember( plugin );
+ QSync::Result result = member.instance();
if ( !result.isError() )
mGroup.save();
@@ -69,40 +71,27 @@ QSync::Result SyncProcess::addMember( const QSync::Plugin &plugin )
return result;
}
+void SyncProcess::removeMember( const QSync::Member &member )
+{
+ member.cleanup();
+ mGroup.removeMember( member );
+ mGroup.save();
+}
+
void SyncProcess::reinitEngine()
{
mEngine->finalize();
delete mEngine;
mEngine = new QSync::Engine( mGroup );
Result result = mEngine->initialize();
- if ( result.isError() )
+ if ( result.isError() ) {
kdDebug() << "SyncProcess::reinitEngine: " << result.message() << endl;
+ KMessageBox::error( 0, i18n("Error initializing Synchronization Engine for group \"%1\":\n %2")
+ .arg( mGroup.name() ).arg( result.message() ) );
- applyObjectTypeFilter();
+ }
emit engineChanged( mEngine );
}
-void SyncProcess::applyObjectTypeFilter()
-{
- const QSync::Conversion conversion = SyncProcessManager::self()->environment()->conversion();
- const TQStringList objectTypes = conversion.objectTypes();
- const TQStringList activeObjectTypes = mGroup.config().activeObjectTypes();
-
- for ( uint i = 0; i < objectTypes.count(); ++i ) {
- if ( activeObjectTypes.contains( objectTypes[ i ] ) ) {
- kdDebug() << "Enabled object type: " << objectTypes[ i ] << endl;
- /*
- * This is not required. Also this lead to filtering problems when sync with "file-sync".
- * Uncomment this line again when OpenSync is fixed!
- *
- * mGroup.setObjectTypeEnabled( objectTypes[ i ], true );
- */
- } else {
- kdDebug() << "Disabled object type: " << objectTypes[ i ] << endl;
- mGroup.setObjectTypeEnabled( objectTypes[ i ], false );
- }
- }
-}
-
#include "syncprocess.moc"
diff --git a/kitchensync/src/syncprocess.h b/kitchensync/src/syncprocess.h
index ef23f7c52..6cdefc408 100644
--- a/kitchensync/src/syncprocess.h
+++ b/kitchensync/src/syncprocess.h
@@ -44,12 +44,10 @@ class SyncProcess : public QObject
TQString memberStatus( const QSync::Member &member ) const;
QSync::Result addMember( const QSync::Plugin &plugin );
+ void removeMember( const QSync::Member &member );
void reinitEngine();
- /** apply object type filter hack **/
- void applyObjectTypeFilter();
-
signals:
/**
This signal is emitted whenever the engine has changed ( reinitialized ).
diff --git a/kitchensync/src/syncprocessmanager.cpp b/kitchensync/src/syncprocessmanager.cpp
index fda111efd..27e09a25e 100644
--- a/kitchensync/src/syncprocessmanager.cpp
+++ b/kitchensync/src/syncprocessmanager.cpp
@@ -23,7 +23,10 @@
#include "syncprocess.h"
-#include <libqopensync/environment.h>
+#include <libqopensync/groupenv.h>
+#include <libqopensync/member.h>
+#include <libqopensync/pluginenv.h>
+#include <libqopensync/result.h>
#include <kstaticdeleter.h>
#include <kmessagebox.h>
@@ -43,14 +46,24 @@ SyncProcessManager *SyncProcessManager::self()
SyncProcessManager::SyncProcessManager()
{
- mEnvironment = new QSync::Environment;
- QSync::Result result = mEnvironment->initialize();
+ mGroupEnv = new QSync::GroupEnv;
+ QSync::Result result = mGroupEnv->initialize();
if ( result.isError() ) {
KMessageBox::error( 0, i18n("Error initializing OpenSync.\n%1")
.arg( result.message() ) );
} else {
- init( mEnvironment );
+ initGroup( mGroupEnv );
}
+
+ mPluginEnv = new QSync::PluginEnv;
+ result = mPluginEnv->initialize();
+ if ( result.isError() ) {
+ KMessageBox::error( 0, i18n("Error initializing OpenSync.\n%1")
+ .arg( result.message() ) );
+ } else {
+// initPlugin( mPluginEnv );
+ }
+
}
SyncProcessManager::~SyncProcessManager()
@@ -61,8 +74,8 @@ SyncProcessManager::~SyncProcessManager()
mProcesses.clear();
- mEnvironment->finalize();
- delete mEnvironment;
+ mGroupEnv->finalize();
+ delete mGroupEnv;
}
int SyncProcessManager::count() const
@@ -102,8 +115,7 @@ void SyncProcessManager::addGroup( const TQString &name )
{
SyncProcess* process = byGroupName( name );
if ( !process ) {
- QSync::Group group = mEnvironment->addGroup();
- group.setName( name );
+ QSync::Group group = mGroupEnv->addGroup( name );
group.save();
mProcesses.append( new SyncProcess( group ) );
@@ -120,22 +132,21 @@ void SyncProcessManager::remove( SyncProcess *syncProcess )
const QSync::Group group = syncProcess->group();
delete syncProcess;
- mEnvironment->removeGroup( group );
+ mGroupEnv->removeGroup( group );
emit changed();
}
}
-void SyncProcessManager::init( QSync::Environment *environment )
+void SyncProcessManager::initGroup( QSync::GroupEnv *groupEnv )
{
- QSync::Environment::GroupIterator it( environment->groupBegin() );
- for ( ; it != environment->groupEnd(); ++it ) {
+ for ( int i = 0; i < groupEnv->groupCount(); ++i ) {
/**
* We check whether the group is valid before we append them
* to mProcesses. That avoids crashes if the plugin of one of
* the members isn't loaded (e.g. not installed).
*/
- const QSync::Group group = *it;
+ const QSync::Group group = groupEnv->groupAt( i );
int count = group.memberCount();
bool isValid = true;
@@ -149,7 +160,7 @@ void SyncProcessManager::init( QSync::Environment *environment )
}
if ( isValid )
- mProcesses.append( new SyncProcess( *it ) );
+ mProcesses.append( new SyncProcess( group ) );
}
emit changed();
@@ -169,4 +180,13 @@ QSync::Result SyncProcessManager::addMember( SyncProcess *process,
return result;
}
+void SyncProcessManager::removeMember( SyncProcess *process, const QSync::Member &member )
+{
+ Q_ASSERT( process );
+
+ process->removeMember( member );
+ process->group().save();
+ emit syncProcessChanged( process );
+}
+
#include "syncprocessmanager.moc"
diff --git a/kitchensync/src/syncprocessmanager.h b/kitchensync/src/syncprocessmanager.h
index b95018a84..38004977d 100644
--- a/kitchensync/src/syncprocessmanager.h
+++ b/kitchensync/src/syncprocessmanager.h
@@ -26,7 +26,8 @@
#include <libqopensync/group.h>
namespace QSync {
-class Environment;
+class GroupEnv;
+class PluginEnv;
}
class SyncProcess;
@@ -43,9 +44,14 @@ class SyncProcessManager : public QObject
~SyncProcessManager();
/**
- Return OpenSync Environment.
+ Return OpenSync GroupEnv.
*/
- QSync::Environment *environment() const { return mEnvironment; }
+ QSync::GroupEnv *groupEnv() const { return mGroupEnv; }
+
+ /**
+ Return OpenSync PluginEnv.
+ */
+ QSync::PluginEnv *pluginEnv() const { return mPluginEnv; }
/**
Returns the number of SyncProcesses.
@@ -82,6 +88,11 @@ class SyncProcessManager : public QObject
*/
QSync::Result addMember( SyncProcess *process, const QSync::Plugin &plugin );
+ /**
+ Removes the @param member from the group of @param process.
+ */
+ void removeMember( SyncProcess *process, const QSync::Member &member );
+
signals:
void changed();
void syncProcessChanged( SyncProcess *process );
@@ -89,10 +100,12 @@ class SyncProcessManager : public QObject
private:
SyncProcessManager();
- void init( QSync::Environment *environment );
+ void initGroup( QSync::GroupEnv *groupEnv );
+// void initPlugin( QSync::PluginEnv *pluginEnv );
TQValueList<SyncProcess*> mProcesses;
- QSync::Environment *mEnvironment;
+ QSync::GroupEnv *mGroupEnv;
+ QSync::PluginEnv *mPluginEnv;
static SyncProcessManager *mSelf;
};
diff --git a/kitchensync/src/xmldiffalgo.cpp b/kitchensync/src/xmldiffalgo.cpp
new file mode 100644
index 000000000..b5f4890fc
--- /dev/null
+++ b/kitchensync/src/xmldiffalgo.cpp
@@ -0,0 +1,166 @@
+/*
+ This file is part of KitchenSync.
+
+ Copyright (c) 2006 Daniel Gollub <dgollub@suse.de>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "xmldiffalgo.h"
+
+#include <kdebug.h>
+
+using namespace KSync;
+
+#ifndef KDE_USE_FINAL
+// With --enable-final, we get the (identical) compareString from
+// addresseediffalgo.cpp
+//
+static bool compareString( const TQString &left, const TQString &right )
+{
+ if ( left.isEmpty() && right.isEmpty() )
+ return true;
+ else
+ return left == right;
+}
+#endif
+
+XmlDiffAlgo::XmlDiffAlgo( const TQString &leftXml, const TQString &rightXml )
+{
+ kdDebug() << __func__ << " " << __LINE__ << endl;
+
+ mLeftXml.setContent( leftXml );
+ mRightXml.setContent( rightXml );
+
+}
+
+XmlDiffAlgo::XmlDiffAlgo( const TQDomDocument &leftXml, const TQDomDocument &rightXml )
+ : mLeftXml( leftXml ), mRightXml( rightXml )
+{
+ kdDebug() << __func__ << " " << __LINE__ << endl;
+}
+
+void XmlDiffAlgo::appendSingleNodes(TQDomElement &element, bool isLeft)
+{
+ TQDomNode node;
+
+ for ( node = element.firstChild(); !node.isNull(); node = node.nextSibling() ) {
+ TQDomElement child = node.toElement();
+
+ if (isLeft)
+ additionalLeftField( node.nodeName(), child.text() );
+ else
+ additionalRightField( node.nodeName(), child.text() );
+ }
+
+}
+
+void XmlDiffAlgo::appendConflictNodes(TQDomElement &leftElement, TQDomElement &rightElement)
+{
+ TQDomNode left, right;
+ TQDomElement leftChild, rightChild;
+
+ for ( left = leftElement.firstChild(); !left.isNull(); left = left.nextSibling() ) {
+ leftChild = left.toElement();
+
+ for ( right = rightElement.firstChild(); !right.isNull(); right = right.nextSibling() ) {
+ rightChild = right.toElement();
+
+ if ( leftChild.tagName() != rightChild.tagName() )
+ continue;
+
+ if (leftChild.text().isEmpty() || rightChild.text().isEmpty())
+ continue;
+
+ TQString id = leftChild.tagName();
+ if (id == "Content")
+ id = left.parentNode().nodeName();
+
+ conflictField( id, leftChild.text(), rightChild.text() );
+
+ left.parentNode().removeChild( left );
+ left = leftElement.firstChild();
+
+ right.parentNode().removeChild( right );
+ right = rightElement.firstChild();
+
+ }
+ }
+}
+
+void XmlDiffAlgo::compareNode(TQDomElement &leftElement, TQDomElement &rightElement)
+{
+ TQDomNode left, right;
+ TQDomElement leftChild, rightChild;
+ TQDomNodeList nlist;
+top:;
+
+ for ( left = leftElement.firstChild(); !left.isNull(); left = left.nextSibling() ) {
+ leftChild = left.toElement();
+
+ for ( right = rightElement.firstChild(); !right.isNull(); right = right.nextSibling() ) {
+ rightChild = right.toElement();
+
+ if (leftChild.tagName() != rightChild.tagName())
+ continue;
+
+ if ( left.childNodes().count() > 1 && right.childNodes().count() > 1 ) {
+ compareNode( leftChild, rightChild );
+
+ if ( !left.hasChildNodes() && !right.hasChildNodes() ) {
+ left.parentNode().removeChild( left );
+ right.parentNode().removeChild( right );
+ goto top;
+ }
+
+ break;
+ }
+
+ if ( leftChild.text() == rightChild.text() ) {
+ TQString id = leftChild.tagName();
+
+ if ( id == "Content" )
+ id = left.parentNode().nodeName();
+
+ if ( id != "Type" )
+ //matchingField( id, leftChild.text(), rightChild.text() );
+
+ left.parentNode().removeChild( left );
+ right.parentNode().removeChild( right );
+ goto top;
+ }
+ }
+ }
+
+ appendConflictNodes(rightElement, leftElement);
+
+ appendSingleNodes(rightElement, false);
+ appendSingleNodes(leftElement, true);
+}
+
+void XmlDiffAlgo::run()
+{
+ kdDebug() << __func__ << endl;
+ begin();
+
+ TQDomElement leftElement = mLeftXml.documentElement();
+ TQDomElement rightElement = mRightXml.documentElement();
+
+ compareNode( leftElement, rightElement );
+
+ end();
+}
+
diff --git a/kitchensync/src/xmldiffalgo.h b/kitchensync/src/xmldiffalgo.h
new file mode 100644
index 000000000..f1f21d3f4
--- /dev/null
+++ b/kitchensync/src/xmldiffalgo.h
@@ -0,0 +1,54 @@
+/*
+ This file is part of KitchenSync
+
+ Copyright (c) 2006 Daniel Gollub <dgollub@suse.de>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KSYNC_XMLDIFFALGO_H
+#define KSYNC_XMLDIFFALGO_H
+
+#include <tqdom.h>
+
+#include <libkdepim/diffalgo.h>
+
+using namespace KPIM;
+
+namespace KSync {
+
+class XmlDiffAlgo : public DiffAlgo
+{
+ public:
+ XmlDiffAlgo( const TQString &leftXml, const TQString &rightXml );
+ XmlDiffAlgo( const TQDomDocument &leftXml, const TQDomDocument &rightXml );
+
+ void run();
+
+ private:
+ void appendConflictNodes(TQDomElement &leftElement, TQDomElement &rightElement);
+ void appendSingleNodes(TQDomElement &element, bool isLeft);
+
+
+ void compareNode(TQDomElement &leftElement, TQDomElement &rightElement);
+
+ TQDomDocument mLeftXml;
+ TQDomDocument mRightXml;
+};
+
+}
+
+#endif