SOURCES: gnome-applets-use-liboobs.patch (NEW) - port modemlights ...

megabajt megabajt at pld-linux.org
Sun Jun 10 13:51:20 CEST 2007


Author: megabajt                     Date: Sun Jun 10 11:51:20 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- port modemlights plugin to liboobs

---- Files affected:
SOURCES:
   gnome-applets-use-liboobs.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/gnome-applets-use-liboobs.patch
diff -u /dev/null SOURCES/gnome-applets-use-liboobs.patch:1.1
--- /dev/null	Sun Jun 10 13:51:20 2007
+++ SOURCES/gnome-applets-use-liboobs.patch	Sun Jun 10 13:51:15 2007
@@ -0,0 +1,1316 @@
+diff -urN gnome-applets-2.18.0/configure.in gnome-applets-2.18.0.new/configure.in
+--- gnome-applets-2.18.0/configure.in	2007-03-12 13:57:09.000000000 +0100
++++ gnome-applets-2.18.0.new/configure.in	2007-06-10 12:30:15.000000000 +0200
+@@ -35,6 +35,7 @@
+ GNOME_PYTHON_REQUIRED=2.10
+ GNOME_ICON_THEME_REQUIRED=2.15.91
+ LIBXML_REQUIRED=2.5.0
++LIBOOBS_REQUIRED=0.5.0
+ dnl ***************************************************************************
+ 
+ AM_MAINTAINER_MODE
+@@ -509,25 +510,20 @@
+ dnl *** modemlights applet check                                            ***
+ dnl ***************************************************************************
+ 
+-SU_TOOL=
+-P_MODEMLIGHTS=
+-HAVE_LIBUTIL=
+-
+-AC_PATH_PROG(SU_TOOL, su)
+-AC_CHECK_LIB(util, forkpty, HAVE_LIBUTIL=true, HAVE_LIBUTIL=false)
+-AM_PATH_SYSTEM_TOOLS_BACKENDS($SYSTEM_TOOLS_BACKENDS_REQUIRED, P_MODEMLIGHTS=modemlights)
+-
+-if test "x$HAVE_LIBUTIL" = "xtrue" -a "x$P_MODEMLIGHTS" = "xmodemlights" -a "x$HAVE_GNOME_SETTINGS_DAEMON" = "xyes"; then
+-  MODEMLIGHTS_LIBS=" -lutil"
+-  AC_SUBST(MODEMLIGHTS_LIBS)
+-  AC_DEFINE_UNQUOTED(STB_SCRIPTS_DIR, "$STB_SCRIPTS_DIR", [System tools backends])
+-  AC_DEFINE_UNQUOTED(SU_PATH, "${SU_TOOL}", [su executable path])
++MODEMLIGHTS_LIBS=
++MODEMLIGHTS_CFLAGS=
++
++PKG_CHECK_MODULES(MODEMLIGHTS, liboobs-1 >= $LIBOOBS_REQUIRED,
++			HAVE_LIBOOBS=yes, HAVE_LIBOOBS=no)
++if test "x$HAVE_LIBOOBS" = "xyes" -a "x$HAVE_GNOME_SETTINGS_DAEMON" = "xyes"; then
+   BUILD_MODEM_LIGHTS=yes
+ else
+   AC_MSG_WARN([*** modemlights applet will not be built ***])
+   BUILD_MODEM_LIGHTS=no
+ fi
+ 
++AC_SUBST(MODEMLIGHTS_LIBS)
++AC_SUBST(MODEMLIGHTS_CFLAGS)
+ AM_CONDITIONAL(APPLET_MODEMLIGHTS, test "x$BUILD_MODEM_LIGHTS" = "xyes")
+ 
+ dnl ***************************************************************************
+diff -urN gnome-applets-2.18.0/modemlights/Makefile.am gnome-applets-2.18.0.new/modemlights/Makefile.am
+--- gnome-applets-2.18.0/modemlights/Makefile.am	2006-12-31 03:16:08.000000000 +0100
++++ gnome-applets-2.18.0.new/modemlights/Makefile.am	2007-06-10 12:31:26.000000000 +0200
+@@ -2,6 +2,7 @@
+ 
+ INCLUDES = -I. -I$(srcdir) 				\
+ 	$(GNOME_APPLETS_CFLAGS)				\
++	$(MODEMLIGHTS_CFLAGS)				\
+ 	$(LIBGLADE_CFLAGS)
+ 
+ libexec_PROGRAMS = modem_applet
+diff -urN gnome-applets-2.18.0/modemlights/modem-applet.c gnome-applets-2.18.0.new/modemlights/modem-applet.c
+--- gnome-applets-2.18.0/modemlights/modem-applet.c	2006-12-31 03:16:08.000000000 +0100
++++ gnome-applets-2.18.0.new/modemlights/modem-applet.c	2007-06-10 13:32:32.000000000 +0200
+@@ -23,31 +23,14 @@
+ #endif
+ 
+ #include <panel-applet.h>
+-#include <fcntl.h>
+-#ifdef HAVE_PTY_H
+-#include <pty.h>
+-#endif
+-#include <sys/poll.h>
+-#include <sys/types.h>
+-#include <sys/wait.h>
+-#include <libxml/tree.h>
++#include <oobs/oobs.h>
+ #include <glade/glade.h>
+ 
+-#ifdef __FreeBSD__
+-#include <sys/ioctl.h>
+-#include <termios.h>
+-#include <libutil.h>
+-#endif
+-
+ #include "modem-applet.h"
+ 
+ #define MODEM_APPLET_GET_PRIVATE(obj)  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_MODEM_APPLET, ModemAppletPrivate))
+ #define NETWORK_TOOL "network-admin"
+-#define END_OF_REQUEST "<!-- GST: end of request -->\n"
+-#define BUF_SIZE 1024
+ 
+-typedef void (*DirectiveCallback) (ModemApplet*, xmlDoc*);
+-typedef struct _BackendDirective   BackendDirective;
+ typedef struct _ModemAppletPrivate ModemAppletPrivate;
+ 
+ struct _ModemAppletPrivate
+@@ -59,47 +42,19 @@
+   GtkWidget    *image;
+   GtkTooltips  *tooltips;
+ 
+-  /* auth dialog */
+-  GtkWidget    *auth_dialog;
+-  GtkWidget    *auth_dialog_label;
+-  GtkWidget    *auth_dialog_entry;
+-
+   /* report window */
+   GtkWidget    *report_window;
+   GtkWidget    *report_window_image;
+   GtkWidget    *report_window_progress;
+ 
+-  guint directives_id;
+-  guint progress_id;
+-  guint tooltip_id;
+-  guint info_id;
+-  guint timeout_id;
+-
+-  /* for communicating with the backend */
+-  gint config_id;
+-  gint pid;
+-  int  read_fd;
+-  int  write_fd;
+-  FILE *read_stream;
+-  FILE *write_stream;
+-  GSList *directives;
+-  gboolean directive_running;
+-
+-  /* interface data */
+-  gboolean configured;  /* is configured? */
+-  gboolean enabled;     /* is enabled? */
+-  gboolean is_isdn;     /* is an isdn device? */
+-  gchar *dev;           /* device name */
+-  gchar *lock_file;     /* lock file */
+-
+-  gboolean  has_root;
+-};
++  /* configuration */
++  OobsSession	*session;
++  OobsObject	*config;
++  OobsIface	*iface;
++  gchar		*lock_file;
+ 
+-struct _BackendDirective
+-{
+-  DirectiveCallback callback;
+-  GSList *directive;
+-  gboolean show_report;
++  guint		pulse_id;
++  guint		tooltip_id;
+ };
+ 
+ static void modem_applet_class_init (ModemAppletClass *class);
+@@ -139,8 +94,6 @@
+ 					   gboolean     backend_alive,
+ 					   gboolean     already_waiting);
+ 
+-static gpointer parent_class;
+-
+ static const BonoboUIVerb menu_verbs[] = {
+   BONOBO_UI_UNSAFE_VERB ("Activate",   on_modem_applet_activate),
+   BONOBO_UI_UNSAFE_VERB ("Deactivate", on_modem_applet_deactivate),
+@@ -150,32 +103,7 @@
+   BONOBO_UI_VERB_END
+ };
+ 
+-static GType
+-modem_applet_get_type (void)
+-{
+-  static GType type = 0;
+-
+-  if (!type)
+-    {
+-      static const GTypeInfo info =
+-        {
+-	  sizeof (ModemAppletClass),
+-	  NULL,		/* base_init */
+-	  NULL,		/* base_finalize */
+-	  (GClassInitFunc) modem_applet_class_init,
+-	  NULL,		/* class_finalize */
+-	  NULL,		/* class_data */
+-	  sizeof (ModemApplet),
+-	  0,		/* n_preallocs */
+-	  (GInstanceInitFunc) modem_applet_init,
+-	};
+-
+-      type = g_type_register_static (PANEL_TYPE_APPLET, "ModemApplet",
+-				     &info, 0);
+-    }
+-
+-  return type;
+-}
++G_DEFINE_TYPE (ModemApplet, modem_applet, PANEL_TYPE_APPLET);
+ 
+ static void
+ modem_applet_class_init (ModemAppletClass *class)
+@@ -185,8 +113,7 @@
+ 
+   object_class = G_OBJECT_CLASS (class);
+   applet_class = PANEL_APPLET_CLASS (class);
+-  parent_class = g_type_class_peek_parent (class);
+-
++  
+   object_class->finalize    = modem_applet_finalize;
+   applet_class->change_size = modem_applet_change_size;
+   applet_class->change_background = modem_applet_change_background;
+@@ -194,6 +121,57 @@
+   g_type_class_add_private (object_class, sizeof (ModemAppletPrivate));
+ }
+ 
++static OobsIface*
++get_modem_iface (OobsIfacesConfig *config)
++{
++  OobsList *list;
++  OobsListIter iter;
++  gboolean valid;
++  
++  /* First try the modem ifaces */
++  list = oobs_ifaces_config_get_ifaces (config, OOBS_IFACE_TYPE_MODEM);
++  valid = oobs_list_get_iter_first (list, &iter);
++
++  if (valid)
++    return (OobsIface *) oobs_list_get (list, &iter);
++
++  /* no modem? try the isdn ifaces */
++  list = oobs_ifaces_config_get_ifaces (config, OOBS_IFACE_TYPE_ISDN);
++  valid = oobs_list_get_iter_first (list, &iter);
++
++  if (valid)
++    return (OobsIface *) oobs_list_get (list, &iter);
++
++  return NULL;
++}
++
++static gchar*
++get_lock_file (OobsIface *iface)
++{
++  gchar *lock_file;
++
++  if (!iface)
++    return NULL;
++
++  if (OOBS_IS_IFACE_MODEM (iface))
++    {
++      const gchar *serial_port, *str;
++
++      serial_port = oobs_iface_modem_get_serial_port (OOBS_IFACE_MODEM (iface));
++
++      if (serial_port)
++	{
++	  str = strchr (serial_port, '/');
++	  lock_file = g_strdup_printf ("/var/lock/LCK..%s", str + 1);
++	}
++    }
++  else if (OOBS_IS_IFACE_ISDN (iface))
++    lock_file = g_strdup ("/var/lock/LCK..capi_0");
++
++  return lock_file;
++}
++
++
+ static void
+ modem_applet_init (ModemApplet *applet)
+ {
+@@ -208,9 +186,10 @@
+   priv->image = gtk_image_new ();
+   priv->tooltips = gtk_tooltips_new ();
+ 
+-  priv->auth_dialog       = glade_xml_get_widget (priv->xml, "auth_dialog");
+-  priv->auth_dialog_label = glade_xml_get_widget (priv->xml, "auth_dialog_label");
+-  priv->auth_dialog_entry = glade_xml_get_widget (priv->xml, "auth_dialog_entry");
++  priv->session = oobs_session_get ();
++  priv->config = oobs_ifaces_config_get (priv->session);
++  priv->iface = get_modem_iface (OOBS_IFACES_CONFIG (priv->config));
++  priv->lock_file = get_lock_file (priv->iface);
+ 
+   priv->report_window          = glade_xml_get_widget (priv->xml, "report_window");
+   priv->report_window_image    = glade_xml_get_widget (priv->xml, "report_window_image");
+@@ -223,19 +202,7 @@
+   gtk_image_set_from_pixbuf (GTK_IMAGE (priv->report_window_image), pixbuf);
+   gdk_pixbuf_unref (pixbuf);
+ 
+-  priv->configured = FALSE;
+-  priv->enabled = FALSE;
+-  priv->dev = NULL;
+-  priv->lock_file = NULL;
+-
+-  priv->has_root = FALSE;
+-
+-  priv->directives = NULL;
+-  priv->directives_id = g_timeout_add (250, (GSourceFunc) dispatch_directives, applet);
+-  priv->directive_running = FALSE;
+   priv->tooltip_id = g_timeout_add (1000, (GSourceFunc) update_tooltip, applet);
+-
+-  launch_backend (applet, FALSE);
+   gtk_container_add (GTK_CONTAINER (applet), priv->image);
+ }
+ 
+@@ -246,18 +213,25 @@
+ 
+   if (priv)
+     {
+-      shutdown_backend (MODEM_APPLET (object), TRUE, TRUE);
+-
+-      gtk_widget_destroy (priv->auth_dialog);
+-      gtk_widget_destroy (priv->report_window);
++      g_object_unref (priv->xml);
+       g_object_unref (priv->icon);
++      gtk_widget_destroy (priv->image);
++
++      if (priv->pulse_id)
++	{
++	  g_source_remove (priv->pulse_id);
++	  priv->pulse_id = 0;
++	}
+ 
+-      g_free (priv->dev);
+-      g_free (priv->lock_file);
++      if (priv->tooltip_id)
++	{
++	  g_source_remove (priv->tooltip_id);
++	  priv->tooltip_id = 0;
++	}
+     }
+ 
+-  if (G_OBJECT_CLASS (parent_class)->finalize)
+-    (* G_OBJECT_CLASS (parent_class)->finalize) (object);
++  if (G_OBJECT_CLASS (modem_applet_parent_class)->finalize)
++    (* G_OBJECT_CLASS (modem_applet_parent_class)->finalize) (object);
+ }
+ 
+ static void
+@@ -312,401 +286,26 @@
+     }
+ }
+ 
+-static gboolean
+-pulse_progressbar (GtkWidget *progressbar)
+-{
+-  gtk_progress_bar_pulse (GTK_PROGRESS_BAR (progressbar));
+-  return TRUE;
+-}
+-
+-/* XML manipulation functions */
+-static xmlNodePtr
+-get_root_node (xmlDoc *doc)
+-{
+-  return xmlDocGetRootElement (doc);
+-}
+-
+-static xmlNodePtr
+-find_first_element (xmlNodePtr node, const gchar *name)
+-{
+-  xmlNodePtr n;
+-	
+-  g_return_val_if_fail (node != NULL, NULL);
+-  g_return_val_if_fail (name != NULL, NULL);
+-
+-  for (n = node->children; n; n = n->next)
+-    if (n->name && (strcmp (name, (char *) n->name) == 0))
+-      break;
+-
+-  return n;
+-}
+-
+-static xmlNodePtr
+-find_next_element (xmlNodePtr node, const gchar *name)
+-{
+-  xmlNodePtr n;
+-	
+-  g_return_val_if_fail (node != NULL, NULL);
+-  g_return_val_if_fail (name != NULL, NULL);
+-
+-  for (n = node->next; n; n = n->next)
+-    if (n->name && (strcmp (name, (char *) n->name) == 0))
+-      break;
+-
+-  return n;
+-}
+-
+-static guchar *
+-element_get_attribute (xmlNodePtr node, const gchar *attribute)
+-{
+-  xmlAttrPtr a;
+-
+-  g_return_val_if_fail (node != NULL, NULL);
+-  a = node->properties;
+-
+-  while (a)
+-    {
+-      if (a->name && (strcmp ((char *) a->name, attribute) == 0))
+-        return xmlNodeGetContent (a->children);
+-
+-      a = a->next;
+-    }
+-
+-  return NULL;
+-}
+-
+-static guchar *
+-element_get_child_content (xmlNodePtr node, const gchar *tag)
+-{
+-  xmlNodePtr child, n;
+-
+-  child = find_first_element (node, tag);
+-  if (!child)
+-    return NULL;
+-
+-  for (n = child->children; n; n = n->next)
+-    if (n->type == XML_TEXT_NODE)
+-      return xmlNodeGetContent (n);
+-
+-  return NULL;
+-}
+-
+-static xmlNodePtr
+-find_dialup_interface_node (xmlNodePtr root)
+-{
+-  xmlNodePtr  node;
+-  gchar      *type;
+-
+-  node = find_first_element (root, "interface");
+-
+-  while (node)
+-    {
+-      type = (char *) element_get_attribute (node, "type");
+-
+-      if (type && (strcmp (type, "modem") == 0 || strcmp (type, "isdn") == 0))
+-        {
+-	  g_free (type);
+-	  return node;
+-	}
+-
+-      g_free (type);
+-      node = find_next_element (node, "interface");
+-    }
+-
+-  return NULL;
+-}
+-
+-/* backend communication functions */
+-static gchar *
+-compose_directive_string (GSList *directive)
+-{
+-  GString *dir;
+-  gchar   *arg, *s, *str;
+-  GSList  *elem;
+-
+-  elem = directive;
+-  dir = g_string_new ("");
+-
+-  while (elem)
+-    {
+-      arg = elem->data;
+-
+-      for (s = arg; *s; s++)
+-        {
+-	  /* escape needed chars */
+-	  if ((*s == '\\') ||
+-	      ((*s == ':') && (* (s + 1) == ':')))
+-	    g_string_append_c (dir, '\\');
+-
+-	  g_string_append_c (dir, *s);
+-	}
+-
+-      g_string_append (dir, "::");
+-      elem = elem->next;
+-    }
+-
+-  g_string_append_c (dir, '\n');
+-
+-  str = dir->str;
+-  g_string_free (dir, FALSE);
+-
+-  return str;
+-}
+-
+-static void
+-poll_backend (ModemAppletPrivate *priv)
+-{
+-  struct pollfd fd;
+-
+-  fd.fd = priv->read_fd;
+-  fd.events = POLLIN || POLLPRI;
+-
+-  while (poll (&fd, 1, 100) <= 0)
+-    {
+-      while (gtk_events_pending ())
+-	gtk_main_iteration ();
+-    }
+-}
+-
+-static xmlDoc*
+-read_xml (ModemApplet *applet, gboolean show_report)
+-{
+-  ModemAppletPrivate *priv = MODEM_APPLET_GET_PRIVATE (applet);
+-  gchar    buffer[BUF_SIZE], *s;
+-  GString *str;
+-  xmlDoc  *doc = NULL;
+-  gboolean backend_alive;
+-
+-  str = g_string_new ("");
+-  backend_alive = (waitpid (priv->pid, NULL, WNOHANG) == 0);
+-
+-  /* if show_report, create pulse timeout and show window */
+-  if (show_report)
+-    {
+-      priv->progress_id = gtk_timeout_add (200, (GSourceFunc) pulse_progressbar, priv->report_window_progress);
+-      gtk_window_set_screen (GTK_WINDOW (priv->report_window), gtk_widget_get_screen (GTK_WIDGET (applet)));
+-      gtk_widget_show (priv->report_window);
+-    }
+-
+-  while (backend_alive && !g_strrstr (str->str, END_OF_REQUEST))
+-    {
+-      poll_backend (priv);
+-      fgets (buffer, BUF_SIZE, priv->read_stream);
+-      g_string_append (str, buffer);
+-
+-      while (gtk_events_pending ())
+-        gtk_main_iteration ();
+-
+-      backend_alive = (waitpid (priv->pid, NULL, WNOHANG) == 0);
+-    }
+-
+-  /* if show_report, hide window and so */
+-  if (show_report)
+-    {
+-      g_source_remove (priv->progress_id);
+-      priv->progress_id = 0;
+-      gtk_widget_hide (priv->report_window);
+-    }
+-
+-  s = str->str;
+-
+-  while (*s && (*s != '<'))
+-    s++;
+-
+-  if (strcmp (s, END_OF_REQUEST) != 0)
+-    doc = xmlParseDoc ((xmlChar *) s);
+-
+-  g_string_free (str, TRUE);
+-
+-  return doc;
+-}
+-
+-static void
+-queue_directive (ModemApplet       *applet,
+-		 DirectiveCallback  callback,
+-		 gboolean           show_report,
+-		 const gchar       *dir,
+-		 ...)
+-{
+-  ModemAppletPrivate *priv = MODEM_APPLET_GET_PRIVATE (applet);
+-  BackendDirective   *directive;
+-  GSList  *list = NULL;
+-  va_list  ap;
+-  gchar   *arg;
+-
+-  list = g_slist_prepend (list, g_strdup (dir));
+-  va_start (ap, dir);
+-
+-  while ((arg = va_arg (ap, gchar *)) != NULL)
+-    list = g_slist_prepend (list, g_strdup (arg));
+-
+-  va_end (ap);
+-  list = g_slist_reverse (list);
+-
+-  directive = g_new0 (BackendDirective, 1);
+-  directive->callback    = callback;
+-  directive->directive   = list;
+-  directive->show_report = show_report;
+-
+-  priv->directives = g_slist_append (priv->directives, directive);
+-}
+-
+-static gboolean
+-dispatch_directives (ModemApplet *applet)
+-{
+-  ModemAppletPrivate *priv = MODEM_APPLET_GET_PRIVATE (applet);
+-  BackendDirective   *directive;
+-  xmlDoc             *doc;
+-  gchar              *dir;
+-  GSList             *elem;
+-
+-  if (priv->directive_running)
+-    return TRUE;
+-
+-  priv->directive_running = TRUE;
+-  elem = priv->directives;
+-
+-  while (elem)
+-    {
+-      directive = elem->data;
+-
+-      dir = compose_directive_string (directive->directive);
+-      fputs (dir, priv->write_stream);
+-      g_free (dir);
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list