[libgovirt] Add OvirtApi class
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgovirt] Add OvirtApi class
- Date: Mon, 2 Sep 2013 15:45:21 +0000 (UTC)
commit 47e5de60d83f21b7fbcce9bf2802c0a150cd6d93
Author: Christophe Fergeau <cfergeau redhat com>
Date: Thu Aug 22 17:12:52 2013 +0200
Add OvirtApi class
This will be the toplevel object to get access to the REST API
govirt/Makefile.am | 3 +
govirt/govirt-private.h | 1 +
govirt/govirt.h | 1 +
govirt/govirt.sym | 3 +
govirt/ovirt-api-private.h | 35 +++++++++++++++++
govirt/ovirt-api.c | 90 ++++++++++++++++++++++++++++++++++++++++++++
govirt/ovirt-api.h | 65 +++++++++++++++++++++++++++++++
7 files changed, 198 insertions(+), 0 deletions(-)
---
diff --git a/govirt/Makefile.am b/govirt/Makefile.am
index 822cd61..652452d 100644
--- a/govirt/Makefile.am
+++ b/govirt/Makefile.am
@@ -15,6 +15,7 @@ lib_LTLIBRARIES = \
libgovirt_ladir = $(includedir)/govirt-1.0/govirt
libgovirt_la_HEADERS = \
govirt.h \
+ ovirt-api.h \
ovirt-collection.h \
ovirt-error.h \
ovirt-proxy.h \
@@ -28,6 +29,7 @@ libgovirt_la_HEADERS = \
noinst_HEADERS = \
glib-compat.h \
govirt-private.h \
+ ovirt-api-private.h \
ovirt-collection-private.h \
ovirt-proxy-private.h \
ovirt-resource-private.h \
@@ -38,6 +40,7 @@ noinst_HEADERS = \
libgovirt_la_SOURCES = \
glib-compat.c \
+ ovirt-api.c \
ovirt-collection.c \
ovirt-error.c \
ovirt-proxy.c \
diff --git a/govirt/govirt-private.h b/govirt/govirt-private.h
index ad66d31..474388e 100644
--- a/govirt/govirt-private.h
+++ b/govirt/govirt-private.h
@@ -22,6 +22,7 @@
#ifndef __OVIRT_PRIVATE_H__
#define __OVIRT_PRIVATE_H__
+#include <govirt/ovirt-api-private.h>
#include <govirt/ovirt-collection-private.h>
#include <govirt/ovirt-enum-types-private.h>
#include <govirt/ovirt-proxy-private.h>
diff --git a/govirt/govirt.h b/govirt/govirt.h
index 5cd661b..c4b1bbe 100644
--- a/govirt/govirt.h
+++ b/govirt/govirt.h
@@ -23,6 +23,7 @@
#define __OVIRT_H__
#include <govirt/ovirt-enum-types.h>
+#include <govirt/ovirt-api.h>
#include <govirt/ovirt-collection.h>
#include <govirt/ovirt-error.h>
#include <govirt/ovirt-proxy.h>
diff --git a/govirt/govirt.sym b/govirt/govirt.sym
index ec4a8c4..4c836bd 100644
--- a/govirt/govirt.sym
+++ b/govirt/govirt.sym
@@ -50,6 +50,9 @@ GOVIRT_0.2.0 {
};
GOVIRT_0.2.1 {
+ ovirt_api_get_type;
+ ovirt_api_new;
+
ovirt_collection_fetch;
ovirt_collection_fetch_async;
ovirt_collection_fetch_finish;
diff --git a/govirt/ovirt-api-private.h b/govirt/ovirt-api-private.h
new file mode 100644
index 0000000..aa47c85
--- /dev/null
+++ b/govirt/ovirt-api-private.h
@@ -0,0 +1,35 @@
+
+/*
+ * ovirt-api-private.h: oVirt API entry point private header
+ *
+ * Copyright (C) 2012, 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Christophe Fergeau <cfergeau redhat com>
+ */
+#ifndef __OVIRT_API_PRIVATE_H__
+#define __OVIRT_API_PRIVATE_H__
+
+#include <ovirt-api.h>
+#include <rest/rest-xml-node.h>
+
+G_BEGIN_DECLS
+
+OvirtApi *ovirt_api_new_from_xml(RestXmlNode *node, GError **error);
+
+G_END_DECLS
+
+#endif /* __OVIRT_API_PRIVATE_H__ */
diff --git a/govirt/ovirt-api.c b/govirt/ovirt-api.c
new file mode 100644
index 0000000..cb3048b
--- /dev/null
+++ b/govirt/ovirt-api.c
@@ -0,0 +1,90 @@
+/*
+ * ovirt-api.c: oVirt API entry point
+ *
+ * Copyright (C) 2012, 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Christophe Fergeau <cfergeau redhat com>
+ */
+
+#include <config.h>
+
+#include "ovirt-enum-types.h"
+#include "ovirt-error.h"
+#include "ovirt-proxy.h"
+#include "ovirt-rest-call.h"
+#include "ovirt-api.h"
+#include "govirt-private.h"
+
+#include <rest/rest-xml-node.h>
+#include <rest/rest-xml-parser.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define OVIRT_API_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_API, OvirtApiPrivate))
+
+
+struct _OvirtApiPrivate {
+ gboolean unused;
+};
+
+
+G_DEFINE_TYPE(OvirtApi, ovirt_api, OVIRT_TYPE_RESOURCE);
+
+
+static gboolean ovirt_api_init_from_xml(OvirtResource *resource,
+ RestXmlNode *node,
+ GError **error)
+{
+ OvirtResourceClass *parent_class;
+#if 0
+ gboolean parsed_ok;
+
+ parsed_ok = ovirt_api_refresh_from_xml(OVIRT_API(resource), node);
+ if (!parsed_ok) {
+ return FALSE;
+ }
+#endif
+ parent_class = OVIRT_RESOURCE_CLASS(ovirt_api_parent_class);
+
+ return parent_class->init_from_xml(resource, node, error);
+}
+
+static void ovirt_api_class_init(OvirtApiClass *klass)
+{
+ OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
+
+ g_type_class_add_private(klass, sizeof(OvirtApiPrivate));
+
+ resource_class->init_from_xml = ovirt_api_init_from_xml;
+}
+
+static void ovirt_api_init(G_GNUC_UNUSED OvirtApi *api)
+{
+ api->priv = OVIRT_API_GET_PRIVATE(api);
+}
+
+OvirtApi *ovirt_api_new_from_xml(RestXmlNode *node, GError **error)
+{
+ return OVIRT_API(g_initable_new(OVIRT_TYPE_API, NULL, error,
+ "xml-node", node, NULL));
+}
+
+OvirtApi *ovirt_api_new(void)
+{
+ return OVIRT_API(g_initable_new(OVIRT_TYPE_API, NULL, NULL, NULL));
+}
diff --git a/govirt/ovirt-api.h b/govirt/ovirt-api.h
new file mode 100644
index 0000000..d28328a
--- /dev/null
+++ b/govirt/ovirt-api.h
@@ -0,0 +1,65 @@
+/*
+ * ovirt-api.h: oVirt API entry point
+ *
+ * Copyright (C) 2012, 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Christophe Fergeau <cfergeau redhat com>
+ */
+#ifndef __OVIRT_API_H__
+#define __OVIRT_API_H__
+
+#include <gio/gio.h>
+#include <glib-object.h>
+#include <govirt/ovirt-resource.h>
+#include <govirt/ovirt-types.h>
+
+G_BEGIN_DECLS
+
+#define OVIRT_TYPE_API (ovirt_api_get_type ())
+#define OVIRT_API(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OVIRT_TYPE_API, OvirtApi))
+#define OVIRT_API_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OVIRT_TYPE_API, OvirtApiClass))
+#define OVIRT_IS_API(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OVIRT_TYPE_API))
+#define OVIRT_IS_API_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_API))
+#define OVIRT_API_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_API, OvirtApiClass))
+
+typedef struct _OvirtApi OvirtApi;
+typedef struct _OvirtApiPrivate OvirtApiPrivate;
+typedef struct _OvirtApiClass OvirtApiClass;
+
+struct _OvirtApi
+{
+ OvirtResource parent;
+
+ OvirtApiPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _OvirtApiClass
+{
+ OvirtResourceClass parent_class;
+
+ gpointer padding[20];
+};
+
+
+GType ovirt_api_get_type(void);
+OvirtApi *ovirt_api_new(void);
+
+G_END_DECLS
+
+#endif /* __OVIRT_API_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]