ucs: fix Persona key extraction
authorStefan Becker <chemobejk@gmail.com>
Tue, 3 Dec 2013 15:39:09 +0000 (3 17:39 +0200)
committerStefan Becker <chemobejk@gmail.com>
Thu, 5 Dec 2013 20:48:42 +0000 (5 22:48 +0200)
Based on the log provided in the following discussion thread

  https://sourceforge.net/p/sipe/discussion/688534/thread/db025884/

it turned out that the text for Attribution/DisplayName is localized,
i.e. the text "Lync Contacts" gets translated to the local language.

Switch over to check IsQuickContact == true and IsHidden == false, which
seems to be another indication that the Attribution node contains the
key for the Lync Contact. It's still a guessing game :-(

(cherry picked from commit 8763852bb5aa9709bbe6f93b9088f8d607e061b8)

src/core/sipe-ucs.c

index c4d1df6..faacd72 100644 (file)
@@ -308,23 +308,35 @@ static void ucs_extract_keys(const sipe_xml *persona_node,
 {
        const sipe_xml *attr_node;
 
-       /* extract Exchange key - not sure if this is correct */
+       /*
+        * extract Exchange key - play the guessing game :-(
+        *
+        * We can't use the "DisplayName" node, because the text is localized.
+        *
+        * Assume that IsQuickContact == "true" and IsHidden == "false" means
+        * this Attribution node contains the information for the Lync contact.
+        */
        for (attr_node = sipe_xml_child(persona_node,
                                        "Attributions/Attribution");
             attr_node;
             attr_node = sipe_xml_twin(attr_node)) {
                const sipe_xml *id_node = sipe_xml_child(attr_node,
                                                         "SourceId");
-               gchar *type = sipe_xml_data(sipe_xml_child(attr_node,
-                                                          "DisplayName"));
+               gchar *hidden = sipe_xml_data(sipe_xml_child(attr_node,
+                                                            "IsHidden"));
+               gchar *quick = sipe_xml_data(sipe_xml_child(attr_node,
+                                                           "IsQuickContact"));
                if (id_node &&
-                   sipe_strequal(type, "Lync Contacts")) {
+                   sipe_strcase_equal(hidden, "false") &&
+                   sipe_strcase_equal(quick,  "true")) {
                        *key = sipe_xml_attribute(id_node, "Id");
                        *change = sipe_xml_attribute(id_node, "ChangeKey");
-                       g_free(type);
+                       g_free(quick);
+                       g_free(hidden);
                        break;
                }
-               g_free(type);
+               g_free(quick);
+               g_free(hidden);
        }
 }