static void
add_or_change_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
{
	CBInfo *info = user_data;
	GError *error = NULL;
	char *zone = NULL;

	if (!dbus_g_proxy_end_call (proxy, call_id, &error,
	                            G_TYPE_STRING, &zone,
	                            G_TYPE_INVALID)) {
		g_assert (error);
		if (g_strcmp0 (error->message, "ZONE_ALREADY_SET") != 0) {
			nm_log_warn (LOGD_FIREWALL, "(%s) firewall zone add/change failed [%u]: (%d) %s",
			             info->iface, info->id, error->code, error->message);
		} else {
			nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone add/change failed [%u]: (%d) %s",
			            info->iface, info->id, error->code, error->message);
		}
	} else {
		nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone add/change succeeded [%u]",
		            info->iface, info->id);
	}

	if (info->callback)
		info->callback (error, info->user_data);

	info->completed = TRUE;
	g_free (zone);
	g_clear_error (&error);
}
static gboolean
add_or_change_idle_cb (gpointer user_data)
{
	CBInfo *info = user_data;

	if (info->idle_id == 0) {
		/* operation was cancelled. _cb_info_free will invoke callback. */
	} else {
		nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone call pretends success [%u]",
		            info->iface, info->id);
		if (info->callback)
			info->callback (NULL, info->user_data);
		info->completed = TRUE;
		info->idle_id = 0;
	}

	_cb_info_free (info);
	return G_SOURCE_REMOVE;
}
Exemplo n.º 3
0
static void
add_or_change_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
{
	CBInfo *info = user_data;
	GError *error = NULL;
	char *zone = NULL;

	if (!dbus_g_proxy_end_call (proxy, call_id, &error,
	                            G_TYPE_STRING, &zone,
	                            G_TYPE_INVALID)) {
		g_assert (error);
		nm_log_warn (LOGD_FIREWALL, "(%s) firewall zone add/change failed: (%d) %s",
		             info->iface, error->code, error->message);
	}

	info->callback (error, info->user_data);

	g_free (zone);
	g_clear_error (&error);
}