$Log$
+ Revision 601.76 2002/11/30 05:39:28 ajc
+ * Started banging out some code to determine when a saved vEvent needs to
+ send out meeting invites.
+
Revision 601.75 2002/11/29 16:24:59 ajc
* When calling ical*_remove_*() routines, the caller then owns the object
which is removed. Added ical*_free() calls to free the memory.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
}
-void cmd_isme(char *argbuf) {
- char addr[SIZ];
+/*
+ * Determine whether a given Internet address belongs to the current user
+ */
+int CtdlIsMe(char *addr) {
struct recptypes *recp;
int i;
- if (CtdlAccessCheck(ac_logged_in)) return;
- extract(addr, argbuf, 0);
recp = validate_recipients(addr);
-
- if (recp == NULL) {
- cprintf("%d Error parsing \n", ERROR + INTERNAL_ERROR);
- return;
- }
+ if (recp == NULL) return(0);
if (recp->num_local == 0) {
- cprintf("%d Not you.\n", ERROR);
phree(recp);
- return;
+ return(0);
}
for (i=0; i<recp->num_local; ++i) {
extract(addr, recp->recp_local, i);
if (!strcasecmp(addr, CC->usersupp.fullname)) {
- cprintf("%d %s\n", CIT_OK, addr);
phree(recp);
- return;
+ return(1);
}
}
- cprintf("%d Not you.\n", ERROR);
phree(recp);
- return;
+ return(0);
+}
+
+
+/*
+ * Citadel protocol command to do the same
+ */
+void cmd_isme(char *argbuf) {
+ char addr[SIZ];
+
+ if (CtdlAccessCheck(ac_logged_in)) return;
+ extract(addr, argbuf, 0);
+
+ if (CtdlIsMe(addr)) {
+ cprintf("%d %s\n", CIT_OK, addr);
+ }
+ else {
+ cprintf("%d Not you.\n", ERROR);
+ }
+
}
}
+/*
+ * ical_send_out_invitations() is called by ical_saving_vevent() when it
+ * finds a VEVENT.
+ */
+void ical_send_out_invitations(icalcomponent *cal) {
+ lprintf(9, "Sending out invitations!\n");
+}
+
+
+/*
+ * When a calendar object is being saved, determine whether it's a VEVENT
+ * and the user saving it is the organizer. If so, send out invitations
+ * to any listed attendees.
+ *
+ *
+ * FIXME, FIXME, FIXME!! This doesn't work, for some reason.
+ *
+ */
+void ical_saving_vevent(icalcomponent *cal) {
+ icalcomponent *c;
+ icalproperty *organizer = NULL;
+ char organizer_string[SIZ];
+
+
+ lprintf(9, "ical_saving_vevent() called\n");
+ strcpy(organizer_string, "");
+ /*
+ * The VEVENT subcomponent is the one we're interested in.
+ * Send out invitations if, and only if, this user is the Organizer.
+ */
+ if (icalcomponent_isa(cal) == ICAL_VEVENT_COMPONENT) {
+ organizer = icalcomponent_get_first_property(cal, ICAL_ORGANIZER_PROPERTY);
+ if (organizer != NULL) {
+ lprintf(9, "Organizer found\n");
+ if (icalproperty_get_organizer(organizer)) {
+ strcpy(organizer_string,
+ icalproperty_get_organizer(organizer) );
+ }
+ }
+ lprintf(9, "organizer: <%s>\n", organizer_string);
+ if (!strncasecmp(organizer_string, "MAILTO:", 7)) {
+ strcpy(organizer_string, &organizer_string[7]);
+ striplt(organizer_string);
+ if (CtdlIsMe(organizer_string)) {
+ ical_send_out_invitations(cal);
+ }
+ }
+ }
+
+ /* If the component has subcomponents, recurse through them. */
+ for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
+ (c != NULL);
+ c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
+ /* Recursively process subcomponent */
+ ical_saving_vevent(c);
+ }
+
+}
+
+
+
/*
* Back end for ical_obj_beforesave()
icalproperty_get_comment(p)
);
}
+ ical_saving_vevent(cal);
icalcomponent_free(cal);
}
}