comparison mcabber/src/commands.c @ 1355:9716cf8a0726

Add on_server flag Add a flag to the roster data, TRUE if the roster item is known by the server. The command /info displays a message if the item is local.
author Mikael Berthe <mikael@lilotux.net>
date Sat, 10 Nov 2007 23:15:16 +0100
parents 61a54e172010
children 7794d76ca90e
comparison
equal deleted inserted replaced
1354:c373ff3fe7e1 1355:9716cf8a0726
1484 1484
1485 static void do_info(char *arg) 1485 static void do_info(char *arg)
1486 { 1486 {
1487 gpointer bud; 1487 gpointer bud;
1488 const char *bjid, *name; 1488 const char *bjid, *name;
1489 guint type; 1489 guint type, on_srv;
1490 char *buffer; 1490 char *buffer;
1491 enum subscr esub; 1491 enum subscr esub;
1492 1492
1493 if (!current_buddy) 1493 if (!current_buddy)
1494 return; 1494 return;
1496 1496
1497 bjid = buddy_getjid(bud); 1497 bjid = buddy_getjid(bud);
1498 name = buddy_getname(bud); 1498 name = buddy_getname(bud);
1499 type = buddy_gettype(bud); 1499 type = buddy_gettype(bud);
1500 esub = buddy_getsubscription(bud); 1500 esub = buddy_getsubscription(bud);
1501 on_srv = buddy_getonserverflag(bud);
1501 1502
1502 buffer = g_new(char, 4096); 1503 buffer = g_new(char, 4096);
1503 1504
1504 if (bjid) { 1505 if (bjid) {
1505 GSList *resources, *p_res; 1506 GSList *resources, *p_res;
1519 if (type == ROSTER_TYPE_USER) bstr = "user"; 1520 if (type == ROSTER_TYPE_USER) bstr = "user";
1520 else if (type == ROSTER_TYPE_ROOM) bstr = "chatroom"; 1521 else if (type == ROSTER_TYPE_ROOM) bstr = "chatroom";
1521 else if (type == ROSTER_TYPE_AGENT) bstr = "agent"; 1522 else if (type == ROSTER_TYPE_AGENT) bstr = "agent";
1522 snprintf(buffer, 127, "Type: %s", bstr); 1523 snprintf(buffer, 127, "Type: %s", bstr);
1523 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); 1524 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0);
1525
1526 if (!on_srv) {
1527 scr_WriteIncomingMessage(bjid, "(Local item, not on the server)",
1528 0, HBB_PREFIX_INFO, 0);
1529 }
1524 1530
1525 if (esub == sub_both) bstr = "both"; 1531 if (esub == sub_both) bstr = "both";
1526 else if (esub & sub_from) bstr = "from"; 1532 else if (esub & sub_from) bstr = "from";
1527 else if (esub & sub_to) bstr = "to"; 1533 else if (esub & sub_to) bstr = "to";
1528 else bstr = "none"; 1534 else bstr = "none";
1585 } 1591 }
1586 #endif 1592 #endif
1587 g_free(p_res->data); 1593 g_free(p_res->data);
1588 } 1594 }
1589 g_slist_free(resources); 1595 g_slist_free(resources);
1590 } else { 1596 } else { /* Item has no jid */
1591 if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name); 1597 if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name);
1592 scr_LogPrint(LPRINT_NORMAL, "Type: %s", 1598 scr_LogPrint(LPRINT_NORMAL, "Type: %s",
1593 type == ROSTER_TYPE_GROUP ? "group" : 1599 type == ROSTER_TYPE_GROUP ? "group" :
1594 (type == ROSTER_TYPE_SPECIAL ? "special" : "unknown")); 1600 (type == ROSTER_TYPE_SPECIAL ? "special" : "unknown"));
1595 } 1601 }