G_DEFINE_QUARK (nm-connection-error-quark, nm_connection_error)
G_DEFINE_QUARK (nm-crypto-error-quark, nm_crypto_error)
+G_DEFINE_QUARK (nm-device-error-quark, nm_device_error)
static void
register_error_domain (GQuark domain,
register_error_domain (NM_CONNECTION_ERROR,
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
NM_TYPE_CONNECTION_ERROR);
+ register_error_domain (NM_DEVICE_ERROR,
+ NM_DBUS_INTERFACE_DEVICE,
+ NM_TYPE_DEVICE_ERROR);
}
#define NM_CRYPTO_ERROR nm_crypto_error_quark ()
GQuark nm_crypto_error_quark (void);
+/**
+ * NMDeviceError:
+ * @NM_DEVICE_ERROR_FAILED: unknown or unclassified error
+ * @NM_DEVICE_ERROR_INVALID_CONNECTION: the specified connection is not valid
+ * @NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION: the specified connection is not
+ * compatible with this device.
+ * @NM_DEVICE_ERROR_NOT_ACTIVE: the device does not have an active connection
+ * @NM_DEVICE_ERROR_NOT_SOFTWARE: the requested operation is only valid on
+ * software devices.
+ *
+ * Device-related errors.
+ *
+ * These errors may be returned directly from #NMDevice methods, or may be
+ * returned from D-Bus operations (where they correspond to errors in the
+ * "org.freedesktop.NetworkManager.Device" namespace).
+ */
+typedef enum {
+ NM_DEVICE_ERROR_FAILED = 0, /*< nick=Failed >*/
+ NM_DEVICE_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/
+ NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, /*< nick=IncompatibleConnection >*/
+ NM_DEVICE_ERROR_NOT_ACTIVE, /*< nick=NotActive >*/
+ NM_DEVICE_ERROR_NOT_SOFTWARE, /*< nick=NotSoftware >*/
+} NMDeviceError;
+
+#define NM_DEVICE_ERROR nm_device_error_quark ()
+GQuark nm_device_error_quark (void);
+
#endif /* __NM_ERRORS_H__ */
static guint signals[LAST_SIGNAL] = { 0 };
-/**
- * nm_device_error_quark:
- *
- * Registers an error quark for #NMDevice if necessary.
- *
- * Returns: the error quark used for #NMDevice errors.
- **/
-GQuark
-nm_device_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("nm-device-error-quark");
- return quark;
-}
-
static void
nm_device_init (NMDevice *device)
{
#define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE))
#define NM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE, NMDeviceClass))
-/**
- * NMDeviceError:
- * @NM_DEVICE_ERROR_FAILED: unknown or unclassified error
- * @NM_DEVICE_ERROR_INVALID_CONNECTION: the connection is not valid
- * @NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION: the connection is not compatible
- * with this device.
- *
- * Errors from #NMDevice methods.
- */
-typedef enum {
- NM_DEVICE_ERROR_FAILED = 0, /*< nick=Failed >*/
- NM_DEVICE_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/
- NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, /*< nick=IncompatibleConnection >*/
-} NMDeviceError;
-
-#define NM_DEVICE_ERROR nm_device_error_quark ()
-GQuark nm_device_error_quark (void);
-
#define NM_DEVICE_DEVICE_TYPE "device-type"
#define NM_DEVICE_UDI "udi"
#define NM_DEVICE_INTERFACE "interface"
g_assert (device);
g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
+ /* Try deleting the device via the ordinary NM interface, which should fail */
+ nm_device_delete (device, NULL, &error);
+ g_assert_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_NOT_SOFTWARE);
+
g_object_unref (client);
g_clear_pointer (&sinfo, nm_test_service_cleanup);
}
/***********************************************************/
-static GQuark
-nm_device_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("nm-device-error");
- return quark;
-}
-
-#define NM_DEVICE_ERROR (nm_device_error_quark ())
-
-/***********************************************************/
-
#define QUEUED_PREFIX "queued state change to "
static const char *state_table[] = {
g_set_error (error,
NM_DEVICE_ERROR,
- NM_DEVICE_ERROR_UNSUPPORTED_DEVICE_TYPE,
+ NM_DEVICE_ERROR_FAILED,
"master device '%s' cannot update a slave connection for slave device '%s' (master type not supported?)",
nm_device_get_iface (self), nm_device_get_iface (slave));
return FALSE;
g_return_val_if_fail (connection != NULL, FALSE);
if (!NM_DEVICE_GET_CLASS (self)->complete_connection) {
- g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CONNECTION_INVALID,
+ g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION,
"Device class %s had no complete_connection method",
G_OBJECT_TYPE_NAME (self));
return FALSE;
typedef enum NMActStageReturn NMActStageReturn;
-typedef enum {
- NM_DEVICE_ERROR_CONNECTION_ACTIVATING = 0, /*< nick=ConnectionActivating >*/
- NM_DEVICE_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/
- NM_DEVICE_ERROR_NOT_ACTIVE, /*< nick=NotActive >*/
- NM_DEVICE_ERROR_UNSUPPORTED_DEVICE_TYPE, /*< nick=UnsupportedDeviceType >*/
- NM_DEVICE_ERROR_NOT_SOFTWARE, /*< nick=NotSoftware >*/
-} NMDeviceError;
-
struct _NMDevice {
GObject parent;
};
###################################################################
IFACE_DEVICE = 'org.freedesktop.NetworkManager.Device'
+class NotSoftwareException(dbus.DBusException):
+ _dbus_error_name = IFACE_DEVICE + '.NotSoftware'
+
PD_UDI = "Udi"
PD_IFACE = "Interface"
PD_DRIVER = "Driver"
def Disconnect(self):
pass
+ @dbus.service.method(dbus_interface=IFACE_DEVICE, in_signature='', out_signature='')
+ def Delete(self):
+ # We don't currently support any software device types, so...
+ raise NotSoftwareException()
+ pass
+
def __notify(self, propname):
props = self._get_dbus_properties(IFACE_DEVICE)
changed = { propname: props[propname] }