You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/01/23 01:19:52 UTC
[1/21] git commit: Empty contact sanity check
Empty contact sanity check
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/5089d5ae
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/5089d5ae
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/5089d5ae
Branch: refs/heads/master
Commit: 5089d5aebf2c83a1c2d088eeb5305a775da36c3d
Parents: dc7f2d2
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Jan 4 17:59:14 2013 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Jan 4 17:59:14 2013 -0800
----------------------------------------------------------------------
.../standalone/cordovalib/Commands/Contacts.cs | 20 +++++++++-----
1 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/5089d5ae/templates/standalone/cordovalib/Commands/Contacts.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/Commands/Contacts.cs b/templates/standalone/cordovalib/Commands/Contacts.cs
index df9c67e..af78942 100644
--- a/templates/standalone/cordovalib/Commands/Contacts.cs
+++ b/templates/standalone/cordovalib/Commands/Contacts.cs
@@ -176,7 +176,7 @@ namespace WPCordovaClassLib.Cordova.Commands
string[] args = JSON.JsonHelper.Deserialize<string[]>(jsonContact);
- JSONContact contact = JSON.JsonHelper.Deserialize<JSONContact>(args[0]) ;
+ JSONContact contact = JSON.JsonHelper.Deserialize<JSONContact>(args[0]);
SaveContactTask contactTask = new SaveContactTask();
@@ -344,7 +344,7 @@ namespace WPCordovaClassLib.Cordova.Commands
deviceContacts.SearchAsync(displayName, FilterKind.DisplayName, task);
});
-
+
}
else if (e.TaskResult == TaskResult.Cancel)
@@ -611,16 +611,22 @@ namespace WPCordovaClassLib.Cordova.Commands
"\"honorificPrefix\":\"{4}\"," +
"\"honorificSuffix\":\"{5}\"";
- retVal = string.Format(formatStr,
- con.CompleteName.FirstName, // TODO:
+ if (con.CompleteName != null)
+ {
+ retVal = string.Format(formatStr,
+ con.CompleteName.FirstName + " " + con.CompleteName.LastName, // TODO: does this need suffix? middlename?
con.CompleteName.LastName,
con.CompleteName.FirstName,
con.CompleteName.MiddleName,
con.CompleteName.Title,
con.CompleteName.Suffix);
+ }
+ else
+ {
+ retVal = string.Format(formatStr,"","","","","","");
+ }
return "{" + retVal + "}";
-
}
private string FormatJSONContact(Contact con, string[] fields)
@@ -641,7 +647,7 @@ namespace WPCordovaClassLib.Cordova.Commands
string jsonContact = String.Format(contactFormatStr,
con.GetHashCode(),
con.DisplayName,
- con.CompleteName.Nickname,
+ con.CompleteName != null ? con.CompleteName.Nickname : "",
FormatJSONPhoneNumbers(con),
FormatJSONEmails(con),
FormatJSONAddresses(con),
@@ -652,7 +658,7 @@ namespace WPCordovaClassLib.Cordova.Commands
//Debug.WriteLine("jsonContact = " + jsonContact);
// JSON requires new line characters be escaped
- return "{" + jsonContact.Replace("\n", "\\n") +"}";
+ return "{" + jsonContact.Replace("\n", "\\n") + "}";
}
}
}