comparison libgaim/protocols/jabber/iq.c @ 14391:6e89bfd2b33f

[gaim-migrate @ 17098] I don't think PRPLs should need to make sure that proto_data is valid in the set_idle() callback. Some of my idle changes on the 23rd added that requirement. This removes the requirement to make things the way they were before. I'm also reverting SVN revision 17005 from faceprint and 17009 from marv_sf. Those revisions fixed the PRPLs so they wouldn't crash if set_idle() was called before the acocunt was fully connected. But that shouldn't be needed any more. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 31 Aug 2006 09:02:10 +0000
parents 8a2b571f9990
children fe05223b5d04
comparison
equal deleted inserted replaced
14390:d4a26ada1971 14391:6e89bfd2b33f
143 JabberIq *iq; 143 JabberIq *iq;
144 const char *type; 144 const char *type;
145 const char *from; 145 const char *from;
146 const char *id; 146 const char *id;
147 xmlnode *query; 147 xmlnode *query;
148 GaimPresence *gpresence; 148 char *idle_time;
149 149
150 type = xmlnode_get_attrib(packet, "type"); 150 type = xmlnode_get_attrib(packet, "type");
151 from = xmlnode_get_attrib(packet, "from"); 151 from = xmlnode_get_attrib(packet, "from");
152 id = xmlnode_get_attrib(packet, "id"); 152 id = xmlnode_get_attrib(packet, "id");
153 153
156 jabber_iq_set_id(iq, id); 156 jabber_iq_set_id(iq, id);
157 xmlnode_set_attrib(iq->node, "to", from); 157 xmlnode_set_attrib(iq->node, "to", from);
158 158
159 query = xmlnode_get_child(iq->node, "query"); 159 query = xmlnode_get_child(iq->node, "query");
160 160
161 gpresence = gaim_account_get_presence(js->gc->account); 161 idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0);
162 162 xmlnode_set_attrib(query, "seconds", idle_time);
163 if(gaim_presence_is_idle(gpresence)) { 163 g_free(idle_time);
164 time_t idle_time = gaim_presence_get_idle_time(gpresence);
165 char *idle_str;
166
167 idle_str = g_strdup_printf("%ld", time(NULL) - idle_time);
168 xmlnode_set_attrib(query, "seconds", idle_str);
169 g_free(idle_str);
170 } else {
171 xmlnode_set_attrib(query, "seconds", "0");
172 }
173 164
174 jabber_iq_send(iq); 165 jabber_iq_send(iq);
175 } 166 }
176 } 167 }
177 168