f-spot r3712 - in trunk: . src src/Utils



Author: sdelcroix
Date: Wed Feb 27 19:50:15 2008
New Revision: 3712
URL: http://svn.gnome.org/viewvc/f-spot?rev=3712&view=rev

Log:
2008-02-27  Stephane Delcroix  <sdelcroix novell com>

	* configure.in: check for mono 2.0

	* src/PhotoStore.cs:
	* src/Utils/UriUtils.cs: don't escape uri for mono < 2.0.


Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/PhotoStore.cs
   trunk/src/Utils/UriUtils.cs

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Wed Feb 27 19:50:15 2008
@@ -90,6 +90,11 @@
 if pkg-config --atleast-version=2.11 gtk-sharp-2.0; then
    CSC_DEFINES="-d:GTK_2_11"
 fi
+if pkg-config --atleast-version=2.0 mono; then
+   CSC_DEFINES="$CSC_DEFINES -d:MONO_2_0"
+fi
+
+
 
 dnl - Choose PreferenceBackend (default to gconf)
 AC_ARG_ENABLE([gconf],[AC_HELP_STRING([--disable-gconf], [build without gconf preference backend])],,)

Modified: trunk/src/PhotoStore.cs
==============================================================================
--- trunk/src/PhotoStore.cs	(original)
+++ trunk/src/PhotoStore.cs	Wed Feb 27 19:50:15 2008
@@ -197,7 +197,11 @@
 		while (reader.Read ()) {
 			uint version_id = Convert.ToUInt32 (reader [0]);
 			string name = reader[1].ToString ();
+#if MONO_2_0
+			System.Uri uri = new System.Uri (reader[2].ToString ());
+#else
 			System.Uri uri = new System.Uri (reader[2].ToString (), true);
+#endif
 			bool is_protected = Convert.ToBoolean (reader[3]);
 			photo.AddVersionUnsafely (version_id, uri, name, is_protected);
 		}
@@ -236,7 +240,11 @@
 			if (reader [1] != null) {
 				uint version_id = Convert.ToUInt32 (reader [1]);
 				string name = reader[2].ToString ();
+#if MONO_2_0
+				System.Uri uri = new System.Uri (reader[3].ToString ());
+#else
 				System.Uri uri = new System.Uri (reader[3].ToString (), true);
+#endif
 				bool is_protected = Convert.ToBoolean (reader[4]);	
 				photo.AddVersionUnsafely (version_id, uri, name, is_protected);
 			}
@@ -289,7 +297,11 @@
 		if (reader.Read ()) {
 			photo = new Photo (id,
 				Convert.ToInt64 (reader [0]),
+#if MONO_2_0
+				new System.Uri (reader [1].ToString ()));
+#else
 				new System.Uri (reader [1].ToString (), true));
+#endif
 
 			photo.Description = reader[2].ToString ();
 			photo.RollId = Convert.ToUInt32 (reader[3]);
@@ -522,7 +534,11 @@
 			if (photo == null) {
 				photo = new Photo (id,
 						   Convert.ToInt64 (reader [1]),
+#if MONO_2_0
+						   new System.Uri (reader [2].ToString ()));
+#else
 						   new System.Uri (reader [2].ToString (), true));
+#endif
 				
 				photo.Description = reader[3].ToString ();
 				photo.RollId = Convert.ToUInt32 (reader[4]);

Modified: trunk/src/Utils/UriUtils.cs
==============================================================================
--- trunk/src/Utils/UriUtils.cs	(original)
+++ trunk/src/Utils/UriUtils.cs	Wed Feb 27 19:50:15 2008
@@ -42,51 +42,55 @@
 			}
 			builder.Append (path);
 	
+#if MONO_2_0
+			return new Uri (builder.ToString ());
+#else
 			return new Uri (builder.ToString (), true);
+#endif
 		}
 
 		static char[] CharsToQuote = { ';', '?', ':', '@', '&', '=', '$', ',', '#' };
-		// NOTE: this was copied from mono's System.Uri where it is protected.
+		// NOTE: this was copied from mono's System.Uri where it is internal.
 		public static string EscapeString (string str, bool escapeReserved, bool escapeHex, bool escapeBrackets) 
 		{
 			if (str == null)
 				return String.Empty;
 			
-			byte [] data = Encoding.UTF8.GetBytes (str);
 			StringBuilder s = new StringBuilder ();
-			int len = data.Length;	
+			int len = str.Length;	
 			for (int i = 0; i < len; i++) {
-				char c = (char) data [i];
-				// reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","
 				// mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
 				// control     = <US-ASCII coded characters 00-1F and 7F hexadecimal>
 				// space       = <US-ASCII coded character 20 hexadecimal>
 				// delims      = "<" | ">" | "#" | "%" | <">
 				// unwise      = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
-				
+
 				// check for escape code already placed in str, 
 				// i.e. for encoding that follows the pattern 
 				// "%hexhex" in a string, where "hex" is a digit from 0-9 
 				// or a letter from A-F (case-insensitive).
-				if('%' == c && Uri.IsHexEncoding(str,i))
-				{
+				if (Uri.IsHexEncoding (str,i)) {
 					// if ,yes , copy it as is
-					s.Append(c);
-					s.Append(str[++i]);
-					s.Append(str[++i]);
+					s.Append(str.Substring (i, 3));
+					i += 2;
 					continue;
 				}
-				
-				if ((c <= 0x20) || (c >= 0x7f) || 
-				    ("<>%\"{}|\\^`".IndexOf (c) != -1) ||
-				    (escapeHex && (c == '#')) ||
-				    (escapeBrackets && (c == '[' || c == ']')) ||
-				    (escapeReserved && (";/?:@&=+$,".IndexOf (c) != -1))) {
-					s.Append (Uri.HexEscape (c));
-					continue;
+
+				byte [] data = Encoding.UTF8.GetBytes (new char[] {str[i]});
+				int length = data.Length;
+				for (int j = 0; j < length; j++) {
+					char c = (char) data [j];
+					// reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","
+					if ((c <= 0x20) || (c >= 0x7f) || 
+					    ("<>%\"{}|\\^`".IndexOf (c) != -1) ||
+					    (escapeHex && (c == '#')) ||
+					    (escapeBrackets && (c == '[' || c == ']')) ||
+					    (escapeReserved && (";/?:@&=+$,".IndexOf (c) != -1))) {
+						s.Append (Uri.HexEscape (c));
+						continue;
+					}	
+					s.Append (c);
 				}
-				
-				s.Append (c);
 			}
 			
 			return s.ToString ();



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