diff options
author | George Hazan <george.hazan@gmail.com> | 2023-12-25 13:05:32 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-12-25 13:05:32 +0300 |
commit | 86d22dec4247e5f582c4a1080e9fecca805defa1 (patch) | |
tree | 29f1a867874548f06e0db0f9a6358bd5b3b5e29d /protocols/JabberG | |
parent | 48c61412caa983bab71785eefa083176bb8becbb (diff) |
Jabber: reducing empty XML nodes in Vcard
Diffstat (limited to 'protocols/JabberG')
-rw-r--r-- | protocols/JabberG/src/jabber_vcard.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index 4e510462cd..41cb908e0b 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -90,11 +90,15 @@ public: bool OnInitDialog() override
{
- ppro->m_vCardUpdates |= (1UL << iPageId);
ppro->WindowSubscribe(m_hwnd);
return true;
}
+ void OnChange() override
+ {
+ ppro->m_vCardUpdates |= (1UL << iPageId);
+ }
+
bool OnApply() override
{
ppro->m_vCardUpdates &= ~(1UL << iPageId);
@@ -857,7 +861,8 @@ void CJabberProto::AppendVcardFromDB(TiXmlElement *n, char *tag, char *key) return;
ptrA tszValue(getUStringA(key));
- n << XCHILD(tag, tszValue);
+ if (mir_strlen(tszValue))
+ n << XCHILD(tag, tszValue);
}
void CJabberProto::SetServerVcard(bool bPhotoChanged, wchar_t *szPhotoFileName)
@@ -875,6 +880,8 @@ void CJabberProto::SetServerVcard(bool bPhotoChanged, wchar_t *szPhotoFileName) AppendVcardFromDB(n, "GIVEN", "FirstName");
AppendVcardFromDB(n, "MIDDLE", "MiddleName");
AppendVcardFromDB(n, "FAMILY", "LastName");
+ if (XmlGetChildCount(n) == 0)
+ v->DeleteChild(n);
AppendVcardFromDB(v, "NICKNAME", "Nick");
AppendVcardFromDB(v, "BDAY", "BirthDate");
@@ -907,6 +914,8 @@ void CJabberProto::SetServerVcard(bool bPhotoChanged, wchar_t *szPhotoFileName) AppendVcardFromDB(n, "PCODE", "ZIP");
AppendVcardFromDB(n, "CTRY", "Country");
AppendVcardFromDB(n, "COUNTRY", "Country"); // for compatibility with client using old vcard format
+ if (XmlGetChildCount(n) == 1)
+ v->DeleteChild(n);
n = v << XCHILD("ADR");
n << XCHILD("WORK");
@@ -918,10 +927,14 @@ void CJabberProto::SetServerVcard(bool bPhotoChanged, wchar_t *szPhotoFileName) AppendVcardFromDB(n, "PCODE", "CompanyZIP");
AppendVcardFromDB(n, "CTRY", "CompanyCountry");
AppendVcardFromDB(n, "COUNTRY", "CompanyCountry"); // for compatibility with client using old vcard format
+ if (XmlGetChildCount(n) == 1)
+ v->DeleteChild(n);
n = v << XCHILD("ORG");
AppendVcardFromDB(n, "ORGNAME", "Company");
AppendVcardFromDB(n, "ORGUNIT", "CompanyDepartment");
+ if (XmlGetChildCount(n) == 0)
+ v->DeleteChild(n);
AppendVcardFromDB(v, "TITLE", "CompanyPosition");
AppendVcardFromDB(v, "ROLE", "Role");
|