comparison mcabber/src/jabglue.c @ 474:27efa1e2671a

Minor code cleanup
author Mikael Berthe <mikael@lilotux.net>
date Sun, 02 Oct 2005 23:29:01 +0200
parents c024d1d5d350
children fa49ac0bb8f3
comparison
equal deleted inserted replaced
473:c024d1d5d350 474:27efa1e2671a
868 if ((x = xmlnode_get_tag(packet->x, "x")) != NULL) { 868 if ((x = xmlnode_get_tag(packet->x, "x")) != NULL) {
869 if ((p = xmlnode_get_attrib(x, "stamp")) != NULL) 869 if ((p = xmlnode_get_attrib(x, "stamp")) != NULL)
870 timestamp = from_iso8601(p, 1); 870 timestamp = from_iso8601(p, 1);
871 } 871 }
872 872
873 if (type && !strcmp(type, "error")) { 873 if (type && !strcmp(type, TMSG_ERROR)) {
874 if ((x = xmlnode_get_tag(packet->x, "error")) != NULL) 874 if ((x = xmlnode_get_tag(packet->x, TMSG_ERROR)) != NULL)
875 display_server_error(x); 875 display_server_error(x);
876 } 876 }
877 if (from && body) 877 if (from && body)
878 gotmessage(type, from, body, enc, timestamp); 878 gotmessage(type, from, body, enc, timestamp);
879 if (tmp) 879 if (tmp)
932 const char *alias = xmlnode_get_attrib(y, "jid"); 932 const char *alias = xmlnode_get_attrib(y, "jid");
933 933
934 if (alias) { 934 if (alias) {
935 const char *name = xmlnode_get_tag_data(y, "name"); 935 const char *name = xmlnode_get_tag_data(y, "name");
936 const char *desc = xmlnode_get_tag_data(y, "description"); 936 const char *desc = xmlnode_get_tag_data(y, "description");
937 // const char *service = xmlnode_get_tag_data(y, "service"); TODO 937 // TODO
938 // const char *service = xmlnode_get_tag_data(y, "service");
938 enum agtype atype = unknown; 939 enum agtype atype = unknown;
939 940
940 if (xmlnode_get_tag(y, "groupchat")) atype = groupchat; else 941 if (xmlnode_get_tag(y, TMSG_GROUPCHAT)) atype = groupchat;
941 if (xmlnode_get_tag(y, "transport")) atype = transport; else 942 else if (xmlnode_get_tag(y, "transport")) atype = transport;
942 if (xmlnode_get_tag(y, "search")) atype = search; 943 else if (xmlnode_get_tag(y, "search")) atype = search;
943 944
944 if (atype == transport) { 945 if (atype == transport) {
945 char *cleanjid = jidtodisp(alias); 946 char *cleanjid = jidtodisp(alias);
946 roster_add_user(cleanjid, NULL, JABBER_AGENT_GROUP, 947 roster_add_user(cleanjid, NULL, JABBER_AGENT_GROUP,
947 ROSTER_TYPE_AGENT); 948 ROSTER_TYPE_AGENT);
948 g_free(cleanjid); 949 g_free(cleanjid);
949 } 950 }
950 if (alias && name && desc) { 951 if (alias && name && desc) {
951 scr_LogPrint(LPRINT_LOGNORM, "Agent: %s / %s / %s / type=%d", 952 scr_LogPrint(LPRINT_LOGNORM,
953 "Agent: %s / %s / %s / type=%d",
952 alias, name, desc, atype); 954 alias, name, desc, atype);
953 955
954 if (atype == search) { 956 if (atype == search) {
955 x = jutil_iqnew (JPACKET__GET, NS_SEARCH); 957 x = jutil_iqnew (JPACKET__GET, NS_SEARCH);
956 xmlnode_put_attrib(x, "to", alias); 958 xmlnode_put_attrib(x, "to", alias);
1003 id = p; 1005 id = p;
1004 x = xmlnode_new_tag("iq"); 1006 x = xmlnode_new_tag("iq");
1005 xmlnode_put_attrib(x, "type", "result"); 1007 xmlnode_put_attrib(x, "type", "result");
1006 xmlnode_put_attrib(x, "to", from); 1008 xmlnode_put_attrib(x, "to", from);
1007 xmlnode_put_attrib(x, "id", id); 1009 xmlnode_put_attrib(x, "id", id);
1008 xmlnode_put_attrib(x, "type", "error"); 1010 xmlnode_put_attrib(x, "type", TMSG_ERROR);
1009 y = xmlnode_insert_tag(x, "error"); 1011 y = xmlnode_insert_tag(x, TMSG_ERROR);
1010 xmlnode_put_attrib(y, "code", "503"); 1012 xmlnode_put_attrib(y, "code", "503");
1011 xmlnode_put_attrib(y, "type", "cancel"); 1013 xmlnode_put_attrib(y, "type", "cancel");
1012 z = xmlnode_insert_tag(y, "feature-not-implemented"); 1014 z = xmlnode_insert_tag(y, "feature-not-implemented");
1013 xmlnode_put_attrib(z, "xmlns", 1015 xmlnode_put_attrib(z, "xmlns",
1014 "urn:ietf:params:xml:ns:xmpp-stanzas"); 1016 "urn:ietf:params:xml:ns:xmpp-stanzas");
1015 jab_send(conn, x); 1017 jab_send(conn, x);
1016 xmlnode_free(x); 1018 xmlnode_free(x);
1017 } 1019 }
1018 } else if (!strcmp(type, "set")) { 1020 } else if (!strcmp(type, "set")) {
1019 /* FIXME: send error */ 1021 /* FIXME: send error */
1020 } else if (!strcmp(type, "error")) { 1022 } else if (!strcmp(type, TMSG_ERROR)) {
1021 if ((x = xmlnode_get_tag(packet->x, "error")) != NULL) 1023 if ((x = xmlnode_get_tag(packet->x, TMSG_ERROR)) != NULL)
1022 display_server_error(x); 1024 display_server_error(x);
1023 } 1025 }
1024 break; 1026 break;
1025 1027
1026 case JPACKET_PRESENCE: 1028 case JPACKET_PRESENCE:
1027 r = jidtodisp(from); 1029 r = jidtodisp(from);
1028 if (type && !strcmp(type, "error")) { 1030 if (type && !strcmp(type, TMSG_ERROR)) {
1029 scr_LogPrint(LPRINT_LOGNORM, "Error presence packet from <%s>", r); 1031 scr_LogPrint(LPRINT_LOGNORM, "Error presence packet from <%s>", r);
1030 if ((x = xmlnode_get_tag(packet->x, "error")) != NULL) 1032 if ((x = xmlnode_get_tag(packet->x, TMSG_ERROR)) != NULL)
1031 display_server_error(x); 1033 display_server_error(x);
1032 g_free(r); 1034 g_free(r);
1033 break; 1035 break;
1034 } 1036 }
1035 1037