mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
Add support for vCard PREFIX and SUFFIX elements
SMACK-673
This commit is contained in:
parent
7a3ca4fd68
commit
c1192f18b4
3 changed files with 34 additions and 1 deletions
|
@ -107,6 +107,8 @@ public class VCard extends IQ {
|
||||||
private String firstName;
|
private String firstName;
|
||||||
private String lastName;
|
private String lastName;
|
||||||
private String middleName;
|
private String middleName;
|
||||||
|
private String prefix;
|
||||||
|
private String suffix;
|
||||||
|
|
||||||
private String emailHome;
|
private String emailHome;
|
||||||
private String emailWork;
|
private String emailWork;
|
||||||
|
@ -197,6 +199,24 @@ public class VCard extends IQ {
|
||||||
updateFN();
|
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() {
|
public String getNickName() {
|
||||||
return otherSimpleFields.get("NICKNAME");
|
return otherSimpleFields.get("NICKNAME");
|
||||||
}
|
}
|
||||||
|
@ -568,6 +588,8 @@ public class VCard extends IQ {
|
||||||
xml.optElement("FAMILY", lastName);
|
xml.optElement("FAMILY", lastName);
|
||||||
xml.optElement("GIVEN", firstName);
|
xml.optElement("GIVEN", firstName);
|
||||||
xml.optElement("MIDDLE", middleName);
|
xml.optElement("MIDDLE", middleName);
|
||||||
|
xml.optElement("PREFIX", prefix);
|
||||||
|
xml.optElement("SUFFIX", suffix);
|
||||||
xml.closeElement("N");
|
xml.closeElement("N");
|
||||||
}
|
}
|
||||||
if (hasOrganizationFields()) {
|
if (hasOrganizationFields()) {
|
||||||
|
@ -692,7 +714,8 @@ public class VCard extends IQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasNameField() {
|
private boolean hasNameField() {
|
||||||
return firstName != null || lastName != null || middleName != null;
|
return firstName != null || lastName != null || middleName != null
|
||||||
|
|| prefix != null || suffix != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasOrganizationFields() {
|
private boolean hasOrganizationFields() {
|
||||||
|
|
|
@ -284,6 +284,12 @@ public class VCardProvider extends IQProvider<VCard> {
|
||||||
case "MIDDLE":
|
case "MIDDLE":
|
||||||
vCard.setMiddleName(parser.nextText());
|
vCard.setMiddleName(parser.nextText());
|
||||||
break;
|
break;
|
||||||
|
case "PREFIX":
|
||||||
|
vCard.setPrefix(parser.nextText());
|
||||||
|
break;
|
||||||
|
case "SUFFIX":
|
||||||
|
vCard.setSuffix(parser.nextText());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class VCardTest extends InitExtensions {
|
||||||
+ "<FAMILY>Name</FAMILY>"
|
+ "<FAMILY>Name</FAMILY>"
|
||||||
+ "<GIVEN>User</GIVEN>"
|
+ "<GIVEN>User</GIVEN>"
|
||||||
+ "<MIDDLE>PJ</MIDDLE>"
|
+ "<MIDDLE>PJ</MIDDLE>"
|
||||||
|
+ "<PREFIX>Mr.</PREFIX>"
|
||||||
|
+ "<SUFFIX>III</SUFFIX>"
|
||||||
+ "</N>"
|
+ "</N>"
|
||||||
+ "<NICKNAME>User dude</NICKNAME>"
|
+ "<NICKNAME>User dude</NICKNAME>"
|
||||||
+ "<URL>http://www.igniterealtime.org</URL>"
|
+ "<URL>http://www.igniterealtime.org</URL>"
|
||||||
|
@ -99,6 +101,8 @@ public class VCardTest extends InitExtensions {
|
||||||
assertEquals("Name", vCard.getLastName());
|
assertEquals("Name", vCard.getLastName());
|
||||||
assertEquals("PJ", vCard.getMiddleName());
|
assertEquals("PJ", vCard.getMiddleName());
|
||||||
assertEquals("User dude", vCard.getNickName());
|
assertEquals("User dude", vCard.getNickName());
|
||||||
|
assertEquals("Mr.", vCard.getPrefix());
|
||||||
|
assertEquals("III", vCard.getSuffix());
|
||||||
|
|
||||||
assertEquals("Programmer & tester", vCard.getField("TITLE"));
|
assertEquals("Programmer & tester", vCard.getField("TITLE"));
|
||||||
assertEquals("Bug fixer", vCard.getField("ROLE"));
|
assertEquals("Bug fixer", vCard.getField("ROLE"));
|
||||||
|
|
Loading…
Reference in a new issue