[network-manager-openconnect/nm-0-9-8] auth-dialog: Introduce FORMCHOICE helper macro



commit d846b4e5bb9b89c1110d8ae38fd06021f3e4a9f2
Author: Kevin Cernekee <cernekee gmail com>
Date:   Mon Dec 30 17:49:35 2013 -0800

    auth-dialog: Introduce FORMCHOICE helper macro
    
    libopenconnect >= 3.0 uses a pointer array so we need to change the way
    the "choices" field is accessed.

 auth-dialog/main.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 2d8c830..9b32f61 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -70,6 +70,8 @@
 #define __openconnect_set_token_mode openconnect_set_token_mode
 #endif
 
+#define FORMCHOICE(sopt, i)            (&(sopt)->choices[i])
+
 #ifdef OPENCONNECT_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/bio.h>
@@ -350,10 +352,10 @@ static void combo_changed(GtkComboBox *combo, ui_fragment_data *data)
        if (entry < 0)
                return;
 
-       data->entry_text = sopt->choices[entry].name;
+       data->entry_text = FORMCHOICE(sopt, entry)->name;
 
        g_queue_foreach(data->ui_data->form_entries, (GFunc)do_override_label,
-                       &sopt->choices[entry]);
+                       FORMCHOICE(sopt, entry));
 }
 
 #ifdef OPENCONNECT_OPENSSL
@@ -449,17 +451,17 @@ static gboolean ui_add_select (ui_fragment_data *data)
        combo = gtk_combo_box_text_new();
        gtk_box_pack_end(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
        for (i = 0; i < sopt->nr_choices; i++) {
-               gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), sopt->choices[i].label);
+               gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), FORMCHOICE(sopt, i)->label);
                if (data->entry_text &&
-                   !strcmp(data->entry_text, sopt->choices[i].name)) {
+                   !strcmp(data->entry_text, FORMCHOICE(sopt, i)->name)) {
                        gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i);
                        g_free(data->entry_text);
-                       data->entry_text = sopt->choices[i].name;
+                       data->entry_text = FORMCHOICE(sopt, i)->name;
                }
        }
        if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) < 0) {
                gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); 
-               data->entry_text = sopt->choices[0].name;
+               data->entry_text = FORMCHOICE(sopt, 0)->name;
        }
 
        if (g_queue_peek_tail(ui_data->form_entries) == data)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]