comparison mcabber/src/commands.c @ 318:45076d02eeef

The /status command can specify a status message We can now use: "/status dnd On the phone..." Related change: Display the buddy status message when a buddy connects/changes his/her status.
author Mikael Berthe <mikael@lilotux.net>
date Fri, 15 Jul 2005 18:45:41 +0100
parents 29b27c8692ea
children a9013124ede6
comparison
equal deleted inserted replaced
317:f2d29644a0df 318:45076d02eeef
366 } 366 }
367 367
368 void do_status(char *arg) 368 void do_status(char *arg)
369 { 369 {
370 enum imstatus st; 370 enum imstatus st;
371 int len;
372 char *msg;
371 373
372 if (!arg || (*arg == 0)) { 374 if (!arg || (*arg == 0)) {
373 scr_LogPrint("Your status is: %c", imstatus2char[jb_getstatus()]); 375 scr_LogPrint("Your status is: %c", imstatus2char[jb_getstatus()]);
374 return; 376 return;
375 } 377 }
376 378
377 if (!strcasecmp(arg, "offline")) st = offline; 379 msg = strchr(arg, ' ');
378 else if (!strcasecmp(arg, "online")) st = available; 380 if (!msg)
379 else if (!strcasecmp(arg, "avail")) st = available; 381 len = strlen(arg);
380 else if (!strcasecmp(arg, "away")) st = away; 382 else
381 else if (!strcasecmp(arg, "invisible")) st = invisible; 383 len = msg - arg;
382 else if (!strcasecmp(arg, "dnd")) st = dontdisturb; 384
383 else if (!strcasecmp(arg, "notavail")) st = notavail; 385 if (!strncasecmp(arg, "offline", len)) st = offline;
384 else if (!strcasecmp(arg, "free")) st = freeforchat; 386 else if (!strncasecmp(arg, "online", len)) st = available;
387 else if (!strncasecmp(arg, "avail", len)) st = available;
388 else if (!strncasecmp(arg, "away", len)) st = away;
389 else if (!strncasecmp(arg, "invisible", len)) st = invisible;
390 else if (!strncasecmp(arg, "dnd", len)) st = dontdisturb;
391 else if (!strncasecmp(arg, "notavail", len)) st = notavail;
392 else if (!strncasecmp(arg, "free", len)) st = freeforchat;
385 else { 393 else {
386 scr_LogPrint("Unrecognized parameter!"); 394 scr_LogPrint("Unrecognized parameter!");
387 return; 395 return;
388 } 396 }
389 397
390 // XXX special case if offline?? 398 if (msg && st != offline && st != invisible) {
391 jb_setstatus(st, NULL); // TODO handle message (instead of NULL) 399 for (msg++ ; *msg && *msg == ' ' ; msg++) ;
400 if (!*msg) msg = NULL;
401 } else
402 msg = NULL;
403
404 jb_setstatus(st, msg);
392 } 405 }
393 406
394 void do_add(char *arg) 407 void do_add(char *arg)
395 { 408 {
396 char *id, *nick; 409 char *id, *nick;