4 * A server-side module for Citadel which supports address book information
5 * using the standard vCard format.
7 * Copyright (c) 1999-2002 / released under the GNU General Public License
11 * Where we keep messages containing the vCards that source our directory. It
12 * makes no sense to change this, because you'd have to change it on every
13 * system on the network. That would be stupid.
15 #define ADDRESS_BOOK_ROOM "Global Address Book"
18 * Format of the "Exclusive ID" field of the message containing a user's
19 * vCard. Doesn't matter what it really looks like as long as it's both
20 * unique and consistent (because we use it for replication checking to
21 * delete the old vCard network-wide when the user enters a new one).
23 #define VCARD_EXT_FORMAT "Citadel vCard: personal card for %s at %s"
34 #include <sys/types.h>
36 #if TIME_WITH_SYS_TIME
37 # include <sys/time.h>
41 # include <sys/time.h>
52 #include "sysdep_decls.h"
53 #include "citserver.h"
57 #include "serv_extensions.h"
63 #include "internet_addressing.h"
66 #include "serv_ldap.h"
69 * set global flag calling for an aide to validate new users
71 void set_mm_valid(void) {
72 begin_critical_section(S_CONTROL);
74 CitControl.MMflags = CitControl.MMflags | MM_VALID ;
76 end_critical_section(S_CONTROL);
82 * Extract Internet e-mail addresses from a message containing a vCard, and
83 * perform a callback for any found.
85 void vcard_extract_internet_addresses(struct CtdlMessage *msg,
86 void (*callback)(char *, char *) ) {
90 char citadel_address[SIZ];
92 int found_something = 0;
94 if (msg->cm_fields['A'] == NULL) return;
95 if (msg->cm_fields['N'] == NULL) return;
96 snprintf(citadel_address, sizeof citadel_address, "%s @ %s",
97 msg->cm_fields['A'], msg->cm_fields['N']);
99 v = vcard_load(msg->cm_fields['M']);
100 if (v == NULL) return;
102 /* Go through the vCard searching for *all* instances of
103 * the "email;internet" key
106 s = vcard_get_prop(v, "email;internet", 0, instance++, 0);
110 if (strlen(addr) > 0) {
111 if (callback != NULL) {
112 callback(addr, citadel_address);
121 } while(found_something);
129 * Callback for vcard_add_to_directory()
130 * (Lotsa ugly nested callbacks. Oh well.)
131 * This little shim function makes sure we're not
133 void vcard_directory_add_user(char *internet_addr, char *citadel_addr) {
136 /* We have to validate that we're not stepping on someone else's
137 * email address ... but only if we're logged in. Otherwise it's
138 * probably just the networker or something.
141 lprintf(CTDL_DEBUG, "Checking for <%s>...\n", internet_addr);
142 if (CtdlDirectoryLookup(buf, internet_addr) == 0) {
143 if (strcasecmp(buf, citadel_addr)) {
144 /* This address belongs to someone else.
145 * Bail out silently without saving.
147 lprintf(CTDL_DEBUG, "DOOP!\n");
152 lprintf(CTDL_INFO, "Adding %s (%s) to directory\n",
153 citadel_addr, internet_addr);
154 CtdlDirectoryAddUser(internet_addr, citadel_addr);
159 * Back end function for cmd_igab()
161 void vcard_add_to_directory(long msgnum, void *data) {
162 struct CtdlMessage *msg;
164 msg = CtdlFetchMessage(msgnum, 1);
166 vcard_extract_internet_addresses(msg, vcard_directory_add_user);
170 ctdl_vcard_to_ldap(msg, V2L_WRITE);
173 CtdlFreeMessage(msg);
178 * Initialize Global Adress Book
180 void cmd_igab(char *argbuf) {
181 char hold_rm[ROOMNAMELEN];
183 if (CtdlAccessCheck(ac_aide)) return;
185 strcpy(hold_rm, CC->room.QRname); /* save current room */
187 if (getroom(&CC->room, ADDRESS_BOOK_ROOM) != 0) {
188 getroom(&CC->room, hold_rm);
189 cprintf("%d cannot get address book room\n", ERROR + ROOM_NOT_FOUND);
193 /* Empty the existing database first.
197 /* We want *all* vCards in this room */
198 CtdlForEachMessage(MSGS_ALL, 0, "text/x-vcard",
199 NULL, vcard_add_to_directory, NULL);
201 getroom(&CC->room, hold_rm); /* return to saved room */
202 cprintf("%d Directory has been rebuilt.\n", CIT_OK);
209 * See if there is a valid Internet address in a vCard to use for outbound
210 * Internet messages. If there is, stick it in CC->cs_inet_email.
212 void vcard_populate_cs_inet_email(struct vCard *v) {
214 int continue_searching = 1;
217 /* Go through the vCard searching for *all* instances of
218 * the "email;internet" key
221 s = vcard_get_prop(v, "email;internet", 0, instance++, 0);
223 continue_searching = 1;
226 if (strlen(addr) > 0) {
227 if (IsDirectory(addr)) {
228 continue_searching = 0;
229 safestrncpy(CC->cs_inet_email,
231 sizeof(CC->cs_inet_email)
238 continue_searching = 0;
240 } while(continue_searching);
246 * This handler detects whether the user is attempting to save a new
247 * vCard as part of his/her personal configuration, and handles the replace
248 * function accordingly (delete the user's existing vCard in the config room
249 * and in the global address book).
251 int vcard_upload_beforesave(struct CtdlMessage *msg) {
256 struct ctdluser usbuf;
258 struct vCard *v = NULL;
261 int yes_my_citadel_config = 0;
262 int yes_any_vcard_room = 0;
264 if (!CC->logged_in) return(0); /* Only do this if logged in. */
266 /* Is this some user's "My Citadel Config" room? */
267 if ( (CC->room.QRflags && QR_MAILBOX)
268 && (!strcasecmp(&CC->room.QRname[11], USERCONFIGROOM)) ) {
269 /* Yes, we want to do this */
270 yes_my_citadel_config = 1;
273 /* Is this a room with an address book in it? */
274 if (CC->curr_view == VIEW_ADDRESSBOOK) {
275 yes_any_vcard_room = 1;
278 /* If neither condition exists, don't run this hook. */
279 if ( (!yes_my_citadel_config) && (!yes_any_vcard_room) ) {
283 /* If this isn't a MIME message, don't bother. */
284 if (msg->cm_format_type != 4) return(0);
286 /* Ok, if we got this far, look into the situation further... */
288 ptr = msg->cm_fields['M'];
289 if (ptr == NULL) return(0);
290 while (ptr != NULL) {
292 linelen = strcspn(ptr, "\n");
293 if (linelen == 0) return(0); /* end of headers */
295 if (!strncasecmp(ptr, "Content-type: text/x-vcard", 26)) {
298 if (yes_my_citadel_config) {
299 /* Bingo! The user is uploading a new vCard, so
300 * delete the old one. First, figure out which user
301 * is being re-registered...
303 what_user = atol(CC->room.QRname);
305 if (what_user == CC->user.usernum) {
306 /* It's the logged in user. That was easy. */
307 memcpy(&usbuf, &CC->user,
308 sizeof(struct ctdluser) );
311 else if (getuserbynumber(&usbuf, what_user) == 0) {
312 /* We fetched a valid user record */
316 /* No user with that number! */
320 /* Delete the user's old vCard. This would probably
321 * get taken care of by the replication check, but we
322 * want to make sure there is absolutely only one
323 * vCard in the user's config room at all times.
325 CtdlDeleteMessages(CC->room.QRname,
328 /* Make the author of the message the name of the user.
330 if (msg->cm_fields['A'] != NULL) {
331 free(msg->cm_fields['A']);
333 msg->cm_fields['A'] = strdup(usbuf.fullname);
336 /* Manipulate the vCard data structure */
337 v = vcard_load(msg->cm_fields['M']);
340 /* Insert or replace RFC2739-compliant free/busy URL */
341 if (yes_my_citadel_config) {
342 sprintf(buf, "http://%s/%s.vfb",
345 for (i=0; i<strlen(buf); ++i) {
346 if (buf[i] == ' ') buf[i] = '_';
348 vcard_set_prop(v, "FBURL;PREF", buf, 0);
351 /* If this is an address book room, and the vCard has
352 * no UID, then give it one.
354 if (yes_any_vcard_room) {
355 s = vcard_get_prop(v, "UID", 0, 0, 0);
358 vcard_set_prop(v, "UID", buf, 0);
362 /* Enforce local UID policy if applicable */
363 if (yes_my_citadel_config) {
364 snprintf(buf, sizeof buf, VCARD_EXT_FORMAT,
365 msg->cm_fields['A'], NODENAME);
366 vcard_set_prop(v, "UID", buf, 0);
370 * Set the EUID of the message to the UID of the vCard.
371 * Also set the Subject if there isn't already one.
373 if (msg->cm_fields['E'] != NULL) free(msg->cm_fields['E']);
374 s = vcard_get_prop(v, "UID", 0, 0, 0);
376 msg->cm_fields['E'] = strdup(s);
377 if (msg->cm_fields['U'] == NULL) {
378 msg->cm_fields['U'] = strdup(s);
382 /* Re-serialize it back into the msg body */
383 ser = vcard_serialize(v);
385 msg->cm_fields['M'] = realloc(
389 sprintf(msg->cm_fields['M'],
390 "Content-type: text/x-vcard"
391 "\r\n\r\n%s\r\n", ser);
397 /* Now allow the save to complete. */
401 ptr = strchr((char *)ptr, '\n');
402 if (ptr != NULL) ++ptr;
411 * This handler detects whether the user is attempting to save a new
412 * vCard as part of his/her personal configuration, and handles the replace
413 * function accordingly (copy the vCard from the config room to the global
416 int vcard_upload_aftersave(struct CtdlMessage *msg) {
422 if (!CC->logged_in) return(0); /* Only do this if logged in. */
424 /* If this isn't the configuration room, or if this isn't a MIME
425 * message, don't bother.
427 if (msg->cm_fields['O'] == NULL) return(0);
428 if (strcasecmp(msg->cm_fields['O'], USERCONFIGROOM)) return(0);
429 if (msg->cm_format_type != 4) return(0);
431 ptr = msg->cm_fields['M'];
432 if (ptr == NULL) return(0);
433 while (ptr != NULL) {
435 linelen = strcspn(ptr, "\n");
436 if (linelen == 0) return(0); /* end of headers */
438 if (!strncasecmp(ptr, "Content-type: text/x-vcard", 26)) {
439 /* Bingo! The user is uploading a new vCard, so
440 * copy it to the Global Address Book room.
443 I = atol(msg->cm_fields['I']);
444 if (I < 0L) return(0);
446 /* Store our Internet return address in memory */
447 v = vcard_load(msg->cm_fields['M']);
448 vcard_populate_cs_inet_email(v);
451 /* Put it in the Global Address Book room... */
452 CtdlSaveMsgPointerInRoom(ADDRESS_BOOK_ROOM, I,
453 (SM_VERIFY_GOODNESS | SM_DO_REPL_CHECK) );
455 /* ...and also in the directory database. */
456 vcard_add_to_directory(I, NULL);
458 /* Some sites want an Aide to be notified when a
459 * user registers or re-registers...
463 /* ...which also means we need to flag the user */
464 lgetuser(&CC->user, CC->curr_user);
465 CC->user.flags |= (US_REGIS|US_NEEDVALID);
471 ptr = strchr((char *)ptr, '\n');
472 if (ptr != NULL) ++ptr;
481 * back end function used for callbacks
483 void vcard_gu_backend(long supplied_msgnum, void *userdata) {
486 msgnum = (long *) userdata;
487 *msgnum = supplied_msgnum;
492 * If this user has a vcard on disk, read it into memory, otherwise allocate
493 * and return an empty vCard.
495 struct vCard *vcard_get_user(struct ctdluser *u) {
496 char hold_rm[ROOMNAMELEN];
497 char config_rm[ROOMNAMELEN];
498 struct CtdlMessage *msg;
502 strcpy(hold_rm, CC->room.QRname); /* save current room */
503 MailboxName(config_rm, sizeof config_rm, u, USERCONFIGROOM);
505 if (getroom(&CC->room, config_rm) != 0) {
506 getroom(&CC->room, hold_rm);
510 /* We want the last (and probably only) vcard in this room */
512 CtdlForEachMessage(MSGS_LAST, 1, "text/x-vcard",
513 NULL, vcard_gu_backend, (void *)&VCmsgnum );
514 getroom(&CC->room, hold_rm); /* return to saved room */
516 if (VCmsgnum < 0L) return vcard_new();
518 msg = CtdlFetchMessage(VCmsgnum, 1);
519 if (msg == NULL) return vcard_new();
521 v = vcard_load(msg->cm_fields['M']);
522 CtdlFreeMessage(msg);
528 * Store this user's vCard in the appropriate place
531 * Write our config to disk
533 void vcard_write_user(struct ctdluser *u, struct vCard *v) {
538 strcpy(temp, tmpnam(NULL));
539 ser = vcard_serialize(v);
541 fp = fopen(temp, "w");
542 if (fp == NULL) return;
544 fprintf(fp, "begin:vcard\r\nend:vcard\r\n");
546 fwrite(ser, strlen(ser), 1, fp);
551 /* This handy API function does all the work for us.
552 * NOTE: normally we would want to set that last argument to 1, to
553 * force the system to delete the user's old vCard. But it doesn't
554 * have to, because the vcard_upload_beforesave() hook above
555 * is going to notice what we're trying to do, and delete the old vCard.
557 CtdlWriteObject(USERCONFIGROOM, /* which room */
558 "text/x-vcard", /* MIME type */
559 temp, /* temp file */
562 0, /* don't delete others of this type */
571 * Old style "enter registration info" command. This function simply honors
572 * the REGI protocol command, translates the entered parameters into a vCard,
573 * and enters the vCard into the user's configuration.
575 void cmd_regi(char *argbuf) {
578 struct vCard *my_vcard;
584 char tmpaddress[SIZ];
585 char tmpcountry[SIZ];
589 if (!(CC->logged_in)) {
590 cprintf("%d Not logged in.\n",ERROR + NOT_LOGGED_IN);
594 my_vcard = vcard_get_user(&CC->user);
597 strcpy(tmpstate, "");
599 strcpy(tmpcountry, "USA");
601 cprintf("%d Send registration...\n", SEND_LISTING);
603 while (client_getln(buf, sizeof buf), strcmp(buf,"000")) {
604 if (a==0) vcard_set_prop(my_vcard, "n", buf, 0);
605 if (a==1) strcpy(tmpaddr, buf);
606 if (a==2) strcpy(tmpcity, buf);
607 if (a==3) strcpy(tmpstate, buf);
609 for (c=0; c<strlen(buf); ++c) {
610 if ((buf[c]>='0') && (buf[c]<='9')) {
617 if (a==5) vcard_set_prop(my_vcard, "tel;home", buf, 0);
618 if (a==6) vcard_set_prop(my_vcard, "email;internet", buf, 0);
619 if (a==7) strcpy(tmpcountry, buf);
623 snprintf(tmpaddress, sizeof tmpaddress, ";;%s;%s;%s;%s;%s",
624 tmpaddr, tmpcity, tmpstate, tmpzip, tmpcountry);
625 vcard_set_prop(my_vcard, "adr", tmpaddress, 0);
626 vcard_write_user(&CC->user, my_vcard);
627 vcard_free(my_vcard);
632 * Protocol command to fetch registration info for a user
634 void cmd_greg(char *argbuf)
636 struct ctdluser usbuf;
643 extract(who, argbuf, 0);
645 if (!(CC->logged_in)) {
646 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
650 if (!strcasecmp(who,"_SELF_")) strcpy(who,CC->curr_user);
652 if ((CC->user.axlevel < 6) && (strcasecmp(who,CC->curr_user))) {
653 cprintf("%d Higher access required.\n",
654 ERROR + HIGHER_ACCESS_REQUIRED);
658 if (getuser(&usbuf, who) != 0) {
659 cprintf("%d '%s' not found.\n", ERROR + NO_SUCH_USER, who);
663 v = vcard_get_user(&usbuf);
665 cprintf("%d %s\n", LISTING_FOLLOWS, usbuf.fullname);
666 cprintf("%ld\n", usbuf.usernum);
667 cprintf("%s\n", usbuf.password);
668 s = vcard_get_prop(v, "n", 0, 0, 0);
669 cprintf("%s\n", s ? s : " "); /* name */
671 s = vcard_get_prop(v, "adr", 0, 0, 0);
672 snprintf(adr, sizeof adr, "%s", s ? s : " ");/* address... */
674 extract_token(buf, adr, 2, ';');
675 cprintf("%s\n", buf); /* street */
676 extract_token(buf, adr, 3, ';');
677 cprintf("%s\n", buf); /* city */
678 extract_token(buf, adr, 4, ';');
679 cprintf("%s\n", buf); /* state */
680 extract_token(buf, adr, 5, ';');
681 cprintf("%s\n", buf); /* zip */
683 s = vcard_get_prop(v, "tel;home", 0, 0, 0);
684 if (s == NULL) s = vcard_get_prop(v, "tel", 1, 0, 0);
692 cprintf("%d\n", usbuf.axlevel);
694 s = vcard_get_prop(v, "email;internet", 0, 0, 0);
695 cprintf("%s\n", s ? s : " ");
696 s = vcard_get_prop(v, "adr", 0, 0, 0);
697 snprintf(adr, sizeof adr, "%s", s ? s : " ");/* address... */
699 extract_token(buf, adr, 6, ';');
700 cprintf("%s\n", buf); /* country */
706 * When a user is being created, create his/her vCard.
708 void vcard_newuser(struct ctdluser *usbuf) {
714 char middlename[SIZ];
715 char honorific_prefixes[SIZ];
716 char honorific_suffixes[SIZ];
721 /* Try to intelligently convert the screen name to a
722 * fully expanded vCard name based on the number of
725 strcpy(lastname, "");
726 strcpy(firstname, "");
727 strcpy(middlename, "");
728 strcpy(honorific_prefixes, "");
729 strcpy(honorific_suffixes, "");
731 strcpy(buf, usbuf->fullname);
733 /* Honorific suffixes */
734 if (num_tokens(buf, ',') > 1) {
735 extract_token(honorific_suffixes, buf, (num_tokens(buf, ' ') - 1), ',');
736 remove_token(buf, (num_tokens(buf, ',') - 1), ',');
739 /* Find a last name */
740 extract_token(lastname, buf, (num_tokens(buf, ' ') - 1), ' ');
741 remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');
743 /* Find honorific prefixes */
744 if (num_tokens(buf, ' ') > 2) {
745 extract_token(honorific_prefixes, buf, 0, ' ');
746 remove_token(buf, 0, ' ');
749 /* Find a middle name */
750 if (num_tokens(buf, ' ') > 1) {
751 extract_token(middlename, buf, (num_tokens(buf, ' ') - 1), ' ');
752 remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');
755 /* Anything left is probably the first name */
756 strcpy(firstname, buf);
759 /* Compose the structured name */
760 sprintf(vname, "%s;%s;%s;%s;%s", lastname, firstname, middlename,
761 honorific_prefixes, honorific_suffixes);
763 lprintf(CTDL_DEBUG, "Converted <%s> to <%s>\n", usbuf->fullname, vname);
765 /* Create and save the vCard */
767 if (v == NULL) return;
768 sprintf(buf, "%s@%s", usbuf->fullname, config.c_fqdn);
769 for (i=0; i<strlen(buf); ++i) {
770 if (buf[i] == ' ') buf[i] = '_';
772 vcard_add_prop(v, "fn", usbuf->fullname);
773 vcard_add_prop(v, "n", vname);
774 vcard_add_prop(v, "adr", "adr:;;_;_;_;00000;__");
775 vcard_add_prop(v, "email;internet", buf);
776 vcard_write_user(usbuf, v);
782 * When a user is being deleted, we have to remove his/her vCard.
783 * This is accomplished by issuing a message with 'CANCEL' in the S (special)
784 * field, and the same Exclusive ID as the existing card.
786 void vcard_purge(struct ctdluser *usbuf) {
787 struct CtdlMessage *msg;
790 msg = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage));
791 if (msg == NULL) return;
792 memset(msg, 0, sizeof(struct CtdlMessage));
794 msg->cm_magic = CTDLMESSAGE_MAGIC;
795 msg->cm_anon_type = MES_NORMAL;
796 msg->cm_format_type = 0;
797 msg->cm_fields['A'] = strdup(usbuf->fullname);
798 msg->cm_fields['O'] = strdup(ADDRESS_BOOK_ROOM);
799 msg->cm_fields['N'] = strdup(NODENAME);
800 msg->cm_fields['M'] = strdup("Purge this vCard\n");
802 snprintf(buf, sizeof buf, VCARD_EXT_FORMAT,
803 msg->cm_fields['A'], NODENAME);
804 msg->cm_fields['E'] = strdup(buf);
806 msg->cm_fields['S'] = strdup("CANCEL");
808 CtdlSubmitMsg(msg, NULL, ADDRESS_BOOK_ROOM);
809 CtdlFreeMessage(msg);
814 * Grab vCard directory stuff out of incoming network messages
816 int vcard_extract_from_network(struct CtdlMessage *msg, char *target_room) {
820 if (msg == NULL) return(0);
822 if (strcasecmp(target_room, ADDRESS_BOOK_ROOM)) {
826 if (msg->cm_format_type != 4) return(0);
828 ptr = msg->cm_fields['M'];
829 if (ptr == NULL) return(0);
830 while (ptr != NULL) {
832 linelen = strcspn(ptr, "\n");
833 if (linelen == 0) return(0); /* end of headers */
835 if (!strncasecmp(ptr, "Content-type: text/x-vcard", 26)) {
836 /* It's a vCard. Add it to the directory. */
837 vcard_extract_internet_addresses(msg,
838 CtdlDirectoryAddUser);
842 ptr = strchr((char *)ptr, '\n');
843 if (ptr != NULL) ++ptr;
852 * When a vCard is being removed from the Global Address Book room, remove it
853 * from the directory as well.
855 void vcard_delete_remove(char *room, long msgnum) {
856 struct CtdlMessage *msg;
860 if (msgnum <= 0L) return;
862 if (strcasecmp(room, ADDRESS_BOOK_ROOM)) {
866 msg = CtdlFetchMessage(msgnum, 1);
867 if (msg == NULL) return;
869 ptr = msg->cm_fields['M'];
870 if (ptr == NULL) goto EOH;
871 while (ptr != NULL) {
872 linelen = strcspn(ptr, "\n");
873 if (linelen == 0) goto EOH;
875 if (!strncasecmp(ptr, "Content-type: text/x-vcard", 26)) {
876 /* Bingo! A vCard is being deleted.
878 vcard_extract_internet_addresses(msg,
879 CtdlDirectoryDelUser);
881 ctdl_vcard_to_ldap(msg, V2L_DELETE);
884 ptr = strchr((char *)ptr, '\n');
885 if (ptr != NULL) ++ptr;
888 EOH: CtdlFreeMessage(msg);
896 void cmd_qdir(char *argbuf) {
897 char citadel_addr[SIZ];
898 char internet_addr[SIZ];
900 if (CtdlAccessCheck(ac_logged_in)) return;
902 extract(internet_addr, argbuf, 0);
904 if (CtdlDirectoryLookup(citadel_addr, internet_addr) != 0) {
905 cprintf("%d %s was not found.\n",
906 ERROR + NO_SUCH_USER, internet_addr);
910 cprintf("%d %s\n", CIT_OK, citadel_addr);
915 * We don't know if the Contacts room exists so we just create it at login
917 void vcard_create_room(void)
922 /* Create the calendar room if it doesn't already exist */
923 create_room(USERCONTACTSROOM, 4, "", 0, 1, 0, VIEW_ADDRESSBOOK);
925 /* Set expiration policy to manual; otherwise objects will be lost! */
926 if (lgetroom(&qr, USERCONTACTSROOM)) {
927 lprintf(CTDL_ERR, "Couldn't get the user CONTACTS room!\n");
930 qr.QRep.expire_mode = EXPIRE_MANUAL;
931 qr.QRdefaultview = VIEW_ADDRESSBOOK; /* 2 = address book view */
934 /* Set the view to a calendar view */
935 CtdlGetRelationship(&vbuf, &CC->user, &qr);
936 vbuf.v_view = 2; /* 2 = address book view */
937 CtdlSetRelationship(&vbuf, &CC->user, &qr);
946 * When a user logs in...
948 void vcard_session_login_hook(void) {
951 v = vcard_get_user(&CC->user);
952 vcard_populate_cs_inet_email(v);
961 char *serv_vcard_init(void)
965 CtdlRegisterSessionHook(vcard_session_login_hook, EVT_LOGIN);
966 CtdlRegisterMessageHook(vcard_upload_beforesave, EVT_BEFORESAVE);
967 CtdlRegisterMessageHook(vcard_upload_aftersave, EVT_AFTERSAVE);
968 CtdlRegisterDeleteHook(vcard_delete_remove);
969 CtdlRegisterProtoHook(cmd_regi, "REGI", "Enter registration info");
970 CtdlRegisterProtoHook(cmd_greg, "GREG", "Get registration info");
971 CtdlRegisterProtoHook(cmd_igab, "IGAB",
972 "Initialize Global Address Book");
973 CtdlRegisterProtoHook(cmd_qdir, "QDIR", "Query Directory");
974 CtdlRegisterUserHook(vcard_newuser, EVT_NEWUSER);
975 CtdlRegisterUserHook(vcard_purge, EVT_PURGEUSER);
976 CtdlRegisterNetprocHook(vcard_extract_from_network);
978 /* Create the Global ADdress Book room if necessary */
979 create_room(ADDRESS_BOOK_ROOM, 3, "", 0, 1, 0, VIEW_ADDRESSBOOK);
981 /* Set expiration policy to manual; otherwise objects will be lost! */
982 if (!lgetroom(&qr, ADDRESS_BOOK_ROOM)) {
983 qr.QRep.expire_mode = EXPIRE_MANUAL;
984 qr.QRdefaultview = VIEW_ADDRESSBOOK; /* 2 = address book view */