diff --git a/VisualCard.Tests/ContactData.cs b/VisualCard.Tests/ContactData.cs index d7a5bc6..97a5703 100644 --- a/VisualCard.Tests/ContactData.cs +++ b/VisualCard.Tests/ContactData.cs @@ -95,6 +95,12 @@ public static class ContactData """ ; + private static readonly string singleMeCardContactFull = + """ + MECARD:N:Sanders,John,,,;SOUND:Saunders,John;TEL:495-522-3560;TEL-AV:495-522-3550;EMAIL:john.s@acme.co;ADR:,,Los Angeles,,,,USA;NOTE:Note test for VisualCard;; + """ + ; + private static readonly string singleVcardContactFromMeCard = """ BEGIN:VCARD @@ -110,6 +116,23 @@ public static class ContactData """ ; + private static readonly string singleVcardContactFullFromMeCard = + """ + BEGIN:VCARD + VERSION:3.0 + FN:John Sanders + NOTE:Note test for VisualCard + N:Sanders;John;;; + TEL:495-522-3560 + TEL;TYPE=VIDEO:495-522-3550 + ADR:;;Los Angeles;;;;USA + EMAIL:john.s@acme.co + X-VISUALCARD-KANA:Saunders;John + END:VCARD + + """ + ; + private static readonly string singleVcardTwoContact = """ BEGIN:VCARD @@ -557,6 +580,9 @@ public static class ContactData [ singleMeCardContact, ], + [ + singleMeCardContactFull, + ], ]; /// @@ -570,6 +596,9 @@ public static class ContactData [ (singleMeCardContact, singleVcardContactFromMeCard), ], + [ + (singleMeCardContactFull, singleVcardContactFullFromMeCard), + ], ]; /// diff --git a/VisualCard/Converters/MeCard.cs b/VisualCard/Converters/MeCard.cs index e853f9f..589fe77 100644 --- a/VisualCard/Converters/MeCard.cs +++ b/VisualCard/Converters/MeCard.cs @@ -60,9 +60,13 @@ public static Card[] GetContactsFromMeCardString(string meCardString) { string value = values[i]; - // "SOUND:" here is actually just a Kana name, so blacklist it. + // "SOUND:" here is actually just a Kana name, so demote it to X-nonstandard if (value.StartsWith($"{VcardConstants._soundSpecifier}:")) - continue; + { + string xNonstandard = $"{VcardConstants._xSpecifier}VISUALCARD-KANA:"; + values[i] = value.Replace(",", ";"); + values[i] = xNonstandard + values[i].Substring(6); + } // Now, replace all the commas in Name and Address with the semicolons. if (value.StartsWith($"{VcardConstants._nameSpecifier}:") || value.StartsWith($"{VcardConstants._addressSpecifier}:")) @@ -74,6 +78,16 @@ public static Card[] GetContactsFromMeCardString(string meCardString) var nameSplits = value.Substring(2).Split(','); fullName = $"{nameSplits[1]} {nameSplits[0]}"; } + + // "TEL-AV:" here is actually just "TEL;TYPE=VIDEO:[...]" + if (value.StartsWith($"{VcardConstants._telephoneSpecifier}-AV:")) + { + string prefix = + $"{VcardConstants._telephoneSpecifier}" + + $"{VcardConstants._fieldDelimiter}" + + $"{VcardConstants._typeArgumentSpecifier}VIDEO:"; + values[i] = prefix + values[i].Substring(7); + } } // Install the values!