1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 10:37:59 +01:00

Add support for vCard PREFIX and SUFFIX elements

SMACK-673
This commit is contained in:
Florian Schmaus 2015-06-02 23:58:50 +02:00
parent 7a3ca4fd68
commit c1192f18b4
3 changed files with 34 additions and 1 deletions

View file

@ -107,6 +107,8 @@ public class VCard extends IQ {
private String firstName;
private String lastName;
private String middleName;
private String prefix;
private String suffix;
private String emailHome;
private String emailWork;
@ -197,6 +199,24 @@ public class VCard extends IQ {
updateFN();
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
updateFN();
}
public String getSuffix() {
return suffix;
}
public void setSuffix(String suffix) {
this.suffix = suffix;
updateFN();
}
public String getNickName() {
return otherSimpleFields.get("NICKNAME");
}
@ -568,6 +588,8 @@ public class VCard extends IQ {
xml.optElement("FAMILY", lastName);
xml.optElement("GIVEN", firstName);
xml.optElement("MIDDLE", middleName);
xml.optElement("PREFIX", prefix);
xml.optElement("SUFFIX", suffix);
xml.closeElement("N");
}
if (hasOrganizationFields()) {
@ -692,7 +714,8 @@ public class VCard extends IQ {
}
private boolean hasNameField() {
return firstName != null || lastName != null || middleName != null;
return firstName != null || lastName != null || middleName != null
|| prefix != null || suffix != null;
}
private boolean hasOrganizationFields() {

View file

@ -284,6 +284,12 @@ public class VCardProvider extends IQProvider<VCard> {
case "MIDDLE":
vCard.setMiddleName(parser.nextText());
break;
case "PREFIX":
vCard.setPrefix(parser.nextText());
break;
case "SUFFIX":
vCard.setSuffix(parser.nextText());
break;
default:
break;
}

View file

@ -48,6 +48,8 @@ public class VCardTest extends InitExtensions {
+ "<FAMILY>Name</FAMILY>"
+ "<GIVEN>User</GIVEN>"
+ "<MIDDLE>PJ</MIDDLE>"
+ "<PREFIX>Mr.</PREFIX>"
+ "<SUFFIX>III</SUFFIX>"
+ "</N>"
+ "<NICKNAME>User dude</NICKNAME>"
+ "<URL>http://www.igniterealtime.org</URL>"
@ -99,6 +101,8 @@ public class VCardTest extends InitExtensions {
assertEquals("Name", vCard.getLastName());
assertEquals("PJ", vCard.getMiddleName());
assertEquals("User dude", vCard.getNickName());
assertEquals("Mr.", vCard.getPrefix());
assertEquals("III", vCard.getSuffix());
assertEquals("Programmer & tester", vCard.getField("TITLE"));
assertEquals("Bug fixer", vCard.getField("ROLE"));