adding create contact support
diff --git a/Res/main.js b/Res/main.js
index c94090a..d637842 100755
--- a/Res/main.js
+++ b/Res/main.js
@@ -181,8 +181,11 @@
     debugPrint("Error = "+contactError.code);

   };

   var contact = navigator.service.contacts.create();

-  contact.displayName = "Plumber";

+  contact.displayName = "John";

   contact.nickname = "Plumber";

+  contact.phoneNumbers = ["6047894567"]

+  contact.emails = ["nomail@noset.com"]

+  contact.urls = ["http://www.domain.com"]

 

   var name = new ContactName();

   name.givenName = "Jane";

diff --git a/Res/phonegap/contact.js b/Res/phonegap/contact.js
index 8ecd5cb..e29c54c 100644
--- a/Res/phonegap/contact.js
+++ b/Res/phonegap/contact.js
@@ -173,9 +173,8 @@
 */
 Contact.prototype.save = function(successCB, errorCB) {
 	// don't modify the original contact
-	var cloned = PhoneGap.clone(this);
-	cloned.convertDatesOut(); 
-	PhoneGap.exec(successCB, errorCB, "com.phonegap.Contacts","save", [{"contact": cloned}]);
+  var bada_contact = {email: this.emails[0], phone: this.phoneNumbers[0], email: this.emails[0], url: this.urls[0]};
+	PhoneGap.exec(successCB, errorCB, "com.phonegap.Contacts", "save", [bada_contact]);
 };
 
 /**
diff --git a/Res/phonegap/phonegap.base.js b/Res/phonegap/phonegap.base.js
index b89153d..2c21e1c 100644
--- a/Res/phonegap/phonegap.base.js
+++ b/Res/phonegap/phonegap.base.js
@@ -489,7 +489,6 @@
 PhoneGap.run_command = function() {
     if (!PhoneGap.available() || !PhoneGap.queue.ready)
         return;
-    PhoneGap.queue.ready = false;
 
     var args = PhoneGap.queue.commands.shift();
     if (PhoneGap.queue.commands.length == 0) {
@@ -521,20 +520,25 @@
         	var arg = args[i];
         	if (arg == undefined || arg == null)
             	continue;
-        	if (typeof(arg) == 'object')
+        	if (typeof(arg) == 'object') {
               for(i in arg) {
-                query.push(i + '=' + encodeURIComponent(arg[i]));
+                if(typeof(arg[i]) != 'object') {
+                  query.push(encodeURIComponent(i) + '=' + encodeURIComponent(arg[i]));
+                }
               }
-        	else
+          }
+        	else {
             	uri.push(encodeURIComponent(arg));
+          }
     	}
     	var next = callbackId != null  ?  ("/" + callbackId + "/") : "/";
     	var url = "gap://" + service + next + uri.join("/");
 
     	if (query.length > 0) {
-        	url += "?" + encodeURIComponent(query.join("&"));
+        	url += "?" + query.join("&");
     	}
-		document.location = url;
+      PhoneGap.queue.ready = false;
+      document.location = url;
    
     } catch (e) {
         console.log("PhoneGapExec Error: "+e);
diff --git a/inc/Contacts.h b/inc/Contacts.h
index a9a3e0b..48592ab 100755
--- a/inc/Contacts.h
+++ b/inc/Contacts.h
@@ -13,14 +13,19 @@
 using namespace Osp::Base::Collection;

 using namespace Osp::App;

 

-class Contacts: public PhoneGapCommand {

+class Contacts: public PhoneGapCommand, IAppControlEventListener {

 public:

 	Contacts(Web* pWeb);

 	virtual ~Contacts();

 public:

 	void Run(const String& command);

-	void Create();

+	void Create(const String& query);

 	void Find();

+public:

+	virtual void OnAppControlCompleted (const Osp::Base::String &appControlId, const Osp::Base::String &operationId, const Osp::Base::Collection::IList *pResultList);

+private:

+	ArrayList* GetDataList(const String& query);

+	String callbackId;

 };

 

 #endif /* CONTACTS_H_ */

diff --git a/inc/WebForm.h b/inc/WebForm.h
index 722ff06..02e216c 100755
--- a/inc/WebForm.h
+++ b/inc/WebForm.h
@@ -13,6 +13,7 @@
 #include "Network.h"

 #include "DebugConsole.h"

 #include "Compass.h"

+#include "Contacts.h"

 

 using namespace Osp::Base;

 using namespace Osp::Base::Collection;

@@ -46,6 +47,7 @@
 	Network*					network;

 	DebugConsole*				console;

 	Compass*					compass;

+	Contacts*					contacts;

 	String*						__phonegapCommand;

 

 public:

diff --git a/src/Compass.cpp b/src/Compass.cpp
index f00c008..44abe6e 100755
--- a/src/Compass.cpp
+++ b/src/Compass.cpp
@@ -20,7 +20,6 @@
 void

 Compass::Run(const String& command) {

 	if (!command.IsEmpty()) {

-

 		String args;

 		String delim(L"/");

 		command.SubString(String(L"gap://").GetLength(), args);

diff --git a/src/Contacts.cpp b/src/Contacts.cpp
index eb9390f..d900af9 100755
--- a/src/Contacts.cpp
+++ b/src/Contacts.cpp
@@ -19,23 +19,62 @@
 void

 Contacts::Run(const String& command) {

 	if(!command.IsEmpty()) {

+		// URL decoding

+		Uri commandUri;

+		commandUri.SetUri(command);

+		String method = commandUri.GetHost();

+		callbackId = commandUri.GetPath();

+		callbackId.Replace(L"/", L"");

+		String contactInfo = commandUri.GetQuery();

+

+//		AppLogDebug("Method %S, callbackId %S, hostAddr %S URI %S", method.GetPointer(), callbackId.GetPointer(), hostAddr.GetPointer(), uri.ToString().GetPointer());

+		AppLogDebug("Method %S callbackId %S query %S", method.GetPointer(), callbackId.GetPointer() , contactInfo.GetPointer());

+		if(method == L"com.phonegap.Contacts.save" && !callbackId.IsEmpty()) {

+			Create(contactInfo);

+		}

 

 	}

 }

 

-void

-Contacts::Create() {

-	ArrayList* pDataList = null;

-	pDataList = new ArrayList();

+ArrayList*

+Contacts::GetDataList(const String& query) {

+	ArrayList* pDataList = new ArrayList();

 	pDataList->Construct();

-	String* pData = null;

-	pData = new String(L"phone:+919899045670");

-	pDataList->Add(*pData);

+	String* pStorage = new String(L"storageType:phone");

+	pDataList->Add(*pStorage);

 

+	String delim(L"&");

+	StringTokenizer strTok(query, delim);

+

+	while(strTok.HasMoreTokens()) {

+		String* pData = new String();

+		strTok.GetNextToken(*pData);

+		pData->Replace(L"=", L":");

+		AppLogDebug("param %S", pData->GetPointer());

+		pDataList->Add(*pData);

+	}

+

+	return pDataList;

+}

+

+void

+Contacts::OnAppControlCompleted(const Osp::Base::String &appControlId,

+								const Osp::Base::String &operationId,

+								const Osp::Base::Collection::IList *pResultList) {

+	AppLogDebug("appControlId %S operationId %S", appControlId.GetPointer(), operationId.GetPointer());

+	for(int i = 0 ; i < pResultList->GetCount() ; i++) {

+		String* obj = (String*)pResultList->GetAt(i);

+		AppLogDebug("OBJ %S", obj->GetPointer());

+	}

+}

+

+void

+Contacts::Create(const String& query) {

+	ArrayList* pDataList = GetDataList(query);

 	AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_CONTACT,OPERATION_ADD);

 	if(pAc)

 	{

-		pAc->Start(pDataList, null);

+		pAc->Start(pDataList, this);

 		delete pAc;

 	}

 	pDataList->RemoveAll(true);

diff --git a/src/WebForm.cpp b/src/WebForm.cpp
index 6c528a0..b88efaf 100755
--- a/src/WebForm.cpp
+++ b/src/WebForm.cpp
@@ -9,6 +9,7 @@
 	network = null;

 	console = null;

 	compass = null;

+	contacts = null;

 }

 

 WebForm::~WebForm(void)

@@ -148,6 +149,9 @@
 		else if(__phonegapCommand->StartsWith(L"gap://com.phonegap.Compass", 0)) {

 			compass->Run(*__phonegapCommand);

 		}

+		else if(__phonegapCommand->StartsWith(L"gap://com.phonegap.Contacts", 0)) {

+			contacts->Run(*__phonegapCommand);

+		}

 		delete __phonegapCommand;

 		__phonegapCommand = null;

 	}

@@ -189,6 +193,7 @@
 		network = new Network(__pWeb);

 		console = new DebugConsole(__pWeb);

 		compass = new Compass(__pWeb);

+		contacts = new Contacts(__pWeb);

 	}

 	return r;