# HG changeset patch # User Cristi Magherusan # Date 1185623148 -10800 # Node ID 1fef0ac7395e9c153e584f8b941dab0429cecdcd # Parent c87dfbb3711e99a6068d8a773cd53eac3cf338b1 fixed crashes diff -r c87dfbb3711e -r 1fef0ac7395e src/audacious/ui_lastfm.c --- a/src/audacious/ui_lastfm.c Sat Jul 28 01:38:07 2007 +0300 +++ b/src/audacious/ui_lastfm.c Sat Jul 28 14:45:48 2007 +0300 @@ -3,7 +3,6 @@ #include #include "configdb.h" #include "playback.h" - #define DEBUG 1 typedef struct { gchar *username, @@ -40,16 +39,16 @@ { /* get the session from mowgli*/ if(login_data->session) - { - g_free(login_data->session); - login_data->session=NULL; - } + { + g_free(login_data->session); + login_data->session=NULL; + } login_data->session = g_strdup(mowgli_global_storage_get("lastfm_session_id")); gchar *url=g_strdup_printf("http://ws.audioscrobbler.com/radio/control.php?session=%s&command=%s&debug=0",login_data->session,comm); g_thread_create(open_url,url,FALSE,NULL); if(!g_str_has_prefix(comm,"love")) - g_thread_create((gpointer)playback_initiate,NULL,FALSE,NULL); -return; + g_thread_create((gpointer)playback_initiate,NULL,FALSE,NULL); + return; } static void change_track_data_cb(gpointer track, gpointer unused) @@ -58,16 +57,21 @@ **t, *alb, *tr; - tr=((track_data*)track)->title; + tr=g_strdup(((track_data*)track)->title); if(tr==NULL) return ; + if(g_strrstr(tr,"last.fm")==NULL) + { + gtk_entry_set_text(GTK_ENTRY(lastfm_url_entry),"Not last.fm stream"); + return; + } + #if DEBUG g_print("New Track: %s \n",tr); #endif if(g_str_has_prefix(tr,"lastfm://")) - return; - + return; if(g_strrstr(tr,"Neighbour")!=NULL) { gchar *temp=g_strdup_printf("lastfm://user/%s/neighbours", login_data->username); @@ -89,6 +93,7 @@ g_free(artist_markup); t = g_strsplit(inf[1], g_strrstr(inf[1],"("),2); + if(t[0]==NULL) return; alb = g_strdup(mowgli_global_storage_get("lastfm_album")); gchar* title_markup=g_strdup_printf("Title: %s" ,t[0]); @@ -111,7 +116,7 @@ { const gchar *markup = N_("Couldn't find your lastfm login data.\n\n" - "Check if your Scrobbler's plugin login settings are configured properly.\n"); + "Check if your Scrobbler's plugin login settings are configured properly.\n"); GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, @@ -175,6 +180,9 @@ gchar *text=NULL; gint poz=0; text = g_strdup(gtk_entry_get_text(GTK_ENTRY(lastfm_url_entry))); + if(playback_get_playing()==TRUE) + playback_stop(); + poz = playlist_get_length(current_playlist); playlist_add_url(current_playlist, text); sleep(1); @@ -208,15 +216,15 @@ } static gboolean keypress_callback(GtkWidget * widget, GdkEventKey * event, gpointer data) { -switch (event->keyval) - { - case GDK_Escape: - gtk_widget_hide_all(widget); - break; - default: - return FALSE; + switch (event->keyval) + { + case GDK_Escape: + gtk_widget_hide_all(widget); + break; + default: + return FALSE; } -return TRUE; + return TRUE; } @@ -323,7 +331,7 @@ gtk_widget_show_all(gui_window); return window; } - +#if 0 static void no_lastfm_plugin_dialog(void) { const gchar *markup = @@ -339,30 +347,30 @@ gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } - +#endif void ui_lastfm(void) { -/*if(!mowgli_global_storage_get("lastfm_loaded")) - { - no_lastfm_plugin_dialog(); - return; - } -*/ -init_last_fm(); -if(!gui_window) + /*if(!mowgli_global_storage_get("lastfm_loaded")) + { + no_lastfm_plugin_dialog(); + return; + } + */ + init_last_fm(); + if(!gui_window) { if((gui_window = ui_lastfm_create())!=NULL); - gtk_widget_show_all(gui_window); + gtk_widget_show_all(gui_window); #if 0 /*here should be set the artist, title and album labels at the first run, because it isn't captured by the hook*/ gchar* current_title = playlist_get_songtitle(current_playlist,playlist_get_position(current_playlist)); if(current_title) - change_track_data_cb(current_title,NULL); + change_track_data_cb(current_title,NULL); #endif } -else - gtk_widget_show_all(gui_window); + else + gtk_widget_show_all(gui_window); }