Re: [Dovecot] IMAP Get Savedate plugin
On Thu, 2009-05-21 at 04:54 +, Alaa Ibrahim wrote: I'm trying to put it in a plugin, but when I call imap_fetch_handlers_register(), it works but all other fetch handlers get removed, my init is Oh, that's because my code looks like: struct imap_fetch_context *imap_fetch_init(struct client_command_context *cmd) .. if (fetch_handlers == NULL) { imap_fetch_handlers_register(imap_fetch_default_handlers, N_ELEMENTS(imap_fetch_default_handlers)); } So imap_fetch_init() would have to be called before you register anything. I guess you could work around it by building a fake cmd struct and calling it, but kind of ugly. :) Anyway, fixed in v1.2+: http://hg.dovecot.org/dovecot-1.2/rev/106e4e3dccbc signature.asc Description: This is a digitally signed message part
[Dovecot] IMAP Get Savedate plugin
Hi, I want to add a feature to the fetch command in IMAP, by enabling it to return the save date, when I request the SAVEDATE parameter. I want to use this for my webmail application, so I can show the users the deleted date when they are viewing the Trash folder. I was able to put it directly into the code (patch attached), but I was wondering if there is a way to put it as a plugin instead. Can somebody guide me on how to do that. Thanks a lot. - Play the best Flash Games on the web with Maktoob Shams Games. http://games.maktoob.com/*** dovecot-1.1.15/src/imap/imap-fetch.c 2009-01-06 16:33:51.0 +0200 --- dovecot-1.1.15-myver/src/imap/imap-fetch.c 2009-05-21 02:47:56.0 +0300 *** *** 20,26 #define ENVELOPE_NIL_REPLY \ (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) ! extern const struct imap_fetch_handler imap_fetch_default_handlers[7]; static buffer_t *fetch_handlers = NULL; static int imap_fetch_handler_cmp(const void *p1, const void *p2) --- 20,26 #define ENVELOPE_NIL_REPLY \ (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) ! extern const struct imap_fetch_handler imap_fetch_default_handlers[8]; static buffer_t *fetch_handlers = NULL; static int imap_fetch_handler_cmp(const void *p1, const void *p2) *** *** 568,573 --- 568,597 return TRUE; } + static int fetch_savedate(struct imap_fetch_context *ctx, struct mail *mail, + void *context ATTR_UNUSED) + { + time_t date; + + if (mail_get_save_date(mail, date) 0) + return -1; + + str_printfa(ctx-cur_str, SAVEDATE \%s\ , + imap_to_datetime(date)); + return 1; + } + + static bool + fetch_savedate_init(struct imap_fetch_context *ctx, const char *name, + const struct imap_arg **args ATTR_UNUSED) + { + ctx-fetch_data |= MAIL_FETCH_SAVE_DATE; + imap_fetch_add_handler(ctx, TRUE, FALSE, name, + \01-Jan-1970 00:00:00 +\, + fetch_savedate, NULL); + return TRUE; + } + static int fetch_uid(struct imap_fetch_context *ctx, struct mail *mail, void *context ATTR_UNUSED) { *** *** 583,594 return TRUE; } ! const struct imap_fetch_handler imap_fetch_default_handlers[7] = { { BODY, fetch_body_init }, { BODYSTRUCTURE, fetch_bodystructure_init }, { ENVELOPE, fetch_envelope_init }, { FLAGS, fetch_flags_init }, { INTERNALDATE, fetch_internaldate_init }, { RFC822, fetch_rfc822_init }, { UID, fetch_uid_init } }; --- 607,619 return TRUE; } ! const struct imap_fetch_handler imap_fetch_default_handlers[8] = { { BODY, fetch_body_init }, { BODYSTRUCTURE, fetch_bodystructure_init }, { ENVELOPE, fetch_envelope_init }, { FLAGS, fetch_flags_init }, { INTERNALDATE, fetch_internaldate_init }, + { SAVEDATE, fetch_savedate_init }, { RFC822, fetch_rfc822_init }, { UID, fetch_uid_init } };
Re: [Dovecot] IMAP Get Savedate plugin
On Thu, 2009-05-21 at 00:25 +, Alaa Ibrahim wrote: I want to add a feature to the fetch command in IMAP, by enabling it to return the save date, when I request the SAVEDATE parameter. I want to use this for my webmail application, so I can show the users the deleted date when they are viewing the Trash folder. I guess this could be useful for other purposes too. Actually today I just needed this for testing that my dbox changes work. So committed it to v1.2+: http://hg.dovecot.org/dovecot-1.2/rev/aedec88c6e31 I was able to put it directly into the code (patch attached), but I was wondering if there is a way to put it as a plugin instead. I think you could have also made it a plugin. In the plugin's init() function just call imap_fetch_handlers_register() to register your new handler(s). signature.asc Description: This is a digitally signed message part
Re: [Dovecot] IMAP Get Savedate plugin
I'm trying to put it in a plugin, but when I call imap_fetch_handlers_register(), it works but all other fetch handlers get removed, my init is void savedate_plugin_init(void) { const struct imap_fetch_handler savedate_handler[1] = { { X-SAVEDATE, fetch_x_savedate_init } }; imap_fetch_handlers_register(savedate_handler,1); } is there something wrong that I'm doing? On Wed, 20 May 2009 22:55:34 -0400, Timo Sirainen t...@iki.fi wrote: On Thu, 2009-05-21 at 00:25 +, Alaa Ibrahim wrote: I want to add a feature to the fetch command in IMAP, by enabling it to return the save date, when I request the SAVEDATE parameter. I want to use this for my webmail application, so I can show the users the deleted date when they are viewing the Trash folder. I guess this could be useful for other purposes too. Actually today I just needed this for testing that my dbox changes work. So committed it to v1.2+: http://hg.dovecot.org/dovecot-1.2/rev/aedec88c6e31 I was able to put it directly into the code (patch attached), but I was wondering if there is a way to put it as a plugin instead. I think you could have also made it a plugin. In the plugin's init() function just call imap_fetch_handlers_register() to register your new handler(s). -- Ala'a A. Ibrahim Senior System Admin Maktoob.com, Inc. - Discuss the hottest sports issue with Sport4ever forum Now! http://sport4ever.maktoob.com/