#include "internet_addressing.h"
#include "tools.h"
#include "vcard.h"
+#include "serv_ldap.h"
struct vcard_internal_info {
long msgnum;
};
/* Message number symbol used internally by these functions */
-unsigned long SYM_VCARD;
#define VC ((struct vcard_internal_info *)CtdlGetUserData(SYM_VCARD))
vcard_extract_internet_addresses(msg, vcard_directory_add_user);
}
+#ifdef HAVE_LDAP
+ ctdl_vcard_to_ldap(msg, V2L_WRITE);
+#endif
+
CtdlFreeMessage(msg);
}
if (getroom(&CC->room, ADDRESS_BOOK_ROOM) != 0) {
getroom(&CC->room, hold_rm);
- cprintf("%d cannot get address book room\n", ERROR);
+ cprintf("%d cannot get address book room\n", ERROR + ROOM_NOT_FOUND);
return;
}
*/
CtdlDirectoryInit();
- /* We want the last (and probably only) vcard in this room */
+ /* We want *all* vCards in this room */
CtdlForEachMessage(MSGS_ALL, 0, "text/x-vcard",
NULL, vcard_add_to_directory, NULL);
char *ptr;
int linelen;
char buf[SIZ];
- struct user usbuf;
+ struct ctdluser usbuf;
long what_user;
if (!CC->logged_in) return(0); /* Only do this if logged in. */
if (what_user == CC->user.usernum) {
/* It's the logged in user. That was easy. */
memcpy(&usbuf, &CC->user,
- sizeof(struct user) );
+ sizeof(struct ctdluser) );
}
else if (getuserbynumber(&usbuf, what_user) == 0) {
* If this user has a vcard on disk, read it into memory, otherwise allocate
* and return an empty vCard.
*/
-struct vCard *vcard_get_user(struct user *u) {
+struct vCard *vcard_get_user(struct ctdluser *u) {
char hold_rm[ROOMNAMELEN];
char config_rm[ROOMNAMELEN];
struct CtdlMessage *msg;
/*
* Write our config to disk
*/
-void vcard_write_user(struct user *u, struct vCard *v) {
+void vcard_write_user(struct ctdluser *u, struct vCard *v) {
char temp[PATH_MAX];
FILE *fp;
char *ser;
char tmpcountry[SIZ];
if (!(CC->logged_in)) {
- cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
+ cprintf("%d Not logged in.\n",ERROR + NOT_LOGGED_IN);
return;
}
*/
void cmd_greg(char *argbuf)
{
- struct user usbuf;
+ struct ctdluser usbuf;
struct vCard *v;
char *s;
char who[SIZ];
extract(who, argbuf, 0);
if (!(CC->logged_in)) {
- cprintf("%d Not logged in.\n", ERROR+NOT_LOGGED_IN);
+ cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
return;
}
if ((CC->user.axlevel < 6) && (strcasecmp(who,CC->curr_user))) {
cprintf("%d Higher access required.\n",
- ERROR+HIGHER_ACCESS_REQUIRED);
+ ERROR + HIGHER_ACCESS_REQUIRED);
return;
}
if (getuser(&usbuf, who) != 0) {
- cprintf("%d '%s' not found.\n", ERROR+NO_SUCH_USER, who);
+ cprintf("%d '%s' not found.\n", ERROR + NO_SUCH_USER, who);
return;
}
*/
vcard_extract_internet_addresses(msg,
CtdlDirectoryDelUser);
+#ifdef HAVE_LDAP
+ ctdl_vcard_to_ldap(msg, V2L_DELETE);
+#endif
}
ptr = strchr((char *)ptr, '\n');
if (ptr != NULL) ++ptr;
if (CtdlDirectoryLookup(citadel_addr, internet_addr) != 0) {
cprintf("%d %s was not found.\n",
- ERROR+NO_SUCH_USER, internet_addr);
+ ERROR + NO_SUCH_USER, internet_addr);
return;
}
}
+/*
+ * We don't know if the Contacts room exists so we just create it at login
+ */
+void vcard_create_room(void)
+{
+ struct ctdlroom qr;
+ struct visit vbuf;
+
+ /* Create the calendar room if it doesn't already exist */
+ create_room(USERCONTACTSROOM, 4, "", 0, 1, 0);
+
+ /* Set expiration policy to manual; otherwise objects will be lost! */
+ if (lgetroom(&qr, USERCONTACTSROOM)) {
+ lprintf(3, "Couldn't get the user CONTACTS room!\n");
+ return;
+ }
+ qr.QRep.expire_mode = EXPIRE_MANUAL;
+ qr.QRdefaultview = 2; /* 2 = address book view */
+ lputroom(&qr);
+
+ /* Set the view to a calendar view */
+ CtdlGetRelationship(&vbuf, &CC->user, &qr);
+ vbuf.v_view = 2; /* 2 = address book view */
+ CtdlSetRelationship(&vbuf, &CC->user, &qr);
+
+ return;
+}
+
+
/*
vcard_populate_cs_inet_email(v);
vcard_free(v);
+
+ vcard_create_room();
}
char *serv_vcard_init(void)
{
- SYM_VCARD = CtdlGetDynamicSymbol();
+ struct ctdlroom qr;
+
CtdlRegisterSessionHook(vcard_session_startup_hook, EVT_START);
CtdlRegisterSessionHook(vcard_session_login_hook, EVT_LOGIN);
CtdlRegisterMessageHook(vcard_upload_beforesave, EVT_BEFORESAVE);
CtdlRegisterProtoHook(cmd_qdir, "QDIR", "Query Directory");
CtdlRegisterUserHook(vcard_purge, EVT_PURGEUSER);
CtdlRegisterNetprocHook(vcard_extract_from_network);
+
+ /* Create the Global ADdress Book room if necessary */
create_room(ADDRESS_BOOK_ROOM, 3, "", 0, 1, 0);
+
+ /* Set expiration policy to manual; otherwise objects will be lost! */
+ if (!lgetroom(&qr, ADDRESS_BOOK_ROOM)) {
+ qr.QRep.expire_mode = EXPIRE_MANUAL;
+ qr.QRdefaultview = 2; /* 2 = address book view */
+ lputroom(&qr);
+ }
+
return "$Id$";
}