summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2017-09-20 10:54:27 +1200
committerRobert Ancell <robert.ancell@canonical.com>2017-09-20 10:54:27 +1200
commit972622609bd5352ff2478029379c53fc784cd246 (patch)
tree1d4f9d8d8f04e2f00c7f2bb636985f2b21dcc567
parent7a112f9b60b460120151fc4651c067c117f1b97a (diff)
packagekit-glib2: Add getters for PkEulaRequired
-rw-r--r--docs/api/PackageKit-docs.sgml4
-rw-r--r--docs/api/PackageKit-sections.txt4
-rw-r--r--lib/packagekit-glib2/pk-eula-required.c68
-rw-r--r--lib/packagekit-glib2/pk-eula-required.h4
-rw-r--r--lib/packagekit-glib2/pk-task-text.c24
-rw-r--r--lib/packagekit-glib2/pk-task.c6
-rw-r--r--src/pk-transaction.c18
7 files changed, 96 insertions, 32 deletions
diff --git a/docs/api/PackageKit-docs.sgml b/docs/api/PackageKit-docs.sgml
index b257bb18f..739ef70a3 100644
--- a/docs/api/PackageKit-docs.sgml
+++ b/docs/api/PackageKit-docs.sgml
@@ -228,5 +228,9 @@
<title>Index of new symbols in 1.1.2</title>
<xi:include href="xml/api-index-1.1.2.xml"/>
</index>
+ <index id="api-index-1-1-8">
+ <title>Index of new symbols in 1.1.8</title>
+ <xi:include href="xml/api-index-1.1.8.xml"/>
+ </index>
</book>
diff --git a/docs/api/PackageKit-sections.txt b/docs/api/PackageKit-sections.txt
index 62725cbf4..ead052f92 100644
--- a/docs/api/PackageKit-sections.txt
+++ b/docs/api/PackageKit-sections.txt
@@ -433,6 +433,10 @@ pk_error_get_type
<FILE>pk-eula-required</FILE>
<TITLE>PkEulaRequired</TITLE>
pk_eula_required_new
+pk_eula_required_get_eula_id
+pk_eula_required_get_license_agreement
+pk_eula_required_get_package_id
+pk_eula_required_get_vendor_name
<SUBSECTION Standard>
PK_EULA_REQUIRED
PK_EULA_REQUIRED_CLASS
diff --git a/lib/packagekit-glib2/pk-eula-required.c b/lib/packagekit-glib2/pk-eula-required.c
index 03cc4b0b0..3dfb8dfc3 100644
--- a/lib/packagekit-glib2/pk-eula-required.c
+++ b/lib/packagekit-glib2/pk-eula-required.c
@@ -62,6 +62,74 @@ enum {
G_DEFINE_TYPE (PkEulaRequired, pk_eula_required, PK_TYPE_SOURCE)
+/**
+ * pk_eula_required_get_eula_id:
+ * @eula_required: a valid #PkEulaRequired instance.
+ *
+ * Get the ID for this EULA
+ *
+ * Return value: an ID
+ *
+ * Since: 1.1.8
+ */
+const gchar *
+pk_eula_required_get_eula_id (PkEulaRequired *eula_required)
+{
+ g_return_val_if_fail (PK_IS_EULA_REQUIRED (eula_required), NULL);
+ return eula_required->priv->eula_id;
+}
+
+/**
+ * pk_eula_required_get_package_id:
+ * @eula_required: a valid #PkEulaRequired instance.
+ *
+ * Get the PackageID this EULA is for
+ *
+ * Return value: a PackageID
+ *
+ * Since: 1.1.8
+ */
+const gchar *
+pk_eula_required_get_package_id (PkEulaRequired *eula_required)
+{
+ g_return_val_if_fail (PK_IS_EULA_REQUIRED (eula_required), NULL);
+ return eula_required->priv->package_id;
+}
+
+/**
+ * pk_eula_required_get_vendor_name:
+ * @eula_required: a valid #PkEulaRequired instance.
+ *
+ * Get the vendor this EULA is from.
+ *
+ * Return value: license vendor name
+ *
+ * Since: 1.1.8
+ */
+const gchar *
+pk_eula_required_get_vendor_name (PkEulaRequired *eula_required)
+{
+ g_return_val_if_fail (PK_IS_EULA_REQUIRED (eula_required), NULL);
+ return eula_required->priv->vendor_name;
+}
+
+/**
+ * pk_eula_required_get_license_agreement:
+ * @eula_required: a valid #PkEulaRequired instance.
+ *
+ * Get the text of the license agreement.
+ *
+ * Return value: license agreement text
+ *
+ * Since: 1.1.8
+ **/
+const gchar *
+pk_eula_required_get_license_agreement (PkEulaRequired *eula_required)
+{
+ g_return_val_if_fail (PK_IS_EULA_REQUIRED (eula_required), NULL);
+ return eula_required->priv->license_agreement;
+}
+
/*
* pk_eula_required_get_property:
**/
diff --git a/lib/packagekit-glib2/pk-eula-required.h b/lib/packagekit-glib2/pk-eula-required.h
index aa7475a4f..cdf58d6b2 100644
--- a/lib/packagekit-glib2/pk-eula-required.h
+++ b/lib/packagekit-glib2/pk-eula-required.h
@@ -66,6 +66,10 @@ struct _PkEulaRequiredClass
GType pk_eula_required_get_type (void);
PkEulaRequired *pk_eula_required_new (void);
+const gchar *pk_eula_required_get_eula_id (PkEulaRequired *eula_required);
+const gchar *pk_eula_required_get_package_id (PkEulaRequired *eula_required);
+const gchar *pk_eula_required_get_vendor_name (PkEulaRequired *eula_required);
+const gchar *pk_eula_required_get_license_agreement (PkEulaRequired *eula_required);
G_END_DECLS
diff --git a/lib/packagekit-glib2/pk-task-text.c b/lib/packagekit-glib2/pk-task-text.c
index 656c5e297..0fc595266 100644
--- a/lib/packagekit-glib2/pk-task-text.c
+++ b/lib/packagekit-glib2/pk-task-text.c
@@ -171,12 +171,7 @@ pk_task_text_eula_question (PkTask *task, guint request, PkResults *results)
{
guint i;
gboolean ret;
- gchar *printable = NULL;
GPtrArray *array;
- PkEulaRequired *item;
- gchar *package_id;
- gchar *vendor_name;
- gchar *license_agreement;
PkTaskTextPrivate *priv = PK_TASK_TEXT(task)->priv;
/* set some user data, for no reason */
@@ -188,15 +183,13 @@ pk_task_text_eula_question (PkTask *task, guint request, PkResults *results)
/* get data */
array = pk_results_get_eula_required_array (results);
for (i = 0; i < array->len; i++) {
+ PkEulaRequired *item;
+ g_autofree gchar *printable = NULL;
+
item = g_ptr_array_index (array, i);
- g_object_get (item,
- "package-id", &package_id,
- "vendor-name", &vendor_name,
- "license-agreement", &license_agreement,
- NULL);
/* create printable */
- printable = pk_package_id_to_printable (package_id);
+ printable = pk_package_id_to_printable (pk_eula_required_get_package_id (item));
/* TRANSLATORS: this is another name for a software licence that has to be read before installing */
g_print ("%s\n", _("End user licence agreement required"));
@@ -205,15 +198,10 @@ pk_task_text_eula_question (PkTask *task, guint request, PkResults *results)
g_print (" %s: %s\n", _("Package"), printable);
/* TRANSLATORS: the vendor (e.g. vmware) that is providing the EULA */
- g_print (" %s: %s\n", _("Vendor"), vendor_name);
+ g_print (" %s: %s\n", _("Vendor"), pk_eula_required_get_vendor_name (item));
/* TRANSLATORS: the EULA text itself (long and boring) */
- g_print (" %s: %s\n", _("Agreement"), license_agreement);
-
- g_free (printable);
- g_free (package_id);
- g_free (vendor_name);
- g_free (license_agreement);
+ g_print (" %s: %s\n", _("Agreement"), pk_eula_required_get_license_agreement (item));
}
/* TRANSLATORS: ask the user if they've read and accepted the EULA */
diff --git a/lib/packagekit-glib2/pk-task.c b/lib/packagekit-glib2/pk-task.c
index ec8342c0a..83ae7de6c 100644
--- a/lib/packagekit-glib2/pk-task.c
+++ b/lib/packagekit-glib2/pk-task.c
@@ -652,7 +652,7 @@ pk_task_accept_eulas (PkTaskState *state)
{
PkEulaRequired *item;
g_autoptr(GError) error = NULL;
- g_autofree gchar *eula_id = NULL;
+ const gchar *eula_id;
g_autoptr(GPtrArray) array = NULL;
/* get results */
@@ -677,9 +677,7 @@ pk_task_accept_eulas (PkTaskState *state)
/* get first item of data */
item = g_ptr_array_index (array, 0);
- g_object_get (item,
- "eula-id", &eula_id,
- NULL);
+ eula_id = pk_eula_required_get_eula_id (item);
/* do new async method */
pk_client_accept_eula_async (PK_CLIENT(state->task), eula_id,
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 859f66f64..8fb509206 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -1411,10 +1411,10 @@ pk_transaction_eula_required_cb (PkBackend *backend,
PkEulaRequired *item,
PkTransaction *transaction)
{
- g_autofree gchar *eula_id = NULL;
- g_autofree gchar *package_id = NULL;
- g_autofree gchar *vendor_name = NULL;
- g_autofree gchar *license_agreement = NULL;
+ const gchar *eula_id;
+ const gchar *package_id;
+ const gchar *vendor_name;
+ const gchar *license_agreement;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -1423,12 +1423,10 @@ pk_transaction_eula_required_cb (PkBackend *backend,
pk_results_add_eula_required (transaction->priv->results, item);
/* get data */
- g_object_get (item,
- "eula-id", &eula_id,
- "package-id", &package_id,
- "vendor-name", &vendor_name,
- "license-agreement", &license_agreement,
- NULL);
+ eula_id = pk_eula_required_get_eula_id (item);
+ package_id = pk_eula_required_get_package_id (item);
+ vendor_name = pk_eula_required_get_vendor_name (item);
+ license_agreement = pk_eula_required_get_license_agreement (item);
/* emit */
g_debug ("emitting eula-required %s, %s, %s, %s",