Mercurial > pidgin
comparison libgaim/protocols/jabber/iq.c @ 14313:8a2b571f9990
[gaim-migrate @ 17005]
a prpl's set_idle function can be called before the login function
this is because the signing-on signal is emitted, and there's a callback to check idle and update all the prpls attached to that signal
this meant that if you were idle, and got disconnected from jabber, upon attempting to reconnect, you'd segfault
I've changed how jabber handles idle updates to work around this. someone may want to audit the other prpls, to make sure their set_idle callbacks (if any) don't assume the connection is up
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Wed, 23 Aug 2006 16:36:58 +0000 |
parents | 8a6154a52b84 |
children | 6e89bfd2b33f |
comparison
equal
deleted
inserted
replaced
14312:ef05f400817f | 14313:8a2b571f9990 |
---|---|
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 char *idle_time; | 148 GaimPresence *gpresence; |
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 idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0); | 161 gpresence = gaim_account_get_presence(js->gc->account); |
162 xmlnode_set_attrib(query, "seconds", idle_time); | 162 |
163 g_free(idle_time); | 163 if(gaim_presence_is_idle(gpresence)) { |
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 } | |
164 | 173 |
165 jabber_iq_send(iq); | 174 jabber_iq_send(iq); |
166 } | 175 } |
167 } | 176 } |
168 | 177 |