[control-center/f17] Add support for FirewallD1 API

mkasik mkasik at fedoraproject.org
Thu Apr 12 13:34:48 UTC 2012


commit d7eff34a375360b8bd794257c6fd99192974ac25
Author: Marek Kasik <mkasik at redhat.com>
Date:   Thu Apr 12 15:34:28 2012 +0200

    Add support for FirewallD1 API
    
    Resolves: #802381

 control-center.spec           |   11 +-
 printers-firewalld1-api.patch |  563 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 573 insertions(+), 1 deletions(-)
---
diff --git a/control-center.spec b/control-center.spec
index 4d3af42..d93cca4 100644
--- a/control-center.spec
+++ b/control-center.spec
@@ -17,7 +17,7 @@
 Summary: Utilities to configure the GNOME desktop
 Name: control-center
 Version: 3.4.0
-Release: 1%{?dist}
+Release: 2%{?dist}
 Epoch: 1
 License: GPLv2+ and GFDL
 Group: User Interface/Desktops
@@ -25,6 +25,10 @@ Group: User Interface/Desktops
 Source: http://download.gnome.org/sources/gnome-control-center/3.4/gnome-control-center-%{version}.tar.xz
 URL: http://www.gnome.org
 
+# https://bugzilla.gnome.org/show_bug.cgi?id=672682
+# https://bugzilla.redhat.com/show_bug.cgi?id=802381
+Patch0: printers-firewalld1-api.patch
+
 Requires: gnome-settings-daemon >= 2.21.91-3
 Requires: redhat-menus >= %{redhat_menus_version}
 Requires: gnome-icon-theme
@@ -124,6 +128,7 @@ utilities.
 
 %prep
 %setup -q -n gnome-control-center-%{version}
+%patch0 -p1 -b .firewalld1
 
 %build
 %configure \
@@ -232,6 +237,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor >&/dev/null || :
 
 
 %changelog
+* Thu Apr 12 2012 Marek Kasik <mkasik at redhat.com> - 3.4.0-2
+- Add support for FirewallD1 API
+- Resolves: #802381
+
 * Mon Mar 26 2012 Richard Hughes <rhughes at redhat.com> - 3.4.0-1
 - New upstream version.
 
diff --git a/printers-firewalld1-api.patch b/printers-firewalld1-api.patch
new file mode 100644
index 0000000..992503e
--- /dev/null
+++ b/printers-firewalld1-api.patch
@@ -0,0 +1,563 @@
+diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
+index 0b21502..0427683 100644
+--- a/panels/printers/pp-new-printer-dialog.c
++++ b/panels/printers/pp-new-printer-dialog.c
+@@ -53,6 +53,10 @@
+ #define FIREWALLD_PATH "/org/fedoraproject/FirewallD"
+ #define FIREWALLD_IFACE "org.fedoraproject.FirewallD"
+ 
++#define FIREWALLD1_BUS "org.fedoraproject.FirewallD1"
++#define FIREWALLD1_PATH "/org/fedoraproject/FirewallD1"
++#define FIREWALLD1_IFACE "org.fedoraproject.FirewallD1.zone"
++
+ #define SCP_BUS   "org.fedoraproject.Config.Printing"
+ #define SCP_PATH  "/org/fedoraproject/Config/Printing"
+ #define SCP_IFACE "org.fedoraproject.Config.Printing"
+@@ -312,6 +316,18 @@ store_device_parameter (gpointer key,
+     }
+ }
+ 
++static gboolean
++is_missing_method_error (GError *error)
++{
++  if (error &&
++      error->domain == G_DBUS_ERROR &&
++      (error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
++       error->code == G_DBUS_ERROR_UNKNOWN_METHOD))
++    return TRUE;
++  else
++    return FALSE;
++}
++
+ static void
+ devices_get_cb (GObject      *source_object,
+                 GAsyncResult *res,
+@@ -565,10 +581,7 @@ devices_get_cb (GObject      *source_object,
+ 
+           if (error)
+             {
+-              if (bus == NULL ||
+-                  (error->domain == G_DBUS_ERROR &&
+-                   (error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
+-                    error->code == G_DBUS_ERROR_UNKNOWN_METHOD)))
++              if (bus == NULL || is_missing_method_error (error))
+                 g_warning ("Install system-config-printer which provides \
+ DBus method \"GroupPhysicalDevices\" to group duplicates in device list.");
+ 
+@@ -756,96 +769,115 @@ line_split (gchar *line)
+   return result;
+ }
+ 
+-static void
+-service_enable (gchar *service_name,
+-                gint   service_timeout)
++static gboolean
++is_zone_immutable (const gchar *zone_name)
+ {
+   GDBusConnection *bus;
+-  GVariant   *output = NULL;
+-  GError     *error = NULL;
++  GVariant        *output;
++  GError          *error = NULL;
++  gboolean         result = FALSE;
+ 
+   bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+   if (!bus)
+     {
+       g_warning ("%s", error->message);
+       g_error_free (error);
+-      return;
++      return FALSE;
+     }
+ 
+   output = g_dbus_connection_call_sync (bus,
+-                                        FIREWALLD_BUS,
+-                                        FIREWALLD_PATH,
+-                                        FIREWALLD_IFACE,
+-                                        "enableService",
+-                                        g_variant_new ("(si)",
+-                                                       service_name,
+-                                                       service_timeout),
+-                                        NULL,
++                                        FIREWALLD1_BUS,
++                                        FIREWALLD1_PATH,
++                                        FIREWALLD1_IFACE,
++                                        "isImmutable",
++                                        g_variant_new ("(s)", zone_name),
++                                        G_VARIANT_TYPE ("(b)"),
+                                         G_DBUS_CALL_FLAGS_NONE,
+-                                        60000,
++                                        -1,
+                                         NULL,
+                                         &error);
+ 
+-  g_object_unref (bus);
+-
+   if (output)
+     {
++      g_variant_get (output, "(b)", &result);
+       g_variant_unref (output);
+     }
+   else
+     {
+-      g_warning ("%s", error->message);
++      if (!is_missing_method_error (error))
++        g_warning ("%s", error->message);
+       g_error_free (error);
+     }
++
++  g_object_unref (bus);
++
++  return result;
+ }
+ 
+-static void
+-service_disable (gchar *service_name)
++static GList *
++get_active_zones ()
+ {
+   GDBusConnection *bus;
+-  GVariant   *output = NULL;
+-  GError     *error = NULL;
++  GVariant        *output;
++  GError          *error = NULL;
++  GList           *result = NULL;
+ 
+   bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+   if (!bus)
+     {
+       g_warning ("%s", error->message);
+       g_error_free (error);
+-      return;
++      return NULL;
+     }
+ 
+   output = g_dbus_connection_call_sync (bus,
+-                                        FIREWALLD_BUS,
+-                                        FIREWALLD_PATH,
+-                                        FIREWALLD_IFACE,
+-                                        "disableService",
+-                                        g_variant_new ("(s)", service_name),
++                                        FIREWALLD1_BUS,
++                                        FIREWALLD1_PATH,
++                                        FIREWALLD1_IFACE,
++                                        "getActiveZones",
+                                         NULL,
++                                        G_VARIANT_TYPE ("(a{sas})"),
+                                         G_DBUS_CALL_FLAGS_NONE,
+-                                        60000,
++                                        -1,
+                                         NULL,
+                                         &error);
+ 
+-  g_object_unref (bus);
+-
+   if (output)
+     {
++      GVariantIter *iter;
++      const gchar  *zone;
++      GVariant     *item;
++
++      g_variant_get (output, "(a{sas})", &iter);
++      while ((item = g_variant_iter_next_value (iter)))
++        {
++          g_variant_get (item, "{sas}", &zone, NULL);
++          if (!is_zone_immutable (zone))
++            result = g_list_append (result, g_strdup (zone));
++        }
++
+       g_variant_unref (output);
+     }
+   else
+     {
+-      g_warning ("%s", error->message);
++      if (!is_missing_method_error (error))
++        g_warning ("%s", error->message);
+       g_error_free (error);
+     }
++
++  g_object_unref (bus);
++
++  return result;
+ }
+ 
+ static gboolean
+-service_enabled (gchar *service_name)
++service_enabled_in_zone (gchar *service_name,
++                         gchar *zone)
+ {
+   GDBusConnection *bus;
+-  GVariant   *output = NULL;
+-  GError     *error = NULL;
+-  gint        query_result = 0;
++  gboolean         result = FALSE;
++  GVariant        *output;
++  GError          *error = NULL;
+ 
+   bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+   if (!bus)
+@@ -856,36 +888,298 @@ service_enabled (gchar *service_name)
+     }
+ 
+   output = g_dbus_connection_call_sync (bus,
+-                                        FIREWALLD_BUS,
+-                                        FIREWALLD_PATH,
+-                                        FIREWALLD_IFACE,
++                                        FIREWALLD1_BUS,
++                                        FIREWALLD1_PATH,
++                                        FIREWALLD1_IFACE,
+                                         "queryService",
+-                                        g_variant_new ("(s)", service_name),
+-                                        G_VARIANT_TYPE ("(i)"),
++                                        g_variant_new ("(ss)",
++                                                       zone,
++                                                       service_name),
++                                        G_VARIANT_TYPE ("(b)"),
+                                         G_DBUS_CALL_FLAGS_NONE,
+-                                        60000,
++                                        -1,
+                                         NULL,
+                                         &error);
+ 
+-  g_object_unref (bus);
+-
+   if (output)
+     {
+-      if (g_variant_n_children (output) == 1)
+-        g_variant_get (output, "(i)", &query_result);
++      g_variant_get (output, "(b)", &result);
+       g_variant_unref (output);
+     }
+   else
+     {
++      if (!is_missing_method_error (error))
++        g_warning ("%s", error->message);
++
++      g_error_free (error);
++    }
++
++  g_object_unref (bus);
++
++  return result;
++}
++
++static void
++service_enable (gchar *service_name,
++                gint   service_timeout)
++{
++  GDBusConnection *bus;
++  GVariant        *output;
++  GError          *error = NULL;
++  GList           *zones, *iter;
++
++  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
++  if (!bus)
++    {
++      g_warning ("%s", error->message);
++      g_error_free (error);
++      return;
++    }
++
++  zones = get_active_zones ();
++
++  if (zones)
++    {
++      for (iter = zones; iter; iter = g_list_next (iter))
++        {
++          if (!service_enabled_in_zone (service_name, (gchar *) iter->data))
++            {
++              output = g_dbus_connection_call_sync (bus,
++                                                    FIREWALLD1_BUS,
++                                                    FIREWALLD1_PATH,
++                                                    FIREWALLD1_IFACE,
++                                                    "addService",
++                                                    g_variant_new ("(ssi)",
++                                                                   (gchar *) iter->data,
++                                                                   service_name,
++                                                                   service_timeout),
++                                                    NULL,
++                                                    G_DBUS_CALL_FLAGS_NONE,
++                                                    -1,
++                                                    NULL,
++                                                    &error);
++
++              if (output)
++                {
++                  g_variant_unref (output);
++                }
++              else
++                {
++                  if (!is_missing_method_error (error))
++                    g_warning ("%s", error->message);
++                  g_error_free (error);
++                }
++            }
++        }
++
++      g_list_free_full (zones, g_free);
++    }
++  else
++    {
++      output = g_dbus_connection_call_sync (bus,
++                                            FIREWALLD_BUS,
++                                            FIREWALLD_PATH,
++                                            FIREWALLD_IFACE,
++                                            "enableService",
++                                            g_variant_new ("(si)",
++                                                           service_name,
++                                                           service_timeout),
++                                            NULL,
++                                            G_DBUS_CALL_FLAGS_NONE,
++                                            -1,
++                                            NULL,
++                                            &error);
++
++      if (output)
++        {
++          g_variant_unref (output);
++        }
++      else
++        {
++          if (!is_missing_method_error (error))
++            g_warning ("%s", error->message);
++          g_error_free (error);
++        }
++    }
++
++  g_object_unref (bus);
++}
++
++static void
++service_disable (gchar *service_name)
++{
++  GDBusConnection *bus;
++  GVariant        *output;
++  GError          *error = NULL;
++  GList           *zones, *iter;
++
++  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
++  if (!bus)
++    {
++      g_warning ("%s", error->message);
++      g_error_free (error);
++      return;
++    }
++
++  zones = get_active_zones ();
++
++  if (zones)
++    {
++      for (iter = zones; iter; iter = g_list_next (iter))
++        {
++          output = g_dbus_connection_call_sync (bus,
++                                                FIREWALLD1_BUS,
++                                                FIREWALLD1_PATH,
++                                                FIREWALLD1_IFACE,
++                                                "removeService",
++                                                g_variant_new ("(ss)",
++                                                               (gchar *) iter->data,
++                                                               service_name),
++                                                NULL,
++                                                G_DBUS_CALL_FLAGS_NONE,
++                                                -1,
++                                                NULL,
++                                                &error);
++
++          if (output)
++            {
++              g_variant_unref (output);
++            }
++          else
++            {
++              if (!is_missing_method_error (error))
++                g_warning ("%s", error->message);
++              g_error_free (error);
++            }
++        }
++
++      g_list_free_full (zones, g_free);
++    }
++  else
++    {
++      output = g_dbus_connection_call_sync (bus,
++                                            FIREWALLD_BUS,
++                                            FIREWALLD_PATH,
++                                            FIREWALLD_IFACE,
++                                            "disableService",
++                                            g_variant_new ("(s)",
++                                                           service_name),
++                                            NULL,
++                                            G_DBUS_CALL_FLAGS_NONE,
++                                            -1,
++                                            NULL,
++                                            &error);
++
++      if (output)
++        {
++          g_variant_unref (output);
++        }
++      else
++        {
++          if (!is_missing_method_error (error))
++            g_warning ("%s", error->message);
++          g_error_free (error);
++        }
++    }
++
++  g_object_unref (bus);
++}
++
++static gboolean
++service_enabled (gchar *service_name)
++{
++  GDBusConnection *bus;
++  gboolean         result = FALSE;
++  GVariant        *output;
++  GError          *error = NULL;
++  GList           *zones, *iter;
++
++  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
++  if (!bus)
++    {
+       g_warning ("%s", error->message);
+       g_error_free (error);
+       return FALSE;
+     }
+ 
+-  if (query_result > 0)
+-    return TRUE;
++  zones = get_active_zones ();
++
++  if (zones)
++    {
++      gboolean zone_result = FALSE;
++
++      result = TRUE;
++
++      for (iter = zones; iter; iter = g_list_next (iter))
++        {
++          output = g_dbus_connection_call_sync (bus,
++                                                FIREWALLD1_BUS,
++                                                FIREWALLD1_PATH,
++                                                FIREWALLD1_IFACE,
++                                                "queryService",
++                                                g_variant_new ("(ss)",
++                                                               (gchar *) iter->data,
++                                                               service_name),
++                                                G_VARIANT_TYPE ("(b)"),
++                                                G_DBUS_CALL_FLAGS_NONE,
++                                                -1,
++                                                NULL,
++                                                &error);
++
++          if (output)
++            {
++              g_variant_get (output, "(b)", &zone_result);
++              g_variant_unref (output);
++            }
++          else
++            {
++              if (!is_missing_method_error (error))
++                g_warning ("%s", error->message);
++
++              g_error_free (error);
++            }
++
++          result = result && zone_result;
++        }
++
++      g_list_free_full (zones, g_free);
++    }
+   else
+-    return FALSE;
++    {
++      gint query_result = 0;
++
++      output = g_dbus_connection_call_sync (bus,
++                                            FIREWALLD_BUS,
++                                            FIREWALLD_PATH,
++                                            FIREWALLD_IFACE,
++                                            "queryService",
++                                            g_variant_new ("(s)", service_name),
++                                            G_VARIANT_TYPE ("(i)"),
++                                            G_DBUS_CALL_FLAGS_NONE,
++                                            -1,
++                                            NULL,
++                                            &error);
++
++      if (output)
++        {
++          g_variant_get (output, "(i)", &query_result);
++          g_variant_unref (output);
++
++          if (query_result > 0)
++            result = TRUE;
++        }
++      else
++        {
++          if (!is_missing_method_error (error))
++            g_warning ("%s", error->message);
++
++          g_error_free (error);
++        }
++    }
++
++  g_object_unref (bus);
++
++  return result;
+ }
+ 
+ static gboolean
+@@ -928,8 +1222,7 @@ dbus_method_available (gchar *name,
+     }
+   else
+     {
+-      if (error->domain == G_DBUS_ERROR &&
+-          error->code == G_DBUS_ERROR_SERVICE_UNKNOWN)
++      if (is_missing_method_error (error))
+         result = FALSE;
+       else
+         result = TRUE;
+@@ -1315,7 +1608,11 @@ populate_devices_list (PpNewPrinterDialog *pp)
+ 
+   actualize_devices_list (pp);
+ 
+-  if (dbus_method_available (FIREWALLD_BUS,
++  if (dbus_method_available (FIREWALLD1_BUS,
++                             FIREWALLD1_PATH,
++                             FIREWALLD1_IFACE,
++                             "getServices") ||
++      dbus_method_available (FIREWALLD_BUS,
+                              FIREWALLD_PATH,
+                              FIREWALLD_IFACE,
+                              "getServices"))
+@@ -1858,10 +2155,14 @@ new_printer_add_button_cb (GtkButton *button,
+             }
+ 
+           if (pp->devices[device_id].device_uri &&
+-              dbus_method_available (FIREWALLD_BUS,
+-                                     FIREWALLD_PATH,
+-                                     FIREWALLD_IFACE,
+-                                     "getServices"))
++              (dbus_method_available (FIREWALLD1_BUS,
++                                      FIREWALLD1_PATH,
++                                      FIREWALLD1_IFACE,
++                                      "getServices") ||
++               dbus_method_available (FIREWALLD_BUS,
++                                      FIREWALLD_PATH,
++                                      FIREWALLD_IFACE,
++                                      "getServices")))
+             {
+               if (g_str_has_prefix (pp->devices[device_id].device_uri, "dnssd:") ||
+                   g_str_has_prefix (pp->devices[device_id].device_uri, "mdns:"))
+@@ -1942,9 +2243,7 @@ new_printer_add_button_cb (GtkButton *button,
+ 
+               if (bus == NULL ||
+                   (error &&
+-                   error->domain == G_DBUS_ERROR &&
+-                   (error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
+-                    error->code == G_DBUS_ERROR_UNKNOWN_METHOD)))
++                   is_missing_method_error (error)))
+                 {
+                   g_warning ("Install system-config-printer which provides \
+ DBus method \"MissingExecutables\" to find missing executables and filters.");


More information about the scm-commits mailing list