Fixed a bug where it doesn't handle multiple addresses
[profile/ivi/phoned.git] / src / obex.cpp
index 7be7846..cab83b7 100644 (file)
@@ -554,11 +554,16 @@ void Obex::parseEContactToJsonTizenContact(EContact *econtact, std::string &cont
        contact += "}";
 
        // addresses:
+       bool firstAddress = true;
        contact += ",\"addresses\":[";
        for(int id=E_CONTACT_ADDRESS_HOME; id<=E_CONTACT_ADDRESS_OTHER; id++) {
            EContactAddress *address = (EContactAddress*)e_contact_get(econtact, (EContactField)id);
            if(address) {
-               contact += "{";
+               if (firstAddress)
+                   contact += "{";
+               else
+                   contact += ",{";
+               firstAddress = false;
                contact += "\"isDefault\":\"false\"";
                if(address->country && strcmp(address->country,"")) {
                    contact += ",\"country\":\"";
@@ -808,7 +813,7 @@ void Obex::handleSignal(GDBusConnection       *connection,
     if(!strcmp(signal_name, "PropertiesChanged"))
     {
                char *objPath = NULL;
-               GVariantIter* iter, iter2;
+               GVariantIter* iter, *iter2;
 
                g_variant_get(parameters, "(sa{sv}as)", &objPath, &iter, &iter2);
 
@@ -839,12 +844,17 @@ void Obex::handleSignal(GDBusConnection       *connection,
                                                ctx->initiateNextSyncRequest();
                                        }
                                }
+                               g_free(prop);
+                               g_variant_unref(var);
                        }
                }
                else
                {
                        LoggerD("No objectPath found. Exiting.");
                }
+               g_variant_iter_free(iter);
+               g_variant_iter_free(iter2);
+               g_free(objPath);
     }
 }