Getting all mail

View: New views
4 Messages — Rating Filter:   Alert me  

Getting all mail

by Filipe Nepomuceno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
_______________________________________________
Evolution-hackers mailing list
Evolution-hackers@...
http://mail.gnome.org/mailman/listinfo/evolution-hackers

Re: Getting all mail

by Milan Crha :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
http://mail.gnome.org/mailman/listinfo/evolution-hackers

Re: Getting all mail

by Filipe Nepomuceno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...> 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@...
> http://mail.gnome.org/mailman/listinfo/evolution-hackers
>



--
If practice makes you perfect and no one is perfect then why practice?
_______________________________________________
Evolution-hackers mailing list
Evolution-hackers@...
http://mail.gnome.org/mailman/listinfo/evolution-hackers

Re: Getting all mail

by Milan Crha :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

        Hi,

On Mon, 2009-06-22 at 20:43 +0200, Filipe Nepomuceno wrote:
> 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.

Might be that it uses "On This Computer" for storing/showing mails. Look
for mail-component.c:mc_setup_local_store for an example how to open the
local store. (There should be enough to construct proper URL and use it
like the one from an EAccount structure, I guess.) See also
load_accounts in the same file, as you do not check for enabled accounts
only.

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

I'm afraid this is out of scope of this mailing list. What do you mean
exactly?

> 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.

Hmm, I usually look around the code. Some information can be found also
on http://go-evolution.org but I've no idea how much accurate/up-to-date
it is. Maybe someone else knows where to find the online devel-doc
version.
        Bye,
        Milan

_______________________________________________
Evolution-hackers mailing list
Evolution-hackers@...
http://mail.gnome.org/mailman/listinfo/evolution-hackers