-static void HandleInterval( mtime_t *next, unsigned int *i_interval )
-{
- if( *i_interval == 0 )
- {
- /* first interval is 1 minute */
- *i_interval = 1;
- }
- else
- {
- /* else we double the previous interval, up to 120 minutes */
- *i_interval <<= 1;
- if( *i_interval > 120 )
- *i_interval = 120;
+ char *failed = strstr((char *) p_buffer, "FAILED");
+ if (failed)
+ {
+ msg_Warn(p_intf, "%s", failed);
+ HandleInterval(&next_exchange, &i_interval);
+ continue;
+ }
+
+ if (strstr((char *) p_buffer, "BADSESSION"))
+ {
+ msg_Err(p_intf, "Authentication failed (BADSESSION), are you connected to last.fm with another program ?");
+ b_handshaked = false;
+ HandleInterval(&next_exchange, &i_interval);
+ continue;
+ }
+
+ if (strstr((char *) p_buffer, "OK"))
+ {
+ for (int i = 0; i < p_sys->i_songs; i++)
+ DeleteSong(&p_sys->p_queue[i]);
+ p_sys->i_songs = 0;
+ i_interval = 0;
+ next_exchange = mdate();
+ msg_Dbg(p_intf, "Submission successful!");
+ }
+ else
+ {
+ msg_Err(p_intf, "Authentication failed, handshaking again (%s)",
+ p_buffer);
+ b_handshaked = false;
+ HandleInterval(&next_exchange, &i_interval);
+ }