summaryrefslogtreecommitdiffstats
path: root/kitchensync/src/syncprocessmanager.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-07 22:30:29 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-07 22:30:29 +0000
commitd8b40941f9d1a221add0b9094eb09405a91a8aab (patch)
tree0b8e9b6347f6e75925bb3c386a47c5300b1a4775 /kitchensync/src/syncprocessmanager.cpp
parent009631d0fc83f471d6c515e2a5001337a5a2ea21 (diff)
downloadtdepim-d8b40941f9d1a221add0b9094eb09405a91a8aab.tar.gz
tdepim-d8b40941f9d1a221add0b9094eb09405a91a8aab.zip
Part 2/2 of Chakra patch commit
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1172727 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kitchensync/src/syncprocessmanager.cpp')
-rw-r--r--kitchensync/src/syncprocessmanager.cpp48
1 files changed, 34 insertions, 14 deletions
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"