Logo Search packages:      
Sourcecode: akonadi version File versions  Download package

QString AgentManager::createAgentInstance ( const QString &  identifier  )  [slot]

Creates a new agent of the given agent type identifier.

The identifier of the new agent if created successfully, an empty string otherwise. The identifier consists of two parts, the type of the agent and an unique instance number, and looks like the following: 'file_1' or 'imap_267'.

Definition at line 151 of file agentmanager.cpp.

References mAgentInstances, mAgents, and save().

  if ( !checkAgentExists( identifier ) )
    return QString();
  AgentInfo agentInfo = mAgents.value( identifier );
  mAgents[ identifier ].instanceCounter++;

  AgentInstanceInfo instance;
  if ( agentInfo.capabilities.contains( AgentInfo::CapabilityUnique ) )
    instance.identifier = identifier;
    instance.identifier = QString::fromLatin1( "%1_%2" ).arg( identifier, QString::number( agentInfo.instanceCounter ) );
  instance.agentType = identifier;

  if ( mAgentInstances.contains( instance.identifier ) ) {
    mTracer->warning( QLatin1String("AgentManager::createAgentInstance"),
                      QString::fromLatin1( "Cannot create another instance of agent '%1'." ).arg( identifier ) );
    return QString();

  if ( !instance.start( agentInfo, this ) )
    return QString();
  mAgentInstances.insert( instance.identifier, instance );

  return instance.identifier;

Generated by  Doxygen 1.6.0   Back to index