Final changes to server to allow message display names to
authorArt Cancro <ajc@citadel.org>
Thu, 22 Feb 2007 21:38:00 +0000 (21:38 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 22 Feb 2007 21:38:00 +0000 (21:38 +0000)
be either the account's display name or the vCard's friendly name.

citadel/citadel.c
citadel/citserver.c
citadel/messages.c
citadel/messages.h
citadel/msgbase.c
citadel/server.h
citadel/user_ops.c

index 1894907d375d2f7c9e71fa243ce04a140583cfdc..0c5ccc835c4a26172f4d90a19abf88c6ddf9c8d7 100644 (file)
@@ -1747,27 +1747,16 @@ NEWUSR: if (strlen(rc_password) == 0) {
                                formout(ipc, "help");
                                break;
                        case 4:
-                               entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0));
+                               entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0), 0);
                                break;
                        case 36:
-                               entmsg(ipc, 0, 1);
+                               entmsg(ipc, 0, 1, 0);
                                break;
                        case 46:
-                               entmsg(ipc, 0, 2);
+                               entmsg(ipc, 0, 2, 0);
                                break;
                        case 78:
-                               {
-                                       /* Only m.author is used */
-                                       struct ctdlipcmessage m;
-                                       newprompt("What do you want your username to be? ",
-                                               m.author, USERNAME_SIZE - 1);
-                                       m.text = "";
-                                       r = CtdlIPCPostMessage(ipc, 2, &m, aaa);
-                                       if (r / 100 != 2)
-                                               scr_printf("%s\n", aaa);
-                                       else
-                                               entmsg(ipc, 0, 0);
-                               }
+                               entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0), 1);
                                break;
                        case 5:                         /* <G>oto */
                                updatels(ipc);
@@ -2247,7 +2236,7 @@ NEWUSR:   if (strlen(rc_password) == 0) {
                                if (mcmd >= 100 && mcmd < (100+MAX_EDITORS))
                                {
                                        /* entmsg mode >=2 select editor */
-                                       entmsg(ipc, 0, mcmd - 100 + 2);
+                                       entmsg(ipc, 0, mcmd - 100 + 2, 0);
                                        break;
                                }
                        }       /* end switch */
index 2a034e5f69f05277b7d30f89f2b1f9263d7c923f..8c2c4cde4c3a052796e4d6eda120bcb26371c00d 100644 (file)
@@ -841,7 +841,6 @@ void begin_session(struct CitContext *con)
        strcpy(con->curr_user, NLI);
        strcpy(con->net_node, "");
        strcpy(con->fake_username, "");
-       strcpy(con->fake_postname, "");
        strcpy(con->fake_hostname, "");
        strcpy(con->fake_roomname, "");
        generate_nonce(con);
index 7788bc822b14d6006fe75cc57820ef2c50393d15..e726f2e1a2410230113d6d1250f1130172564346 100644 (file)
@@ -1098,8 +1098,9 @@ void break_big_lines(char *msg) {
  */
 int entmsg(CtdlIPC *ipc,
                int is_reply,   /* nonzero if this was a <R>eply command */
-               int c)          /* mode */
-{
+               int c,          /* mode */
+               int masquerade  /* prompt for a non-default display name? */
+) {
        char buf[SIZ];
        int a, b;
        int need_recp = 0;
@@ -1125,9 +1126,14 @@ int entmsg(CtdlIPC *ipc,
        strcpy(message.recipient, "");
        strcpy(message.author, "");
        strcpy(message.subject, "");
-       message.text = message.author;  /* point to "", changes later */
+       message.text = "";              /* point to "", changes later */
        message.anonymous = 0;
        message.type = mode;
+
+       if (masquerade) {
+               newprompt("Display name for this message: ", message.author, 40);
+       }
+
        r = CtdlIPCPostMessage(ipc, 0, &message, buf);
 
        if (r / 100 != 2 && r / 10 != 57) {
@@ -1824,7 +1830,7 @@ RMSGREAD: scr_flush();
                        goto RMSGREAD;
                case 'r':
                        savedpos = num_msgs;
-                       entmsg(ipc, 1, ((userflags & US_EXTEDIT) ? 2 : 0));
+                       entmsg(ipc, 1, ((userflags & US_EXTEDIT) ? 2 : 0), 0);
                        num_msgs = savedpos;
                        goto RMSGREAD;
                case 'u':
index 4453190b4be938c4e0abb784d704a921d2feb176..ce5c4a64cc29f6b7642100b000eee7567b7185f1 100644 (file)
@@ -5,7 +5,7 @@ extern int num_urls;
 extern char urls[MAXURLS][SIZ];
 
 int ka_system(char *shc);
-int entmsg(CtdlIPC *ipc, int is_reply, int c);
+int entmsg(CtdlIPC *ipc, int is_reply, int c, int masquerade);
 void readmsgs(CtdlIPC *ipc, enum MessageList c, enum MessageDirection rdir, int q);
 void edit_system_message(CtdlIPC *ipc, char *which_message);
 pid_t ka_wait(int *kstatus);
index 74a2f898ff31a0ce9616a1ef7aded23d5d682a38..f8a9791b50ef55fd50a8950f39617a78fd519815 100644 (file)
@@ -2906,8 +2906,8 @@ struct CtdlMessage *CtdlMakeMessage(
        char *supplied_euid,            /* ...or NULL if this is irrelevant */
        char *preformatted_text         /* ...or NULL to read text from client */
 ) {
-       char dest_node[SIZ];
-       char buf[SIZ];
+       char dest_node[256];
+       char buf[1024];
        struct CtdlMessage *msg;
 
        msg = malloc(sizeof(struct CtdlMessage));
@@ -2987,8 +2987,7 @@ struct CtdlMessage *CtdlMakeMessage(
                msg->cm_fields['M'] = preformatted_text;
        }
        else {
-               msg->cm_fields['M'] = CtdlReadMessageBody("000",
-                                       config.c_maxmsglen, NULL, 0);
+               msg->cm_fields['M'] = CtdlReadMessageBody("000", config.c_maxmsglen, NULL, 0);
        }
 
        return(msg);
@@ -3255,10 +3254,9 @@ void cmd_ent0(char *entargs)
        char cc[SIZ];
        char bcc[SIZ];
        char supplied_euid[128];
-       char masquerade_as[SIZ];
        int anon_flag = 0;
        int format_type = 0;
-       char newusername[SIZ];
+       char newusername[256];
        struct CtdlMessage *msg;
        int anonymous = 0;
        char errmsg[SIZ];
@@ -3278,6 +3276,7 @@ void cmd_ent0(char *entargs)
        anon_flag = extract_int(entargs, 2);
        format_type = extract_int(entargs, 3);
        extract_token(subject, entargs, 4, '|', sizeof subject);
+       extract_token(newusername, entargs, 5, '|', sizeof newusername);
        do_confirm = extract_int(entargs, 6);
        extract_token(cc, entargs, 7, '|', sizeof cc);
        extract_token(bcc, entargs, 8, '|', sizeof bcc);
@@ -3301,19 +3300,17 @@ void cmd_ent0(char *entargs)
 
        /* Check some other permission type things. */
 
-       if (post == 2) {
-               if (CC->user.axlevel < 6) {
-                       cprintf("%d You don't have permission to masquerade.\n",
-                               ERROR + HIGHER_ACCESS_REQUIRED);
-                       return;
-               }
-               extract_token(newusername, entargs, 5, '|', sizeof newusername);
-               memset(CC->fake_postname, 0, sizeof(CC->fake_postname) );
-               safestrncpy(CC->fake_postname, newusername,
-                       sizeof(CC->fake_postname) );
-               cprintf("%d ok\n", CIT_OK);
+       if (  (CC->user.axlevel < 6)
+          && (strcasecmp(newusername, CC->user.fullname))
+          && (strcasecmp(newusername, CC->cs_inet_fn))
+       ) {     
+               cprintf("%d You don't have permission to author messages as '%s'.\n",
+                       ERROR + HIGHER_ACCESS_REQUIRED,
+                       newusername
+               );
                return;
        }
+
        CC->cs_flags |= CS_POSTING;
 
        /* In the Mail> room we have to behave a little differently --
@@ -3430,17 +3427,6 @@ void cmd_ent0(char *entargs)
        free(valid_cc);
        free(valid_bcc);
 
-       /* Handle author masquerading */
-       if (CC->fake_postname[0]) {
-               strcpy(masquerade_as, CC->fake_postname);
-       }
-       else if (CC->fake_username[0]) {
-               strcpy(masquerade_as, CC->fake_username);
-       }
-       else {
-               strcpy(masquerade_as, "");
-       }
-
        /* Read in the message from the client. */
        if (do_confirm) {
                cprintf("%d send message\n", START_CHAT_MODE);
@@ -3450,7 +3436,7 @@ void cmd_ent0(char *entargs)
 
        msg = CtdlMakeMessage(&CC->user, recp, cc,
                CC->room.QRname, anonymous, format_type,
-               masquerade_as, subject,
+               newusername, subject,
                ((strlen(supplied_euid) > 0) ? supplied_euid : NULL),
                NULL);
 
@@ -3500,7 +3486,6 @@ void cmd_ent0(char *entargs)
 
                CtdlFreeMessage(msg);
        }
-       CC->fake_postname[0] = '\0';
        if (valid != NULL) {
                free(valid);
        }
index db01ba68fcba90701419c2bb44d8b56486299ec0..bdb7a7ebeb5997643390311811d63b7b2199b046 100644 (file)
@@ -129,11 +129,10 @@ struct CitContext {
        int disable_exp;        /* Set to 1 to disable incoming pages */
        int newmail;            /* Other sessions increment this */
 
-       /* Masquerade... */
-       char fake_username[USERNAME_SIZE];      /* Fake username <bc> */ 
-       char fake_postname[USERNAME_SIZE];      /* Fake postname <bc> */
-       char fake_hostname[64];                 /* Fake hostname <bc> */
-       char fake_roomname[ROOMNAMELEN];        /* Fake roomname <bc> */
+       /* Masqueraded values in the 'who is online' list */
+       char fake_username[USERNAME_SIZE];
+       char fake_hostname[64];
+       char fake_roomname[ROOMNAMELEN];
 
        char preferred_formats[256];            /* Preferred MIME formats */
 
index 4b23c646fa0284cdea803291a9bc16b49265ca6b..296a576774442d87ed2a01678d39cdf8d339c6e3 100644 (file)
@@ -541,7 +541,6 @@ void logout(struct CitContext *who)
         * make that assumption.
         */
        strcpy(who->fake_username, "");
-       strcpy(who->fake_postname, "");
        strcpy(who->fake_hostname, "");
        strcpy(who->fake_roomname, "");
        who->logged_in = 0;