* serv_calendar.c: ICAL FREEBUSY command now tries the supplied name not
authorArt Cancro <ajc@citadel.org>
Tue, 13 Apr 2004 18:31:40 +0000 (18:31 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 13 Apr 2004 18:31:40 +0000 (18:31 +0000)
  only as a screen name, but as an email address, and then as an
  unqualified email address in every hosted domain.  (For Kolab compat)

citadel/ChangeLog
citadel/serv_calendar.c

index b57b6b8fbb982acc825ea7da583b95d52a43295b..a7ec4b940b42d7d53c62b81b541e26563d1a7d82 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 620.12  2004/04/13 18:31:40  ajc
+ * serv_calendar.c: ICAL FREEBUSY command now tries the supplied name not
+   only as a screen name, but as an email address, and then as an
+   unqualified email address in every hosted domain.  (For Kolab compat)
+
  Revision 620.11  2004/04/13 02:45:07  ajc
  * Don't display the "Ending SSL/TLS" log message unless TLS is actually present
 
@@ -5676,3 +5681,4 @@ 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 6445c2818e0887c54d7985cd3ac8128d7a51e1ea..ce20785944379696b4947aebe090faab12e3c901 100644 (file)
@@ -31,6 +31,7 @@
 #include "tools.h"
 #include "msgbase.h"
 #include "mime_parser.h"
+#include "internet_addressing.h"
 #include "serv_calendar.h"
 
 #ifdef CITADEL_WITH_CALENDAR_SERVICE
@@ -1141,8 +1142,71 @@ void ical_freebusy(char *who) {
        char *serialized_request = NULL;
        icalcomponent *encaps = NULL;
        icalcomponent *fb = NULL;
+       int found_user = (-1);
+       struct recptypes *recp = NULL;
+       char buf[SIZ];
+       char host[SIZ];
+       char type[SIZ];
+       int i = 0;
+       int config_lines = 0;
+
+       /* First try an exact match. */
+       found_user = getuser(&usbuf, who);
+
+       /* If not found, try it as an unqualified email address. */
+       if (found_user != 0) {
+               strcpy(buf, who);
+               recp = validate_recipients(buf);
+               lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+               if (recp != NULL) {
+                       if (recp->num_local == 1) {
+                               found_user = getuser(&usbuf, recp->recp_local);
+                       }
+                       free(recp);
+               }
+       }
+
+       /* If still not found, try it as an address qualified with the
+        * primary FQDN of this Citadel node.
+        */
+       if (found_user != 0) {
+               snprintf(buf, sizeof buf, "%s@%s", who, config.c_fqdn);
+               lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+               recp = validate_recipients(buf);
+               if (recp != NULL) {
+                       if (recp->num_local == 1) {
+                               found_user = getuser(&usbuf, recp->recp_local);
+                       }
+                       free(recp);
+               }
+       }
+
+       /* Still not found?  Try qualifying it with every domain we
+        * might have addresses in.
+        */
+       if (found_user != 0) {
+               config_lines = num_tokens(inetcfg, '\n');
+               for (i=0; ((i < config_lines) && (found_user != 0)); ++i) {
+                       extract_token(buf, inetcfg, i, '\n');
+                       extract_token(host, buf, 0, '|');
+                       extract_token(type, buf, 1, '|');
+
+                       if ( (!strcasecmp(type, "localhost"))
+                          || (!strcasecmp(type, "directory")) ) {
+                               snprintf(buf, sizeof buf, "%s@%s", who, host);
+                               lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+                               recp = validate_recipients(buf);
+                               if (recp != NULL) {
+                                       if (recp->num_local == 1) {
+                                               found_user = getuser(&usbuf, recp->recp_local);
+                                       }
+                                       free(recp);
+                               }
+                       }
+               }
+       }
 
-       if (getuser(&usbuf, who) != 0) {
+       if (found_user != 0) {
                cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
                return;
        }