[maemo-commits] [maemo-commits] r8699 - projects/haf/branches/hildon-fm/1.x/hildon-fm
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Dec 8 17:06:00 EET 2006
- Previous message: [maemo-commits] r8698 - projects/haf/branches/hildon-fm/1.x/hildon-fm
- Next message: [maemo-commits] r8700 - in projects/haf/branches/hildon-fm/1.x: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll
Date: 2006-12-08 17:05:59 +0200 (Fri, 08 Dec 2006)
New Revision: 8699
Modified:
projects/haf/branches/hildon-fm/1.x/hildon-fm/hildon-file-system-private.c
Log:
* hildon-fm/hildon-file-system-private.c (hex_digit_to_int,
unescape_string): New.
(_hildon_file_system_create_file_name): Use them to unescape the
fallback display name that is directly extracted from the URI.
(N47877)
Modified: projects/haf/branches/hildon-fm/1.x/hildon-fm/hildon-file-system-private.c
===================================================================
--- projects/haf/branches/hildon-fm/1.x/hildon-fm/hildon-file-system-private.c 2006-12-08 14:21:29 UTC (rev 8698)
+++ projects/haf/branches/hildon-fm/1.x/hildon-fm/hildon-file-system-private.c 2006-12-08 15:05:59 UTC (rev 8699)
@@ -447,10 +447,52 @@
}
}
+static int
+hex_digit_to_int (char d)
+{
+ if (d >= '0' && d <= '9')
+ return d - '0';
+ if (d >= 'a' && d <= 'f')
+ return d - 'a' + 10;
+ if (d >= 'A' && d <= 'F')
+ return d - 'A' + 10;
+ return -1;
+}
+
+static char *
+unescape_string (const char *escaped)
+{
+ char *result = g_strdup (escaped);
+ char *a, *b;
+
+ a = b = result;
+ while (*a)
+ {
+ if (a[0] == '%' && a[1] != '\0' && a[2] != '\0')
+ {
+ int d1 = hex_digit_to_int (a[1]), d2 = hex_digit_to_int (a[2]);
+ int c = 16*d1 + d2;
+
+ if (d1 >= 0 && d2 >= 0 && c != 0)
+ {
+ a += 3;
+ *b++ = c;
+ continue;
+ }
+ }
+
+ *b++ = *a++;
+ }
+ *b = '\0';
+
+ return result;
+}
+
gchar *
-_hildon_file_system_create_file_name(GtkFileSystem *fs,
- const GtkFilePath *path, HildonFileSystemSpecialLocation *location,
- GtkFileInfo *info)
+_hildon_file_system_create_file_name (GtkFileSystem *fs,
+ const GtkFilePath *path,
+ HildonFileSystemSpecialLocation *location,
+ GtkFileInfo *info)
{
if (location) {
char *name;
@@ -461,7 +503,7 @@
if (info)
return g_strdup(gtk_file_info_get_display_name(info));
- return g_strdup(get_custom_root_name(path));
+ return unescape_string (get_custom_root_name (path));
}
gchar *
- Previous message: [maemo-commits] r8698 - projects/haf/branches/hildon-fm/1.x/hildon-fm
- Next message: [maemo-commits] r8700 - in projects/haf/branches/hildon-fm/1.x: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
