Fix deprecated GVAlueArray. Patch from Páder Rezső
authorMichael Rasmussen <mir@datanom.net>
Sat, 1 Aug 2015 21:43:40 +0000 (23:43 +0200)
committerMichael Rasmussen <mir@datanom.net>
Sat, 1 Aug 2015 21:43:40 +0000 (23:43 +0200)
configure.ac
src/dbus/server-object.c
src/utils.c

index c2e8a6e59e0028fa28220b1175ad039c46e6f70c..b00064c697884a1531b882ae6fbc3fdf784a792b 100644 (file)
@@ -41,9 +41,9 @@ if test "x$prefix" = "xNONE"; then
        prefix=$ac_default_prefix
 fi
 if test "x$enable-maintainer-mode" = "x"; then
-    CFLAGS="-g -Wall -O -O2 -Wno-unused-variable -Wno-uninitialized -Wno-deprecated"
+    CFLAGS="-g -Wall -O -O2 -Wno-unused-variable -Wno-uninitialized"
 else
-    CFLAGS="-g -Wno-deprecated -Wall"
+    CFLAGS="-g -Wall"
 fi
 BINDIR="${prefix}/bin"
 AC_DEFINE_UNQUOTED(BINDIR, "$BINDIR", [Where is binary installed])
index 1ac72900ec3a166941529439a2e0bcf6c2d9520b..2d15dfa5c0e7f9b311e11a9fe3a8488784ba58a9 100644 (file)
@@ -310,24 +310,40 @@ static void get_emails(GPtrArray* array,
 }
 
 static void email_ptr_foreach(gpointer data, gpointer user_data) {
+#if GLIB_CHECK_VERSION(2,32,0)
+       GArray* email = g_array_sized_new(FALSE, FALSE, sizeof(GValue), sizeof(data));
+#else
        GValueArray* email = (GValueArray *) data;
+#endif
        GValue* email_member;
        guint i, j;
     Contact* contact = (Contact *) user_data;
     Email* mail;
     
+#if GLIB_CHECK_VERSION(2,32,0)
+    if (! email || ! contact || email->len < 1)
+#else
     if (! email || ! contact || email->n_values < 1)
+#endif
         return;
 
     mail = g_new0(Email, 1);
+#if GLIB_CHECK_VERSION(2,32,0)
+       for (i = j = 0; i < email->len; j++, i++) {
+#else
        for (i = j = 0; i < email->n_values; j++, i++) {
+#endif
         if (j > 0 && j % 3 == 0) {
             mail = g_new0(Email, 1);
             contact->emails = g_slist_prepend(contact->emails, mail);
             j = 0;
         }
             
+#if GLIB_CHECK_VERSION(2,32,0)
+               email_member = &g_array_index(email, GValue, i);
+#else
                email_member = g_value_array_get_nth(email, i);
+#endif
         switch (j) {
             case 0:
                 mail->alias = g_value_dup_string(email_member);
@@ -370,7 +386,11 @@ static void contact_data_save(DBusContact* dbus_contact, Contact* contact) {
  * address where every string is empty (empty as in "" and not NULL)
  */
 static GPtrArray* get_email_list(GPtrArray* list) {
-    GValueArray* email;
+#if GLIB_CHECK_VERSION(2,32,0)
+       GArray* email = g_array_sized_new(FALSE, FALSE, sizeof(GValue), 1);
+#else
+       GValueArray* email;
+#endif
     GValue* item;
     guint i;
     gboolean found = FALSE;
@@ -379,8 +399,13 @@ static GPtrArray* get_email_list(GPtrArray* list) {
         return list;
     
     email = g_ptr_array_index(list, 0);
+#if GLIB_CHECK_VERSION(2,32,0)
+    for (i = 0; !found && i < email->len; i++) {
+        item = &g_array_index(email, GValue, i);
+#else
     for (i = 0; !found && i < email->n_values; i++) {
         item = g_value_array_get_nth(email, i);
+#endif
         gchar* str = (gchar *) g_value_get_string(item);
         if (str && strlen(str) > 0)
             found = TRUE;
index a346086b37064d250acdd1a2c93509da8792c26a..d0f7354c6e7db310bd9a99e431e9d43483573ffa 100644 (file)
@@ -1084,15 +1084,24 @@ guint set_log_handler() {
 }
 
 void g_value_email_free(gpointer data) {
+#if GLIB_CHECK_VERSION(2,32,0)
+       GArray* email = g_array_sized_new(FALSE, FALSE, sizeof(GValue), sizeof(data));
+#else
        GValueArray* email = (GValueArray *) data;
+#endif
        GValue* email_member;
        guint i;
        
        if (! email)
                return;
        
+#if GLIB_CHECK_VERSION(2,32,0)
+       for (i = 0; i < email->len; i++) {
+               email_member = &g_array_index(email, GValue, i);
+#else
        for (i = 0; i < email->n_values; i++) {
                email_member = g_value_array_get_nth(email, i);
+#endif
                g_value_unset(email_member);
        }
 }
@@ -1102,13 +1111,21 @@ GPtrArray* g_value_email_new() {
 }
 
 static void email_ptr_foreach(gpointer data, gpointer user_data) {
+#if GLIB_CHECK_VERSION(2,32,0)
+       GArray* email = g_array_sized_new(FALSE, FALSE, sizeof(GValue), sizeof(data));
+#else
        GValueArray* email = (GValueArray *) data;
+#endif
        GValue* email_member;
        guint i, j;
        FILE* f = (FILE *) user_data;
        gchar* text = NULL;
        
+#if GLIB_CHECK_VERSION(2,32,0)
+       for (i = j = 0; email && i < email->len; j++, i++) {
+#else
        for (i = j = 0; email && i < email->n_values; j++, i++) {
+#endif 
         if (j > 0 && j % 3 == 0) {
                        if (f)
                                fprintf(f, "---------------------------------------------\n");
@@ -1116,7 +1133,11 @@ static void email_ptr_foreach(gpointer data, gpointer user_data) {
                                g_message("---------------------------------------------\n");
             j = 0;
         }
+#if GLIB_CHECK_VERSION(2,32,0)
+               email_member = &g_array_index(email, GValue, i);
+#else
                email_member = g_value_array_get_nth(email, i);
+#endif
         switch (j) {
             case 0:
                 text = g_strdup_printf("Alias: %s\n", g_value_get_string(email_member));