2007-02-05 Tambet Ingo <tambet@ximian.com>

* src/dhcp-manager/nm-dhcp-marshal-main.c: Add.

	* src/dhcp-manager/nm-dhcp-marshal.list: Add.

	* src/dhcp-manager/nm-dhcp-manager.c:
	* src/dhcp-manager/nm-dhcp-manager.h:
		- Convert it to GObject since we need to signal state changes.
		- Remove all references to other NM classes, this class is one
		  of the lowest classes in our hierarchy.
		- One less class to use NMActRequest.
		- Make it singleton, one less user of NMData.
		- Remove a couple of sleep() calls.
		- Convert a bunch of low-level dbus API calls to dbus-glib calls.
		  One less class to use the NM's custom tailored signal handlig.

	* Makefile.am: Generate marshallers, add them to build.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2283 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Tambet Ingo
2007-02-05 09:42:19 +00:00
committed by Tambet Ingo
parent 4cf05ff525
commit 1bbdd977e3
5 changed files with 472 additions and 418 deletions

View File

@@ -6,8 +6,14 @@ INCLUDES = -I${top_srcdir} \
noinst_LTLIBRARIES = libdhcp-manager.la
libdhcp_manager_la_SOURCES = nm-dhcp-manager.c \
nm-dhcp-manager.h
BUILT_SOURCES = \
nm-dhcp-marshal.h \
nm-dhcp-marshal.c
libdhcp_manager_la_SOURCES = \
nm-dhcp-manager.c \
nm-dhcp-manager.h \
nm-dhcp-marshal-main.c
libdhcp_manager_la_CPPFLAGS = $(DBUS_CFLAGS) \
$(GTHREAD_CFLAGS) \
@@ -22,3 +28,21 @@ libdhcp_manager_la_CPPFLAGS = $(DBUS_CFLAGS) \
libdhcp_manager_la_LIBADD = $(DBUS_LIBS) $(GTHREAD_LIBS)
EXTRA_DIST = nm-dhcp-marshal.list
CLEANFILES = $(BUILT_SOURCES)
nm-dhcp-marshal.h: nm-dhcp-marshal.list
$(GLIB_GENMARSHAL) --prefix=nm_dhcp_marshal $(srcdir)/nm-dhcp-marshal.list --header > \
xgen-gmh \
&& (cmp -s xgen-gmh nm-dhcp-marshal.h || cp xgen-gmh nm-dhcp-marshal.h) \
&& rm -f xgen-gmh xgen-gmh~
nm-dhcp-marshal.c: nm-dhcp-marshal.list
$(GLIB_GENMARSHAL) --prefix=nm_dhcp_marshal $(srcdir)/nm-dhcp-marshal.list --body > \
xgen-gmc \
&& cp xgen-gmc nm-dhcp-marshal.c \
&& rm -f xgen-gmc xgen-gmc~
nm-dhcp-marshal-main.c: nm-dhcp-marshal.c nm-dhcp-marshal.h

File diff suppressed because it is too large Load Diff

View File

@@ -21,16 +21,18 @@
#ifndef NM_DHCP_MANAGER_H
#define NM_DHCP_MANAGER_H
#include "NetworkManagerMain.h"
#include "nm-device.h"
#include <glib/gtypes.h>
#include <glib-object.h>
#include "nm-ip4-config.h"
/*
* FIXME: These should go in a header shared by NetworkManager and dhcdbd,
* but right now NetworkManager and dhcdbd do not share any header. The
* following is copied (and cleaned up) from dhcdbd.h.
*/
enum dhcdbd_state
{
#define NM_TYPE_DHCP_MANAGER (nm_dhcp_manager_get_type ())
#define NM_DHCP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_MANAGER, NMDHCPManager))
#define NM_DHCP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_MANAGER, NMDHCPManagerClass))
#define NM_IS_DHCP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_MANAGER))
#define NM_IS_DHCP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DHCP_MANAGER))
#define NM_DHCP_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_MANAGER, NMDHCPManagerClass))
typedef enum {
DHCDBD_NBI=0, /* no broadcast interfaces found */
DHCDBD_PREINIT, /* configuration started */
DHCDBD_BOUND, /* lease obtained */
@@ -47,16 +49,28 @@ enum dhcdbd_state
DHCDBD_ABEND, /* dhclient exited abnormally */
DHCDBD_END, /* dhclient exited normally */
DHCDBD_END_OPTIONS, /* last option in subscription sent */
};
} NMDHCPState;
NMDHCPManager * nm_dhcp_manager_new (NMData *data);
void nm_dhcp_manager_dispose (NMDHCPManager *manager);
typedef struct {
GObject parent;
} NMDHCPManager;
gboolean nm_dhcp_manager_begin_transaction (NMDHCPManager *manager, NMActRequest *req);
void nm_dhcp_manager_cancel_transaction (NMDHCPManager *manager, NMActRequest *req);
typedef struct {
GObjectClass parent;
NMIP4Config * nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager, NMActRequest *req);
/* Signals */
void (*state_changed) (NMDHCPManager *manager, char *iface, NMDHCPState state);
void (*timeout) (NMDHCPManager *manager, char *iface);
} NMDHCPManagerClass;
guint32 nm_dhcp_manager_get_state_for_device (NMDHCPManager *manager, NMDevice *dev);
GType nm_dhcp_manager_get_type (void);
#endif
NMDHCPManager *nm_dhcp_manager_get (void);
gboolean nm_dhcp_manager_begin_transaction (NMDHCPManager *manager, const char *iface);
void nm_dhcp_manager_cancel_transaction (NMDHCPManager *manager,
const char *iface,
gboolean blocking);
NMIP4Config *nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager, const char *iface);
NMDHCPState nm_dhcp_manager_get_state_for_device (NMDHCPManager *manager, const char *iface);
#endif /* NM_DHCP_MANAGER_H */

View File

@@ -0,0 +1,3 @@
#include "nm-dhcp-marshal.h"
#include "nm-dhcp-marshal.c"

View File

@@ -0,0 +1,2 @@
VOID:STRING,UCHAR