Skip to content

Commit

Permalink
add - doc - Added support for vCard 5.0 files
Browse files Browse the repository at this point in the history
---

We've added support for our own version of vCard 4.0, dubbed vCard 5.0, to VisualCard's parser.

Check out the specs in the vcard-50-aptivi.txt file.

---

Type: add
Breaking: False
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Dec 16, 2023
1 parent 5531634 commit 578928a
Show file tree
Hide file tree
Showing 23 changed files with 1,314 additions and 29 deletions.
3 changes: 3 additions & 0 deletions VisualCard.ShowContacts/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static void Main(string[] args)
}

// Show contact information
bool showVcard5Disclaimer = Contacts.Any((card) => card.CardVersion == "5.0");
foreach (Card Contact in Contacts)
{
TextWriterColor.WriteColor("----------------------------", ConsoleColors.Green);
Expand Down Expand Up @@ -181,6 +182,8 @@ static void Main(string[] args)
);
TextWriterColor.Write(raw);
}
if (showVcard5Disclaimer)
TextWriterColor.WriteColor("This application uses vCard 5.0, a revised version of vCard 4.0, made by Aptivi.", ConsoleColors.Gray);
}
}
}
Expand Down
261 changes: 261 additions & 0 deletions VisualCard.Tests/ContactData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,31 @@ public static class ContactData
};
#endregion

#region singleVcardFiveContactShort
private static readonly string singleVcardFiveContactShort =
"""
BEGIN:VCARD
VERSION:5.0
N:Hood;Rick;;;
FN:Rick Hood
END:VCARD
"""
;

private static readonly Card singleVcardFiveContactShortInstance = new
(
null,
"5.0"
)
{
ContactNames =
[
new NameInfo(0, [], "Rick", "Hood", [], [], [])
],
ContactFullName = "Rick Hood"
};
#endregion

#region singleVcardTwoContact
private static readonly string singleMeCardContact =
"""
Expand Down Expand Up @@ -376,6 +401,74 @@ public static class ContactData
};
#endregion

#region singleVcardFiveContact
private static readonly string singleVcardFiveContact =
"""
BEGIN:VCARD
VERSION:5.0
ADR;TYPE=home:;;Los Angeles\, USA;;;;
EMAIL;TYPE=HOME:[email protected]
FN:John Sanders
IMPP:aim:john.s
N:Sanders;John;;;
NOTE:Note test for VisualCard
ORG:Acme Co.
TEL;TYPE=cell:495-522-3560
TITLE:Product Manager
X-ANDROID-CUSTOM:vnd.android.cursor.item/nickname;JS;1;;;;;;;;;;;;;
X-PHONETIC-FIRST-NAME:Saunders
X-PHONETIC-LAST-NAME:John
SORT-STRING:johnsanders
END:VCARD
"""
;

private static readonly Card singleVcardFiveContactInstance = new
(
null,
"5.0"
)
{
ContactNames =
[
new NameInfo(0, [], "John", "Sanders", [], [], [])
],
ContactFullName = "John Sanders",
ContactTelephones =
[
new TelephoneInfo(0, [], ["cell"], "495-522-3560")
],
ContactAddresses =
[
new AddressInfo(0, [], ["home"], "", "", "Los Angeles, USA", "", "", "", "")
],
ContactOrganizations =
[
new OrganizationInfo(0, [], "Acme Co.", "", "", ["WORK"])
],
ContactTitles =
[
new TitleInfo(0, [], "Product Manager")
],
ContactNotes = "Note test for VisualCard",
ContactMails =
[
new EmailInfo(0, [], ["HOME"], "[email protected]")
],
ContactXNames =
[
new XNameInfo(0, [], "ANDROID-CUSTOM", ["vnd.android.cursor.item/nickname", "JS", "1", "", "", "", "", "", "", "", "", "", "", "", "", ""], []),
new XNameInfo(0, [], "PHONETIC-FIRST-NAME", ["Saunders"], []),
new XNameInfo(0, [], "PHONETIC-LAST-NAME", ["John"], [])
],
ContactImpps =
[
new ImppInfo(0, [], "aim:john.s", ["HOME"])
],
ContactSortString = "johnsanders"
};
#endregion

#region multipleVcardTwoContacts
private static readonly string multipleVcardTwoContacts =
"""
Expand Down Expand Up @@ -833,6 +926,165 @@ public static class ContactData
private static readonly Card multipleVcardFourContactsInstanceFour = singleVcardFourContactInstance;
#endregion

#region multipleVcardFiveContacts
private static readonly string multipleVcardFiveContacts =
"""
BEGIN:VCARD
VERSION:5.0
FN:Rick Hood
N:Hood;Rick;;;
END:VCARD
BEGIN:VCARD
VERSION:5.0
ADR;TYPE=work:POBOX;;Street Address ExtAddress;Reg;Loc;Postal;Country
ADR;TYPE=home:;;Street Address;;;;
EMAIL;TYPE=HOME:[email protected]
EMAIL;TYPE=WORK:[email protected]
FN:Neville Navasquillo
IMPP;TYPE=HOME:aim:IM
IMPP;TYPE=HOME:msn:Windows LIVE
IMPP;TYPE=HOME:ymsgr:Yahoo
N:Navasquillo;Neville;Neville\,Nevile;Mr.;Jr.
N;ALTID=0;LANGUAGE=de:NAVASQUILLO;Neville;Neville\,Nevile;Mr.;Jr.
NOTE:Notes
ORG:Organization
TEL;TYPE=work:098-765-4321
TEL;TYPE=cell:1-234-567-890
TEL;TYPE=voice:078-494-6434
TEL;TYPE=home:348-404-8404
TITLE:Title
X-ANDROID-CUSTOM:vnd.android.cursor.item/nickname;NVL.N;1;;;;;;;;;;;;;
END:VCARD
BEGIN:VCARD
VERSION:5.0
ADR;TYPE=home:;;New York\, USA;;;;
EMAIL;TYPE=HOME:[email protected]
EMAIL;TYPE=WORK:[email protected]
FN:Sarah Santos
N:Santos;Sarah;;;
ORG:Support Scammer Outcry Organization
TEL;TYPE=cell:589-210-1059
TITLE:Chief Executive Officer
URL:https://sso.org/
BDAY:19890222
X-SIP-SIP:sip test
SORT-STRING:sarahsantos
END:VCARD
BEGIN:VCARD
VERSION:5.0
ADR;TYPE=home:;;Los Angeles\, USA;;;;
EMAIL;TYPE=HOME:[email protected]
FN:John Sanders
IMPP:aim:john.s
N:Sanders;John;;;
NOTE:Note test for VisualCard
ORG:Acme Co.
TEL;TYPE=cell:495-522-3560
TITLE:Product Manager
X-ANDROID-CUSTOM:vnd.android.cursor.item/nickname;JS;1;;;;;;;;;;;;;
X-PHONETIC-FIRST-NAME:Saunders
X-PHONETIC-LAST-NAME:John
SORT-STRING:johnsanders
END:VCARD
"""
;

private static readonly Card multipleVcardFiveContactsInstanceOne = singleVcardFiveContactShortInstance;
private static readonly Card multipleVcardFiveContactsInstanceTwo = new
(
null,
"5.0"
)
{
ContactNames =
[
new NameInfo(0, [], "Neville", "Navasquillo", ["Neville", "Nevile"], ["Mr."], ["Jr."]),
new NameInfo(0, ["LANGUAGE=de"], "Neville", "NAVASQUILLO", ["Neville", "Nevile"], ["Mr."], ["Jr."])
],
ContactFullName = "Neville Navasquillo",
ContactTelephones =
[
new TelephoneInfo(0, [], ["work"], "098-765-4321"),
new TelephoneInfo(0, [], ["cell"], "1-234-567-890"),
new TelephoneInfo(0, [], ["voice"], "078-494-6434"),
new TelephoneInfo(0, [], ["home"], "348-404-8404"),
],
ContactAddresses =
[
new AddressInfo(0, [], ["work"], "POBOX", "", "Street Address ExtAddress", "Reg", "Loc", "Postal", "Country"),
new AddressInfo(0, [], ["home"], "", "", "Street Address", "", "", "", ""),
],
ContactOrganizations =
[
new OrganizationInfo(0, [], "Organization", "", "", ["WORK"])
],
ContactTitles =
[
new TitleInfo(0, [], "Title")
],
ContactNotes = "Notes",
ContactMails =
[
new EmailInfo(0, [], ["HOME"], "[email protected]"),
new EmailInfo(0, [], ["WORK"], "[email protected]"),
],
ContactXNames =
[
new XNameInfo(0, [], "ANDROID-CUSTOM", ["vnd.android.cursor.item/nickname", "NVL.N", "1", "", "", "", "", "", "", "", "", "", "", "", "", ""], []),
],
ContactImpps =
[
new ImppInfo(0, [], "aim:IM", ["HOME"]),
new ImppInfo(0, [], "msn:Windows LIVE", ["HOME"]),
new ImppInfo(0, [], "ymsgr:Yahoo", ["HOME"])
],
};
private static readonly Card multipleVcardFiveContactsInstanceThree = new
(
null,
"5.0"
)
{
ContactNames =
[
new NameInfo(0, [], "Sarah", "Santos", [], [], [])
],
ContactFullName = "Sarah Santos",
ContactTelephones =
[
new TelephoneInfo(0, [], ["cell"], "589-210-1059")
],
ContactAddresses =
[
new AddressInfo(0, [], ["home"], "", "", "New York, USA", "", "", "", "")
],
ContactOrganizations =
[
new OrganizationInfo(0, [], "Support Scammer Outcry Organization", "", "", ["WORK"])
],
ContactTitles =
[
new TitleInfo(0, [], "Chief Executive Officer")
],
ContactURL = "https://sso.org/",
ContactMails =
[
new EmailInfo(0, [], ["HOME"], "[email protected]"),
new EmailInfo(0, [], ["WORK"], "[email protected]"),
],
ContactXNames =
[
new XNameInfo(0, [], "SIP-SIP", ["sip test"], []),
],
ContactBirthdate = new DateTime(1989, 2, 22),
ContactSortString = "sarahsantos"
};
private static readonly Card multipleVcardFiveContactsInstanceFour = singleVcardFiveContactInstance;
#endregion

#region vcardThreeOldSample
private static readonly string vcardThreeOldSample =
"""
Expand Down Expand Up @@ -949,6 +1201,7 @@ public static class ContactData
singleVcardTwoContactShort,
singleVcardThreeContactShort,
singleVcardFourContactShort,
singleVcardFiveContactShort,
];

/// <summary>
Expand All @@ -959,6 +1212,7 @@ public static class ContactData
singleVcardTwoContact,
singleVcardThreeContact,
singleVcardFourContact,
singleVcardFiveContact,
];

/// <summary>
Expand All @@ -969,6 +1223,7 @@ public static class ContactData
multipleVcardTwoContacts,
multipleVcardThreeContacts,
multipleVcardFourContacts,
multipleVcardFiveContacts,
];

/// <summary>
Expand Down Expand Up @@ -1005,9 +1260,11 @@ public static readonly (string, string)[] vCardFromMeCardContacts =
singleVcardTwoContactShortInstance,
singleVcardThreeContactShortInstance,
singleVcardFourContactShortInstance,
singleVcardFiveContactShortInstance,
singleVcardTwoContactInstance,
singleVcardThreeContactInstance,
singleVcardFourContactInstance,
singleVcardFiveContactInstance,
multipleVcardTwoContactsInstanceOne,
multipleVcardTwoContactsInstanceTwo,
multipleVcardTwoContactsInstanceThree,
Expand All @@ -1020,6 +1277,10 @@ public static readonly (string, string)[] vCardFromMeCardContacts =
multipleVcardFourContactsInstanceTwo,
multipleVcardFourContactsInstanceThree,
multipleVcardFourContactsInstanceFour,
multipleVcardFiveContactsInstanceOne,
multipleVcardFiveContactsInstanceTwo,
multipleVcardFiveContactsInstanceThree,
multipleVcardFiveContactsInstanceFour,
vcardThreeOldSampleInstanceOne,
vcardThreeOldSampleInstanceTwo,
vcardThreeOldSampleInstanceThree,
Expand Down
2 changes: 1 addition & 1 deletion VisualCard/CardTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static List<BaseVcardParser> GetCardParsers(StreamReader stream)
if (!CardSawNull)
CardLine = stream.ReadLine();
CardSawNull = false;
if (CardLine != "VERSION:2.1" && CardLine != "VERSION:3.0" && CardLine != "VERSION:4.0" && !VersionSpotted)
if (CardLine != "VERSION:2.1" && CardLine != "VERSION:3.0" && CardLine != "VERSION:4.0" && CardLine != "VERSION:5.0" && !VersionSpotted)
throw new InvalidDataException($"This has an invalid VCard version {CardLine}.");
else if (!VersionSpotted)
{
Expand Down
Loading

0 comments on commit 578928a

Please sign in to comment.