* Refactored the code that populates the session's knowledge of the user's
authorArt Cancro <ajc@citadel.org>
Thu, 19 Jan 2006 18:21:21 +0000 (18:21 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 19 Jan 2006 18:21:21 +0000 (18:21 +0000)
  primary internet email address.  We need it to be generic so that we can
  do this for other users.

citadel/ChangeLog
citadel/serv_vcard.c

index d3823cd83b2cf9175c05dabd5de04c1978d85cdf..ba7037452af10a8fa1f02a225f2a20b37f9d1317 100644 (file)
@@ -1,5 +1,10 @@
 $Id$
 
+Thu Jan 19 13:20:30 EST 2006 ajc
+* Refactored the code that populates the session's knowledge of the user's
+  primary internet email address.  We need it to be generic so that we can
+  do this for other users.
+
 Tue Jan 17 22:23:19 EST 2006 ajc
 * Misc small fixes to the new host auth mode.
 
index 24ab2199e12a9d1c444741179eff4e9fd3d54bce..2afd0f597d6448a7dcce123eca2a9a2e51b28dd0 100644 (file)
@@ -200,9 +200,9 @@ void cmd_igab(char *argbuf) {
 
 /*
  * See if there is a valid Internet address in a vCard to use for outbound
- * Internet messages.  If there is, stick it in CC->cs_inet_email.
+ * Internet messages.  If there is, stick it in the buffer.
  */
-void vcard_populate_cs_inet_email(struct vCard *v) {
+void extract_primary_inet_email(char *emailaddrbuf, size_t emailaddrbuf_len, struct vCard *v) {
        char *s, *addr;
        int continue_searching = 1;
        int instance = 0;
@@ -219,10 +219,8 @@ void vcard_populate_cs_inet_email(struct vCard *v) {
                        if (strlen(addr) > 0) {
                                if (IsDirectory(addr)) {
                                        continue_searching = 0;
-                                       safestrncpy(CC->cs_inet_email,
-                                               addr,
-                                               sizeof(CC->cs_inet_email)
-                                       );
+                                       safestrncpy(emailaddrbuf, addr,
+                                               emailaddrbuf_len);
                                }
                        }
                        free(addr);
@@ -451,7 +449,8 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
 
                        /* Store our Internet return address in memory */
                        v = vcard_load(msg->cm_fields['M']);
-                       vcard_populate_cs_inet_email(v);
+                       extract_primary_inet_email(CC->cs_inet_email,
+                                               sizeof CC->cs_inet_email, v);
                        vcard_free(v);
 
                        /* Put it in the Global Address Book room... */
@@ -907,8 +906,8 @@ void vcard_session_login_hook(void) {
        struct vCard *v;
 
        v = vcard_get_user(&CC->user);
-       vcard_populate_cs_inet_email(v);
-
+       extract_primary_inet_email(CC->cs_inet_email,
+                               sizeof CC->cs_inet_email, v);
        vcard_free(v);
 
        vcard_create_room();