[Kde-pim] synchronizing a collection

Sebastian Kügler sebas at kde.org
Tue Apr 14 02:13:21 BST 2009


Hi,

I'm trying to write the implementation for a refresh button in Lion Mail 
collections. I'm running into two problems, though;

- Akonadi::Collection(id).resource() returns an empty string

- I've yet to find a way to get at an instance derived from ResourceBase. I do 
get an AgentInstance just fine if I pass the AgentManager a hardcoded 
identifier string. What I need is an instance of the resource derived from 
ResourceBase, because I need the signals synchronized(), and the method 
setCollection(id). The AgentInstance doesn't have those, it doesn't even 
derive from QObject.

I'm getting the impression that I'm doing something fundamentally wrong, 
here's my code:

void MailExtender::refresh()
{
	// id is a qint64
    Akonadi::Collection col = Akonadi::Collection(id);
    // First problem: col.resource()  returns an empty string
    //const QString identifier = col.resource();
	// so set it manually for now
    const QString identifier = "akonadi_maildir_resource_0"; 
    kDebug() << "Refresh" << id << identifier << col.id() << col.resource();
    Akonadi::AgentInstance agent = Akonadi::AgentManager::self()->instance( 		
																identifier);
    if (agent.isValid()) {
        /*
        // Need something deriving from ResourceBase here
        if (rbase.isValid()) {
            rbase.synchronizeCollection(id);
            connect(rbase, SIGNAL(percent(int progress)), 		
							SLOT(percentSynchronized(int progress)));
            connect(rbase, SIGNAL(synchronized()), SLOT(synchronized()));
            connect(rbase, SIGNAL(error(const QString&)), 
							SLOT(synchronizeError(const QString&)));
        }
        */
        // on the agent, we can only all synchronizeCollectionTree 
		// or synchronize,  just do that then :/
        agent.synchronize();
    }

    // This works, however
    Akonadi::AgentInstance::List instances = 
						Akonadi::AgentManager::self()->instances();
    foreach ( const Akonadi::AgentInstance &instance, instances ) {
        qDebug() << "Name:" << instance.name() << "(" << instance.identifier() 
<< ")";
    }
}

Can someone enlighten me? :)
-- 
sebas

 http://www.kde.org | http://vizZzion.org |  GPG Key ID: 9119 0EF9 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 489 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20090414/6c7973df/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list