more minor style cleanups
[citadel.git] / citadel / modules / instmsg / serv_instmsg.c
index 9884785373f4701758aabdef6031e2f6b2103b77..1bf8c728a9877ca1b6cd35fa7030b70214d73c39 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This module handles instant messaging between users.
  * 
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2018 by the citadel.org team
  *
  * 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.
@@ -110,12 +110,9 @@ void log_instant_message(struct CitContext *me, struct CitContext *them, char *m
                this_im->conversation = NewStrBuf();
                this_im->next = imlist;
                imlist = this_im;
-               StrBufAppendBufPlain(this_im->conversation, HKEY(
-                       "<html><body>\r\n"
-                       ), 0);
+               StrBufAppendBufPlain(this_im->conversation, HKEY("<html><body>\r\n"), 0);
        }
 
-
        /* Since it's possible for this function to get called more than once if a user is logged
         * in on multiple sessions, we use the message's serial number to keep track of whether
         * we've already logged it.
@@ -152,7 +149,6 @@ void delete_instant_messages(void) {
 }
 
 
-
 /*
  * Retrieve instant messages
  */
@@ -188,6 +184,7 @@ void cmd_gexp(char *argbuf) {
        free(ptr);
 }
 
+
 /*
  * Asynchronously deliver instant messages
  */
@@ -202,6 +199,7 @@ void cmd_gexp_async(void) {
        cprintf("%d instant msg\n", ASYNC_MSG + ASYNC_GEXP);
 }
 
+
 /*
  * Back end support function for send_instant_message() and company
  */
@@ -227,8 +225,6 @@ void add_xmsg_to_context(struct CitContext *ccptr, struct ExpressMessage *newmsg
 }
 
 
-
-
 /* 
  * This is the back end to the instant message sending function.  
  * Returns the number of users to which the message was sent.
@@ -243,7 +239,7 @@ int send_instant_message(char *lun, char *lem, char *x_user, char *x_msg)
        int do_send = 0;                /* 1 = send message; 0 = only check for valid recipient */
        static int serial_number = 0;   /* this keeps messages from getting logged twice */
 
-       if (strlen(x_msg) > 0) {
+       if (!IsEmptyStr(x_msg)) {
                do_send = 1;
        }
 
@@ -289,6 +285,7 @@ int send_instant_message(char *lun, char *lem, char *x_user, char *x_msg)
        return (message_sent);
 }
 
+
 /*
  * send instant messages
  */
@@ -305,10 +302,12 @@ void cmd_sexp(char *argbuf)
                cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
                return;
        }
-       if (CC->fake_username[0])
+       if (CC->fake_username[0]) {
                lun = CC->fake_username;
-       else
+       }
+       else {
                lun = CC->user.fullname;
+       }
 
        lem = CC->cs_inet_email;
 
@@ -358,21 +357,24 @@ void cmd_sexp(char *argbuf)
                message_sent = PerformXmsgHooks(lun, lem, x_user, x_msg);
 
                if (message_sent > 0) {
-                       if (!IsEmptyStr(x_msg))
+                       if (!IsEmptyStr(x_msg)) {
                                cprintf("%d Message sent", CIT_OK);
-                       else
+                       }
+                       else {
                                cprintf("%d Ok to send message", CIT_OK);
-                       if (message_sent > 1)
+                       }
+                       if (message_sent > 1) {
                                cprintf(" to %d users", message_sent);
+                       }
                        cprintf(".\n");
                } else {
-                       if (CtdlGetUser(NULL, x_user))
-                               cprintf("%d '%s' does not exist.\n",
-                                               ERROR + NO_SUCH_USER, x_user);
-                       else
-                               cprintf("%d '%s' is not logged in "
-                                               "or is not accepting pages.\n",
+                       if (CtdlGetUser(NULL, x_user)) {
+                               cprintf("%d '%s' does not exist.\n", ERROR + NO_SUCH_USER, x_user);
+                       }
+                       else {
+                               cprintf("%d '%s' is not logged in or is not accepting instant messages.\n",
                                                ERROR + RESOURCE_NOT_OPEN, x_user);
+                       }
                }
 
 
@@ -380,7 +382,6 @@ void cmd_sexp(char *argbuf)
 }
 
 
-
 /*
  * Enter or exit paging-disabled mode
  */
@@ -457,10 +458,11 @@ void flush_individual_conversation(struct imlog *im) {
        FullMsgBuf = NewStrBufPlain(NULL, StrLength(im->conversation) + 100);
 
        StrBufAppendBufPlain(FullMsgBuf, HKEY(
-                       "Content-type: text/html; charset=UTF-8\r\n"
-                       "Content-Transfer-Encoding: quoted-printable\r\n"
-                       "\r\n"
-                       ), 0);
+               "Content-type: text/html; charset=UTF-8\r\n"
+               "Content-Transfer-Encoding: quoted-printable\r\n"
+               "\r\n"
+               ), 0
+       );
        StrBufAppendBuf (FullMsgBuf, MsgBuf, 0);
        FreeStrBuf(&MsgBuf);
 
@@ -479,7 +481,6 @@ void flush_individual_conversation(struct imlog *im) {
        }
 
        CM_SetField(msg, eOriginalRoom, HKEY(PAGELOGROOM));
-       CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
        CM_SetAsFieldSB(msg, eMesageText, &FullMsgBuf); /* we own this memory now */
 
        /* Start with usernums[1] because it's guaranteed to be higher than usernums[0],