Re: [Evolution-hackers] EPlugin, export mail folder, recursive issues.

On Fri, 2004-10-29 at 02:52 +0200, smurfd wrote:
Hey again, im sorry to keep bothering you guys!

Im having problems getting it to digg through a whole tree of folders.
it can digg down to the end of one folder, but doesnt step to the next
after that.

example : 
i have setup a folder tree like : 

what it does now, is that it diggs to "f21" and then stops. I ofcourse
want it to do all the subfolders that "Inbox" contains. (otherwise it
wouldnt be recursive :) )

So, what im thinking, is that the CamelFolderInfo doesnt do all the
folders, and that i might need to use CamelFolderList, but then there is
the question on how to go from CamelFolderInfo to CamelFolderList... 

Any pointers are welcomed, and very much appreciated!!

code follows below.

Best regards
void org_gnome_export_mail_folder (EPlugin *ep, EMPopupTargetFolder
void do_export_mail_folder (char *uri);

static void
export_mail_folder (char *uri, CamelFolder *folder, gpointer data)
	CamelFolder **save = data;
	GPtrArray *pids;
	CamelFolderInfo *cfi;
	CamelStore *cs;
			CamelFolder *f = NULL;
			int fid2;
	CamelDList *dl;
	CamelFolderInfo *cfiold = NULL;	

	if (folder) 
		while(cfi) {
		*save = folder;
		camel_object_ref (folder);
		pids = (GPtrArray *) g_malloc(sizeof(GPtrArray));
This is really really wrong.  You MUST use g_ptr_array_new().
		pids = camel_folder_get_uids((CamelFolder *)folder);		

		cs = (CamelStore *) g_malloc(sizeof(CamelStore));
		cfi= (CamelFolderInfo *) g_malloc(sizeof(CamelFolderInfo));
These are really really really wrong.  You're allocating a camel-store object and assigning to the pointer.  You never allocate one of those, you just need the pointer.
		cs = camel_folder_get_parent_store((CamelFolder *)folder);
		cfi = camel_store_get_folder_info((CamelStore
Uh, you're passing exception id's to get_folder_info, no.  That isn't how it works, not even close.  See where the code is used elsewhere. I'm surprised it isn't just crashing instantly.

You're passing 0 to the flags for get_folder_info, you need to pass the recursive flag, otherwise you only get 1 level of folders.  Or you need to call it recursively, one or the other.  Calling recursive flag can be bad since some imap servers can loop if you have softlinks in your tree.
		// for debug purpose only
		printf("%s\n", camel_folder_get_full_name(folder));
		// commented away, until working properly
		// em_utils_save_messages(0, folder, pids);

			fid2 =

You also really don't want to do this.  You'll fire off *concurrent* threads for all folders.  i.e. lots of thrashing and a bad user experience.  You want to serialise it.

get_folder_info needs to run in another thread too.  You should move everything into another thread if thats what you're doing.

		cfi = cfi->next;		

do_export_mail_folder(char *uri) 
	CamelFolder *folder = NULL;
	int fid;

	fid =

org_gnome_export_mail_folder (EPlugin *ep, EMPopupTargetFolder *target)

evolution-hackers maillist  -  evolution-hackers lists ximian com
Michael Zucchi <notzed ximian com>
"born to die, live to work, it's all downhill from here"
Novell's Evolution and Free Software Developer

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