Skip to content

Commit

Permalink
add - doc - Added TEL-AV and SOUND support
Browse files Browse the repository at this point in the history
---

We've finally added both the Kana SOUND:[...] as X-VISUALCARD-KANA:[...] and TEL-AV:[...] as TEL;TYPE=VIDEO:[...].

---

Type: add
Breaking: False
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Apr 1, 2024
1 parent 50293e9 commit db0f717
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
29 changes: 29 additions & 0 deletions VisualCard.Tests/ContactData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected];ADR:,,Los Angeles,,,,USA;NOTE:Note test for VisualCard;;
"""
;

private static readonly string singleVcardContactFromMeCard =
"""
BEGIN:VCARD
Expand All @@ -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:[email protected]
X-VISUALCARD-KANA:Saunders;John
END:VCARD

"""
;

private static readonly string singleVcardTwoContact =
"""
BEGIN:VCARD
Expand Down Expand Up @@ -557,6 +580,9 @@ public static class ContactData
[
singleMeCardContact,
],
[
singleMeCardContactFull,
],
];

/// <summary>
Expand All @@ -570,6 +596,9 @@ public static class ContactData
[
(singleMeCardContact, singleVcardContactFromMeCard),
],
[
(singleMeCardContactFull, singleVcardContactFullFromMeCard),
],
];

/// <summary>
Expand Down
18 changes: 16 additions & 2 deletions VisualCard/Converters/MeCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}:"))
Expand All @@ -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!
Expand Down

0 comments on commit db0f717

Please sign in to comment.