* Started banging out some code to determine when a saved vEvent needs to
authorArt Cancro <ajc@citadel.org>
Sat, 30 Nov 2002 05:39:29 +0000 (05:39 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 30 Nov 2002 05:39:29 +0000 (05:39 +0000)
  send out meeting invites.

citadel/ChangeLog
citadel/msgbase.c
citadel/msgbase.h
citadel/serv_calendar.c

index 9da49d276c982321bdf309ef2eba09ff4c6b7c48..f9e4898d84b3702fb3cca5b44685075f5674f166 100644 (file)
@@ -1,4 +1,8 @@
  $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.
@@ -4252,4 +4256,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index c78d7e345e23155c6466edb1a56d31d4eb77d29c..2c0bd0f507f7959397d01adf90b30926941bea63 100644 (file)
@@ -3180,36 +3180,48 @@ void CtdlPutSysConfig(char *sysconfname, char *sysconfdata) {
 }
 
 
-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);
+       }
+
 }
index 76696b2bcab8df85edc894656dfd4c85f7c38671..f902a40480e09d5a8a5c6e6de1d8b33aaf7f4714 100644 (file)
@@ -138,3 +138,4 @@ struct CtdlMessage *CtdlMakeMessage(
         char *preformatted_text         /* ...or NULL to read text from client */
 );
 int CtdlCheckInternetMailPermission(struct usersupp *who);
+int CtdlIsMe(char *addr);
index dd97848f80d6ba4eb3f4be4121fbdbb044a690ad..c1a97a3c043f44be0ec7e9e0a5653f1d4733e641 100644 (file)
@@ -671,6 +671,67 @@ void ical_create_room(void)
 }
 
 
+/*
+ * 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()
@@ -697,6 +758,7 @@ void ical_ctdl_set_extended_msgid(char *name, char *filename, char *partnum,
                                        icalproperty_get_comment(p)
                                );
                        }
+                       ical_saving_vevent(cal);
                        icalcomponent_free(cal);
                }
        }