00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "agentbase.h"
00024 #include "agentbase_p.h"
00025
00026 #include "changerecorder.h"
00027 #include "controladaptor.h"
00028 #include "itemfetchjob.h"
00029 #include "monitor_p.h"
00030 #include "servermanager_p.h"
00031 #include "session.h"
00032 #include "session_p.h"
00033 #include "statusadaptor.h"
00034 #include "xdgbasedirs_p.h"
00035
00036 #include <kaboutdata.h>
00037 #include <kcmdlineargs.h>
00038 #include <kdebug.h>
00039 #include <klocale.h>
00040 #include <kstandarddirs.h>
00041
00042 #include <QtCore/QDir>
00043 #include <QtCore/QSettings>
00044 #include <QtCore/QTimer>
00045 #include <QtDBus/QtDBus>
00046 #include <QtGui/QApplication>
00047
00048 #include <signal.h>
00049 #include <stdlib.h>
00050
00051 using namespace Akonadi;
00052
00053 static AgentBase *sAgentBase = 0;
00054
00055 AgentBase::Observer::Observer()
00056 {
00057 }
00058
00059 AgentBase::Observer::~Observer()
00060 {
00061 }
00062
00063 void AgentBase::Observer::itemAdded( const Item &item, const Collection &collection )
00064 {
00065 Q_UNUSED( item );
00066 Q_UNUSED( collection );
00067 if ( sAgentBase != 0 )
00068 sAgentBase->d_ptr->changeProcessed();
00069 }
00070
00071 void AgentBase::Observer::itemChanged( const Item &item, const QSet<QByteArray> &partIdentifiers )
00072 {
00073 Q_UNUSED( item );
00074 Q_UNUSED( partIdentifiers );
00075 if ( sAgentBase != 0 )
00076 sAgentBase->d_ptr->changeProcessed();
00077 }
00078
00079 void AgentBase::Observer::itemRemoved( const Item &item )
00080 {
00081 Q_UNUSED( item );
00082 if ( sAgentBase != 0 )
00083 sAgentBase->d_ptr->changeProcessed();
00084 }
00085
00086 void AgentBase::Observer::collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent )
00087 {
00088 Q_UNUSED( collection );
00089 Q_UNUSED( parent );
00090 if ( sAgentBase != 0 )
00091 sAgentBase->d_ptr->changeProcessed();
00092 }
00093
00094 void AgentBase::Observer::collectionChanged( const Collection &collection )
00095 {
00096 Q_UNUSED( collection );
00097 if ( sAgentBase != 0 )
00098 sAgentBase->d_ptr->changeProcessed();
00099 }
00100
00101 void AgentBase::Observer::collectionRemoved( const Collection &collection )
00102 {
00103 Q_UNUSED( collection );
00104 if ( sAgentBase != 0 )
00105 sAgentBase->d_ptr->changeProcessed();
00106 }
00107
00108 void AgentBase::ObserverV2::itemMoved( const Akonadi::Item &item, const Akonadi::Collection &source, const Akonadi::Collection &dest )
00109 {
00110 Q_UNUSED( item );
00111 Q_UNUSED( source );
00112 Q_UNUSED( dest );
00113 if ( sAgentBase != 0 )
00114 sAgentBase->d_ptr->changeProcessed();
00115 }
00116
00117 void AgentBase::ObserverV2::itemLinked( const Akonadi::Item& item, const Akonadi::Collection& collection )
00118 {
00119 Q_UNUSED( item );
00120 Q_UNUSED( collection );
00121 if ( sAgentBase != 0 )
00122 sAgentBase->d_ptr->changeProcessed();
00123 }
00124
00125 void AgentBase::ObserverV2::itemUnlinked( const Akonadi::Item& item, const Akonadi::Collection& collection )
00126 {
00127 Q_UNUSED( item );
00128 Q_UNUSED( collection );
00129 if ( sAgentBase != 0 )
00130 sAgentBase->d_ptr->changeProcessed();
00131 }
00132
00133 void AgentBase::ObserverV2::collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &dest )
00134 {
00135 Q_UNUSED( collection );
00136 Q_UNUSED( source );
00137 Q_UNUSED( dest );
00138 if ( sAgentBase != 0 )
00139 sAgentBase->d_ptr->changeProcessed();
00140 }
00141
00142 void AgentBase::ObserverV2::collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &partIdentifiers )
00143 {
00144 Q_UNUSED( partIdentifiers );
00145 collectionChanged( collection );
00146 }
00147
00148
00149
00150 AgentBasePrivate::AgentBasePrivate( AgentBase *parent )
00151 : q_ptr( parent ),
00152 mStatusCode( AgentBase::Idle ),
00153 mProgress( 0 ),
00154 mNeedsNetwork( false ),
00155 mOnline( false ),
00156 mSettings( 0 ),
00157 mObserver( 0 )
00158 {
00159 Internal::setClientType( Internal::Agent );
00160 }
00161
00162 AgentBasePrivate::~AgentBasePrivate()
00163 {
00164 mChangeRecorder->setConfig( 0 );
00165 delete mSettings;
00166 }
00167
00168 void AgentBasePrivate::init()
00169 {
00170 Q_Q( AgentBase );
00171
00175 SessionPrivate::createDefaultSession( mId.toLatin1() );
00176
00177 mTracer = new org::freedesktop::Akonadi::Tracer( QLatin1String( "org.freedesktop.Akonadi" ), QLatin1String( "/tracing" ),
00178 QDBusConnection::sessionBus(), q );
00179
00180 new Akonadi__ControlAdaptor( q );
00181 new Akonadi__StatusAdaptor( q );
00182 if ( !QDBusConnection::sessionBus().registerObject( QLatin1String( "/" ), q, QDBusConnection::ExportAdaptors ) )
00183 q->error( QString::fromLatin1( "Unable to register object at dbus: %1" ).arg( QDBusConnection::sessionBus().lastError().message() ) );
00184
00185 mSettings = new QSettings( QString::fromLatin1( "%1/agent_config_%2" ).arg( XdgBaseDirs::saveDir( "config", QLatin1String( "akonadi" ) ), mId ), QSettings::IniFormat );
00186
00187 mChangeRecorder = new ChangeRecorder( q );
00188 mChangeRecorder->ignoreSession( Session::defaultSession() );
00189 mChangeRecorder->itemFetchScope().setCacheOnly( true );
00190 mChangeRecorder->setConfig( mSettings );
00191
00192 mOnline = mSettings->value( QLatin1String( "Agent/Online" ), true ).toBool();
00193
00194
00195 mStatusMessage = defaultReadyMessage();
00196
00197 mName = mSettings->value( QLatin1String( "Agent/Name" ) ).toString();
00198 if ( mName.isEmpty() ) {
00199 mName = mSettings->value( QLatin1String( "Resource/Name" ) ).toString();
00200 if ( !mName.isEmpty() ) {
00201 mSettings->remove( QLatin1String( "Resource/Name" ) );
00202 mSettings->setValue( QLatin1String( "Agent/Name" ), mName );
00203 }
00204 }
00205
00206 connect( mChangeRecorder, SIGNAL( itemAdded( const Akonadi::Item&, const Akonadi::Collection& ) ),
00207 SLOT( itemAdded( const Akonadi::Item&, const Akonadi::Collection& ) ) );
00208 connect( mChangeRecorder, SIGNAL( itemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) ),
00209 SLOT( itemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) ) );
00210 connect( mChangeRecorder, SIGNAL( itemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& ) ),
00211 SLOT( itemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& ) ) );
00212 connect( mChangeRecorder, SIGNAL( itemRemoved( const Akonadi::Item& ) ),
00213 SLOT( itemRemoved( const Akonadi::Item& ) ) );
00214 connect( mChangeRecorder, SIGNAL( collectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ) ),
00215 SLOT( collectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ) ) );
00216 connect( mChangeRecorder, SIGNAL( itemLinked( const Akonadi::Item&, const Akonadi::Collection& ) ),
00217 SLOT( itemLinked( const Akonadi::Item&, const Akonadi::Collection& ) ) );
00218 connect( mChangeRecorder, SIGNAL( itemUnlinked( const Akonadi::Item&, const Akonadi::Collection& ) ),
00219 SLOT( itemUnlinked( const Akonadi::Item&, const Akonadi::Collection& ) ) );
00220 connect( mChangeRecorder, SIGNAL( collectionChanged( const Akonadi::Collection& ) ),
00221 SLOT( collectionChanged( const Akonadi::Collection& ) ) );
00222 connect( mChangeRecorder, SIGNAL( collectionChanged( const Akonadi::Collection&, const QSet<QByteArray>& ) ),
00223 SLOT( collectionChanged( const Akonadi::Collection&, const QSet<QByteArray>& ) ) );
00224 connect( mChangeRecorder, SIGNAL( collectionMoved( const Akonadi::Collection&, const Akonadi::Collection&, const Akonadi::Collection& ) ),
00225 SLOT( collectionMoved( const Akonadi::Collection&, const Akonadi::Collection&, const Akonadi::Collection& ) ) );
00226 connect( mChangeRecorder, SIGNAL( collectionRemoved( const Akonadi::Collection& ) ),
00227 SLOT( collectionRemoved( const Akonadi::Collection& ) ) );
00228
00229 connect( q, SIGNAL( status( int, const QString& ) ), q, SLOT( slotStatus( int, const QString& ) ) );
00230 connect( q, SIGNAL( percent( int ) ), q, SLOT( slotPercent( int ) ) );
00231 connect( q, SIGNAL( warning( const QString& ) ), q, SLOT( slotWarning( const QString& ) ) );
00232 connect( q, SIGNAL( error( const QString& ) ), q, SLOT( slotError( const QString& ) ) );
00233
00234
00235
00236 KGlobal::ref();
00237 KGlobal::setAllowQuit( true );
00238
00239
00240 if ( KApplication::kApplication() )
00241 KApplication::kApplication()->disableSessionManagement();
00242
00243 QTimer::singleShot( 0, q, SLOT( delayedInit() ) );
00244 }
00245
00246 void AgentBasePrivate::delayedInit()
00247 {
00248 Q_Q( AgentBase );
00249 if ( !QDBusConnection::sessionBus().registerService( QLatin1String( "org.freedesktop.Akonadi.Agent." ) + mId ) )
00250 kFatal() << "Unable to register service at dbus:" << QDBusConnection::sessionBus().lastError().message();
00251 q->setOnline( mOnline );
00252 }
00253
00254 void AgentBasePrivate::itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection )
00255 {
00256 if ( mObserver != 0 )
00257 mObserver->itemAdded( item, collection );
00258 }
00259
00260 void AgentBasePrivate::itemChanged( const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers )
00261 {
00262 if ( mObserver != 0 )
00263 mObserver->itemChanged( item, partIdentifiers );
00264 }
00265
00266 void AgentBasePrivate::itemMoved( const Akonadi::Item &item, const Akonadi::Collection &source, const Akonadi::Collection &dest )
00267 {
00268 AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
00269 if ( mObserver ) {
00270
00271 if ( !source.resource().isEmpty() && !dest.resource().isEmpty() ) {
00272 if ( source.resource() != dest.resource() ) {
00273 if ( source.resource() == q_ptr->identifier() ) {
00274 Akonadi::Item i( item );
00275 i.setParentCollection( source );
00276 mObserver->itemRemoved( i );
00277 }
00278 else if ( dest.resource() == q_ptr->identifier() )
00279 mObserver->itemAdded( item, dest );
00280 else if ( observer2 )
00281 observer2->itemMoved( item, source, dest );
00282 else
00283
00284 changeProcessed();
00285 return;
00286 }
00287 }
00288
00289 if ( observer2 ) {
00290 observer2->itemMoved( item, source, dest );
00291 } else {
00292
00293
00294
00295 mObserver->itemAdded( item, dest );
00296
00297 }
00298 }
00299 }
00300
00301 void AgentBasePrivate::itemRemoved( const Akonadi::Item &item )
00302 {
00303 if ( mObserver != 0 )
00304 mObserver->itemRemoved( item );
00305 }
00306
00307 void AgentBasePrivate::itemLinked( const Akonadi::Item &item, const Akonadi::Collection &collection )
00308 {
00309 AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
00310 if ( observer2 )
00311 observer2->itemLinked( item, collection );
00312 else
00313 changeProcessed();
00314 }
00315
00316 void AgentBasePrivate::itemUnlinked( const Akonadi::Item &item, const Akonadi::Collection &collection )
00317 {
00318 AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
00319 if ( observer2 )
00320 observer2->itemUnlinked( item, collection );
00321 else
00322 changeProcessed();
00323 }
00324
00325 void AgentBasePrivate::collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent )
00326 {
00327 if ( mObserver != 0 )
00328 mObserver->collectionAdded( collection, parent );
00329 }
00330
00331 void AgentBasePrivate::collectionChanged( const Akonadi::Collection &collection )
00332 {
00333 AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
00334 if ( mObserver != 0 && observer2 == 0 )
00335 mObserver->collectionChanged( collection );
00336 }
00337
00338 void AgentBasePrivate::collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &partIdentifiers )
00339 {
00340 AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
00341 if ( observer2 != 0 )
00342 observer2->collectionChanged( collection, partIdentifiers );
00343 }
00344
00345 void AgentBasePrivate::collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &dest )
00346 {
00347 AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
00348 if ( mObserver ) {
00349
00350 if ( !source.resource().isEmpty() && !dest.resource().isEmpty() ) {
00351 if ( source.resource() != dest.resource() ) {
00352 if ( source.resource() == q_ptr->identifier() )
00353 mObserver->collectionRemoved( collection );
00354 else if ( dest.resource() == q_ptr->identifier() )
00355 mObserver->collectionAdded( collection, dest );
00356 else if ( observer2 )
00357 observer2->collectionMoved( collection, source, dest );
00358 else
00359 changeProcessed();
00360 return;
00361 }
00362 }
00363
00364 if ( observer2 ) {
00365 observer2->collectionMoved( collection, source, dest );
00366 } else {
00367
00368
00369
00370 mObserver->collectionAdded( collection, dest );
00371 }
00372 }
00373 }
00374
00375 void AgentBasePrivate::collectionRemoved( const Akonadi::Collection &collection )
00376 {
00377 if ( mObserver != 0 )
00378 mObserver->collectionRemoved( collection );
00379 }
00380
00381 void AgentBasePrivate::changeProcessed()
00382 {
00383 mChangeRecorder->changeProcessed();
00384 QTimer::singleShot( 0, mChangeRecorder, SLOT( replayNext() ) );
00385 }
00386
00387 void AgentBasePrivate::slotStatus( int status, const QString &message )
00388 {
00389 mStatusMessage = message;
00390 mStatusCode = 0;
00391
00392 switch ( status ) {
00393 case AgentBase::Idle:
00394 if ( mStatusMessage.isEmpty() )
00395 mStatusMessage = defaultReadyMessage();
00396
00397 mStatusCode = 0;
00398 break;
00399 case AgentBase::Running:
00400 if ( mStatusMessage.isEmpty() )
00401 mStatusMessage = defaultSyncingMessage();
00402
00403 mStatusCode = 1;
00404 break;
00405 case AgentBase::Broken:
00406 if ( mStatusMessage.isEmpty() )
00407 mStatusMessage = defaultErrorMessage();
00408
00409 mStatusCode = 2;
00410 break;
00411 default:
00412 Q_ASSERT( !"Unknown status passed" );
00413 break;
00414 }
00415 }
00416
00417 void AgentBasePrivate::slotPercent( int progress )
00418 {
00419 mProgress = progress;
00420 }
00421
00422 void AgentBasePrivate::slotWarning( const QString& message )
00423 {
00424 mTracer->warning( QString::fromLatin1( "AgentBase(%1)" ).arg( mId ), message );
00425 }
00426
00427 void AgentBasePrivate::slotError( const QString& message )
00428 {
00429 mTracer->error( QString::fromLatin1( "AgentBase(%1)" ).arg( mId ), message );
00430 }
00431
00432 void AgentBasePrivate::slotNetworkStatusChange( Solid::Networking::Status stat )
00433 {
00434 Q_Q( AgentBase );
00435 q->setOnline( stat == Solid::Networking::Unknown || stat == Solid::Networking::Connected );
00436 }
00437
00438
00439 AgentBase::AgentBase( const QString & id )
00440 : d_ptr( new AgentBasePrivate( this ) )
00441 {
00442 sAgentBase = this;
00443 d_ptr->mId = id;
00444 d_ptr->init();
00445 }
00446
00447 AgentBase::AgentBase( AgentBasePrivate* d, const QString &id ) :
00448 d_ptr( d )
00449 {
00450 sAgentBase = this;
00451 d_ptr->mId = id;
00452 d_ptr->init();
00453 }
00454
00455 AgentBase::~AgentBase()
00456 {
00457 delete d_ptr;
00458 }
00459
00460 QString AgentBase::parseArguments( int argc, char **argv )
00461 {
00462 QString identifier;
00463 if ( argc < 3 ) {
00464 kDebug() << "Not enough arguments passed...";
00465 exit( 1 );
00466 }
00467
00468 for ( int i = 1; i < argc - 1; ++i ) {
00469 if ( QLatin1String( argv[ i ] ) == QLatin1String( "--identifier" ) )
00470 identifier = QLatin1String( argv[ i + 1 ] );
00471 }
00472
00473 if ( identifier.isEmpty() ) {
00474 kDebug() << "Identifier argument missing";
00475 exit( 1 );
00476 }
00477
00478 QByteArray catalog;
00479 char *p = strrchr( argv[0], '/' );
00480 if ( p )
00481 catalog = QByteArray( p + 1 );
00482 else
00483 catalog = QByteArray( argv[0] );
00484
00485 KCmdLineArgs::init( argc, argv, identifier.toLatin1(), catalog, ki18n( "Akonadi Agent" ), "0.1",
00486 ki18n( "Akonadi Agent" ) );
00487
00488 KCmdLineOptions options;
00489 options.add( "identifier <argument>", ki18n( "Agent identifier" ) );
00490 KCmdLineArgs::addCmdLineOptions( options );
00491
00492 return identifier;
00493 }
00494
00495
00496
00497 int AgentBase::init( AgentBase *r )
00498 {
00499 QApplication::setQuitOnLastWindowClosed( false );
00500 KGlobal::locale()->insertCatalog( QLatin1String( "libakonadi" ) );
00501 int rv = kapp->exec();
00502 delete r;
00503 return rv;
00504 }
00505
00506 int AgentBase::status() const
00507 {
00508 Q_D( const AgentBase );
00509
00510 return d->mStatusCode;
00511 }
00512
00513 QString AgentBase::statusMessage() const
00514 {
00515 Q_D( const AgentBase );
00516
00517 return d->mStatusMessage;
00518 }
00519
00520 int AgentBase::progress() const
00521 {
00522 Q_D( const AgentBase );
00523
00524 return d->mProgress;
00525 }
00526
00527 QString AgentBase::progressMessage() const
00528 {
00529 Q_D( const AgentBase );
00530
00531 return d->mProgressMessage;
00532 }
00533
00534 bool AgentBase::isOnline() const
00535 {
00536 Q_D( const AgentBase );
00537
00538 return d->mOnline;
00539 }
00540
00541 void AgentBase::setNeedsNetwork( bool needsNetwork )
00542 {
00543 Q_D( AgentBase );
00544 d->mNeedsNetwork = needsNetwork;
00545
00546 if ( d->mNeedsNetwork ) {
00547 connect( Solid::Networking::notifier()
00548 , SIGNAL( statusChanged( Solid::Networking::Status ) )
00549 , this, SLOT( slotNetworkStatusChange( Solid::Networking::Status ) ) );
00550 } else {
00551 disconnect( Solid::Networking::notifier(), 0, 0, 0 );
00552 setOnline( true );
00553 }
00554 }
00555
00556 void AgentBase::setOnline( bool state )
00557 {
00558 Q_D( AgentBase );
00559 d->mOnline = state;
00560 d->mSettings->setValue( QLatin1String( "Agent/Online" ), state );
00561 doSetOnline( state );
00562 emit onlineChanged( state );
00563 }
00564
00565 void AgentBase::doSetOnline( bool online )
00566 {
00567 Q_UNUSED( online );
00568 }
00569
00570 void AgentBase::configure( WId windowId )
00571 {
00572 Q_UNUSED( windowId );
00573 emit configurationDialogAccepted();
00574 }
00575
00576 #ifdef Q_OS_WIN //krazy:exclude=cpp
00577 void AgentBase::configure( qlonglong windowId )
00578 {
00579 configure( reinterpret_cast<WId>( windowId ) );
00580 }
00581 #endif
00582
00583 WId AgentBase::winIdForDialogs() const
00584 {
00585 const bool registered = QDBusConnection::sessionBus().interface()->isServiceRegistered( QLatin1String( "org.freedesktop.akonaditray" ) );
00586 if ( !registered )
00587 return 0;
00588
00589 QDBusInterface dbus( QLatin1String( "org.freedesktop.akonaditray" ), QLatin1String( "/Actions" ),
00590 QLatin1String( "org.freedesktop.Akonadi.Tray" ) );
00591 const QDBusMessage reply = dbus.call( QLatin1String( "getWinId" ) );
00592
00593 if ( reply.type() == QDBusMessage::ErrorMessage )
00594 return 0;
00595
00596 const WId winid = (WId)reply.arguments().at( 0 ).toLongLong();
00597
00598 return winid;
00599 }
00600
00601 void AgentBase::quit()
00602 {
00603 Q_D( AgentBase );
00604 aboutToQuit();
00605
00606 if ( d->mSettings ) {
00607 d->mChangeRecorder->setConfig( 0 );
00608 d->mSettings->sync();
00609 }
00610
00611 KGlobal::deref();
00612 }
00613
00614 void AgentBase::aboutToQuit()
00615 {
00616 }
00617
00618 void AgentBase::cleanup()
00619 {
00620 Q_D( AgentBase );
00621
00622
00623 d->mChangeRecorder->blockSignals( true );
00624
00625 aboutToQuit();
00626
00627 const QString fileName = d->mSettings->fileName();
00628
00629
00630
00631
00632 d->mChangeRecorder->setConfig( 0 );
00633 delete d->mSettings;
00634 d->mSettings = 0;
00635
00636
00637
00638
00639 QFile::remove( fileName );
00640
00641
00642
00643
00644 QFile::remove( fileName + QLatin1String( "_changes.dat" ) );
00645
00646
00647
00648
00649 QString configFile = KStandardDirs::locateLocal( "config", KGlobal::config()->name() );
00650 QFile::remove( configFile );
00651
00652 KGlobal::deref();
00653 }
00654
00655 void AgentBase::registerObserver( Observer *observer )
00656 {
00657 d_ptr->mObserver = observer;
00658 }
00659
00660 QString AgentBase::identifier() const
00661 {
00662 return d_ptr->mId;
00663 }
00664
00665 void AgentBase::setAgentName( const QString &name )
00666 {
00667 Q_D( AgentBase );
00668 if ( name == d->mName )
00669 return;
00670
00671
00672 d->mName = name;
00673
00674 if ( d->mName.isEmpty() || d->mName == d->mId ) {
00675 d->mSettings->remove( QLatin1String( "Resource/Name" ) );
00676 d->mSettings->remove( QLatin1String( "Agent/Name" ) );
00677 } else
00678 d->mSettings->setValue( QLatin1String( "Agent/Name" ), d->mName );
00679
00680 d->mSettings->sync();
00681
00682 emit agentNameChanged( d->mName );
00683 }
00684
00685 QString AgentBase::agentName() const
00686 {
00687 Q_D( const AgentBase );
00688 if ( d->mName.isEmpty() )
00689 return d->mId;
00690 else
00691 return d->mName;
00692 }
00693
00694 void AgentBase::changeProcessed()
00695 {
00696 Q_D( AgentBase );
00697 d->changeProcessed();
00698 }
00699
00700 ChangeRecorder * AgentBase::changeRecorder() const
00701 {
00702 return d_ptr->mChangeRecorder;
00703 }
00704
00705 void AgentBase::abort()
00706 {
00707 emit abortRequested();
00708 }
00709
00710 void AgentBase::reconfigure()
00711 {
00712 emit reloadConfiguration();
00713 }
00714
00715 #include "agentbase.moc"
00716 #include "agentbase_p.moc"