[Easytag-mailing] Use GNUDB instead of FREEBD for the manual search (with patch)



Hi,

Since more than one month, the manual search didn't work since MAGIX aquired freedb. But www.gnudb.org offers a similar service that you can be used with the patch attached to this mail for EasyTAG 1.99.12.

Regards,
Jerome


Jérôme COUDERC wrote, the 06.10.2006 21:27 :

Hi,

If you are using the Cddb lanual search, you probably remark that it doesn't work any more... On the home page of the site http://www.freedb.org you will see that "MAGIX acquires www.freedb.org".

Due to problem of license, some services have been removed for the moment, like the "search.php" page. This page used for the online search was also used for the manual in EasyTAG. So this feature can't work for the moment.

But a new search will be supplied later as you can see in this forum :
   http://www.freedb.org/en/forum/read.php?1,8

So we hope that it will be available quickly

Regards,
Jerome


--
EasyTAG - Tag editor for MP3 and Ogg Vorbis files
http://easytag.sourceforge.net
--
Jerome COUDERC <easytag gmail com>

diff -ruN easytag-1.99.12.orig/src/cddb.c easytag-1.99.12/src/cddb.c
--- easytag-1.99.12.orig/src/cddb.c	2006-03-21 23:45:34.000000000 +0100
+++ easytag-1.99.12/src/cddb.c	2006-11-20 00:01:53.569643568 +0100
@@ -143,16 +143,17 @@
 gboolean Cddb_Free_Album_List (void);
 gboolean Cddb_Free_Track_Album_List (GList *track_list);
 
-gint Cddb_Open_Connection  (gchar *host, gint port);
-void Cddb_Close_Connection (gint socket_id);
-gint Cddb_Read_Line        (gint socket_id, gchar *cddb_out);
-gint Cddb_Read_Http_Header (gint socket_id, gchar *cddb_out);
-gint Cddb_Read_Cddb_Header (gint socket_id, gchar *cddb_out);
-
-gboolean Cddb_Search_Album_List_From_String (void);
-gboolean Cddb_Search_Album_From_Selected_Files (void);
-gboolean Cddb_Get_Album_Tracks_List_CB(GtkTreeSelection *selection, gpointer data);
-gboolean Cddb_Get_Album_Tracks_List(GtkTreeSelection *selection);
+gint     Cddb_Open_Connection  (gchar *host, gint port);
+void     Cddb_Close_Connection (gint socket_id);
+glong    Cddb_Read_Line        (gint socket_id, gchar *cddb_out);
+glong    Cddb_Read_Http_Header (gint socket_id, gchar *cddb_out);
+glong    Cddb_Read_Cddb_Header (gint socket_id, gchar *cddb_out);
+
+gboolean Cddb_Search_Album_List_From_String_Freedb (void);
+gboolean Cddb_Search_Album_List_From_String_Gnudb  (void);
+gboolean Cddb_Search_Album_From_Selected_Files     (void);
+gboolean Cddb_Get_Album_Tracks_List_CB (GtkTreeSelection *selection, gpointer data);
+gboolean Cddb_Get_Album_Tracks_List    (GtkTreeSelection *selection);
 
 void     Cddb_Load_Album_List              (gboolean only_red_lines);
 void     Cddb_Load_Track_Album_List        (GList *track_list);
@@ -367,7 +368,7 @@
     Load_Cddb_Search_String_List(CddbSearchStringModel, MISC_COMBO_TEXT);
 
     g_signal_connect(G_OBJECT(GTK_ENTRY(GTK_BIN(CddbSearchStringCombo)->child)),"activate",
-        G_CALLBACK(Cddb_Search_Album_List_From_String),NULL);
+        G_CALLBACK(Cddb_Search_Album_List_From_String_Gnudb),NULL);
     gtk_entry_set_text(GTK_ENTRY(GTK_BIN(CddbSearchStringCombo)->child),"");
 
     // Set content of the clipboard if available
@@ -378,7 +379,7 @@
     gtk_box_pack_start(GTK_BOX(hbox),CddbSearchButton,FALSE,FALSE,0);
     GTK_WIDGET_SET_FLAGS(CddbSearchButton,GTK_CAN_DEFAULT);
     gtk_widget_grab_default(CddbSearchButton);
-    g_signal_connect(G_OBJECT(CddbSearchButton),"clicked", G_CALLBACK(Cddb_Search_Album_List_From_String),NULL);
+    g_signal_connect(G_OBJECT(CddbSearchButton),"clicked", G_CALLBACK(Cddb_Search_Album_List_From_String_Gnudb),NULL);
     g_signal_connect(G_OBJECT(GTK_ENTRY(GTK_BIN(CddbSearchStringCombo)->child)),"changed", G_CALLBACK(Cddb_Set_Search_Button_Sensivity),NULL);
 
     // Button to stop the search
@@ -1228,7 +1229,7 @@
 /*
  * Show collected infos of the album in the status bar
  */
-void Cddb_Show_Album_Info(GtkTreeSelection *selection, gpointer data)
+void Cddb_Show_Album_Info (GtkTreeSelection *selection, gpointer data)
 {
     CddbAlbum *cddbalbum = NULL;
     gchar *msg, *duration_str;
@@ -1508,6 +1509,9 @@
 /*
  * Open a connection to "server_name" and retun the socket_id
  * On error, returns 0.
+ *
+ * Some help on : http://shoe.bocks.com/net/
+ *                http://www.zone-h.org/files/4/socket.txt
  */
 gint Cddb_Open_Connection (gchar *host, gint port)
 {
@@ -1615,18 +1619,22 @@
  * <html>\n                                         }
  * [...]                                            } "Body"
  */
-gint Cddb_Read_Line (gint socket_id, gchar *cddb_out)
+glong Cddb_Read_Line (gint socket_id, gchar *cddb_out)
 {
-    gint bytes_returned = 0;
     gint bytes_read = 0;
+    glong bytes_returned = 0;
     gint i;
-
+    
     for (i=0;i<CDDB_ANSWER_LINE_SIZE;i++)
     {
         //bytes_read = read(socket_id,&cddb_out[i],1); // This returns "Wrong Answer..." under FreeBSD 5.1
         bytes_read = recv(socket_id,&cddb_out[i],1,0); // Patch from Jan Kanty Palus 13/01/2004
+        //g_print("%i: %d -> %c\n",i,bytes_read,cddb_out[i]);
         if (bytes_read < 0)
+        {
+            g_print(_("Error when reading cddb response (%s)!\n"),g_strerror(errno)); 
             return -1; // Error!
+        }
 
         bytes_returned += bytes_read;
         // Cases : end of the line, or no more data
@@ -1642,6 +1650,8 @@
             }
         }
     }
+    
+    //g_print("Line : %lu : %s\n",bytes_returned,cddb_out);
     return bytes_returned;
 }
 
@@ -1650,20 +1660,24 @@
  * Read HTTP header data : from "HTTP/1.1 200 OK" to the blank line
  */
 
-gint Cddb_Read_Http_Header (gint socket_id, gchar *cddb_out)
+glong Cddb_Read_Http_Header (gint socket_id, gchar *cddb_out)
 {
-    gint bytes_returned = 0;
-    gint bytes_read;
+    glong bytes_read;
+    glong bytes_returned = 0;
 
     if ( (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) < 0 )
         return -1; // Error!
     // First line must be "HTTP/1.1 200 OK"
     if ( strncmp("HTTP",cddb_out,4)!=0 || strstr(cddb_out,"200 OK")==NULL )
         return -1;
+
     // Read until end of the http header
     while ( (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 && strlen(cddb_out) > 0 )
+    {
         bytes_returned += bytes_read;
+    }
 
+    //g_print("Header : %lu : %s\n",bytes_returned,cddb_out);
     return bytes_returned;
 }
 
@@ -1674,14 +1688,15 @@
  * Take one line like this : "210 rock 780dfe09 CD database entry follows (until terminating `.')"
  */
 
-gint Cddb_Read_Cddb_Header (gint socket_id, gchar *cddb_out)
+glong Cddb_Read_Cddb_Header (gint socket_id, gchar *cddb_out)
 {
-    gint bytes_read;
+    glong bytes_read;
 
     if ( (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) < 0 )
         return -1; // Error!
 
-    // Some request receive some strange data at the beginning (2 or 3 characters)... so we read one line more...
+    // Some requests receive some strange data at the beginning (2 or 3 characters)...
+    // so we read one line more...
     if ( !cddb_out || strlen(cddb_out) < 10 )
         if ( (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) < 0 )
             return -1; // Error!
@@ -1826,7 +1841,7 @@
     {
         GList *tracklist = g_list_first(track_list);
 
-    // Must block the select signal of the target to avoid looping
+        // Must block the select signal of the target to avoid looping
         gtk_list_store_clear(CddbTrackListModel);
         while (tracklist)
         {
@@ -1926,10 +1941,11 @@
 
 
 /*
+ * Site FREEDB.ORG
  * Send request (using the HTML search page in freedb.org site) to the CD database
  * to get the list of albums matching to a string.
  */
-gboolean Cddb_Search_Album_List_From_String (void)
+gboolean Cddb_Search_Album_List_From_String_Freedb (void)
 {
     gint   socket_id;
     gchar *string = NULL;
@@ -1947,7 +1963,7 @@
     gchar *html_end_str;
     gchar  buffer[CDDB_ANSWER_LINE_SIZE+1];
     gint   bytes_written;
-    gint   bytes_read;
+    glong  bytes_read;
     gulong bytes_read_total = 0;
     gboolean web_search_disabled = FALSE;
 
@@ -2001,6 +2017,7 @@
                               APPNAME,VERSION,
                               (proxy_auth=Cddb_Format_Proxy_Authentification())
                               );
+
     g_free(string);
     g_free(tmp);
     g_free(proxy_auth);
@@ -2048,15 +2065,17 @@
     }
     bytes_read_total = bytes_read;
 
-    // Read other lines,and get list of matching albums
+    // Read other lines, and get list of matching albums
     // Composition of a line : 
+    //  - freedb.org
     // <a href="http://www.freedb.org/freedb_search_fmt.php?cat=rock&id=8c0f0a0b";>Bob Dylan / MTV Unplugged</a><br>
     cat_str      = g_strdup("http://www.freedb.org/freedb_search_fmt.php?cat=";);
     id_str       = g_strdup("&id=");
     art_alb_str  = g_strdup("\">");
     end_str      = g_strdup("</a>"); //"</a><br>");
     html_end_str = g_strdup("</body>"); // To avoid the cddb lookups to hang
-    while ( CddbWindow && !CddbStopSearch && (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 )
+    while ( CddbWindow && !CddbStopSearch
+    && (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 )
     {
         gchar *size_str;
         bytes_read_total += bytes_read;
@@ -2090,11 +2109,13 @@
 
             cddbalbum = g_malloc0(sizeof(CddbAlbum));
 
+
             // Get album category
             cddb_out_tmp = ptr_cat + strlen(cat_str);
             strncpy(buffer,cddb_out_tmp,CDDB_ANSWER_LINE_SIZE);
             if ( (ptr_id=strstr(buffer,id_str)) != NULL )
                 *ptr_id = 0;
+
             copy = g_strdup(buffer);
 
             if (g_utf8_validate(copy, -1, NULL))
@@ -2108,13 +2129,16 @@
 
             cddbalbum->category = valid;
 
+
             // Get album ID
-            cddb_out_tmp = strstr(cddb_out_tmp,id_str) + strlen(id_str);
+            //cddb_out_tmp = strstr(cddb_out_tmp,id_str) + strlen(id_str);
+            cddb_out_tmp = ptr_cat + strlen(cat_str) + 2;
             strncpy(buffer,cddb_out_tmp,CDDB_ANSWER_LINE_SIZE);
             if ( (ptr_art_alb=strstr(buffer,art_alb_str)) != NULL )
                 *ptr_art_alb = 0;
             cddbalbum->id = g_strdup(buffer);
 
+
             // Get album and artist names.
             // Note : some names can be like this "<font size=-1>2</font>" (for other version of the same album)
             cddb_out_tmp = strstr(cddb_out_tmp,art_alb_str) + strlen(art_alb_str);
@@ -2157,6 +2181,7 @@
                 use_art_alb = FALSE;
             }
 
+
             // New position the search the next string
             cddb_out_tmp = strstr(cddb_out_tmp,end_str) + strlen(end_str);
 
@@ -2167,8 +2192,8 @@
         /* It appears that on some systems that cddb lookups continue to attempt
          * to get data from the socket even though the other system has completed 
          * sending. Here we see if the actual end of data is in the last block read.
-         * In the case of the html scan, the /body tag is used because there's
-         * no crlf followint the /html tag.
+         * In the case of the html scan, the </body> tag is used because there's
+         * no crlf followint the </html> tag.
          */
         if (strstr(cddb_out_tmp,html_end_str)!=NULL) 
             break;
@@ -2200,6 +2225,339 @@
 
 
 /*
+ * Site GNUDB.ORG
+ * Send request (using the HTML search page in freedb.org site) to the CD database
+ * to get the list of albums matching to a string.
+ */
+gboolean Cddb_Search_Album_List_From_String_Gnudb (void)
+{
+    gint   socket_id;
+    gchar *string = NULL;
+    gchar *tmp, *tmp1;
+    gchar *cddb_in;    // For the request to send
+    gchar *cddb_out;   // Answer received
+    gchar *cddb_out_tmp;
+    gchar *msg;
+    gchar *proxy_auth = NULL;
+
+    gchar *ptr_cat, *cat_str, *art_alb_str;
+    gchar *art_alb_tmp = NULL;
+    gboolean use_art_alb = FALSE;
+    gchar *end_str;
+    gchar *html_end_str;
+    gchar  buffer[CDDB_ANSWER_LINE_SIZE+1];
+    gint   bytes_written;
+    glong  bytes_read;
+    gulong bytes_read_total = 0;
+    //gboolean web_search_disabled = FALSE;
+    gchar *next_page = NULL;
+    gint   next_page_cpt = 0;
+    gboolean next_page_found;
+
+
+    gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,"");
+
+    /* Get words to search... */
+    string = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(CddbSearchStringCombo)->child)));
+    if (!string || g_utf8_strlen(string, -1) <= 0)
+        return FALSE;
+
+    /* Format the string of words */
+    Strip_String(string);
+    /* Remove the duplicated spaces */
+    while ((tmp=strstr(string,"  "))!=NULL) // Search 2 spaces
+    {
+        tmp1 = tmp + 1;
+        while (*tmp1)
+            *(tmp++) = *(tmp1++);
+        *tmp = '\0';
+    }
+
+    Add_String_To_Combo_List(CddbSearchStringModel, string);
+
+    /* Convert spaces to '+' */
+    while ( (tmp=strchr(string,' '))!=NULL )
+        *tmp = '+';
+
+
+    // Delete previous album list
+    gtk_list_store_clear(CddbAlbumListModel);
+    gtk_list_store_clear(CddbTrackListModel);
+    Cddb_Free_Album_List();
+    gtk_widget_set_sensitive(GTK_WIDGET(CddbStopSearchButton),TRUE);
+    gtk_widget_set_sensitive(GTK_WIDGET(CddbStopSearchAutoButton),TRUE);
+
+
+    // Do a loop to load all the pages of results
+    do
+    {
+
+        /* Connection to the server */
+        if ( (socket_id=Cddb_Open_Connection(CDDB_USE_PROXY?CDDB_PROXY_NAME:"www.gnudb.org",
+                                             CDDB_USE_PROXY?CDDB_PROXY_PORT:80)) <= 0 )
+        {
+            g_free(string);
+            return FALSE;
+        }
+
+    
+        /* Build request */
+        cddb_in = g_strdup_printf("GET /search/"
+                                  "%s"
+                                  "?page=%d"
+                                  " HTTP/1.1\r\n"
+                                  "Host: %s:%d\r\n"
+                                  "User-Agent: %s %s\r\n"
+                                  "%s"
+                                  "Connection: close\r\n"
+                                  "\r\n",
+                                  string,
+                                  next_page_cpt,
+                                  "www.gnudb.org",80, //CDDB_SERVER_NAME,CDDB_SERVER_PORT,
+                                  APPNAME,VERSION,
+                                  (proxy_auth=Cddb_Format_Proxy_Authentification())
+                                  );
+        next_page_found = FALSE;
+        g_free(proxy_auth);
+        //g_print("Request : '%s'\n", cddb_in);
+    
+        // Send the request
+        gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,_("Sending request ..."));
+        while (gtk_events_pending()) gtk_main_iteration();
+        if ( (bytes_written=send(socket_id,cddb_in,strlen(cddb_in)+1,0)) < 0)
+        {
+            g_print(_("Can't send the request (%s)!\n"),g_strerror(errno)); 
+            Cddb_Close_Connection(socket_id);
+            g_free(cddb_in);
+            return FALSE;
+        }
+        g_free(cddb_in);
+    
+    
+        /*
+         * Read the answer
+         */
+        msg = g_strdup_printf(_("Receiving data of page %d ..."),next_page_cpt);
+        gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg);
+        g_free(msg);
+        while (gtk_events_pending())
+            gtk_main_iteration();
+        
+        cddb_out = g_malloc0(CDDB_ANSWER_LINE_SIZE+1);
+        
+        // Parse server answer : Check returned code in the first line
+        if ( !cddb_out || (bytes_read=Cddb_Read_Http_Header(socket_id,cddb_out)) <= 0 )
+        {
+            msg = g_strdup_printf(_("The server returned a wrong answer! (%s)"),cddb_out);
+            gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg);
+            g_print("%s\n",msg);
+            g_free(msg);
+            g_free(cddb_out);
+            gtk_widget_set_sensitive(GTK_WIDGET(CddbStopSearchButton),FALSE);
+            gtk_widget_set_sensitive(GTK_WIDGET(CddbStopSearchAutoButton),FALSE);
+            return FALSE;
+        }
+        bytes_read_total += bytes_read;
+    
+        // The next page if exists will contains this url :
+        g_free(next_page);
+        next_page = g_strdup_printf("?page=%d",++next_page_cpt);
+    
+        // Read other lines, and get list of matching albums
+        // Composition of a line : 
+        //  - gnudb.org
+        // <a href="http://www.gnudb.org/cd/ro21123813";><b>Indochine / Le Birthday Album</b></a><br>
+        cat_str      = g_strdup("http://www.gnudb.org/cd/";);
+        art_alb_str  = g_strdup("\"><b>");
+        end_str      = g_strdup("</b></a>"); //"</a><br>");
+        html_end_str = g_strdup("</body>"); // To avoid the cddb lookups to hang
+        while ( CddbWindow && !CddbStopSearch
+        && (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 )
+        {
+            gchar *size_str;
+            bytes_read_total += bytes_read;
+            size_str = Convert_Size_1(bytes_read_total);
+            msg = g_strdup_printf(_("Receiving data (%s) ..."),size_str);
+            gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg);
+            g_free(msg);
+            g_free(size_str);
+            while (gtk_events_pending())
+                gtk_main_iteration();
+    
+            cddb_out_tmp = cddb_out;
+            //g_print("%s\n",cddb_out); // To print received data
+    
+            // If the web search is disabled! (ex : http://www.freedb.org/modules.php?name=News&file=article&sid=246)
+            // The following string is displayed in the search page
+            //if (cddb_out != NULL && strstr(cddb_out_tmp,"Sorry, The web-based search is currently down.") != NULL)
+            //{
+            //    web_search_disabled = TRUE;
+            //    break;
+            //}
+    
+            // We may have severals album in the same line (other version of the same album?)
+            // Note : we test that the 'end' delimiter exists to avoid crashes
+            // Not true for GNUDB.ORG
+            while ( cddb_out != NULL 
+            && (ptr_cat=strstr(cddb_out_tmp,cat_str)) != NULL 
+            && strstr(cddb_out_tmp,end_str) != NULL )
+            {
+                gchar *ptr_font, *ptr_font1;
+                gchar *ptr_art_alb, *ptr_end;
+                gchar *copy, *valid;
+                CddbAlbum *cddbalbum;
+    
+                cddbalbum = g_malloc0(sizeof(CddbAlbum));
+    
+    
+                // Get album category
+                cddb_out_tmp = ptr_cat + strlen(cat_str);
+                strncpy(buffer,cddb_out_tmp,CDDB_ANSWER_LINE_SIZE);
+                *(buffer+2) = 0;
+    
+                // Check only the 2 first characters to set the right category
+                if ( strncmp(buffer,"blues",2)==0 )
+                    valid = g_strdup("blues");
+                else if ( strncmp(buffer,"classical",2)==0 )
+                    valid = g_strdup("classical");
+                else if ( strncmp(buffer,"country",2)==0 )
+                    valid = g_strdup("country");
+                else if ( strncmp(buffer,"data",2)==0 )
+                    valid = g_strdup("data");
+                else if ( strncmp(buffer,"folk",2)==0 )
+                    valid = g_strdup("folk");
+                else if ( strncmp(buffer,"jazz",2)==0 )
+                    valid = g_strdup("jazz");
+                else if ( strncmp(buffer,"newage",2)==0 )
+                    valid = g_strdup("newage");
+                else if ( strncmp(buffer,"reggae",2)==0 )
+                    valid = g_strdup("reggae");
+                else if ( strncmp(buffer,"rock",2)==0 )
+                    valid = g_strdup("rock");
+                else if ( strncmp(buffer,"soundtrack",2)==0 )
+                    valid = g_strdup("soundtrack");
+                else //if ( strncmp(buffer,"misc",2)==0 )
+                    valid = g_strdup("misc");
+    
+                cddbalbum->category = valid;
+    
+    
+                // Get album ID
+                //cddb_out_tmp = strstr(cddb_out_tmp,id_str) + strlen(id_str);
+                cddb_out_tmp = ptr_cat + strlen(cat_str) + 2;
+                strncpy(buffer,cddb_out_tmp,CDDB_ANSWER_LINE_SIZE);
+                if ( (ptr_art_alb=strstr(buffer,art_alb_str)) != NULL )
+                    *ptr_art_alb = 0;
+                cddbalbum->id = g_strdup(buffer);
+    
+    
+                // Get album and artist names.
+                // Note : some names can be like this "<font size=-1>2</font>" (for other version of the same album)
+                cddb_out_tmp = strstr(cddb_out_tmp,art_alb_str) + strlen(art_alb_str);
+                strncpy(buffer,cddb_out_tmp,CDDB_ANSWER_LINE_SIZE);
+                if ( (ptr_end=strstr(buffer,end_str)) != NULL )
+                    *ptr_end = 0;
+                if ( (ptr_font=strstr(buffer,"</font>")) != NULL )
+                {
+                    *ptr_font = 0;
+                    if ( (ptr_font1=strstr(buffer,">")) != NULL )
+                    {
+                        copy = g_strdup_printf("%s -> %s",ptr_font1+1,art_alb_tmp);
+                        cddbalbum->other_version = TRUE;
+                    }else
+                    {
+                        copy = g_strdup(buffer);
+                    }
+    
+                }else
+                {
+                    copy = g_strdup(buffer);
+                    use_art_alb = TRUE;
+                    art_alb_tmp = cddbalbum->artist_album;
+                }
+    
+                if (g_utf8_validate(copy, -1, NULL))
+                {
+                    valid = copy;
+                } else
+                {
+                    valid = convert_string(copy, "iso-8859-1", "utf-8",TRUE);
+                    g_free(copy);
+                }
+    
+                cddbalbum->artist_album = valid;
+    
+                if (use_art_alb)
+                {
+                    art_alb_tmp = valid;
+                    use_art_alb = FALSE;
+                }
+    
+    
+                // New position the search the next string
+                cddb_out_tmp = strstr(cddb_out_tmp,end_str) + strlen(end_str);
+    
+                CddbAlbumList = g_list_append(CddbAlbumList,cddbalbum);
+            }
+            
+            // To avoid the cddb lookups to hang (Patch from Paul Giordano)
+            /* It appears that on some systems that cddb lookups continue to attempt
+             * to get data from the socket even though the other system has completed 
+             * sending. Here we see if the actual end of data is in the last block read.
+             * In the case of the html scan, the </body> tag is used because there's
+             * no crlf followint the </html> tag.
+             */
+            if (strstr(cddb_out_tmp,html_end_str)!=NULL) 
+                break;
+
+
+            // Check if the link to the next results exists to loop again with the next link
+            if (cddb_out != NULL && next_page != NULL
+            && strstr(cddb_out_tmp,next_page) != NULL )
+            {
+                next_page_found = TRUE;
+
+                msg = g_strdup_printf(_("More results to load ..."));
+                gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg);
+                g_free(msg);
+
+                while (gtk_events_pending())
+                    gtk_main_iteration();
+            }
+
+        }
+        g_free(cat_str); g_free(art_alb_str); g_free(end_str); g_free(html_end_str);
+
+        // Close connection
+        Cddb_Close_Connection(socket_id);
+
+    } while (next_page_found);
+    g_free(string);
+
+
+    gtk_widget_set_sensitive(GTK_WIDGET(CddbStopSearchButton),FALSE);
+    gtk_widget_set_sensitive(GTK_WIDGET(CddbStopSearchAutoButton),FALSE);
+
+    g_free(cddb_out);
+
+    //if (web_search_disabled)
+    //    msg = g_strdup_printf(_("Sorry, the web-based search is currently down!"));
+    //else
+        msg = g_strdup_printf(_("Found %d matching album(s)"),g_list_length(CddbAlbumList));
+    gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg);
+    g_free(msg);
+
+    // Initialize the button
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(CddbDisplayRedLinesButton),FALSE);
+
+    // Load the albums found in the list
+    Cddb_Load_Album_List(FALSE);
+
+    return TRUE;
+}
+
+
+/*
  * Send cddb query using the CddbId generated from the selected files to get the
  * list of albums matching with this cddbid.
  */
@@ -2207,7 +2565,7 @@
 {
     gint   socket_id;
     gint   bytes_written;
-    gint   bytes_read;
+    glong  bytes_read;
     gulong bytes_read_total = 0;
 
     gchar *cddb_in;               /* For the request to send */
@@ -2402,7 +2760,8 @@
     bytes_read_total = bytes_read;
     cddb_end_str = g_strdup(".");
 
-    while ( CddbWindow && !CddbStopSearch && (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 )
+    while ( CddbWindow && !CddbStopSearch
+    && (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 )
     {
         gchar *size_str;
         bytes_read_total += bytes_read;
@@ -2535,7 +2894,8 @@
     CddbAlbum *cddbalbum = NULL;
     GList     *TrackOffsetList = NULL;
     gchar     *cddb_in, *cddb_out, *cddb_end_str, *msg, *copy, *valid, *proxy_auth;
-    gint       bytes_written, bytes_read, bytes_read1, bytes_read_total;
+    gint       bytes_written;
+    glong      bytes_read, bytes_read1, bytes_read_total;
     gboolean   read_track_offset = FALSE;
     GtkTreeIter row;
 
@@ -2614,7 +2974,8 @@
     bytes_read_total = bytes_read + bytes_read1;
     cddb_end_str = g_strdup(".");
     
-    while ( CddbWindow && !CddbStopSearch && (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 )
+    while ( CddbWindow && !CddbStopSearch
+    && (bytes_read=Cddb_Read_Line(socket_id,cddb_out)) > 0 )
     {
         gchar *size_str;
         bytes_read_total += bytes_read;
@@ -3036,6 +3397,8 @@
         }
     }
 
+    //ET_Debug_Print_File_List (NULL, __FILE__, __LINE__, __FUNCTION__);
+    
     for (row=0; row < rows_to_loop; row++)
     {
         if (CddbTrackList_Line_Selected == FALSE)
diff -ruN easytag-1.99.12.orig/src/prefs.c easytag-1.99.12/src/prefs.c
--- easytag-1.99.12.orig/src/prefs.c	2006-03-21 20:48:12.000000000 +0100
+++ easytag-1.99.12/src/prefs.c	2006-11-20 00:02:22.744208360 +0100
@@ -1028,11 +1028,12 @@
     CddbServerName = gtk_combo_box_entry_new_text();
     gtk_box_pack_start(GTK_BOX(hbox),CddbServerName,FALSE,FALSE,0);
     gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "freedb.freedb.org");
+    gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "gnudb.gnudb.org");
     gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "at.freedb.org");
     gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "au.freedb.org");
     gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "ca.freedb.org");
-    gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "ca2.freedb.org");
-    gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "de.freedb.org");
+    //gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "ca2.freedb.org");
+    //gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "de.freedb.org");
     gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "es.freedb.org");
     gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "fi.freedb.org");
     gtk_combo_box_append_text(GTK_COMBO_BOX(CddbServerName), "ru.freedb.org");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]