Author: fejj
Date: 2008-02-19 15:14:07 -0500 (Tue, 19 Feb 2008)
New Revision: 96183
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/text.cpp
trunk/moon/src/text.h
trunk/moon/src/uri.cpp
trunk/moon/src/uri.h
Log:
2008-02-19 Jeffrey Stedfast <[EMAIL PROTECTED]>
* uri.cpp (Uri::ToString): Now takes a 'flags' argument to let us
know which, if any, parts of the URI to hide.
(Uri::Parse): If we don't have a protocol, don't simply assume
that the entire string is the filename. We might have a fragment
attached, for example.
* text.cpp (Glyphs::OnPropertyChanged): Decode the URI here and
get the font index (if a fragment is set). Also, use the parsed
Uri's ::ToString() method to hide the fragment so that requesting
the file actually works.
(Glyphs::DownloaderComplete): Don't need to parse the URI here
anymore, we've already got the index from OnPropertyChanged().
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2008-02-19 20:03:01 UTC (rev 96182)
+++ trunk/moon/src/ChangeLog 2008-02-19 20:14:07 UTC (rev 96183)
@@ -1,3 +1,18 @@
+2008-02-19 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ * uri.cpp (Uri::ToString): Now takes a 'flags' argument to let us
+ know which, if any, parts of the URI to hide.
+ (Uri::Parse): If we don't have a protocol, don't simply assume
+ that the entire string is the filename. We might have a fragment
+ attached, for example.
+
+ * text.cpp (Glyphs::OnPropertyChanged): Decode the URI here and
+ get the font index (if a fragment is set). Also, use the parsed
+ Uri's ::ToString() method to hide the fragment so that requesting
+ the file actually works.
+ (Glyphs::DownloaderComplete): Don't need to parse the URI here
+ anymore, we've already got the index from OnPropertyChanged().
+
2008-02-19 Jackson Harper <[EMAIL PROTECTED]>
* xaml.cpp: Parser error if we can't find the owner type or
Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp 2008-02-19 20:03:01 UTC (rev 96182)
+++ trunk/moon/src/text.cpp 2008-02-19 20:14:07 UTC (rev 96183)
@@ -1342,6 +1342,7 @@
attrs = new List ();
text = NULL;
+ index = 0;
origin_y_specified = false;
origin_x = 0.0;
@@ -1691,28 +1692,13 @@
Glyphs::DownloaderComplete ()
{
char *filename = downloader_get_response_file (downloader, "");
- Value *value = downloader->GetValue (Downloader::UriProperty);
- const char *str;
- int id = 0;
- Uri *uri;
/* the download was aborted */
if (!filename)
return;
- if (value && (str = value->AsString ())) {
- uri = new Uri ();
-
- if (uri->Parse (str) && uri->fragment) {
- if ((id = strtol (uri->fragment, NULL, 10)) < 0)
- id = 0;
- }
-
- delete uri;
- }
-
desc->SetFilename (filename);
- desc->SetIndex (id);
+ desc->SetIndex (index);
g_free (filename);
dirty = true;
@@ -1823,19 +1809,28 @@
}
if (prop == Glyphs::FontUriProperty) {
- char *uri = glyphs_get_font_uri (this);
+ char *str = glyphs_get_font_uri (this);
+ Uri *uri = new Uri ();
if (downloader) {
downloader_abort (downloader);
downloader->unref ();
downloader = NULL;
+ index = 0;
}
- if (uri && *uri) {
+ if (str && *str && uri->Parse (str)) {
downloader = Surface::CreateDownloader (this);
- //printf ("setting media source to %s\n", uri);
- downloader_open (downloader, "GET", uri);
+ if (uri->fragment) {
+ if ((index = strtol (uri->fragment, NULL, 10))
< 0 || index == LONG_MAX)
+ index = 0;
+ }
+
+ str = uri->ToString (UriHideFragment);
+ downloader_open (downloader, "GET", str);
+ g_free (str);
+
downloader->AddHandler (downloader->CompletedEvent,
downloader_complete, this);
if (downloader->Started () || downloader->Completed ())
{
if (downloader->Completed ())
@@ -1848,6 +1843,8 @@
}
}
+ delete uri;
+
invalidate = false;
} else if (prop == Glyphs::FillProperty) {
if (fill != NULL) {
Modified: trunk/moon/src/text.h
===================================================================
--- trunk/moon/src/text.h 2008-02-19 20:03:01 UTC (rev 96182)
+++ trunk/moon/src/text.h 2008-02-19 20:14:07 UTC (rev 96183)
@@ -243,6 +243,7 @@
gunichar *text;
List *attrs;
Brush *fill;
+ int index;
bool origin_y_specified;
double origin_x;
Modified: trunk/moon/src/uri.cpp
===================================================================
--- trunk/moon/src/uri.cpp 2008-02-19 20:03:01 UTC (rev 96182)
+++ trunk/moon/src/uri.cpp 2008-02-19 20:14:07 UTC (rev 96183)
@@ -112,17 +112,9 @@
start = uri;
if (!(inptr = strchr (start, ':'))) {
protocol = g_strdup ("file");
+ inptr = uri;
- /* canonicalise and save the path component */
- if ((n = strlen (start))) {
- value = g_strndup (start, n);
- url_decode (value, uri);
-
- if (!(path = canon_path (value, true)))
- g_free (value);
- }
-
- goto done;
+ goto decode_path;
}
protocol = g_ascii_strdown (start, inptr - start);
@@ -247,6 +239,7 @@
}
if (*inptr == '/') {
+ decode_path:
/* look for params, query, or fragment */
start = inptr;
while (*inptr && *inptr != ';' && *inptr != '?' && *inptr !=
'#')
@@ -385,15 +378,17 @@
}
char *
-Uri::ToString ()
+Uri::ToString (UriToStringFlags flags)
{
GString *string;
char *uri;
- string = g_string_new (this->protocol);
- g_string_append (string, "://");
+ string = g_string_new ("");
if (this->host) {
+ g_string_append (string, this->protocol);
+ g_string_append (string, "://");
+
if (this->user) {
append_url_encoded (string, this->user, ":;@/");
@@ -402,7 +397,7 @@
append_url_encoded (string, this->auth, ":@/");
}
- if (this->passwd) {
+ if (this->passwd && !(flags & UriHidePasswd)) {
g_string_append_c (string, ':');
append_url_encoded (string, this->passwd, "@/");
}
@@ -433,7 +428,7 @@
append_url_encoded (string, this->query, "#");
}
- if (this->fragment) {
+ if (this->fragment && !(flags & UriHideFragment)) {
g_string_append_c (string, '#');
append_url_encoded (string, this->fragment, "");
}
Modified: trunk/moon/src/uri.h
===================================================================
--- trunk/moon/src/uri.h 2008-02-19 20:03:01 UTC (rev 96182)
+++ trunk/moon/src/uri.h 2008-02-19 20:14:07 UTC (rev 96183)
@@ -13,6 +13,11 @@
#include <glib.h>
+enum UriToStringFlags {
+ UriHidePasswd = 1 << 0,
+ UriHideFragment = 1 << 1,
+};
+
class Uri {
public:
char *protocol;
@@ -31,7 +36,8 @@
bool Parse (const char *uri);
- char *ToString ();
+ char *ToString (UriToStringFlags flags);
+ char *ToString () { return ToString ((UriToStringFlags) 0); }
};
#endif /* __URI_H__ */
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches