comparison mcabber/src/jab_iq.c @ 1058:c0d44a9a99bc

Code cleanup Cosmetics. Mostly get rid of "jid" variables, as it is a structure pointer defined in libjabber/jabber.h.
author Mikael Berthe <mikael@lilotux.net>
date Thu, 30 Nov 2006 19:51:09 +0100
parents f7ef8003fc35
children 995dde656033
comparison
equal deleted inserted replaced
1057:4cdf19d9c74e 1058:c0d44a9a99bc
54 }; 54 };
55 55
56 // iqs_new(type, namespace, prefix, timeout) 56 // iqs_new(type, namespace, prefix, timeout)
57 // Create a query (GET, SET) IQ structure. This function should not be used 57 // Create a query (GET, SET) IQ structure. This function should not be used
58 // for RESULT packets. 58 // for RESULT packets.
59 eviqs *iqs_new(guint8 type, const char *ns, const char *prefix, time_t timeout) 59 eviqs *iqs_new(guint8 type, const char *ns, const char *prefix, time_t tmout)
60 { 60 {
61 static guint iqs_idn; 61 static guint iqs_idn;
62 eviqs *new_iqs; 62 eviqs *new_iqs;
63 time_t now_t; 63 time_t now_t;
64 64
65 iqs_idn++; 65 iqs_idn++;
66 66
67 new_iqs = g_new0(eviqs, 1); 67 new_iqs = g_new0(eviqs, 1);
68 time(&now_t); 68 time(&now_t);
69 new_iqs->ts_create = now_t; 69 new_iqs->ts_create = now_t;
70 if (timeout) 70 if (tmout)
71 new_iqs->ts_expire = now_t + timeout; 71 new_iqs->ts_expire = now_t + tmout;
72 new_iqs->type = type; 72 new_iqs->type = type;
73 new_iqs->xmldata = jutil_iqnew(type, (char*)ns); 73 new_iqs->xmldata = jutil_iqnew(type, (char*)ns);
74 if (prefix) 74 if (prefix)
75 new_iqs->id = g_strdup_printf("%s_%d", prefix, iqs_idn); 75 new_iqs->id = g_strdup_printf("%s_%d", prefix, iqs_idn);
76 else 76 else
180 } 180 }
181 181
182 static void handle_iq_roster(xmlnode x) 182 static void handle_iq_roster(xmlnode x)
183 { 183 {
184 xmlnode y; 184 xmlnode y;
185 const char *jid, *name, *group, *sub, *ask; 185 const char *fjid, *name, *group, *sub, *ask;
186 char *cleanalias; 186 char *cleanalias;
187 enum subscr esub; 187 enum subscr esub;
188 int need_refresh = FALSE; 188 int need_refresh = FALSE;
189 guint roster_type; 189 guint roster_type;
190 190
191 for (y = xmlnode_get_tag(x, "item"); y; y = xmlnode_get_nextsibling(y)) { 191 for (y = xmlnode_get_tag(x, "item"); y; y = xmlnode_get_nextsibling(y)) {
192 192
193 jid = xmlnode_get_attrib(y, "jid"); 193 fjid = xmlnode_get_attrib(y, "jid");
194 name = xmlnode_get_attrib(y, "name"); 194 name = xmlnode_get_attrib(y, "name");
195 sub = xmlnode_get_attrib(y, "subscription"); 195 sub = xmlnode_get_attrib(y, "subscription");
196 ask = xmlnode_get_attrib(y, "ask"); 196 ask = xmlnode_get_attrib(y, "ask");
197 197
198 group = xmlnode_get_tag_data(y, "group"); 198 group = xmlnode_get_tag_data(y, "group");
199 199
200 if (!jid) 200 if (!fjid)
201 continue; 201 continue;
202 202
203 cleanalias = jidtodisp(jid); 203 cleanalias = jidtodisp(fjid);
204 204
205 esub = sub_none; 205 esub = sub_none;
206 if (sub) { 206 if (sub) {
207 if (!strcmp(sub, "to")) esub = sub_to; 207 if (!strcmp(sub, "to")) esub = sub_to;
208 else if (!strcmp(sub, "from")) esub = sub_from; 208 else if (!strcmp(sub, "from")) esub = sub_from;
592 592
593 // Get result data... 593 // Get result data...
594 handle_vcard_node(bjid, ansqry); 594 handle_vcard_node(bjid, ansqry);
595 } 595 }
596 596
597 void request_vcard(const char *jid) 597 void request_vcard(const char *bjid)
598 { 598 {
599 eviqs *iqn; 599 eviqs *iqn;
600 char *barejid; 600 char *barejid;
601 601
602 barejid = jidtodisp(jid); 602 barejid = jidtodisp(bjid);
603 603
604 // Create a new IQ structure. We use NULL for the namespace because 604 // Create a new IQ structure. We use NULL for the namespace because
605 // we'll have to use a special tag, not the usual "query" one. 605 // we'll have to use a special tag, not the usual "query" one.
606 iqn = iqs_new(JPACKET__GET, NULL, "vcard", IQS_DEFAULT_TIMEOUT); 606 iqn = iqs_new(JPACKET__GET, NULL, "vcard", IQS_DEFAULT_TIMEOUT);
607 xmlnode_put_attrib(iqn->xmldata, "to", barejid); 607 xmlnode_put_attrib(iqn->xmldata, "to", barejid);
615 g_free(barejid); 615 g_free(barejid);
616 } 616 }
617 617
618 static void storage_bookmarks_parse_conference(xmlnode xmldata) 618 static void storage_bookmarks_parse_conference(xmlnode xmldata)
619 { 619 {
620 const char *jid, *name, *autojoin; 620 const char *fjid, *name, *autojoin;
621 char *bjid; 621 char *bjid;
622 GSList *room_elt; 622 GSList *room_elt;
623 623
624 jid = xmlnode_get_attrib(xmldata, "jid"); 624 fjid = xmlnode_get_attrib(xmldata, "jid");
625 if (!jid) 625 if (!fjid)
626 return; 626 return;
627 name = xmlnode_get_attrib(xmldata, "name"); 627 name = xmlnode_get_attrib(xmldata, "name");
628 autojoin = xmlnode_get_attrib(xmldata, "autojoin"); 628 autojoin = xmlnode_get_attrib(xmldata, "autojoin");
629 629
630 bjid = jidtodisp(jid); // Bare jid 630 bjid = jidtodisp(fjid); // Bare jid
631 631
632 // Make sure this is a room (it can be a conversion user->room) 632 // Make sure this is a room (it can be a conversion user->room)
633 room_elt = roster_find(bjid, jidsearch, 0); 633 room_elt = roster_find(bjid, jidsearch, 0);
634 if (!room_elt) { 634 if (!room_elt) {
635 room_elt = roster_add_user(bjid, name, NULL, ROSTER_TYPE_ROOM, sub_none); 635 room_elt = roster_add_user(bjid, name, NULL, ROSTER_TYPE_ROOM, sub_none);