[network-manager-applet/lr/team: 4/4] mm



commit b269286fc9548c0caab534828887034610e2bc17
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Tue Jul 12 19:18:23 2016 +0200

    mm

 configure.ac                      |   15 ++
 src/connection-editor/Makefile.am |    2 +
 src/connection-editor/page-team.c |  456 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 472 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a64f4cf..9975f28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -137,6 +137,21 @@ AM_CONDITIONAL(WITH_WWAN, test "${with_wwan}" = "yes")
 dnl Check for gudev
 PKG_CHECK_MODULES(GUDEV, gudev-1.0 >= 147)
 
+dnl Jansson for teamd configuration editing
+PKG_CHECK_MODULES(JANSSON, jansson, [have_jansson=yes], [have_jansson=no])
+AC_ARG_ENABLE(team,
+              AS_HELP_STRING([--enable-team], [Enable teaming configuration editor in libnm]),
+              [enable_team=${enableval}],
+              [enable_team=${have_jansson}])
+if (test "${enable_team}" = "yes"); then
+    if test x"$have_jansson" = x"no"; then
+        AC_MSG_ERROR(Jansson is required for team configuration editor)
+    fi
+    AC_DEFINE(WITH_JANSSON, 1, [Define if JANSSON is available])
+else
+    AC_DEFINE(WITH_JANSSON, 0, [Define if JANSSON is available])
+fi
+
 dnl Check for gobject introspection
 GOBJECT_INTROSPECTION_CHECK([0.9.6])
 
diff --git a/src/connection-editor/Makefile.am b/src/connection-editor/Makefile.am
index 59681f3..6e4a005 100644
--- a/src/connection-editor/Makefile.am
+++ b/src/connection-editor/Makefile.am
@@ -3,6 +3,7 @@ bin_PROGRAMS = nm-connection-editor
 nm_connection_editor_CPPFLAGS = \
        $(GTK_CFLAGS) \
        $(LIBNM_CFLAGS) \
+       $(JANSSON_CFLAGS) \
        -DLIBNM_BUILD \
        -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_2 \
        -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_2 \
@@ -87,6 +88,7 @@ nm_connection_editor_LDADD = \
        ${top_builddir}/src/libnma/libnma.la \
        $(GTK_LIBS) \
        $(LIBNM_LIBS) \
+       $(JANSSON_LIBS) \
        -lm
 
 uidir = $(datadir)/nm-applet
diff --git a/src/connection-editor/page-team.c b/src/connection-editor/page-team.c
index 5091ba5..f38f1a6 100644
--- a/src/connection-editor/page-team.c
+++ b/src/connection-editor/page-team.c
@@ -23,6 +23,7 @@
 #include "nm-default.h"
 
 #include <stdlib.h>
+#include <jansson.h>
 
 #include "page-team.h"
 #include "page-infiniband.h"
@@ -166,6 +167,447 @@ out:
 
 
 
+static gboolean
+get_device (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_device (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_debug_level (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_debug_level (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_hwaddr (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_hwaddr (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_name (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_name (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_notify_peers_count (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_notify_peers_count (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_notify_peers_interval (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_notify_peers_interval (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_mcast_rejoin_count (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_mcast_rejoin_count (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_mcast_rejoin_interval (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_mcast_rejoin_interval (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_name (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_name (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_hwaddr_policy (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_hwaddr_policy (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_tx_hash (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_tx_hash (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_tx_balancer_name (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_tx_balancer_name (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_tx_balancer_balancing_interval (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_tx_balancer_balancing_interval (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_active (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_active (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_fast_rate (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_fast_rate (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_sys_prio (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_sys_prio (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_min_ports (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_min_ports (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_runner_agg_select_policy (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_runner_agg_select_policy (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_delay_up (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_delay_up (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_delay_down (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_delay_down (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_interval (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_interval (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_init_wait (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_init_wait (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_missed_max (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_missed_max (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_source_host (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_source_host (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_target_host (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_target_host (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_validate_active (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_validate_active (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_validate_inactive (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_validate_inactive (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+get_link_watch_send_always (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+static gboolean
+set_link_watch_send_always (CEPageTeam *self, json_t *json)
+{
+       return TRUE;
+}
+
+typedef struct {
+       const char *l1, *l2, *l3;
+       json_type type;
+       gboolean (*set) (CEPageTeam *self, json_t *json);
+       gboolean (*get) (CEPageTeam *self, json_t *json);
+} TeamConfField;
+
+#define F1(l1, type)         { #l1, NULL, NULL, type, get_ ## l1, \
+                                                      set_ ## l1 }
+#define F2(l1, l2, type)     { #l1, #l2,  NULL, type, get_ ## l1 ## _ ## l2, \
+                                                      set_ ## l1 ## _ ## l2 }
+#define F3(l1, l2, l3, type) { #l1, #l2,  NULL, type, get_ ## l1 ## _ ## l2 ## _ ## l3 , \
+                                                      set_ ## l1 ## _ ## l2 ## _ ## l3 }
+//static
+const TeamConfField fields[] = {
+       F1 (device,                                   JSON_STRING),
+       F1 (debug_level,                              JSON_INTEGER),
+       F1 (hwaddr,                                   JSON_STRING),
+       F2 (runner, name,                             JSON_STRING),
+       F2 (notify_peers, count,                      JSON_INTEGER),
+       F2 (notify_peers, interval,                   JSON_INTEGER),
+       F2 (mcast_rejoin, count,                      JSON_INTEGER),
+       F2 (mcast_rejoin, interval,                   JSON_INTEGER),
+       F2 (link_watch, name,                         JSON_STRING),
+       F2 (runner, hwaddr_policy,                    JSON_STRING),
+       F2 (runner, tx_hash,                          JSON_ARRAY),
+       F3 (runner, tx_balancer, name,                JSON_STRING),
+       F3 (runner, tx_balancer, balancing_interval,  JSON_INTEGER),
+       F2 (runner, active,                           JSON_TRUE),
+       F2 (runner, fast_rate,                        JSON_TRUE),
+       F2 (runner, tx_hash,                          JSON_ARRAY),
+       F2 (runner, sys_prio,                         JSON_INTEGER),
+       F2 (runner, min_ports,                        JSON_INTEGER),
+       F2 (runner, agg_select_policy,                JSON_STRING),
+       F2 (link_watch, delay_up,                     JSON_INTEGER),
+       F2 (link_watch, delay_down,                   JSON_INTEGER),
+       F2 (link_watch, interval,                     JSON_INTEGER),
+       F2 (link_watch, init_wait,                    JSON_INTEGER),
+       F2 (link_watch, missed_max,                   JSON_INTEGER),
+       F2 (link_watch, source_host,                  JSON_STRING),
+       F2 (link_watch, target_host,                  JSON_STRING),
+       F2 (link_watch, validate_active,              JSON_TRUE),
+       F2 (link_watch, validate_inactive,            JSON_TRUE),
+       F2 (link_watch, send_always,                  JSON_TRUE),
+       F2 (link_watch, interval,                     JSON_INTEGER),
+       F2 (link_watch, init_wait,                    JSON_INTEGER),
+       F2 (link_watch, missed_max,                   JSON_INTEGER),
+       F2 (link_watch, target_host,                  JSON_STRING),
+       { NULL, NULL, NULL, 0 },
+};
+#undef F1
+#undef F2
+#undef F3
+
+
+static void
+json_to_dialog (CEPageTeam *self)
+{
+
+       CEPageTeamPrivate *priv = CE_PAGE_TEAM_GET_PRIVATE (self);
+       NMSettingTeam *s_team = priv->setting;
+       const char *json_config;
+       json_t *json;
+       json_error_t json_error;
+       const char *key;
+       json_t *value;
+
+       json_config = nm_setting_team_get_config (s_team);
+
+g_printerr (">>> %s <<<\n", json_config);
+
+
+       json = json_loads (json_config, 0, &json_error);
+       if (!json) {
+               g_printerr ("[%d] [%s]\n", json_error.line, json_error.text);
+               return;
+       }
+
+       if (!json_is_object (json)) {
+               g_printerr ("not an object");
+               goto out;
+       }
+
+       {
+               char *t = json_dumps (json, 0);
+               g_printerr ("]]] %s [[[\n", t);
+               free (t);
+       }
+
+       json_object_foreach (json, key, value) {
+               g_printerr (">> %s <<\n", key);
+
+               if (strcmp (key, "runner") == 0) {
+               } else if (strcmp (key, "link_watch") == 0) {
+               } else {
+                       g_printerr ("Unknown key: %s\n", key);
+                       goto out;
+               }
+       }
+       
+
+out:
+       json_decref (json);
+}
+
 
 
 static void
@@ -175,14 +617,21 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
        CEPageTeamPrivate *priv = CE_PAGE_TEAM_GET_PRIVATE (self);
         GtkWidget *toplevel;
 
+
+
+
+
+
+
         toplevel = gtk_widget_get_toplevel (CE_PAGE (self)->page);
         g_return_if_fail (gtk_widget_is_toplevel (toplevel));
 
         gtk_window_set_transient_for (GTK_WINDOW (priv->advanced_dialog), GTK_WINDOW (toplevel));
 
-       if (gtk_dialog_run (GTK_DIALOG (priv->advanced_dialog)) == GTK_RESPONSE_ACCEPT) {
+       if (gtk_dialog_run (priv->advanced_dialog) == GTK_RESPONSE_ACCEPT) {
                g_printerr ("YOLO\n");
        }
+       gtk_widget_hide (GTK_WIDGET (priv->advanced_dialog));
 }
 
 
@@ -223,6 +672,11 @@ populate_ui (CEPageTeam *self)
 
 //////////////
        g_signal_connect (priv->advanced_button, "clicked", G_CALLBACK (advanced_button_clicked_cb), self);
+
+
+json_to_dialog (self);
+exit (0);
+//advanced_button_clicked_cb (NULL, self);
 }
 
 static void


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