00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <libqopensync/engine.h>
00022 #include <libqopensync/environment.h>
00023
00024 #include <kdebug.h>
00025 #include <tdelocale.h>
00026
00027 #include "syncprocess.h"
00028 #include "syncprocessmanager.h"
00029
00030 using namespace QSync;
00031
00032 SyncProcess::SyncProcess( const QSync::Group &group )
00033 : TQObject( 0, "SyncProcess" )
00034 {
00035 mGroup = group;
00036 mEngine = new QSync::Engine( mGroup );
00037
00038 Result result = mEngine->initialize();
00039 if ( result.isError() )
00040 kdDebug() << "SyncProcess::SyncProcess: " << result.message() << endl;
00041 }
00042
00043 SyncProcess::~SyncProcess()
00044 {
00045 mEngine->finalize();
00046
00047 delete mEngine;
00048 mEngine = 0;
00049 }
00050
00051 TQString SyncProcess::groupStatus() const
00052 {
00053 return i18n( "Ready" );
00054 }
00055
00056 TQString SyncProcess::memberStatus( const QSync::Member& ) const
00057 {
00058 return i18n( "Ready" );
00059 }
00060
00061 QSync::Result SyncProcess::addMember( const QSync::Plugin &plugin )
00062 {
00063 QSync::Member member = mGroup.addMember();
00064 QSync::Result result = member.instance( plugin );
00065
00066 if ( !result.isError() )
00067 mGroup.save();
00068
00069 return result;
00070 }
00071
00072 void SyncProcess::reinitEngine()
00073 {
00074 mEngine->finalize();
00075 delete mEngine;
00076 mEngine = new QSync::Engine( mGroup );
00077 Result result = mEngine->initialize();
00078 if ( result.isError() )
00079 kdDebug() << "SyncProcess::reinitEngine: " << result.message() << endl;
00080
00081 applyObjectTypeFilter();
00082
00083 emit engineChanged( mEngine );
00084 }
00085
00086 void SyncProcess::applyObjectTypeFilter()
00087 {
00088 const QSync::Conversion conversion = SyncProcessManager::self()->environment()->conversion();
00089 const TQStringList objectTypes = conversion.objectTypes();
00090 const TQStringList activeObjectTypes = mGroup.config().activeObjectTypes();
00091
00092 for ( uint i = 0; i < objectTypes.count(); ++i ) {
00093 if ( activeObjectTypes.contains( objectTypes[ i ] ) ) {
00094 kdDebug() << "Enabled object type: " << objectTypes[ i ] << endl;
00095
00096
00097
00098
00099
00100
00101 } else {
00102 kdDebug() << "Disabled object type: " << objectTypes[ i ] << endl;
00103 mGroup.setObjectTypeEnabled( objectTypes[ i ], false );
00104 }
00105 }
00106 }
00107
00108 #include "syncprocess.moc"