Changeset 3576 for trunk/rms

Show
Ignore:
Timestamp:
07/09/03 15:31:31 (5 years ago)
Author:
dreamforce2
Message:

patch by O. Novy, slightly revised.

Location:
trunk/rms/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/rms/src/rms.cpp

    r3565 r3576  
    4848const unsigned short CODE_VIEWxTEXTxSTART = 222; 
    4949const unsigned short CODE_VIEWxTEXTxEND = 223; 
     50const unsigned short CODE_ADDUSERxDONE = 224; 
     51const unsigned short CODE_REMUSERxDONE = 225; 
     52const unsigned short CODE_SECURExOPEN = 226; 
     53const unsigned short CODE_SECURExCLOSE = 227; 
     54const unsigned short CODE_SECURExSTAT = 228; 
    5055const unsigned short CODE_VIEWxUNKNOWN = 299; 
    5156// 300 - further action required 
     
    6570const unsigned short CODE_EVENTxFAILED = 501; 
    6671const unsigned short CODE_EVENTxERROR = 502; 
     72const unsigned short CODE_ADDUSERxERROR = 503; 
     73const unsigned short CODE_SECURExNOTCOMPILED = 504; 
    6774 
    6875const unsigned short STATE_UIN = 1; 
     
    8390}; 
    8491 
    85 static const unsigned short NUM_COMMANDS = 12; 
     92static const unsigned short NUM_COMMANDS = 15; 
    8693static struct Command commands[NUM_COMMANDS] = 
    8794{ 
     95  { "ADDUSER", &CRMSClient::Process_ADDUSER, 
     96    "Add user to contact list { <uin> }." }, 
     97  { "AR", &CRMSClient::Process_AR, 
     98    "Set your (or a user custom) auto response { [ <uin> ] }." }, 
     99  { "GROUPS", &CRMSClient::Process_GROUPS, 
     100    "Show list of groups." }, 
    88101  { "HELP", &CRMSClient::Process_HELP, 
    89102    "Print out help on commands." }, 
     103  { "INFO", &CRMSClient::Process_INFO, 
     104    "Print out user information.  Argument is the uin, or none for personal." }, 
     105  { "LIST", &CRMSClient::Process_LIST, 
     106    "List users { [ <group #> ] [ <online|offline|all> ] [ <format> ] }." }, 
     107  { "LOG", &CRMSClient::Process_LOG, 
     108    "Dump log messages { <log types> }." }, 
     109  { "MESSAGE", &CRMSClient::Process_MESSAGE, 
     110    "Send a message { <uin> }." }, 
    90111  { "QUIT", &CRMSClient::Process_QUIT, 
    91112    "Close the connection.  With an argument of 1 causes the plugin to unload." }, 
     113  { "REMUSER", &CRMSClient::Process_REMUSER, 
     114    "Remove user from contact list { <uin> }." }, 
     115  { "SECURE", &CRMSClient::Process_SECURE, 
     116    "Open/close/check secure channel { <uin> [ <open|close> ] } ." }, 
     117  { "STATUS", &CRMSClient::Process_STATUS, 
     118    "Set or show status.  Argument is new status, or blank to display current." }, 
    92119  { "TERM", &CRMSClient::Process_TERM, 
    93120    "Terminate the licq daemon." }, 
    94   { "INFO", &CRMSClient::Process_INFO, 
    95     "Print out user information.  Argument is the uin, or none for personal." }, 
    96   { "STATUS", &CRMSClient::Process_STATUS, 
    97     "Set or show status.  Argument is new status, or blank to display current." }, 
    98   { "GROUPS", &CRMSClient::Process_GROUPS, 
    99     "Show list of groups." }, 
    100   { "LIST", &CRMSClient::Process_LIST, 
    101     "List users { [ <group #> ] [ <online|offline|all> ] [ <format> ] }." }, 
    102   { "MESSAGE", &CRMSClient::Process_MESSAGE, 
    103     "Send a message { <uin> }." }, 
    104   { "URL", &CRMSClient::Process_URL, 
    105     "Send a url { <uin> }." }, 
    106   { "LOG", &CRMSClient::Process_LOG, 
    107     "Dump log messages { <log types> }." }, 
    108121  { "VIEW", &CRMSClient::Process_VIEW, 
    109122    "View event (next or specific user) { [ <uin> ] }." }, 
    110   { "AR", &CRMSClient::Process_AR, 
    111     "Set your (or a user custom) auto response { [ <uin> ] }." } 
     123  { "URL", &CRMSClient::Process_URL, 
     124    "Send a url { <uin> }." } 
    112125}; 
    113126 
     
    11341147} 
    11351148 
    1136  
     1149/*--------------------------------------------------------------------------- 
     1150 * CRMSClient::Process_ADDUSER 
     1151 * 
     1152 * Command: 
     1153 *   ADDUSER <uin> 
     1154 * 
     1155 * Response: 
     1156 * 
     1157 *-------------------------------------------------------------------------*/ 
     1158int CRMSClient::Process_ADDUSER() 
     1159{ 
     1160  unsigned long nUin = atol(data_arg); 
     1161 
     1162  if (nUin >= 10000) 
     1163  { 
     1164    if (licqDaemon->AddUserToList(nUin)) 
     1165    { 
     1166      fprintf(fs, "%d User added\n", CODE_ADDUSERxDONE); 
     1167    } 
     1168    else 
     1169    { 
     1170      fprintf(fs, "%d User not added\n", CODE_ADDUSERxERROR); 
     1171    } 
     1172  } 
     1173  else 
     1174  { 
     1175    fprintf(fs, "%d Invalid UIN.\n", CODE_INVALIDxUSER); 
     1176  } 
     1177 
     1178  return fflush(fs); 
     1179} 
     1180 
     1181/*--------------------------------------------------------------------------- 
     1182 * CRMSClient::Process_REMUSER 
     1183 * 
     1184 * Command: 
     1185 *   REMUSER <uin> 
     1186 * 
     1187 * Response: 
     1188 * 
     1189 *-------------------------------------------------------------------------*/ 
     1190int CRMSClient::Process_REMUSER() 
     1191{ 
     1192  unsigned long nUin = atol(data_arg); 
     1193 
     1194  if (nUin >= 10000) 
     1195  { 
     1196    licqDaemon->RemoveUserFromList(nUin); 
     1197    fprintf(fs, "%d User removed\n", CODE_REMUSERxDONE); 
     1198  } 
     1199  else 
     1200  { 
     1201    fprintf(fs, "%d Invalid UIN.\n", CODE_INVALIDxUSER); 
     1202  } 
     1203 
     1204  return fflush(fs); 
     1205} 
     1206 
     1207/*--------------------------------------------------------------------------- 
     1208 * CRMSClient::Process_SECURE 
     1209 * 
     1210 * Command: 
     1211 *   SECURE <uin> <what> 
     1212 * 
     1213 * Response: 
     1214 * 
     1215 *-------------------------------------------------------------------------*/ 
     1216int CRMSClient::Process_SECURE() 
     1217{ 
     1218  unsigned long nUin = 0; 
     1219 
     1220  if(!licqDaemon->CryptoEnabled()) 
     1221  { 
     1222    fprintf(fs, "%d Licq secure channel not compiled. Please recompile with OpenSSL.\n", CODE_SECURExNOTCOMPILED); 
     1223    return fflush(fs); 
     1224  } 
     1225   
     1226 
     1227  if (isdigit(*data_arg)) 
     1228  { 
     1229    nUin = atol(data_arg); 
     1230    while (*data_arg != '\0' && *data_arg != ' ') data_arg++; 
     1231    NEXT_WORD(data_arg); 
     1232  } 
     1233   else 
     1234  { 
     1235    fprintf(fs, "%d Invalid UIN.\n", CODE_INVALIDxUSER); 
     1236    return fflush(fs); 
     1237  } 
     1238 
     1239  if (nUin < 10000) 
     1240  { 
     1241    fprintf(fs, "%d Invalid UIN.\n", CODE_INVALIDxUSER); 
     1242    return fflush(fs); 
     1243  } 
     1244 
     1245  if (strncasecmp(data_arg, "open", 4) == 0) 
     1246  { 
     1247    fprintf(fs, "%d Opening secure connection.\n", CODE_SECURExOPEN); 
     1248    licqDaemon->icqOpenSecureChannel(nUin); 
     1249  } 
     1250  else 
     1251  if (strncasecmp(data_arg, "close", 5) == 0) 
     1252  { 
     1253    fprintf(fs, "%d Closing secure connection.\n", CODE_SECURExCLOSE); 
     1254    licqDaemon->icqCloseSecureChannel(nUin); 
     1255  } 
     1256  else 
     1257  { 
     1258   ICQUser *u = gUserManager.FetchUser(nUin,LOCK_R); 
     1259   if (u->Secure() == 0) 
     1260   { 
     1261    fprintf(fs, "%d Status: secure connection is closed.\n", CODE_SECURExSTAT); 
     1262   } 
     1263   if (u->Secure() == 1) 
     1264   { 
     1265    fprintf(fs, "%d Status: secure connection is open.\n", CODE_SECURExSTAT); 
     1266   } 
     1267   gUserManager.DropUser(u); 
     1268  } 
     1269   
     1270  return fflush(fs); 
     1271} 
  • trunk/rms/src/rms.h

    r3013 r3576  
    7979  int Process_VIEW(); 
    8080  int Process_AR(); 
     81  int Process_ADDUSER(); 
     82  int Process_REMUSER(); 
     83  int Process_SECURE(); 
    8184 
    8285protected: