presence: fix endless publish/409 error loop at startup
As has also been noticed by other users in my company, it can sometimes happen
that SIPE gets stuck in a "busy" loop at startup, constantly re-sending the
same message which gets rejected by the server. This is especially nasty when
SIPE is running on a mobile device, like the N900, where it causes a huge drain
on the battery.
The loop happens when we receive a "409 Conflict" response from the server
under the following conditions:
- initial publish, i.e. we include the "device" category
- server sends us back a fault for category X
(In all the cases I've studied category X was "device")
- sip->our_publications does not contain category X
(I'm not sure why this happens. This might be the root cause...)
I've circumvented the problem by adding a publication for the "lost" category
using the fault information provided by the server. When this happens you'll
see in the log messages like:
sipe: added lost category 'device' key '<device><
2625814930><2>'
I'm pretty sure this has something to do with improper de-registering when
Pidgin exits and SIPE doesn't have enough time to send out all messages. That
could leave incorrect information on the server which leads it to reject our
publication on the next login.