static gboolean
soundmenu_lastfm_connect_idle (gpointer data)
{
	SoundmenuLastfm *lastfm = data;

	if (g_str_empty0(lastfm->lastfm_user) ||
	    g_str_empty0(lastfm->lastfm_pass))
		return FALSE;

	lastfm->session_id = LASTFM_init(LASTFM_API_KEY, LASTFM_SECRET);
	if (lastfm->session_id != NULL) {
	    lastfm->status = LASTFM_login (lastfm->session_id,
		                               lastfm->lastfm_user,
		                               lastfm->lastfm_pass);

		if (lastfm->status != LASTFM_STATUS_OK) {
			LASTFM_dinit(lastfm->session_id);
			lastfm->session_id = NULL;
		}
	}

	soundmenu_update_lastfm_menu (lastfm);

	return FALSE;
}
Exemplo n.º 2
0
 cSession::~cSession()
 {
   if (pSession != nullptr) {
     LASTFM_dinit(pSession);
     pSession = nullptr;
   }
 }
void
soundmenu_lastfm_disconnect (SoundmenuLastfm *lastfm)
{
	if (lastfm->session_id == NULL) {
		LASTFM_dinit (lastfm->session_id);

		lastfm->session_id = NULL;
		lastfm->status = LASTFM_STATUS_INVALID;
	}

	soundmenu_update_lastfm_menu (lastfm);
}
void
soundmenu_lastfm_free (SoundmenuLastfm *lastfm)
{
	if (lastfm->session_id)
		LASTFM_dinit (lastfm->session_id);

	if (g_str_nempty0(lastfm->lastfm_user))
		g_free (lastfm->lastfm_user);
	if (g_str_nempty0(lastfm->lastfm_pass))
		g_free (lastfm->lastfm_pass);

	g_slice_free(SoundmenuLastfm, lastfm);
}