summary string, and the message Date/time to the event start time.
+ Revision 601.88 2002/12/14 23:21:29 ajc
+ * When saving a calendar event, set the message Subject to the event
+ summary string, and the message Date/time to the event start time.
+
Revision 601.87 2002/12/10 23:36:20 ajc
* Fixed a bug in the allocation of per-session dynamic data for calendar module
Revision 601.87 2002/12/10 23:36:20 ajc
* Fixed a bug in the allocation of per-session dynamic data for calendar module
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
-#include "serv_calendar.h"
#include "citadel.h"
#include "server.h"
#include "citserver.h"
#include "citadel.h"
#include "server.h"
#include "citserver.h"
#include "tools.h"
#include "msgbase.h"
#include "mime_parser.h"
#include "tools.h"
#include "msgbase.h"
#include "mime_parser.h"
+#include "serv_calendar.h"
/*
* Back end for ical_obj_beforesave()
/*
* Back end for ical_obj_beforesave()
- * This hunts for the UID of the calendar event.
+ * This hunts for the UID of the calendar event (becomes Citadel msg EUID),
+ * the summary of the event (becomes message subject),
+ * and the start time (becomes message date/time).
*/
void ical_ctdl_set_extended_msgid(char *name, char *filename, char *partnum,
char *disp, void *content, char *cbtype, size_t length,
*/
void ical_ctdl_set_extended_msgid(char *name, char *filename, char *partnum,
char *disp, void *content, char *cbtype, size_t length,
{
icalcomponent *cal;
icalproperty *p;
{
icalcomponent *cal;
icalproperty *p;
+ struct icalmessagemod *imm;
+
+ imm = (struct icalmessagemod *)cbuserdata;
/* If this is a text/calendar object, hunt for the UID and drop it in
* the "user data" pointer for the MIME parser. When
/* If this is a text/calendar object, hunt for the UID and drop it in
* the "user data" pointer for the MIME parser. When
if (cal != NULL) {
p = ical_ctdl_get_subprop(cal, ICAL_UID_PROPERTY);
if (p != NULL) {
if (cal != NULL) {
p = ical_ctdl_get_subprop(cal, ICAL_UID_PROPERTY);
if (p != NULL) {
- strcpy((char *)cbuserdata,
- icalproperty_get_comment(p)
- );
+ strcpy(imm->uid, icalproperty_get_comment(p));
+ }
+ p = ical_ctdl_get_subprop(cal, ICAL_SUMMARY_PROPERTY);
+ if (p != NULL) {
+ strcpy(imm->subject,
+ icalproperty_get_comment(p));
+ }
+ p = ical_ctdl_get_subprop(cal, ICAL_DTSTART_PROPERTY);
+ if (p != NULL) {
+ imm->dtstart = icaltime_as_timet(icalproperty_get_dtstart(p));
}
icalcomponent_free(cal);
}
}
icalcomponent_free(cal);
}
* ID to the UID of the object. This causes our replication checker to
* automatically delete any existing instances of the same object. (Isn't
* that cool?)
* ID to the UID of the object. This causes our replication checker to
* automatically delete any existing instances of the same object. (Isn't
* that cool?)
+ *
+ * We also set the message's Subject to the event summary, and the Date/time to
+ * the event start time.
*/
int ical_obj_beforesave(struct CtdlMessage *msg)
{
char roomname[ROOMNAMELEN];
char *p;
int a;
*/
int ical_obj_beforesave(struct CtdlMessage *msg)
{
char roomname[ROOMNAMELEN];
char *p;
int a;
+ struct icalmessagemod imm;
/*
* Only messages with content-type text/calendar
/*
* Only messages with content-type text/calendar
while (--a > 0) {
if (!strncasecmp(p, "Content-Type: ", 14)) { /* Found it */
if (!strncasecmp(p + 14, "text/calendar", 13)) {
while (--a > 0) {
if (!strncasecmp(p, "Content-Type: ", 14)) { /* Found it */
if (!strncasecmp(p + 14, "text/calendar", 13)) {
+ memset(&imm, 0, sizeof(struct icalmessagemod));
mime_parser(msg->cm_fields['M'],
NULL,
*ical_ctdl_set_extended_msgid,
NULL, NULL,
mime_parser(msg->cm_fields['M'],
NULL,
*ical_ctdl_set_extended_msgid,
NULL, NULL,
- if (strlen(eidbuf) > 0) {
+ if (strlen(imm.uid) > 0) {
if (msg->cm_fields['E'] != NULL) {
phree(msg->cm_fields['E']);
}
if (msg->cm_fields['E'] != NULL) {
phree(msg->cm_fields['E']);
}
- msg->cm_fields['E'] = strdoop(eidbuf);
+ msg->cm_fields['E'] = strdoop(imm.uid);
+ }
+ if (strlen(imm.subject) > 0) {
+ if (msg->cm_fields['U'] != NULL) {
+ phree(msg->cm_fields['U']);
+ }
+ msg->cm_fields['U'] = strdoop(imm.subject);
+ }
+ if (imm.dtstart > 0) {
+ if (msg->cm_fields['T'] != NULL) {
+ phree(msg->cm_fields['T']);
+ }
+ msg->cm_fields['T'] = strdoop("000000000000000000");
+ sprintf(msg->cm_fields['T'], "%ld", imm.dtstart);
};
#define CIT_ICAL ((struct cit_ical *)CtdlGetUserData(SYM_CIT_ICAL))
};
#define CIT_ICAL ((struct cit_ical *)CtdlGetUserData(SYM_CIT_ICAL))
+
+/*
+ * When saving a message containing calendar information, we keep track of
+ * some components in the calendar object that need to be inserted into
+ * message fields.
+ */
+struct icalmessagemod {
+ char subject[SIZ];
+ char uid[SIZ];
+ time_t dtstart;
+};