]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/vcard/serv_vcard.c
DVCA: init string literals to empty just to be shure. hopefully silences valgrind...
[citadel.git] / citadel / modules / vcard / serv_vcard.c
index a467c9f22bec961d53d169125224eb31494c6aff..07b33336cc22904369ac16e486bef82c4fb48dc8 100644 (file)
@@ -2,21 +2,21 @@
  * A server-side module for Citadel which supports address book information
  * using the standard vCard format.
  * 
- * Copyright (c) 1999-2009 by the citadel.org team
+ * Copyright (c) 1999-2012 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
+ * 
+ * 
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ * 
+ * 
  */
 
 /*
@@ -154,10 +154,12 @@ int vcard_directory_add_user(char *internet_addr, char *citadel_addr) {
                                 * Bail out silently without saving.
                                 */
                                syslog(LOG_DEBUG, "DOOP!\n");
-                               StrBufAppendBufPlain(CCC->StatusMessage, _("unable to add this emailaddress again."), -1, 0);
-                               StrBufAppendBufPlain(CCC->StatusMessage, HKEY("|"), 0);
+                               
+                               StrBufAppendPrintf(CCC->StatusMessage, "\n%d|", ERROR+ALREADY_EXISTS);
                                StrBufAppendBufPlain(CCC->StatusMessage, internet_addr, -1, 0);
                                StrBufAppendBufPlain(CCC->StatusMessage, HKEY("|"), 0);
+                               StrBufAppendBufPlain(CCC->StatusMessage, _("unable to add this emailaddress again."), -1, 0);
+                               StrBufAppendBufPlain(CCC->StatusMessage, HKEY("\n"), 0);
                                return 0;
                        }
                }
@@ -165,18 +167,18 @@ int vcard_directory_add_user(char *internet_addr, char *citadel_addr) {
        syslog(LOG_INFO, "Adding %s (%s) to directory\n", citadel_addr, internet_addr);
        if (CtdlDirectoryAddUser(internet_addr, citadel_addr))
        {
-               StrBufAppendBufPlain(CCC->StatusMessage, _("successfully addded emailaddress."), -1, 0);
-               StrBufAppendBufPlain(CCC->StatusMessage, HKEY("|"), 0);
+               StrBufAppendPrintf(CCC->StatusMessage, "\n%d|", CIT_OK);
                StrBufAppendBufPlain(CCC->StatusMessage, internet_addr, -1, 0);
                StrBufAppendBufPlain(CCC->StatusMessage, HKEY("|"), 0);
+               StrBufAppendBufPlain(CCC->StatusMessage, _("successfully addded emailaddress."), -1, 0);
                return 1;
        }
        else
        {
-               StrBufAppendBufPlain(CCC->StatusMessage, _("unable to add this emailaddress; its not matching our domain."), -1, 0);
-               StrBufAppendBufPlain(CCC->StatusMessage, HKEY("|"), 0);
+               StrBufAppendPrintf(CCC->StatusMessage, "\n%d|", ERROR+ ILLEGAL_VALUE);
                StrBufAppendBufPlain(CCC->StatusMessage, internet_addr, -1, 0);
                StrBufAppendBufPlain(CCC->StatusMessage, HKEY("|"), 0);
+               StrBufAppendBufPlain(CCC->StatusMessage, _("unable to add this emailaddress; its not matching our domain."), -1, 0);
                return 0;
        }
 }
@@ -272,11 +274,10 @@ void extract_inet_email_addrs(char *emailaddrbuf, size_t emailaddrbuf_len,
                                }
                                if (!IsDirectoryAddress && local_addrs_only)
                                {
-                                       StrBufAppendBufPlain(CCC->StatusMessage, 
-                                                            _("unable to add this emailaddress; its not matching our domain."), -1, 0);
-                                       StrBufAppendBufPlain(CCC->StatusMessage, HKEY("|"), 0);
+                                       StrBufAppendPrintf(CCC->StatusMessage, "\n%d|", ERROR+ ILLEGAL_VALUE);
                                        StrBufAppendBufPlain(CCC->StatusMessage, addr, -1, 0);
                                        StrBufAppendBufPlain(CCC->StatusMessage, HKEY("|"), 0);
+                                       StrBufAppendBufPlain(CCC->StatusMessage, _("unable to add this emailaddress; its not matching our domain."), -1, 0);
                                }
                        }
                        free(addr);
@@ -396,7 +397,6 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
        }
 
        s = vcard_get_prop(v, "fn", 1, 0, 0);
-       if (s) syslog(LOG_DEBUG, "vCard beforesave hook running for <%s>\n", s);
 
        if (yes_my_citadel_config) {
                /* Bingo!  The user is uploading a new vCard, so
@@ -547,6 +547,8 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
 
        NewStrBufDupAppendFlush(&CC->StatusMessage, NULL, NULL, 0);
 
+       StrBufPrintf(CC->StatusMessage, "%d\n", LISTING_FOLLOWS);
+
        while (ptr != NULL) {
        
                linelen = strcspn(ptr, "\n");
@@ -559,8 +561,8 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
                         * copy it to the Global Address Book room.
                         */
 
-                       I = atol(msg->cm_fields['I']);
-                       if (I < 0L) return(0);
+                       I = atol(msg->cm_fields['3']);
+                       if (I <= 0L) return(0);
 
                        /* Store our Internet return address in memory */
                        if (is_MY_UserConf) {
@@ -1051,9 +1053,9 @@ void dvca_mime_callback(char *name, char *filename, char *partnum, char *disp,
                char *cbid, void *cbuserdata) {
 
        struct vCard *v;
-       char displayname[256];
+       char displayname[256] = "";
        int displayname_len;
-       char emailaddr[256];
+       char emailaddr[256] = "";
        int i;
        int has_commas = 0;