/* * Handles commands the user sends. * * Copyright: This file may be distributed under version 2 of the GPL licence. * * $Id$ */ #include "micq.h" #include "cmd_user.h" #include "util.h" #include "util_ui.h" #include "util_io.h" #include "util_table.h" #include "cmd_pkt_cmd_v5.h" #include "cmd_pkt_cmd_v5_util.h" #include "cmd_pkt_v8.h" #include "cmd_pkt_v8_snac.h" #include "preferences.h" #include "tabs.h" #include "session.h" #include "tcp.h" #include "file_util.h" #include "buildmark.h" #include "contact.h" #include "server.h" #include #include #include #include static jump_f CmdUserChange, CmdUserRandom, CmdUserHelp, CmdUserInfo, CmdUserTrans, CmdUserAuto, CmdUserAlter, CmdUserMessage, CmdUserResend, CmdUserPeek, CmdUserVerbose, CmdUserRandomSet, CmdUserIgnoreStatus, CmdUserSMS, CmdUserStatusDetail, CmdUserStatusWide, CmdUserStatusShort, CmdUserStatusSelf, CmdUserSound, CmdUserSoundOnline, CmdUserRegister, CmdUserSoundOffline, CmdUserAutoaway, CmdUserSet, CmdUserClear, CmdUserTogIgnore, CmdUserTogInvis, CmdUserTogVisible, CmdUserAdd, CmdUserRem, CmdUserRInfo, CmdUserAuth, CmdUserURL, CmdUserSave, CmdUserTabs, CmdUserLast, CmdUserUptime, CmdUserOldSearch, CmdUserSearch, CmdUserUpdate, CmdUserPass, CmdUserOther, CmdUserAbout, CmdUserQuit, CmdUserTCP, CmdUserConn, CmdUserContactDL; static void CmdUserProcess (const char *command, int *idle_val, int *idle_flag); /* 1 = do not apply idle stuff next time v 2 = count this line as being idle v */ static jump_t jump[] = { { &CmdUserRandom, "rand", NULL, 0, 0 }, { &CmdUserRandomSet, "setr", NULL, 0, 0 }, { &CmdUserHelp, "help", NULL, 0, 0 }, { &CmdUserInfo, "info", NULL, 0, 0 }, { &CmdUserTrans, "lang", NULL, 0, 0 }, { &CmdUserTrans, "trans", NULL, 0, 0 }, { &CmdUserAuto, "auto", NULL, 0, 0 }, { &CmdUserAlter, "alter", NULL, 0, 0 }, { &CmdUserMessage, "msg", NULL, 0, 1 }, { &CmdUserMessage, "r", NULL, 0, 2 }, { &CmdUserMessage, "a", NULL, 0, 4 }, { &CmdUserMessage, "msga", NULL, 0, 8 }, { &CmdUserResend, "resend", NULL, 0, 0 }, { &CmdUserVerbose, "verbose", NULL, 0, 0 }, { &CmdUserIgnoreStatus, "i", NULL, 0, 0 }, { &CmdUserStatusDetail, "status", NULL, 2, 0 }, { &CmdUserStatusWide, "wide", NULL, 2, 1 }, { &CmdUserStatusWide, "ewide", NULL, 2, 0 }, { &CmdUserStatusShort, "w", NULL, 2, 1 }, { &CmdUserStatusShort, "e", NULL, 2, 0 }, { &CmdUserStatusSelf, "s", NULL, 0, 0 }, { &CmdUserSet, "set", NULL, 0, 0 }, { &CmdUserSound, "sound", NULL, 2, 0 }, { &CmdUserSoundOnline, "soundonline", NULL, 2, 0 }, { &CmdUserSoundOffline, "soundoffline", NULL, 2, 0 }, { &CmdUserAutoaway, "autoaway", NULL, 2, 0 }, { &CmdUserChange, "change", NULL, 1, -1 }, { &CmdUserChange, "online", NULL, 1, 0 }, { &CmdUserChange, "away", NULL, 1, 1 }, { &CmdUserChange, "na", NULL, 1, 5 }, { &CmdUserChange, "occ", NULL, 1, 17 }, { &CmdUserChange, "dnd", NULL, 1, 19 }, { &CmdUserChange, "ffc", NULL, 1, 32 }, { &CmdUserChange, "inv", NULL, 1, 256 }, { &CmdUserClear, "clear", NULL, 2, 0 }, { &CmdUserTogIgnore, "togig", NULL, 0, 0 }, { &CmdUserTogVisible, "togvis", NULL, 0, 0 }, { &CmdUserTogInvis, "toginv", NULL, 0, 0 }, { &CmdUserAdd, "add", NULL, 0, 0 }, { &CmdUserRem, "rem", NULL, 0, 0 }, { &CmdUserRegister, "reg", NULL, 0, 0 }, { &CmdUserRInfo, "rinfo", NULL, 0, 0 }, { &CmdUserAuth, "auth", NULL, 0, 0 }, { &CmdUserURL, "url", NULL, 0, 0 }, { &CmdUserSave, "save", NULL, 0, 0 }, { &CmdUserTabs, "tabs", NULL, 0, 0 }, { &CmdUserLast, "last", NULL, 0, 0 }, { &CmdUserUptime, "uptime", NULL, 0, 0 }, { &CmdUserTCP, "peer", NULL, 0, 0 }, { &CmdUserTCP, "tcp", NULL, 0, 0 }, { &CmdUserQuit, "q", NULL, 0, 0 }, { &CmdUserPass, "pass", NULL, 0, 0 }, { &CmdUserSMS, "sms", NULL, 0, 0 }, { &CmdUserPeek, "peek", NULL, 0, 0 }, { &CmdUserContactDL, "contactdl", NULL, 0, 0 }, { &CmdUserOldSearch, "oldsearch", NULL, 0, 0 }, { &CmdUserSearch, "search", NULL, 0, 0 }, { &CmdUserUpdate, "update", NULL, 0, 0 }, { &CmdUserOther, "other", NULL, 0, 0 }, { &CmdUserAbout, "about", NULL, 0, 0 }, { &CmdUserConn, "conn", NULL, 0, 0 }, { NULL, NULL, NULL, 0 } }; #define SESSION Session *sess; if (!(sess = SessionFind (TYPE_SERVER, 0))) sess = SessionFind (TYPE_SERVER_OLD, 0); \ if (!sess) { M_print (i18n (1931, "Couldn't find server connection.\n")); return 0; } /* * Returns a pointer to the jump table. */ jump_t *CmdUserTable (void) { return jump; } /* * Looks up an entry in the jump table. */ jump_t *CmdUserLookup (const char *cmd, int flags) { jump_t *j; for (j = CmdUserTable (); j->f; j++) if ( ((flags & CU_DEFAULT) && j->defname && !strcasecmp (cmd, j->defname)) || ((flags & CU_USER) && j->name && !strcasecmp (cmd, j->name))) return j; return NULL; } /* * Looks up just the current command name. */ const char *CmdUserLookupName (const char *cmd) { jump_t *j; j = CmdUserLookup (cmd, CU_DEFAULT); if (!j) j = CmdUserLookup (cmd, CU_USER); if (!j) return ""; if (j->name) return j->name; return j->defname; } /* * Change status. */ static JUMP_F(CmdUserChange) { char *arg1; SESSION; arg1 = strtok (args, " \n\r"); if (data == -1) { if (arg1 == NULL) { M_print (i18n (1703, COLCLIENT "Status modes: \n")); M_print (" %-20s %d\n", i18n (1921, "Online"), STATUS_ONLINE); M_print (" %-20s %d\n", i18n (1923, "Away"), STATUS_AWAY); M_print (" %-20s %d\n", i18n (1922, "Do not disturb"), STATUS_DND); M_print (" %-20s %d\n", i18n (1924, "Not Available"), STATUS_NA); M_print (" %-20s %d\n", i18n (1927, "Free for chat"), STATUS_FFC); M_print (" %-20s %d\n", i18n (1925, "Occupied"), STATUS_OCC); M_print (" %-20s %d", i18n (1926, "Invisible"), STATUS_INV); M_print (COLNONE "\n"); return 0; } data = atoi (arg1); } if (sess->ver > 6) SnacCliSetstatus (sess, data, 1); else { CmdPktCmdStatusChange (sess, data); Time_Stamp (); M_print (" "); Print_Status (sess->status); M_print ("\n"); } return 0; } /* * Finds random user. */ static JUMP_F(CmdUserRandom) { char *arg1; SESSION; arg1 = strtok (args, " \n\r"); if (arg1 == NULL) { M_print (i18n (1704, COLCLIENT "Groups: \n")); M_print (i18n (1705, "General 1\n")); M_print (i18n (1706, "Romance 2\n")); M_print (i18n (1707, "Games 3\n")); M_print (i18n (1708, "Students 4\n")); M_print (i18n (1709, "20 something 6\n")); M_print (i18n (1710, "30 something 7\n")); M_print (i18n (1711, "40 something 8\n")); M_print (i18n (1712, "50+ 9\n")); M_print (i18n (1713, "Man chat requesting women 10\n")); M_print (i18n (1714, "Woman chat requesting men 11\n")); M_print (i18n (1715, "mICQ 49 (might not work but try it)")); M_print (COLNONE "\n"); } else { if (sess->ver > 6) SnacCliSearchrandom (sess, atoi (arg1)); else CmdPktCmdRandSearch (sess, atoi (arg1)); } return 0; } /* * Sets the random user group. */ static JUMP_F(CmdUserRandomSet) { char *arg1; SESSION; arg1 = strtok (args, " \n\r"); if (arg1 == NULL) { M_print (i18n (1704, COLCLIENT "Groups: \n")); if (sess->ver > 6) M_print (i18n (2010, "None 0\n")); else M_print (i18n (1716, "None -1\n")); M_print (i18n (1705, "General 1\n")); M_print (i18n (1706, "Romance 2\n")); M_print (i18n (1707, "Games 3\n")); M_print (i18n (1708, "Students 4\n")); M_print (i18n (1709, "20 something 6\n")); M_print (i18n (1710, "30 something 7\n")); M_print (i18n (1711, "40 something 8\n")); M_print (i18n (1712, "50+ 9\n")); M_print (i18n (1713, "Man chat requesting women 10\n")); M_print (i18n (1714, "Woman chat requesting men 11\n")); M_print (i18n (1715, "mICQ 49 (might not work but try it)")); M_print (COLNONE "\n"); } else { if (sess->ver > 6) SnacCliSetrandom (sess, atoi (arg1)); else CmdPktCmdRandSet (sess, atoi (arg1)); } return 0; } /* * Displays help. */ /* TODO: needs updateing */ static JUMP_F(CmdUserHelp) { char *arg1; arg1 = strtok (args, " \n\r"); if (!arg1) { M_print (COLCLIENT "%s\n", i18n (1442, "Please select one of the help topics below.")); M_print ("%s\t-\t%s\n", i18n (1447, "Client"), i18n (1443, "Commands relating to mICQ displays and configuration.")); M_print ("%s\t-\t%s\n", i18n (1448, "Message"), i18n (1446, "Commands relating to sending messages.")); M_print ("%s\t-\t%s\n", i18n (1449, "User"), i18n (1444, "Commands relating to finding other users.")); M_print ("%s\t-\t%s\n", i18n (1450, "Account"), i18n (1445, "Commands relating to your ICQ account.")); } else if (!strcasecmp (arg1, i18n (1447, "Client"))) { M_print (COLMESS "%s []" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("verbose"), i18n (1418, "Set the verbosity level, or display verbosity level.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("clear"), i18n (1419, "Clears the screen.")); M_print (COLMESS "%s [%s|%s|]" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("sound"), i18n (1085, "on"), i18n (1086, "off"), i18n (1420, "Switches beeping when receiving new messages on or off, sets a command for this event or displays current state of this option.")); M_print (COLMESS "%s [%s|%s|]" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("soundonline"), i18n (1085, "on"), i18n (1086, "off"), i18n (2040, "Switches beeping for incoming contacts on or off, sets a command for this event or displays current state of this option.")); M_print (COLMESS "%s [%s|%s|]" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("soundoffline"), i18n (1085, "on"), i18n (1086, "off"), i18n (2041, "Switches beeping for offgoing contacts on or off, sets a command for this event or displays current state of this option.")); M_print (COLMESS "%s []" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("autoaway"), i18n (1767, "Toggles auto cycling to away/not available.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("q"), i18n (1422, "Logs off and quits.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("auto"), i18n (1423, "Displays your autoreply status.")); M_print (COLMESS "%s [on|off]" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("auto"), i18n (1424, "Toggles sending messages when your status is DND, NA, etc.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("auto"), i18n (1425, "Sets the message to send as an auto reply for the status.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("alter"), i18n (1417, "This command allows you to alter your command set on the fly.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("trans"), i18n (1800, "Change the working language to .")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("uptime"), i18n (2035, "Show uptime and some statistics.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("save"), i18n (2036, "Save current preferences to disc.")); M_print (COLMESS "%s open|close|off uin|nick" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("peer"), i18n (2037, "Open or close a peer-to-peer connection, or disable using peer-to-peer connections for uin|nick.")); M_print (COLMESS "%s open|login " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("conn"), i18n (2038, "Opens connection number nr.")); M_print (COLMESS "%s color|funny|quiet " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("set"), i18n (2044, "Set or clear an option.")); M_print (" " COLCLIENT "\x1b«%s\x1b»" COLNONE "\n", i18n (1717, "! as the first character of a command will execute a shell command (e.g. \"!ls\" \"!dir\" \"!mkdir temp\")")); } else if (!strcasecmp (arg1, i18n (1448, "Message"))) { M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("auth"), i18n (1413, "Authorize uin or nick to add you to their list.")); M_print (COLMESS "%s []" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("msg"), i18n (1409, "Sends a message to uin or nick.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("url"), i18n (1410, "Sends a url and message to uin.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("sms"), i18n (2039, "Sends a message to a cell phone.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("msga"), i18n (1411, "Sends a multiline message to everyone on your list.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("a"), i18n (1412, "Sends a message to the last person you sent a message to.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("r"), i18n (1414, "Replys to the last person to send you a message.")); M_print (COLMESS "%s []" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("last"), i18n (1403, "Displays the last message received from , or a list of who has send you at least one message.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("tabs"), i18n (1098, "Display a list of nicknames that you can tab through.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("resend"), i18n (1770, "Resend your last message to a new uin.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("uptime"), i18n (1719, "Shows how long mICQ has been running.")); M_print (" " COLCLIENT "\x1b«%s\x1b»" COLNONE "\n", i18n (1720, "uin can be either a number or the nickname of the user.")); M_print (" " COLCLIENT "\x1b«%s\x1b»" COLNONE "\n", i18n (1721, "Sending a blank message will put the client into multiline mode.\nUse . on a line by itself to end message.\nUse # on a line by itself to cancel the message.")); } else if (!strcasecmp (arg1, i18n (1449, "User"))) { M_print (COLMESS "%s []" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("rand"), i18n (1415, "Finds a random user in the specified group or lists the groups.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("pass"), i18n (1408, "Changes your password to secret.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("status"), i18n (1400, "Shows locally stored info on user.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("s"), i18n (1769, "Displays your current online status.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("w"), i18n (1416, "Displays the current status of everyone on your contact list.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("e"), i18n (1407, "Displays the current status of online people on your contact list.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("wide"), i18n (1801, "Displays a list of people on your contact list in a screen wide format.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("ewide"), i18n (2042, "Displays a list of online people on your contact list in a screen wide format.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("info"), i18n (1430, "Displays general info on uin.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("i"), i18n (1405, "Lists ignored nicks/uins.")); M_print (COLMESS "%s [|| ]" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("search"), i18n (1429, "Searches for a ICQ user.")); M_print (COLMESS "%s []" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("add"), i18n (1428, "Adds the uin number to your contact list with nickname, or renames it.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("rem"), i18n (2043, "Remove contact from your contact list.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("togig"), i18n (1404, "Toggles ignoring/unignoring nick.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("toginv"), i18n (2045, "Toggles your visibility to a user when you're online.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("togvis"), i18n (1406, "Toggles your visibility to a user when you're invisible.")); } else if (!strcasecmp (arg1, i18n (1450, "Account"))) { M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("change"), i18n (1427, "Changes your status to the status number. Without a number it lists the available modes.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("reg"), i18n (1426, "Creates a new UIN with the specified password.")); M_print (COLMESS "%s|%s|%s|%s|%s|%s|%s" COLNONE "\n\t\x1b«%s\n%s\n%s\n%s\n%s\n%s\n%s\x1b»\n", CmdUserLookupName ("online"), CmdUserLookupName ("away"), CmdUserLookupName ("na"), CmdUserLookupName ("occ"), CmdUserLookupName ("dnd"), CmdUserLookupName ("ffc"), CmdUserLookupName ("inv"), i18n (1431, "Change status to Online."), i18n (1432, "Mark as Away."), i18n (1433, "Mark as Not Available."), i18n (1434, "Mark as Occupied."), i18n (1435, "Mark as Do not Disturb."), i18n (1436, "Mark as Free for Chat."), i18n (1437, "Mark as Invisible.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("update"), i18n (1438, "Updates your basic info (email, nickname, etc.).")); M_print (COLMESS "other" COLNONE "\n\t\x1b«%s\x1b»\n", i18n (1401, "Updates more user info like age and sex.")); M_print (COLMESS "%s" COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("about"), i18n (1402, "Updates your about user info.")); M_print (COLMESS "%s " COLNONE "\n\t\x1b«%s\x1b»\n", CmdUserLookupName ("setr"), i18n (1439, "Sets your random user group.")); } return 0; } /* * Sets a new password. */ static JUMP_F(CmdUserPass) { char *arg1; SESSION; arg1 = strtok (args, "\n"); if (!arg1) M_print (i18n (2012, "No password given.\n")); else { if (sess->ver < 6) CmdPktCmdMetaPass (sess, arg1); else SnacCliMetasetpass (sess, arg1); sess->passwd = strdup (arg1); if (sess->spref->passwd && strlen (sess->spref->passwd)) sess->spref->passwd = strdup (arg1); } return 0; } /* * Sends an SMS message. */ static JUMP_F(CmdUserSMS) { char *arg1, *arg2; SESSION; if (sess->ver < 6) { M_print (i18n (2013, "This command is v8 only.\n")); return 0; } arg1 = strtok (args, " "); if (!arg1) M_print (i18n (2014, "No number given.\n")); else { arg2 = strtok (NULL, "\n"); if (!arg2) M_print (i18n (2015, "No message given.\n")); SnacCliSendsms (sess, arg1, arg2); } return 0; } /* * Queries basic info of a user */ static JUMP_F(CmdUserInfo) { char *arg1; UDWORD uin; SESSION; arg1 = strtok (args, "\n"); if (arg1 == NULL) { M_print (i18n (1932, "Need uin to ask for.\n")); return 0; } uin = ContactFindByNick (arg1); if (-1 == uin) { M_print (i18n (1061, "%s not recognized as a nick name.\n"), arg1); return 0; } M_print (i18n (1672, "%s's IP address is "), arg1); Print_IP (uin); if ((UWORD) Get_Port (uin) != (UWORD) 0xffff) { M_print (i18n (1673, "\tThe port is %d\n"), (UWORD) Get_Port (uin)); } else { M_print (i18n (1674, "\tThe port is unknown\n")); } M_print (i18n (1765, "%s has UIN %d."), arg1, uin); M_print ("\n"); if (sess->ver > 6) SnacCliMetareqinfo (sess, uin); else CmdPktCmdMetaReqInfo (sess, uin); /* send_ext_info_req( sok, uin );*/ return 0; } /* * Peeks whether a user is really offline. */ static JUMP_F(CmdUserPeek) { UDWORD uin; SESSION; if (sess->ver < 6) return 0; if (!args || !*args) { M_print (i18n (2028, "Wrong argument count.\n"), strlen(args)); return 0; } uin = ContactFindByNick (args); if (uin == -1) M_print (i18n (1061, "%s not recognized as a nick name.\n"), args); else SnacCliSendmsg (sess, uin, "", 0xe8); return 0; } /* * Gives information about internationalization and translates * strings by number. */ static JUMP_F(CmdUserTrans) { const char *arg1; int ver; arg1 = strtok (args, " \t\n"); if (!arg1) { ver = atoi (i18n (1003, "0")); /* i18n (1079, "Translation (%s, %s) from %s, last modified on %s by %s, for mICQ %d.%d.%d%s.\n") */ M_print (i18n (-1, "1079:No translation; using compiled-in strings.¶"), i18n (1001, ""), i18n (1002, ""), i18n (1004, ""), i18n (1006, ""), i18n (1005, ""), ver / 1000, (ver / 100) % 10, (ver / 10) % 10, ver % 10 ? UtilFill (".pl%d", ver % 10) : ""); return 0; } for (;arg1; arg1 = strtok (NULL, " \t")) { char *p; int i; i = strtol (arg1, &p, 10); if (i || !*p) { if (*p) M_print ("%s\n", i18n (1087, "Ignoring garbage after number.")); M_print ("%3d:%s\n", i, i18n (i, i18n (1078, "No translation available."))); } else { if (!strcmp (arg1, "all")) { const char *p; int l = 0; for (i = 0; i - l < 100; i++) { p = i18n (i, NULL); if (p) { l = i; M_print ("%3d:%s\n", i, p); } } } else { if (!strcmp (arg1, ".") || !strcmp (arg1, "none") || !strcmp (arg1, "unload")) { p = strdup (i18n (1089, "Unloaded translation.")); i18nClose (); M_print ("%s\n", p); free (p); continue; } i = i18nOpen (arg1); if (i == -1) M_print (i18n (1080, "Couldn't load \"%s\" internationalization.\n"), arg1); else if (i) M_print (i18n (1081, "Successfully loaded en translation (%d entries).\n"), i); else M_print ("No internationalization requested.\n"); } } } return 0; } /* * Manually handles peer-to-peer (TCP) connections. */ static JUMP_F(CmdUserTCP) { #ifdef TCP_COMM char *cmd, *nick; UDWORD uin; Session *sess; cmd = strtok (args, " \t\n"); if (cmd) { nick = strtok (NULL, " \t\n"); if (!nick) { M_print (i18n (1916, "Need a nick or uin.\n")); return 0; } uin = ContactFindByNick (nick); if (uin == -1) { M_print (i18n (1845, "Nick %s unknown.\n"), nick); return 0; } sess = SessionFind (TYPE_LISTEN, 0); if (!sess) { M_print (i18n (2011, "You do not have a listening peer-to-peer connection.\n")); return 0; } if (!strcmp (cmd, "open")) TCPDirectOpen (sess, uin); else if (!strcmp (cmd, "close")) TCPDirectClose ( uin); else if (!strcmp (cmd, "reset")) TCPDirectClose ( uin); else if (!strcmp (cmd, "off")) TCPDirectOff ( uin); #ifdef WIP else if (!strcmp (cmd, "file")) { char *files[10], *ass[10], *des = NULL, *as; int count; for (count = 0; count < 10; count++) { des = strtok (NULL, " \t\n"); if (!des) { des = "no descriptione, sir."; break; } as = strtok (NULL, " \t\n"); if (!as) break; if (*as == '/' && !*(as + 1)) as = (index (des, '/')) ? rindex (des, '/') + 1 : des; if (*as == '.' && !*(as + 1)) as = des; files[count] = des; ass[count] = as; } TCPSendFiles (sess, uin, des, files, ass, count); } #endif else if (!strcmp (cmd, "auto")) TCPGetAuto (sess, uin, 0); else if (!strcmp (cmd, "away")) TCPGetAuto (sess, uin, TCP_MSG_GET_AWAY); else if (!strcmp (cmd, "na")) TCPGetAuto (sess, uin, TCP_MSG_GET_NA); else if (!strcmp (cmd, "dnd")) TCPGetAuto (sess, uin, TCP_MSG_GET_DND); else if (!strcmp (cmd, "ffc")) TCPGetAuto (sess, uin, TCP_MSG_GET_FFC); } else { M_print (i18n (1846, "Opens and closes TCP connections:\n")); M_print (i18n (1847, " open - Opens TCP connection.\n")); M_print (i18n (1848, " close - Closes/resets TCP connection(s).\n")); M_print (i18n (1870, " off - Closes TCP connection(s) and don't try TCP again.\n")); M_print (i18n (2056, " auto - Get the auto-response from the contact.\n")); M_print (i18n (2057, " away - Get the auto-response for away from the contact.\n")); M_print (i18n (2058, " na - Get the auto-response for not available from the contact.\n")); M_print (i18n (2059, " dnd - Get the auto-response for do not disturb from the contact.\n")); M_print (i18n (2060, " ffc - Get the auto-response for free for chat from the contact.\n")); } #else M_print (i18n (1866, "This version of mICQ is compiled without TCP support.\n")); #endif return 0; } /* * Changes automatic reply messages. */ static JUMP_F(CmdUserAuto) { char *cmd; char *arg1; cmd = strtok (args, "\n"); if (cmd == NULL) { M_print (i18n (1724, "Automatic replies are %s.\n"), prG->flags & FLAG_AUTOREPLY ? i18n (1085, "on") : i18n (1086, "off")); M_print ("%30s %s\n", i18n (1727, "The do not disturb message is:"), prG->auto_dnd); M_print ("%30s %s\n", i18n (1728, "The away message is:"), prG->auto_away); M_print ("%30s %s\n", i18n (1729, "The not available message is:"), prG->auto_na); M_print ("%30s %s\n", i18n (1730, "The occupied message is:"), prG->auto_occ); M_print ("%30s %s\n", i18n (1731, "The invisible message is:"), prG->auto_inv); M_print ("%30s %s\n", i18n (2054, "The free for chat message is:"), prG->auto_ffc); return 0; } else if (strcasecmp (cmd, "on") == 0) { prG->flags |= FLAG_AUTOREPLY; M_print (i18n (1724, "Automatic replies are %s.\n"), i18n (1085, "on")); } else if (strcasecmp (cmd, "off") == 0) { prG->flags &= ~FLAG_AUTOREPLY; M_print (i18n (1724, "Automatic replies are %s.\n"), i18n (1086, "off")); } else { arg1 = strtok (cmd, " \t\n"); if (arg1 == NULL) { M_print (i18n (1734, "Sorry wrong syntax, can't find a status somewhere.\r\n")); return 0; } if (!strcasecmp (arg1, CmdUserLookupName ("dnd"))) { cmd = strtok (NULL, "\n"); if (cmd == NULL) { M_print (i18n (1735, "Must give a message.\n")); return 0; } prG->auto_dnd = strdup (cmd); } else if (!strcasecmp (arg1, CmdUserLookupName ("away"))) { cmd = strtok (NULL, "\n"); if (cmd == NULL) { M_print (i18n (1735, "Must give a message.\n")); return 0; } prG->auto_away = strdup (cmd); } else if (!strcasecmp (arg1, CmdUserLookupName ("na"))) { cmd = strtok (NULL, "\n"); if (cmd == NULL) { M_print (i18n (1735, "Must give a message.\n")); return 0; } prG->auto_na = strdup (cmd); } else if (!strcasecmp (arg1, CmdUserLookupName ("occ"))) { cmd = strtok (NULL, "\n"); if (cmd == NULL) { M_print (i18n (1735, "Must give a message.\n")); return 0; } prG->auto_occ = strdup (cmd); } else if (!strcasecmp (arg1, CmdUserLookupName ("inv"))) { cmd = strtok (NULL, "\n"); if (cmd == NULL) { M_print (i18n (1735, "Must give a message.\n")); return 0; } prG->auto_inv = strdup (cmd); } else if (!strcasecmp (arg1, CmdUserLookupName ("ffc"))) { cmd = strtok (NULL, "\n"); if (cmd == NULL) { M_print (i18n (1735, "Must give a message.\n")); return 0; } prG->auto_ffc = strdup (cmd); } else M_print (i18n (1736, "Sorry wrong syntax. Read tha help man!\n")); M_print (i18n (1737, "Automatic reply setting\n")); } return 0; } /* * Relabels commands. */ static JUMP_F(CmdUserAlter) { char *cmd; jump_t *j; int quiet = 0; cmd = strtok (args, " \t\n"); if (cmd && !strcasecmp ("quiet", cmd)) { quiet = 1; cmd = strtok (NULL, " \t\n"); } if (cmd == NULL) { M_print (i18n (1738, "Need a command to alter!\n")); return 0; } j = CmdUserLookup (cmd, CU_DEFAULT); if (!j) j = CmdUserLookup (cmd, CU_USER); if (!j) { M_print (i18n (1722, "Type help to see your current command, because this one you typed wasn't one!")); M_print ("\n"); } else { char *new = strtok (NULL, " \t\n"); if (new) { if (CmdUserLookup (new, CU_USER)) { if (!quiet) { M_print (i18n (1768, "The label '%s' is already being used."), new); M_print ("\n"); } return 0; } else { if (j->name) free ((char *) j->name); j->name = strdup (new); } } if (!quiet) { if (j->name) M_print (i18n (1763, "The command '%s' has been renamed to '%s'."), j->defname, j->name); else M_print (i18n (1764, "The command '%s' is unchanged."), j->defname); M_print ("\n"); } } return 0; } /* * Resend your last message */ static JUMP_F (CmdUserResend) { UDWORD uin; char *arg1, *b; SESSION; if (!uiG.last_message_sent) { M_print (i18n (1771, "You haven't sent a message to anyone yet!\n")); return 0; } #ifdef HAVE_STRTOK_R arg1 = strtok_r (args, UIN_DELIMS, &b); #else arg1 = strtok (args, UIN_DELIMS); #endif if (!arg1) { M_print (i18n (1676, "Need uin to send to.\n")); return 0; } while (arg1) { uin = ContactFindByNick (arg1); if (uin == -1) M_print (i18n (1061, "%s not recognized as a nick name.\n"), arg1); else icq_sendmsg (sess, uiG.last_sent_uin = uin, uiG.last_message_sent, uiG.last_message_sent_type); #ifdef HAVE_STRTOK_R arg1 = strtok_r (NULL, UIN_DELIMS, &b); #else arg1 = NULL; #endif } return 0; } /* * Send an instant message. */ static JUMP_F (CmdUserMessage) { static UDWORD multi_uin; static int offset = 0; static char msg[1024]; char *arg1 = NULL, *p, *temp; int len; UDWORD uin = 0; Contact *cont; SESSION; if (status) { arg1 = args; msg[offset] = 0; if (strcmp (arg1, END_MSG_STR) == 0) { msg[offset - 1] = msg[offset - 2] = 0; if (multi_uin == -1) { char *temp; for (cont = ContactStart (); ContactHasNext (cont); cont = ContactNext (cont)) { temp = strdup (msg); icq_sendmsg (sess, cont->uin, temp, MRNORM_MESS); free (temp); } } else { icq_sendmsg (sess, multi_uin, msg, NORM_MESS); uiG.last_sent_uin = multi_uin; } return 0; } else if (strcmp (arg1, CANCEL_MSG_STR) == 0) { M_print (i18n (1038, "Message canceled\n")); return 0; } else { int diff, first = 1; while (offset + strlen (arg1) + 2 > 450) { M_print (i18n (1037, "Message sent before last line buffer is full\n")); if (first) { diff = 0; first = 0; } else { diff = 450 - offset - 2; while (arg1[diff] != ' ') if (!--diff) break; diff = diff ? diff : 450 - offset - 2; snprintf (msg + offset, diff, "%s\r\n", arg1); arg1 += diff; while (*arg1 == ' ') arg1++; } if (multi_uin == -1) { for (cont = ContactStart (); ContactHasNext (cont); cont = ContactNext (cont)) { temp = strdup (msg); icq_sendmsg (sess, cont->uin, temp, MRNORM_MESS); free (temp); } } else { temp = strdup (msg); icq_sendmsg (sess, multi_uin, temp, NORM_MESS); free (temp); uiG.last_sent_uin = multi_uin; } msg[0] = '\0'; offset = 0; } strcat (msg, arg1); strcat (msg, "\r\n"); offset += strlen (arg1) + 2; } } else { switch (data) { case 1: arg1 = strtok (p = strdup (args), UIN_DELIMS); if (!arg1) { M_print (i18n (1676, "Need uin to send to.\n")); return 0; } uin = ContactFindByNick (arg1); len = 0; while (uin == -1) { len += strlen (arg1); free (p); p = strdup (args); arg1 = strtok (p + len + 1, UIN_DELIMS); if (!arg1) { M_print (i18n (1061, "%s not recognized as a nick name.\n"), strtok (args, UIN_DELIMS)); return 0; } uin = ContactFindByNick (p); } arg1 = strtok (NULL, "\n"); break; case 2: if (!uiG.last_rcvd_uin) { M_print (i18n (1741, "Must receive a message first\n")); return 0; } uin = uiG.last_rcvd_uin; arg1 = strtok (args, "\n"); break; case 4: if (!uiG.last_sent_uin) { M_print (i18n (1742, "Must write one message first\n")); return 0; } uin = uiG.last_sent_uin; arg1 = strtok (args, "\n"); break; case 8: uin = -1; arg1 = strtok (args, "\n"); break; default: assert (0); } if (data != 8) { uiG.last_sent_uin = uin; TabAddUIN (uin); } if (arg1) { if (data == 8) { char *temp; for (cont = ContactStart (); ContactHasNext (cont); cont = ContactNext (cont)) { temp = strdup (arg1); icq_sendmsg (sess, cont->uin, temp, MRNORM_MESS); free (temp); } } else { icq_sendmsg (sess, uin, arg1, NORM_MESS); uiG.last_sent_uin = uin; } return 0; } multi_uin = uin; if (uin == -1) M_print (i18n (1664, "Composing message to " COLCONTACT "all" COLNONE ":\n")); else if (ContactFindNick (uin)) M_print (i18n (1739, "Composing message to " COLCONTACT "%s" COLNONE ":\n"), ContactFindNick (uin)); else M_print (i18n (1740, "Composing message to " COLCLIENT "%d" COLNONE ":\n"), uin); offset = 0; status = data; } if (status == 8) R_doprompt (i18n (1042, "msg all> ")); else R_doprompt (i18n (1041, "msg> ")); return status; } /* * Changes verbosity. */ static JUMP_F(CmdUserVerbose) { char *arg1; arg1 = strtok (args, "\n"); if (arg1 != NULL) { prG->verbose = atoi (arg1); } M_print (i18n (1060, "Verbosity level is %d.\n"), prG->verbose); return 0; } /* * Shows the contact list in a very detailed way. */ static JUMP_F(CmdUserStatusDetail) { UDWORD num; Contact *cont; char *name = strtok (args, "\n"); SESSION; if (name) { num = ContactFindByNick (name); if (num == -1) { M_print (i18n (1699, "Must give a valid uin/nickname\n")); return 0; } cont = ContactFind (num); if (cont == NULL) { M_print (i18n (1700, "%s is not a valid user in your list.\n"), name); return 0; } if (cont->flags & CONT_TEMPORARY) M_print (COLSERV "#" COLNONE); else if (cont->flags & CONT_INTIMATE) M_print (COLSERV "*" COLNONE); else if (cont->flags & CONT_HIDEFROM) M_print (COLSERV "-" COLNONE); else if (cont->flags & CONT_IGNORE) M_print (COLSERV "^" COLNONE); else M_print (" "); M_print ("%6ld=", cont->uin); M_print (COLCONTACT "%-20s\t%s(", cont->nick, COLMESS); Print_Status (cont->status); M_print (")%s\n", COLNONE); if (cont->status == STATUS_OFFLINE) { if (-1L != cont->last_time) { M_print (i18n (1069, " Last online at %s"), ctime ((time_t *) & cont->last_time)); } else { M_print (i18n (1070, " Last on-line unknown.")); M_print ("\n"); } } else { if (-1L != cont->last_time) { M_print (i18n (1068, " Online since %s"), ctime ((time_t *) & cont->last_time)); } else { M_print (i18n (1070, " Last on-line unknown.")); M_print ("\n"); } } M_print ("%-15s %s:%d\n", i18n (1441, "IP:"), UtilIOIP (cont->outside_ip), cont->port); M_print ("%-15s %d\n", i18n (1453, "TCP version:"), cont->TCP_version); M_print ("%-15s %s\n", i18n (1454, "Connection:"), cont->connection_type == 4 ? i18n (1493, "Peer-to-Peer") : i18n (1494, "Server Only")); M_print ("%-15s %08x\n", i18n (2026, "TCP cookie:"), cont->cookie); return 0; } M_print (W_SEPERATOR); Time_Stamp (); M_print (" "); M_print (i18n (1071, "Your status is ")); Print_Status (sess->status); M_print ("\n"); /* First loop sorts thru all offline users */ M_print ("%s%s\n", W_SEPERATOR, i18n (1072, "Users offline:")); for (cont = ContactStart (); ContactHasNext (cont); cont = ContactNext (cont)) { if (!(cont->flags & CONT_ALIAS)) { if (!(cont->flags & CONT_IGNORE)) { if (cont->status == STATUS_OFFLINE) { if (cont->flags & CONT_INTIMATE) M_print (COLSERV "*" COLNONE); else M_print (" "); M_print ("%8ld=", cont->uin); M_print (COLCONTACT "%-20s\t%s(", cont->nick, COLMESS); Print_Status (cont->status); M_print (")" COLNONE); if (-1L != cont->last_time) { M_print (i18n (1069, " Last online at %s"), ctime ((time_t *) & cont->last_time)); } else { M_print (i18n (1070, " Last on-line unknown.")); M_print ("\n"); /* if time is unknow they can't be logged on cause we */ /* set the time at login */ } } } } } /* The second loop displays all the online users */ M_print ("%s%s\n", W_SEPERATOR, i18n (1073, "Users online:")); for (cont = ContactStart (); ContactHasNext (cont); cont = ContactNext (cont)) { if (!(cont->flags & CONT_ALIAS)) { if (!(cont->flags & CONT_IGNORE)) { if (cont->status != STATUS_OFFLINE) { if (cont->flags & CONT_INTIMATE) M_print (COLSERV "*" COLNONE); else M_print (" "); M_print ("%8ld=", cont->uin); M_print (COLCONTACT "%-20s\t%s(", cont->nick, COLMESS); Print_Status (cont->status); M_print (")" COLNONE); if (-1L != cont->last_time) { if (cont->status == STATUS_OFFLINE) M_print (i18n (1069, " Last online at %s"), ctime ((time_t *) & cont->last_time)); else M_print (i18n (1068, " Online since %s"), ctime ((time_t *) & cont->last_time)); } else { M_print (i18n (1070, " Last on-line unknown.")); M_print ("\n"); /* if time is unknow they can't be logged on cause we */ /* set the time at login */ } } } } } M_print (W_SEPERATOR); return 0; } /* * Shows the ignored user on the contact list. */ static JUMP_F(CmdUserIgnoreStatus) { Contact *cont; M_print ("%s%s\n", W_SEPERATOR, i18n (1062, "Users ignored:")); /* Sorts thru all ignored users */ for (cont = ContactStart (); ContactHasNext (cont); cont = ContactNext (cont)) { if (!(cont->flags & CONT_ALIAS)) { if (cont->flags & CONT_IGNORE) { if (cont->flags & CONT_INTIMATE) M_print (COLSERV "*" COLNONE); else if (cont->flags & CONT_HIDEFROM) M_print (COLSERV "~" COLNONE); else M_print (" "); M_print (COLCONTACT "%-20s\t" COLMESS "(", cont->nick); Print_Status (cont->status); M_print (")" COLNONE "\n"); } } } M_print (W_SEPERATOR); return 0; } /* * Displays the contact list in a wide format, similar to the ls command. */ static JUMP_F(CmdUserStatusWide) { Contact **Online; /* definitely won't need more; could */ Contact **Offline = NULL; /* probably get away with less. */ int MaxLen = 0; /* legnth of longest contact name */ int i; int OnIdx = 0; /* for inserting and tells us how many there are */ int OffIdx = 0; /* for inserting and tells us how many there are */ int NumCols; /* number of columns to display on screen */ Contact *cont = NULL; if (data) { if ((Offline = (Contact **) malloc (MAX_CONTACTS * sizeof (Contact *))) == NULL) { M_print (i18n (1652, "Insuffificient memory to display a wide Contact List.\n")); return 0; } } if ((Online = (Contact **) malloc (MAX_CONTACTS * sizeof (Contact *))) == NULL) { M_print (i18n (1652, "Insuffificient memory to display a wide Contact List.\n")); return 0; } /* Filter the contact list into two lists -- online and offline. Also find the longest name in the list -- this is used to determine how many columns will fit on the screen. */ for (cont = ContactStart (); ContactHasNext (cont); cont = ContactNext (cont)) { if (!(cont->flags & CONT_ALIAS)) { if (cont->status == STATUS_OFFLINE) { if (data) { Offline[OffIdx++] = cont; if (strlen (cont->nick) > MaxLen) MaxLen = strlen (cont->nick); } } else { Online[OnIdx++] = cont; if (strlen (cont->nick) > MaxLen) MaxLen = strlen (cont->nick); } } } /* end for */ /* This is probably a very ugly way to determine the number of columns to use... it's probably specific to my own contact list. */ NumCols = Get_Max_Screen_Width () / (MaxLen + 4); if (NumCols < 1) NumCols = 1; /* sanity check. :) */ if (data) { /* Fairly simple print routine. We check that we only print the right number of columns to the screen. */ M_print (COLMESS); for (i = 0; i < (Get_Max_Screen_Width () - strlen (i18n (1653, "Offline"))) / 2; i++) { M_print ("="); } M_print (COLCLIENT "%s" COLMESS, i18n (1653, "Offline")); for (i += strlen (i18n (1653, "Offline")); i < Get_Max_Screen_Width (); i++) { M_print ("="); } M_print (COLNONE "\n"); for (i = 0; i < OffIdx; i++) { M_print (COLCONTACT " %-*s" COLNONE, MaxLen + 2, Offline[i]->nick); if ((i + 1) % NumCols == 0) M_print ("\n"); } if (i % NumCols != 0) M_print ("\n"); } /* The user status for Online users is indicated by a one-character prefix to the nickname. Unfortunately not all statuses (statusae? :) are unique at one character. A better way to encode the information is needed. */ M_print (COLMESS); for (i = 0; i < (Get_Max_Screen_Width () - strlen (i18n (1654, "Online"))) / 2; i++) { M_print ("="); } M_print (COLCLIENT "%s" COLMESS, i18n (1654, "Online")); for (i += strlen (i18n (1654, "Online")); i < Get_Max_Screen_Width (); i++) { M_print ("="); } M_print (COLNONE "\n"); for (i = 0; i < OnIdx; i++) { const char *status; char weird = 'W'; /* for weird statuses that are reported as hex */ status = Convert_Status_2_Str (Online[i]->status); status = status ? status : &weird; if ((Online[i]->status & 0xfff) == STATUS_ONLINE) { status = " "; } M_print (COLNONE "%c " COLCONTACT "%-*s" COLNONE, *status, MaxLen + 2, Online[i]->nick); if ((i + 1) % NumCols == 0) M_print ("\n"); } if (i % NumCols != 0) { M_print ("\n"); } M_print (COLMESS); for (i = 0; i < Get_Max_Screen_Width (); i++) { M_print ("="); } M_print (COLNONE "\n"); free (Online); if (data) free (Offline); return 0; } /* * Display your personal online status */ static JUMP_F(CmdUserStatusSelf) { SESSION; M_print (W_SEPERATOR); Time_Stamp (); M_print (" " MAGENTA BOLD "%10lu" COLNONE " ", sess->uin); M_print (i18n (1071, "Your status is ")); Print_Status (sess->status); M_print ("\n"); M_print (W_SEPERATOR); return 0; } /* * Display offline and online users on your contact list. */ static JUMP_F(CmdUserStatusShort) { Contact *cont; SESSION; M_print (W_SEPERATOR); Time_Stamp (); M_print (" " MAGENTA BOLD "%10lu" COLNONE " ", sess->uin); M_print (i18n (1071, "Your status is ")); Print_Status (sess->status); M_print ("\n"); if (data) { M_print ("%s%s\n", W_SEPERATOR, i18n (1072, "Users offline:")); for (cont = ContactStart (); ContactHasNext (cont); cont = ContactNext (cont)) { if (!(cont->flags & CONT_ALIAS)) { if (!(cont->flags & CONT_IGNORE)) { if (cont->status == STATUS_OFFLINE) { if (cont->flags & CONT_INTIMATE) M_print (COLSERV "*" COLNONE); else M_print (" "); M_print (COLCONTACT "%-20s\t" COLMESS "(", cont->nick); Print_Status (cont->status); M_print (")" COLNONE "\n"); } } } } } M_print ("%s%s\n", W_SEPERATOR, i18n (1073, "Users online:")); for (cont = ContactStart (); ContactHasNext (cont); cont = ContactNext (cont)) { if (!(cont->flags & CONT_ALIAS)) { if (!(cont->flags & CONT_IGNORE)) { if (cont->status != STATUS_OFFLINE) { if (cont->flags & CONT_INTIMATE) M_print (COLSERV "*" COLNONE); else M_print (" "); M_print (COLCONTACT "%-20s\t" COLMESS "(", cont->nick); Print_Status (cont->status); M_print (")" COLNONE); if (cont->version) M_print (" [%s]", cont->version); if (cont->status & STATUSF_BIRTH) M_print (" (%s)", i18n (2033, "born today")); M_print ("\n"); } } } } M_print (W_SEPERATOR); return 0; } /* * Toggles sound or changes sound command. */ static JUMP_F(CmdUserSound) { char *arg1; if ((arg1 = strtok (args, "\n"))) { prG->sound &= ~SFLAG_BEEP & ~SFLAG_CMD; if (!strcasecmp (arg1, i18n (1085, "on"))) prG->sound |= SFLAG_BEEP; else if (!strcasecmp (arg1, i18n (1086, "off"))) ; else { prG->sound |= SFLAG_CMD; prG->sound_cmd = strdup (arg1); } } if (prG->sound & SFLAG_BEEP) M_print ("%s " COLSERV "%s" COLNONE ".\n", i18n (1084, "Sound"), i18n (1085, "on")); else if (prG->sound & SFLAG_CMD) M_print ("%s " COLSERV "%s" COLNONE ".\n", i18n (1083, "Sound cmd"), prG->sound_cmd); else M_print ("%s " COLSERV "%s" COLNONE ".\n", i18n (1084, "Sound"), i18n (1086, "off")); return 0; } /* * Toggles soundonline or changes soundonline command. */ static JUMP_F(CmdUserSoundOnline) { char *arg1; if ((arg1 = strtok (args, "\n"))) { prG->sound &= ~SFLAG_ON_BEEP & ~SFLAG_ON_CMD; if (!strcasecmp (arg1, i18n (1085, "on"))) prG->sound |= SFLAG_ON_BEEP; else if (!strcasecmp (arg1, i18n (1086, "off"))) ; else { prG->sound |= SFLAG_ON_CMD; prG->sound_on_cmd = strdup (arg1); } } if (prG->sound & SFLAG_ON_BEEP) M_print ("%s " COLSERV "%s" COLNONE ".\n", i18n (1804, "SoundOnline"), i18n (1085, "on")); else if (prG->sound & SFLAG_ON_CMD) M_print ("%s " COLSERV "%s" COLNONE ".\n", i18n (1802, "SoundOnline cmd"), prG->sound_on_cmd); else M_print ("%s " COLSERV "%s" COLNONE ".\n", i18n (1804, "SoundOnline"), i18n (1086, "off")); return 0; } /* * Toggles soundoffine or changes soundoffline command. */ static JUMP_F(CmdUserSoundOffline) { char *arg1; if ((arg1 = strtok (args, "\n"))) { prG->sound &= ~SFLAG_OFF_BEEP & ~SFLAG_OFF_CMD; if (!strcasecmp (arg1, i18n (1085, "on"))) prG->sound |= SFLAG_OFF_BEEP; else if (!strcasecmp (arg1, i18n (1086, "off"))) ; else { prG->sound |= SFLAG_OFF_CMD; prG->sound_off_cmd = strdup (arg1); } } if (prG->sound & SFLAG_OFF_BEEP) M_print ("%s " COLSERV "%s" COLNONE ".\n", i18n (1805, "SoundOffline"), i18n (1085, "on")); else if (prG->sound & SFLAG_OFF_CMD) M_print ("%s " COLSERV "%s" COLNONE ".\n", i18n (1803, "SoundOffline cmd"), prG->sound_off_cmd); else M_print ("%s " COLSERV "%s" COLNONE ".\n", i18n (1805, "SoundOffline"), i18n (1086, "off")); return 0; } /* * Toggles autoaway or sets autoaway time. */ static JUMP_F(CmdUserAutoaway) { char *arg1; if ((arg1 = strtok (args, " \t\n"))) { if (!strcmp (arg1, i18n (1085, "on")) || !strcmp (arg1, "on")) { prG->away_time = uiG.away_time_prev ? uiG.away_time_prev : default_away_time; } else if (!strcmp (arg1, i18n (1086, "off")) || !strcmp (arg1, "off") || !atoi (arg1)) { if (prG->away_time) uiG.away_time_prev = prG->away_time; prG->away_time = 0; } else { if (prG->away_time) uiG.away_time_prev = prG->away_time; prG->away_time = atoi (arg1); } } M_print (i18n (1766, "Changing status to away resp. not available after idling %s%d%s seconds.\n"), COLMESS, prG->away_time, COLNONE); return 0; } /* * Toggles simple options. */ static JUMP_F(CmdUserSet) { int quiet = 0; char *arg1; arg1 = strtok (args, " \t\n"); if (!arg1 || !strcmp (arg1, "help") || !strcmp (arg1, "?")) { M_print (i18n (1820, "%s