diff --git a/lib/Makefile.am.inc b/lib/Makefile.am.inc
index 837eed0da..071fdcdf2 100644
--- a/lib/Makefile.am.inc
+++ b/lib/Makefile.am.inc
@@ -6,6 +6,7 @@ public_headers = \
lib/xdg-app.h \
lib/xdg-app-ref.h \
lib/xdg-app-installed-ref.h \
+ lib/xdg-app-remote-ref.h \
lib/xdg-app-installation.h \
lib/xdg-app-remote.h \
lib/xdg-app-version-macros.h \
@@ -43,6 +44,7 @@ sources = \
lib/xdg-app-ref.c \
lib/xdg-app-installed-ref.c \
lib/xdg-app-installed-ref-private.h \
+ lib/xdg-app-remote-ref.c \
lib/xdg-app-remote-private.h \
lib/xdg-app-remote.c \
lib/xdg-app-installation.c \
diff --git a/lib/test-lib.c b/lib/test-lib.c
index ef0f60c1b..86e8532fb 100644
--- a/lib/test-lib.c
+++ b/lib/test-lib.c
@@ -5,7 +5,7 @@ main (int argc, char *argv[])
{
XdgAppInstallation *installation;
XdgAppInstalledRef **apps;
- XdgAppRef **refs;
+ XdgAppRemoteRef **refs;
XdgAppInstalledRef *app1;
XdgAppInstalledRef *app2;
XdgAppInstalledRef **runtimes;
@@ -98,11 +98,11 @@ main (int argc, char *argv[])
for (j = 0; refs[j] != NULL; j++)
{
g_print ("%d %s %s %s %s\n",
- xdg_app_ref_get_kind (refs[j]),
- xdg_app_ref_get_name (refs[j]),
- xdg_app_ref_get_arch (refs[j]),
- xdg_app_ref_get_version (refs[j]),
- xdg_app_ref_get_commit (refs[j]));
+ xdg_app_ref_get_kind (XDG_APP_REF(refs[j])),
+ xdg_app_ref_get_name (XDG_APP_REF(refs[j])),
+ xdg_app_ref_get_arch (XDG_APP_REF(refs[j])),
+ xdg_app_ref_get_version (XDG_APP_REF(refs[j])),
+ xdg_app_ref_get_commit (XDG_APP_REF(refs[j])));
}
}
}
diff --git a/lib/xdg-app-remote-ref-private.h b/lib/xdg-app-remote-ref-private.h
new file mode 100644
index 000000000..b20e62a19
--- /dev/null
+++ b/lib/xdg-app-remote-ref-private.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2015 Red Hat, Inc
+ *
+ * This program 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 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 .
+ *
+ * Authors:
+ * Alexander Larsson
+ */
+
+#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION)
+#error "Only can be included remote_refectly."
+#endif
+
+#ifndef __XDG_APP_REMOTE_REF_PRIVATE_H__
+#define __XDG_APP_REMOTE_REF_PRIVATE_H__
+
+#include
+
+XdgAppRemoteRef *xdg_app_remote_ref_new (const char *full_ref,
+ const char *commit);
+
+#endif /* __XDG_APP_REMOTE_REF_PRIVATE_H__ */
diff --git a/lib/xdg-app-remote-ref.c b/lib/xdg-app-remote-ref.c
new file mode 100644
index 000000000..0c4b0d867
--- /dev/null
+++ b/lib/xdg-app-remote-ref.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright © 2015 Red Hat, Inc
+ *
+ * This program 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 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 .
+ *
+ * Authors:
+ * Alexander Larsson
+ */
+
+#include "config.h"
+
+#include
+
+#include "xdg-app-remote-ref.h"
+#include "xdg-app-enum-types.h"
+#include "xdg-app-error.h"
+
+typedef struct _XdgAppRemoteRefPrivate XdgAppRemoteRefPrivate;
+
+struct _XdgAppRemoteRefPrivate
+{
+ int dummy;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (XdgAppRemoteRef, xdg_app_remote_ref, XDG_APP_TYPE_REF)
+
+enum {
+ PROP_0,
+
+};
+
+static void
+xdg_app_remote_ref_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (xdg_app_remote_ref_parent_class)->finalize (object);
+}
+
+static void
+xdg_app_remote_ref_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+ {
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+xdg_app_remote_ref_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+ {
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+xdg_app_remote_ref_class_init (XdgAppRemoteRefClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = xdg_app_remote_ref_get_property;
+ object_class->set_property = xdg_app_remote_ref_set_property;
+ object_class->finalize = xdg_app_remote_ref_finalize;
+}
+
+static void
+xdg_app_remote_ref_init (XdgAppRemoteRef *self)
+{
+}
+
+XdgAppRemoteRef *
+xdg_app_remote_ref_new (const char *full_ref,
+ const char *commit)
+{
+ XdgAppRefKind kind = XDG_APP_REF_KIND_APP;
+ g_auto(GStrv) parts = NULL;
+
+ parts = g_strsplit (full_ref, "/", -1);
+
+ if (strcmp (parts[0], "app") != 0)
+ kind = XDG_APP_REF_KIND_RUNTIME;
+
+ return g_object_new (XDG_APP_TYPE_REMOTE_REF,
+ "kind", kind,
+ "name", parts[1],
+ "arch", parts[2],
+ "version", parts[3],
+ "commit", commit,
+ NULL);
+}
diff --git a/lib/xdg-app-remote-ref.h b/lib/xdg-app-remote-ref.h
new file mode 100644
index 000000000..faf3d404b
--- /dev/null
+++ b/lib/xdg-app-remote-ref.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2015 Red Hat, Inc
+ *
+ * This program 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 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 .
+ *
+ * Authors:
+ * Alexander Larsson
+ */
+
+#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION)
+#error "Only can be included remote_refectly."
+#endif
+
+#ifndef __XDG_APP_REMOTE_REF_H__
+#define __XDG_APP_REMOTE_REF_H__
+
+typedef struct XdgAppRemoteRef XdgAppRemoteRef;
+
+#include
+#include
+
+#define XDG_APP_TYPE_REMOTE_REF xdg_app_remote_ref_get_type()
+#define XDG_APP_REMOTE_REF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDG_APP_TYPE_REMOTE_REF, XdgAppRemoteRef))
+#define XDG_APP_IS_REMOTE_REF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XDG_APP_TYPE_REMOTE_REF))
+
+XDG_APP_EXTERN GType xdg_app_remote_ref_get_type (void);
+
+struct XdgAppRemoteRef {
+ XdgAppRef parent;
+};
+
+typedef struct {
+ XdgAppRefClass parent_class;
+} XdgAppRemoteRefClass;
+
+#if !GLIB_CHECK_VERSION(2, 43, 4)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppRemoteRef, g_object_unref)
+#endif
+
+#endif /* __XDG_APP_REMOTE_REF_H__ */
diff --git a/lib/xdg-app-remote.c b/lib/xdg-app-remote.c
index 9ff974676..6fb559a68 100644
--- a/lib/xdg-app-remote.c
+++ b/lib/xdg-app-remote.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "xdg-app-remote-private.h"
+#include "xdg-app-remote-ref-private.h"
#include "xdg-app-enum-types.h"
#include "xdg-app-utils.h"
@@ -170,28 +171,6 @@ xdg_app_remote_get_gpg_verify (XdgAppRemote *self)
return FALSE;
}
-static XdgAppRef *
-get_ref (XdgAppRemote *self,
- const char *full_ref,
- const char *commit)
-{
- g_auto(GStrv) parts = NULL;
- XdgAppRefKind kind = XDG_APP_REF_KIND_APP;
-
- parts = g_strsplit (full_ref, "/", -1);
-
- if (strcmp (parts[0], "app") != 0)
- kind = XDG_APP_REF_KIND_RUNTIME;
-
- return g_object_new (XDG_APP_TYPE_REF,
- "kind", kind,
- "name", parts[1],
- "arch", parts[2],
- "version", parts[3],
- "commit", commit,
- NULL);
-}
-
/**
* xdg_app_remote_list_refs:
* @self: a #XdgAppRemove
@@ -201,9 +180,9 @@ get_ref (XdgAppRemote *self,
* Lists all the refs in a #XdgAppRemote.
*
* Returns: (transfer full) (array zero-terminated=1): a %NULL-terminated array
- * of #XdgAppRef instances
+ * of #XdgAppRemoteRef instances
*/
-XdgAppRef **
+XdgAppRemoteRef **
xdg_app_remote_list_refs (XdgAppRemote *self,
GCancellable *cancellable,
GError **error)
@@ -229,11 +208,11 @@ xdg_app_remote_list_refs (XdgAppRemote *self,
const char *checksum = value;
g_ptr_array_add (refs,
- get_ref (self, refspec, checksum));
+ xdg_app_remote_ref_new (refspec, checksum));
}
g_ptr_array_add (refs, NULL);
- return (XdgAppRef **)g_ptr_array_free (g_steal_pointer (&refs), FALSE);
+ return (XdgAppRemoteRef **)g_ptr_array_free (g_steal_pointer (&refs), FALSE);
}
diff --git a/lib/xdg-app-remote.h b/lib/xdg-app-remote.h
index 510cab55b..a74297d70 100644
--- a/lib/xdg-app-remote.h
+++ b/lib/xdg-app-remote.h
@@ -28,7 +28,7 @@
typedef struct XdgAppRemote XdgAppRemote;
#include
-#include
+#include
#define XDG_APP_TYPE_REMOTE xdg_app_remote_get_type()
#define XDG_APP_REMOTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDG_APP_TYPE_REMOTE, XdgAppRemote))
@@ -54,7 +54,7 @@ XDG_APP_EXTERN char * xdg_app_remote_get_title (XdgAppRemote *self);
XDG_APP_EXTERN gboolean xdg_app_remote_get_gpg_verify (XdgAppRemote *self);
XDG_APP_EXTERN gboolean xdg_app_remote_get_noenumerate (XdgAppRemote *self);
-XDG_APP_EXTERN XdgAppRef ** xdg_app_remote_list_refs (XdgAppRemote *self,
+XDG_APP_EXTERN XdgAppRemoteRef **xdg_app_remote_list_refs (XdgAppRemote *self,
GCancellable *cancellable,
GError **error);
diff --git a/lib/xdg-app.h b/lib/xdg-app.h
index 72fa1f981..c039617db 100644
--- a/lib/xdg-app.h
+++ b/lib/xdg-app.h
@@ -29,6 +29,7 @@
#include
#include
#include
+#include
#include
#include