* Clicking "Enter Message" in a room with an Address Book view opens
authorArt Cancro <ajc@citadel.org>
Fri, 24 Oct 2003 02:50:19 +0000 (02:50 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 24 Oct 2003 02:50:19 +0000 (02:50 +0000)
  a blank vCard entry screen.

webcit/ChangeLog
webcit/messages.c
webcit/vcard_edit.c

index bafab1eccd93dc3a3bfe667249c0fdbe69521709..be498c1528a48711d0da6e89a180d723dc401c0c 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 502.1  2003/10/24 02:50:19  ajc
+* Clicking "Enter Message" in a room with an Address Book view opens
+  a blank vCard entry screen.
+
 Revision 502.0  2003/10/23 03:16:50  ajc
 * THIS IS 5.02
 
@@ -1616,3 +1620,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 01f8bb04d51acc22cc52db6393ef3e5f86c1a0fe..1c50808b754c444b4d0d954988297a096cea3ed6 100644 (file)
@@ -1429,6 +1429,15 @@ void display_enter(void)
                gotoroom(bstr("force_room"), 0);
        }
 
+       /* Are we perhaps in an address book view?  If so, then an "enter
+        * message" command really means "add new entry."
+        */
+       if (WC->wc_view == 2) {
+               do_edit_vcard(-1, "", "");
+               return;
+       }
+
+       /* Otherwise proceed normally */
        output_headers(1);
        sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
        serv_puts(buf);
index 65f0f3fc1c25eec7526820808ab2f51c7bd56396..1eec8b339a13bc04d86523a5d1847c988bd070c8 100644 (file)
 #include "vcard.h"
 
 
-
+/* Edit the vCard component of a MIME message.  Supply the message number
+ * and MIME part number to fetch.  Or, specify -1 for the message number
+ * to start with a blank card.
+ */
 void do_edit_vcard(long msgnum, char *partnum, char *return_to) {
        char buf[SIZ];
        char *serialized_vcard = NULL;
@@ -76,91 +79,94 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) {
        output_headers(3);
 
        strcpy(whatuser, "");
-       sprintf(buf, "MSG0 %ld|1", msgnum);
-       serv_puts(buf);
-       serv_gets(buf);
-       if (buf[0] != '1') {
-               wDumpContent(1);
-               return;
-       }
-       while (serv_gets(buf), strcmp(buf, "000")) {
-               if (!strncasecmp(buf, "from=", 5)) {
-                       strcpy(whatuser, &buf[5]);
-               }
-               else if (!strncasecmp(buf, "node=", 5)) {
-                       strcat(whatuser, " @ ");
-                       strcat(whatuser, &buf[5]);
-               }
-       }
 
-       sprintf(buf, "OPNA %ld|%s", msgnum, partnum);
-       serv_puts(buf);
-       serv_gets(buf);
-       if (buf[0] != '2') {
-               wDumpContent(1);
-               return;
-       }
-
-       total_len = atoi(&buf[4]);
-       serialized_vcard = malloc(total_len + 1);
-
-       read_server_binary(serialized_vcard, total_len);
-
-       serv_puts("CLOS");
-       serv_gets(buf);
-       serialized_vcard[total_len + 1] = 0;
-
-       v = vcard_load(serialized_vcard);
-       free(serialized_vcard);
-
-       /* Populate the variables for our form */
-       i = 0;
-       while (key = vcard_get_prop(v, "", 0, i, 1), key != NULL) {
-               value = vcard_get_prop(v, "", 0, i++, 0);
-
-               if (!strcasecmp(key, "n")) {
-                       extract_token(lastname, value, 0, ';');
-                       extract_token(firstname, value, 1, ';');
-                       extract_token(middlename, value, 2, ';');
-                       extract_token(prefix, value, 3, ';');
-                       extract_token(suffix, value, 4, ';');
-               }
-
-               else if (!strcasecmp(key, "adr")) {
-                       extract_token(pobox, value, 0, ';');
-                       extract_token(extadr, value, 1, ';');
-                       extract_token(street, value, 2, ';');
-                       extract_token(city, value, 3, ';');
-                       extract_token(state, value, 4, ';');
-                       extract_token(zipcode, value, 5, ';');
-                       extract_token(country, value, 6, ';');
+       if (msgnum >= 0) {
+               sprintf(buf, "MSG0 %ld|1", msgnum);
+               serv_puts(buf);
+               serv_gets(buf);
+               if (buf[0] != '1') {
+                       wDumpContent(1);
+                       return;
                }
-
-               else if (!strcasecmp(key, "tel;home")) {
-                       extract_token(hometel, value, 0, ';');
+               while (serv_gets(buf), strcmp(buf, "000")) {
+                       if (!strncasecmp(buf, "from=", 5)) {
+                               strcpy(whatuser, &buf[5]);
+                       }
+                       else if (!strncasecmp(buf, "node=", 5)) {
+                               strcat(whatuser, " @ ");
+                               strcat(whatuser, &buf[5]);
+                       }
                }
-
-               else if (!strcasecmp(key, "tel;work")) {
-                       extract_token(worktel, value, 0, ';');
+       
+               sprintf(buf, "OPNA %ld|%s", msgnum, partnum);
+               serv_puts(buf);
+               serv_gets(buf);
+               if (buf[0] != '2') {
+                       wDumpContent(1);
+                       return;
                }
-
-               else if (!strcasecmp(key, "email;internet")) {
-                       if (inetemail[0] != 0) {
-                               strcat(inetemail, "\n");
+       
+               total_len = atoi(&buf[4]);
+               serialized_vcard = malloc(total_len + 1);
+       
+               read_server_binary(serialized_vcard, total_len);
+       
+               serv_puts("CLOS");
+               serv_gets(buf);
+               serialized_vcard[total_len + 1] = 0;
+       
+               v = vcard_load(serialized_vcard);
+               free(serialized_vcard);
+       
+               /* Populate the variables for our form */
+               i = 0;
+               while (key = vcard_get_prop(v, "", 0, i, 1), key != NULL) {
+                       value = vcard_get_prop(v, "", 0, i++, 0);
+       
+                       if (!strcasecmp(key, "n")) {
+                               extract_token(lastname, value, 0, ';');
+                               extract_token(firstname, value, 1, ';');
+                               extract_token(middlename, value, 2, ';');
+                               extract_token(prefix, value, 3, ';');
+                               extract_token(suffix, value, 4, ';');
                        }
-                       strcat(inetemail, value);
-               }
-
-               else {
-                       strcat(extrafields, key);
-                       strcat(extrafields, ":");
-                       strcat(extrafields, value);
-                       strcat(extrafields, "\n");
+       
+                       else if (!strcasecmp(key, "adr")) {
+                               extract_token(pobox, value, 0, ';');
+                               extract_token(extadr, value, 1, ';');
+                               extract_token(street, value, 2, ';');
+                               extract_token(city, value, 3, ';');
+                               extract_token(state, value, 4, ';');
+                               extract_token(zipcode, value, 5, ';');
+                               extract_token(country, value, 6, ';');
+                       }
+       
+                       else if (!strcasecmp(key, "tel;home")) {
+                               extract_token(hometel, value, 0, ';');
+                       }
+       
+                       else if (!strcasecmp(key, "tel;work")) {
+                               extract_token(worktel, value, 0, ';');
+                       }
+       
+                       else if (!strcasecmp(key, "email;internet")) {
+                               if (inetemail[0] != 0) {
+                                       strcat(inetemail, "\n");
+                               }
+                               strcat(inetemail, value);
+                       }
+       
+                       else {
+                               strcat(extrafields, key);
+                               strcat(extrafields, ":");
+                               strcat(extrafields, value);
+                               strcat(extrafields, "\n");
+                       }
+       
                }
-
-       }
        
-       vcard_free(v);
+               vcard_free(v);
+       }
 
        /* Display the form */
        do_template("beginbox_nt");