From 54caff0ba361f473e9b22971265f4efe7a089c78 Mon Sep 17 00:00:00 2001
From: marshall <mculpepper@appcelerator.com>
Date: Tue, 14 Dec 2010 16:14:29 -0600
Subject: [PATCH 1/5] bump to 1.5.1 on 1_5_X

---
 build/titanium_version.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/build/titanium_version.py b/build/titanium_version.py
index 4139253..b9148ac 100755
--- a/build/titanium_version.py
+++ b/build/titanium_version.py
@@ -1 +1 @@
-version = '1.5.0'
+version = '1.5.1'
-- 
1.7.2


From 1a59cc3e35219d743e9d50558eb33560ba5bcd13 Mon Sep 17 00:00:00 2001
From: donthorp <don@donthorp.net>
Date: Mon, 13 Dec 2010 17:34:00 -0600
Subject: [PATCH 2/5] [#2558 state:fixed-in-qa] Moving to the new kroll we didn't catch the fact that we were expecting a String array as an argument. Now we just check for object array and create the string arrays to pass through the intent.

---
 .../ti/modules/titanium/ui/EmailDialogProxy.java   |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/android/modules/ui/src/ti/modules/titanium/ui/EmailDialogProxy.java b/android/modules/ui/src/ti/modules/titanium/ui/EmailDialogProxy.java
index b629ca2..be46c4d 100644
--- a/android/modules/ui/src/ti/modules/titanium/ui/EmailDialogProxy.java
+++ b/android/modules/ui/src/ti/modules/titanium/ui/EmailDialogProxy.java
@@ -297,8 +297,14 @@ public class EmailDialogProxy extends TiViewProxy {
 	
 	private void putAddressExtra(Intent intent, String extraType, String ourkey) {
 		Object testprop = this.getProperty(ourkey);
-		if (testprop instanceof String[]) {
-			intent.putExtra(extraType, (String[])testprop);
+		if (testprop instanceof Object[]) {
+			Object[] oaddrs = (Object[]) testprop;
+			int len = oaddrs.length;
+			String[] addrs = new String[len];
+			for (int i = 0; i < len; i++) {
+				addrs[i] = TiConvert.toString(oaddrs[i]);
+			}
+			intent.putExtra(extraType, addrs);
 		}		
 	}
 
-- 
1.7.2


From fbc043377a7e44753497c3ec0c9979c0cb53b359 Mon Sep 17 00:00:00 2001
From: billdawson <bill@billdawson.com>
Date: Wed, 15 Dec 2010 19:47:35 +0100
Subject: [PATCH 3/5] [#2589 state:fixed-in-qa][#1491] Add autoEncodeUrl property to HTTPClient (default=true, thus preserving current behavior).  Setting to false means your url will remain untouched.  Add drillbit unit tests.

---
 .../modules/titanium/network/HTTPClientProxy.java  |   12 +++++++
 .../ti/modules/titanium/network/TiHTTPClient.java  |   32 +++++++++++++++++--
 .../tests/android/android.network.httpclient.js    |   20 ++++++++++++
 3 files changed, 60 insertions(+), 4 deletions(-)
 create mode 100644 drillbit/tests/android/android.network.httpclient.js

diff --git a/android/modules/network/src/ti/modules/titanium/network/HTTPClientProxy.java b/android/modules/network/src/ti/modules/titanium/network/HTTPClientProxy.java
index 60b8f6f..62d0ae5 100644
--- a/android/modules/network/src/ti/modules/titanium/network/HTTPClientProxy.java
+++ b/android/modules/network/src/ti/modules/titanium/network/HTTPClientProxy.java
@@ -112,4 +112,16 @@ public class HTTPClientProxy extends KrollProxy {
 	public boolean getConnected() {
 		return client.isConnected();
 	}
+
+	@Kroll.getProperty @Kroll.method
+	public boolean getAutoEncodeUrl()
+	{
+		return client.getAutoEncodeUrl();
+	}
+
+	@Kroll.setProperty @Kroll.method
+	public void setAutoEncodeUrl(boolean value)
+	{
+		client.setAutoEncodeUrl(value);
+	}
 }
diff --git a/android/modules/network/src/ti/modules/titanium/network/TiHTTPClient.java b/android/modules/network/src/ti/modules/titanium/network/TiHTTPClient.java
index fdc2a79..aa978e7 100644
--- a/android/modules/network/src/ti/modules/titanium/network/TiHTTPClient.java
+++ b/android/modules/network/src/ti/modules/titanium/network/TiHTTPClient.java
@@ -135,6 +135,7 @@ public class TiHTTPClient
 	Thread clientThread;
 	private boolean aborted;
 	private int timeout = -1;
+	private boolean autoEncodeUrl = true;
 	
 	class RedirectHandler extends DefaultRedirectHandler {
 		@Override
@@ -700,15 +701,20 @@ public class TiHTTPClient
 		if (DBG) {
 			Log.d(LCAT, "open request method=" + method + " url=" + url);
 		}
-		this.uri = getCleanUri(url);
-		
+
+		if (autoEncodeUrl) {
+			this.uri = getCleanUri(url);
+		} else {
+			this.uri = Uri.parse(url);
+		}
+
 		// If the original url does not contain any
 		// escaped query string (i.e., does not look
 		// pre-encoded), go ahead and reset it to the 
 		// clean uri. Else keep it as is so the user's
 		// escaping stays in effect.  The users are on their own
 		// at that point.
-		if (!url.matches(".*\\?.*\\%\\d\\d.*$")) {
+		if (autoEncodeUrl && !url.matches(".*\\?.*\\%\\d\\d.*$")) {
 			this.url = this.uri.toString();
 		} else {
 			this.url = url;
@@ -743,7 +749,11 @@ public class TiHTTPClient
 		} else {
 			port = uri.getPort();
 		}
-		
+
+		if (DBG) {
+			Log.d(LCAT, "Instantiating host with hostString='" + hostString + "', port='" + port + "', scheme='" + uri.getScheme() + "'");
+		}
+
 		host = new HttpHost(hostString, port, uri.getScheme());
 		if (uri.getUserInfo() != null) {
 			credentials = new UsernamePasswordCredentials(uri.getUserInfo());
@@ -864,6 +874,10 @@ public class TiHTTPClient
 			}
 		}
 
+		if (DBG) {
+			Log.d(LCAT, "Instantiating http request with method='" + method + "' and this url:");
+			Log.d(LCAT, this.url);
+		}
 		request = new DefaultHttpRequestFactory().newHttpRequest(method, this.url);
 		for (String header : headers.keySet()) {
 			request.setHeader(header, headers.get(header));
@@ -1044,4 +1058,14 @@ public class TiHTTPClient
 	public void setTimeout(int millis) {
 		timeout = millis;
 	}
+
+	protected void setAutoEncodeUrl(boolean value)
+	{
+		autoEncodeUrl = value;
+	}
+
+	protected boolean getAutoEncodeUrl()
+	{
+		return autoEncodeUrl;
+	}
 }
diff --git a/drillbit/tests/android/android.network.httpclient.js b/drillbit/tests/android/android.network.httpclient.js
new file mode 100644
index 0000000..3224dff
--- /dev/null
+++ b/drillbit/tests/android/android.network.httpclient.js
@@ -0,0 +1,20 @@
+describe("Android HTTPClient tests", {
+	
+	//https://appcelerator.lighthouseapp.com/projects/32238/tickets/2589-major-regression-in-android-sdk-15-httpclient
+	notEncodeUrl: function() {
+		var url = "http://www.appcelerator.com/a/b/c;jsessionid=abcdefg";
+		var xhr = Ti.Network.createHTTPClient();
+		xhr.autoEncodeUrl = false;
+		xhr.open('GET', url);
+		valueOf(xhr.location).shouldBe(url);
+	}, 
+
+	// https://appcelerator.lighthouseapp.com/projects/32238/tickets/1491-android-auto-encode-network-urls
+	encodeUrl: function() {
+		var url = 'http://developer.appcelerator.com/sub2.php?uname=ld@appcelerator.com.com&appname=testt&desc=test&success=why&datesub=2010/08/01&phoneid=1';
+		var encoded = 'http://developer.appcelerator.com/sub2.php?uname=ld%40appcelerator.com.com&appname=testt&desc=test&success=why&datesub=2010%2F08%2F01&phoneid=1';
+		var xhr = Ti.Network.createHTTPClient();
+		xhr.open('GET', url);
+		valueOf(xhr.location).shouldBe(encoded);
+	}
+});
-- 
1.7.2


From 16bbb921e3227a2312976acceb9da2156e448a65 Mon Sep 17 00:00:00 2001
From: Ralf Pfeiffer <rip@Ralf-Pfeiffers-MacBook-Pro.local>
Date: Thu, 16 Dec 2010 14:09:03 -0800
Subject: [PATCH 4/5] adding Release Notes for 1.5.1

---
 apidoc/Titanium/CHANGELOG/1.5.1.mdoc |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
 create mode 100644 apidoc/Titanium/CHANGELOG/1.5.1.mdoc

diff --git a/apidoc/Titanium/CHANGELOG/1.5.1.mdoc b/apidoc/Titanium/CHANGELOG/1.5.1.mdoc
new file mode 100644
index 0000000..79e04d6
--- /dev/null
+++ b/apidoc/Titanium/CHANGELOG/1.5.1.mdoc
@@ -0,0 +1,16 @@
+Titanium Mobile 1.5.1 - 12/16/2010
+==================================
+
+This point release contains four key fixes, reported after we released 1.5.0
+
+Android Changes
+---------------
+
+- #2589: Auto-encoding with URL containing semicolon incorrect
+- #2558: Email Dialog Address fields won't poplulate 
+
+iOS Changes
+-----------
+
+- #2450: XHR status values not correct
+- #1789: Implementation of SHA-1 algorithm not correct
\ No newline at end of file
-- 
1.7.2


From 1d91671338ecc4c09b303defeb6c1994187d53ac Mon Sep 17 00:00:00 2001
From: Lukas <lukaso@gmail.com>
Date: Sun, 2 Jan 2011 14:44:11 +0000
Subject: [PATCH 5/5] Patch which somewhat reduces threading errors in Titanium.
 The locks themselves don't seem to help. Only the NSLog entries, which seem to cause the problem to delay.

---
 build/titanium_version.py  |    2 +-
 iphone/Classes/AppModule.h |    1 +
 iphone/Classes/AppModule.m |   40 ++++++++++++++++++++++++++++++++++++++--
 3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/build/titanium_version.py b/build/titanium_version.py
index b9148ac..f85237e 100755
--- a/build/titanium_version.py
+++ b/build/titanium_version.py
@@ -1 +1 @@
-version = '1.5.1'
+version = '1.5.22'
diff --git a/iphone/Classes/AppModule.h b/iphone/Classes/AppModule.h
index 659aa53..278632e 100644
--- a/iphone/Classes/AppModule.h
+++ b/iphone/Classes/AppModule.h
@@ -13,6 +13,7 @@
 @interface AppModule : TiModule {
 @private
 	NSMutableDictionary *appListeners;
+	NSRecursiveLock* appListeners_lock;
 	TiAppPropertiesProxy *properties;
 #ifdef USE_TI_APPIOS
 	TiProxy *iOS;
diff --git a/iphone/Classes/AppModule.m b/iphone/Classes/AppModule.m
index 25702d9..7320cb1 100644
--- a/iphone/Classes/AppModule.m
+++ b/iphone/Classes/AppModule.m
@@ -29,8 +29,14 @@ extern NSString * const TI_APPLICATION_GUID;
 
 -(void)dealloc
 {
+	NSLog(@"[WARN] appListeners_lock dealloc lock");
+	[appListeners_lock lock];
 	[appListeners removeAllObjects];
+	NSLog(@"[WARN] appListeners_lock dealloc unlock");
+	[appListeners_lock unlock];
 	RELEASE_TO_NIL(appListeners);
+	NSLog(@"[WARN] appListeners_lock dealloc RELEASE_TO_NIL");
+	RELEASE_TO_NIL(appListeners_lock);
 	RELEASE_TO_NIL(properties);
 #ifdef USE_TI_APPIOS
 	RELEASE_TO_NIL(iOS);
@@ -47,6 +53,8 @@ extern NSString * const TI_APPLICATION_GUID;
 	if (appListeners==nil)
 	{
 		appListeners = [[NSMutableDictionary alloc] init];
+		NSLog(@"[WARN] appListeners_lock addEventListener alloc::init");
+		appListeners_lock = [[NSRecursiveLock alloc] init];
 	}
 	
 	id<TiEvaluator> context = [self executionContext]==nil ? [self pageContext] : [self executionContext];
@@ -62,7 +70,8 @@ extern NSString * const TI_APPLICATION_GUID;
 		entry.type = type;
 	}
 
-	
+	NSLog(@"[WARN] appListeners_lock addEventListener lock");
+	[appListeners_lock lock];
 	NSMutableArray *l = [appListeners objectForKey:type];
 	if (l==nil)
 	{
@@ -71,6 +80,8 @@ extern NSString * const TI_APPLICATION_GUID;
 		[l release];
 	}
 	[l addObject:entry];
+	NSLog(@"[WARN] appListeners_lock addEventListener unlock");
+	[appListeners_lock unlock];
 	[entry release];
 }
 
@@ -81,6 +92,8 @@ extern NSString * const TI_APPLICATION_GUID;
 	
 	ListenerEntry *entry = nil;
 	
+	NSLog(@"[WARN] appListeners_lock removeEventListener lock");
+	[appListeners_lock lock];
 	NSMutableArray *l = [appListeners objectForKey:type];
 
 	BOOL needsScanning;
@@ -100,7 +113,16 @@ extern NSString * const TI_APPLICATION_GUID;
 	
 	if ([appListeners count]==0)
 	{
+		NSLog(@"[WARN] appListeners_lock removeEventListener unlock");
+		[appListeners_lock unlock];
 		RELEASE_TO_NIL(appListeners);
+		NSLog(@"[WARN] appListeners_lock removeEventListener RELEASE_TO_NIL");
+		RELEASE_TO_NIL(appListeners_lock);
+	}
+	else
+	{
+		NSLog(@"[WARN] appListeners_lock removeEventListener unlock");
+		[appListeners_lock unlock];		
 	}
 	
 	[[self _host] removeListener:listener context:pageContext];
@@ -108,15 +130,21 @@ extern NSString * const TI_APPLICATION_GUID;
 
 -(BOOL)_hasListeners:(NSString *)type
 {
+	NSLog(@"[WARN] appListeners_lock _hasListeners lock");
+	[appListeners_lock lock];
 	if (appListeners!=nil && [appListeners count] > 0)
 	{
 		NSArray *array = [appListeners objectForKey:type];
 		
 		if (array!=nil && [array count] > 0)
 		{
+			NSLog(@"[WARN] appListeners_lock _hasListeners unlock");
+			[appListeners_lock unlock];	
 			return YES;
 		}
 	}
+	NSLog(@"[WARN] appListeners_lock _hasListeners unlock");
+	[appListeners_lock unlock];
 	return NO;
 }
 
@@ -130,7 +158,9 @@ extern NSString * const TI_APPLICATION_GUID;
 #ifdef DEBUG
 		NSLog(@"[DEBUG] fire app event: %@ with %@",type,obj);
 #endif
-		
+
+		NSLog(@"[WARN] appListeners_lock fireEvent lock");
+		[appListeners_lock lock];
 		NSArray *array = [appListeners objectForKey:type];
 		
 		if (array!=nil && [array count] > 0)
@@ -158,6 +188,8 @@ extern NSString * const TI_APPLICATION_GUID;
 				[host fireEvent:[entry listener] withObject:jsonObject remove:NO context:[entry context] thisObject:nil];
 			}
 		}
+		NSLog(@"[WARN] appListeners_lock fireEvent unlock");
+		[appListeners_lock unlock];
 	}
 }
 
@@ -240,6 +272,8 @@ extern NSString * const TI_APPLICATION_GUID;
 	// is toast.
 	if (appListeners!=nil)
 	{
+		NSLog(@"[WARN] appListeners_lock willShutdownContext lock");
+		[appListeners_lock lock];
 		NSMutableArray *found = [NSMutableArray array];
 		id context = [note object];
 		for (NSString *type in appListeners)
@@ -269,6 +303,8 @@ extern NSString * const TI_APPLICATION_GUID;
 				[self removeEventListener:a];
 			}
 		}
+		NSLog(@"[WARN] appListeners_lock willShutdownContext unlock");
+		[appListeners_lock unlock];
 	}
 }
 
-- 
1.7.2

