[Player-cvs] app/gtk commonapp.cpp, 1.58, 1.59 mainapp.cpp, 1.83, 1.84 upgrade.cpp, 1.11, 1.12
rggammon at helixcommunity.org rggammon at helixcommunity.orgUpdate of /cvsroot/player/app/gtk
In directory cvs-new:/tmp/cvs-serv3938
Modified Files:
commonapp.cpp mainapp.cpp upgrade.cpp
Log Message:
Merging fix 3071 and 2950 from gold
Index: commonapp.cpp
===================================================================
RCS file: /cvsroot/player/app/gtk/commonapp.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- commonapp.cpp 15 Sep 2004 02:23:03 -0000 1.58
+++ commonapp.cpp 17 Sep 2004 00:29:23 -0000 1.59
@@ -79,6 +79,7 @@
#include "hxgvalue.h"
#include "hxgprefs.h"
#include "hxgerror.h"
+#include "hxguri.h"
#include "favorites.h"
@@ -227,46 +228,83 @@
hxcommon_get_title_from_url(const gchar* url)
{
const gchar* pos;
+ gchar* p;
gint len = 0;
gchar* title;
+ const gchar* slash_pos = NULL;
+ guint i;
pos = url;
- while(*pos && *pos != '?')
- {
- pos++;
- }
-
- while(pos != url)
+ while(*pos)
{
- if(*pos == '/' || *pos == G_DIR_SEPARATOR)
+ if(*pos == '/')
+ {
+ slash_pos = pos;
+ }
+ else if(*pos == '?')
{
break;
}
- pos--;
- len++;
+ pos++;
}
- pos++;
- len--;
+ if(slash_pos)
+ {
+ len = pos - slash_pos;
+ }
+ else
+ {
+ len = pos - url - 1;
+ }
- if(len <= 0)
+ if(!slash_pos || len == 0)
{
title = g_strdup(_("untitled"));
}
else
{
- if(len > MAX_TITLE_LENGTH)
- {
- title = (gchar*) g_malloc(MAX_TITLE_LENGTH + 4);
- strncpy(title, pos, MAX_TITLE_LENGTH);
- strcpy(&title[MAX_TITLE_LENGTH], "...");
- }
- else
+ /* Decode the title */
+ gchar* encoded_filename;
+ gchar* filename;
+ gchar c;
+
+ encoded_filename = (gchar*) g_malloc(len + 1);
+ strncpy(encoded_filename, slash_pos + 1, len);
+ encoded_filename[len] = '\0';
+
+ filename = hx_unescape_string(encoded_filename);
+ g_free(encoded_filename);
+
+ /* Filename is in utf-8 at this point. Truncate if necessary. */
+ c = g_utf8_get_char (filename);
+ p = filename;
+ i = 0;
+ while(c)
{
- title = (gchar*) g_malloc(len + 1);
- strncpy(title, pos, len);
- title[len] = '\0';
+ p = g_utf8_next_char(p);
+ c = g_utf8_get_char (p);
+ i++;
+ if(i == MAX_TITLE_LENGTH)
+ {
+ /* Back up 3 characters */
+ p = g_utf8_prev_char(p);
+ p = g_utf8_prev_char(p);
+ p = g_utf8_prev_char(p);
+
+ /* XXXRGG: Not sure if this is valid for all languages... */
+ *p++ = '.';
+ *p++ = '.';
+ *p++ = '.';
+ *p++ = '\0';
+
+ /* Trim the buffer */
+ filename = (gchar*) g_realloc(filename, p - filename);
+
+ break;
+ }
}
+
+ title = filename;
}
return title;
Index: mainapp.cpp
===================================================================
RCS file: /cvsroot/player/app/gtk/mainapp.cpp,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- mainapp.cpp 8 Sep 2004 20:49:57 -0000 1.83
+++ mainapp.cpp 17 Sep 2004 00:29:23 -0000 1.84
@@ -4083,6 +4083,24 @@
return;
}
+ else if(hxcode == HXR_INVALID_PROTOCOL)
+ {
+ const gchar* url = hx_player_get_url(HX_PLAYER(window->player));
+ gchar pnm_component[] = "protocol_pnm";
+
+ GList* component_list = NULL;
+ component_list = g_list_append(component_list, pnm_component);
+
+ hxcommon_run_request_upgrade_dialog(GTK_WINDOW(window->window),
+ NULL,
+ url,
+ component_list,
+ TRUE);
+ g_list_free(component_list);
+
+ return;
+ }
+
#endif
hxcommon_run_error_dialog(GTK_WINDOW(window->window),
Index: upgrade.cpp
===================================================================
RCS file: /cvsroot/player/app/gtk/upgrade.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- upgrade.cpp 27 Aug 2004 20:24:36 -0000 1.11
+++ upgrade.cpp 17 Sep 2004 00:29:23 -0000 1.12
@@ -123,7 +123,9 @@
"wav",
"aiff",
"au",
- "protocol_rtsp_rdt" // synthesized by the player.
+
+ "protocol_rtsp_rdt", // synthesized by the player.
+ "protocol_pnm" // synthesized by the player.
};
gboolean rp_only = FALSE;