Re: [Evolution-hackers] Getting all mail



Thanks Milan.

The problem I'm having now is when I ask for the folderinfo it returns
a null pointer at the point indicated below.
Evolution is set-up with a gmail pop account. When I tried it with the
IMAP settings it worked and I managed to get the CamelFolders.

The other thing I don't understand is the threading thing. Could
someone please explain that.

One more question, I cant seem to compile the devel-guide, is there an
online version of it? I've just been grepping everything and wanted to
know if there is some kind of API out there that makes it easier.


//mail grabbing entry point
gboolean pimp_mail_init(void)
{
	EAccountList* accounts;
	EIterator* accIter;
	
	//get accounts
	if(!(accounts = mail_config_get_accounts()))
		return FALSE;
	
	//foreach account
	accIter = e_list_get_iterator((EList *) accounts);
	while(e_iterator_is_valid(accIter))
	{
		EAccount *acc = (EAccount *) e_iterator_get(accIter);
		
		//get store
		mail_get_store(e_account_get_string(acc, E_ACCOUNT_SOURCE_URL),
NULL, pimp_mail_get_store, NULL);
				
		e_iterator_next(accIter);
	}
	
	return TRUE;
}

static void pimp_mail_get_store(char *uri, CamelStore *store, void *user_data)
{	
	if(store == NULL)
		return;
		
	//get folderinfo
	mail_get_folderinfo(store, NULL, pimp_mail_get_folderinfo, NULL);
}

static gboolean pimp_mail_get_folderinfo(CamelStore *store,
CamelFolderInfo *info, void *data)
{
	if(info == NULL)
<----------------------------------------------------------------------Null
pointer
		return FALSE;
	
	//function call to get other folderinfo's
	pimp_mail_get_folderinfo_recursive(info);
	return TRUE;
}

static void pimp_mail_get_folderinfo_recursive(CamelFolderInfo *info)
{
	//does this recursion work???? is it the right way to do it?
	if(info->child != NULL)
		pimp_mail_get_folderinfo_recursive(info->child);
	
	if(info->next != NULL)
		pimp_mail_get_folderinfo_recursive(info->next);
	
	mail_get_folder(info->uri, 0, pimp_mail_get_folder, NULL,
mail_msg_unordered_push/*dunno what this does*/);
}

static void pimp_mail_get_folder(char *uri, CamelFolder *folder, void *data)
{
	/*
	if(folder != NULL)
		camel calls in here
	*/
		
}


On Fri, Jun 19, 2009 at 4:17 PM, Milan Crha<mcrha redhat com> wrote:
> On Fri, 2009-06-19 at 12:22 +0200, Filipe Nepomuceno wrote:
>> Hey all,
>>
>> I'm currently making a plugin for evolution as a final year project
>> that gets all the messages and contacts from evolution and then displays
>> them as a mind-map.
>>
>> The (major) problem I'm having is getting a list of ALL the e-mails in
>> ALL the folders. From the plugins and documentation that I've read I can
>> get a list of a single folder provided it is in the plugins context i.e.
>> you right click on the folder and launch the plugin.
>>
>> Is what I'm trying to do possible and if so could someone please point
>> me in the right direction?
>>
>> Regards,
>> Filipe
>
>        Hi,
> you can do that in your event by couple of steps:
> a) obtain list of all configured accounts with mail_config_get_accounts
> b) for all enabled accounts ask for the CamelStore with mail_get_store
> c) for each CamelStore ask for a folder info with call of
>   mail_get_folderinfo , where you'll receive a folder hierarchy
>   for all the folders in the given store
> d) then for each folder info ask for a CamelFolder with
>   mail_get_folder
> e) and finally for messages in a returned folder.
>
> Just take care of not calling camel functions in a main thread. Those
> mail_* functions from the above take care of it itself, as they are
> async, but I guess the e) will be pure camel call(s) for you.
>
> You can do the same also by only-camel-calls in one thread, except
> of a), just mimic working parts of those mentioned functions above.
>        Hope that helps,
>        Milan
>
> _______________________________________________
> Evolution-hackers mailing list
> Evolution-hackers gnome org
> http://mail.gnome.org/mailman/listinfo/evolution-hackers
>



-- 
If practice makes you perfect and no one is perfect then why practice?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]