[packagekit] packagekit: Branch 'master' - 4 commits

Richard Hughes hughsient at kemper.freedesktop.org
Sat Oct 13 16:21:07 PDT 2007


 TODO                     |    8 +-
 libpackagekit/pk-enum.c  |    3 +
 libpackagekit/pk-enum.h  |    3 +
 policy/packagekit.policy |    9 +++
 src/pk-engine.c          |  130 +++++++++++++++++++++++++++++++++++++++++++++++
 src/pk-engine.h          |   16 +++++
 src/pk-interface.xml     |   22 +++++++
 src/pk-marshal.list      |    1 
 8 files changed, 188 insertions(+), 4 deletions(-)

New commits:
commit 989edd81845b8bb71cc22dc8d359e44fb68bb6d4
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 14 00:19:40 2007 +0100

    add the initial daemon bits for the repo management

diff --git a/TODO b/TODO
index f1a934b..6ae5561 100644
--- a/TODO
+++ b/TODO
@@ -4,9 +4,10 @@ Order of no particular importance:
 TimeRemaining()
 
 *** the backends will have repo controls ***
-a(s=rid,s=description)=GetRepoList()
-RepoEnable(s=rid,s=value)
-RepoSetData(s=rid,s=data,s=value)
+Add the callback and methods in PkBackend
+Add details to the help file
+Add stubs in the backends
+Add methods and signals to the client library
 
 *** Prepare download to refresh system ***
 Either use a flag or a new method. I'm not sure which yet.
diff --git a/src/pk-engine.c b/src/pk-engine.c
index e5c66a1..30f8bac 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -89,6 +89,7 @@ enum {
 	PK_ENGINE_DESCRIPTION,
 	PK_ENGINE_ALLOW_INTERRUPT,
 	PK_ENGINE_LOCKED,
+	PK_ENGINE_REPO_DETAIL,
 	PK_ENGINE_LAST_SIGNAL
 };
 
@@ -1722,6 +1723,129 @@ pk_engine_update_package (PkEngine *engine, const gchar *tid, const gchar *packa
 }
 
 /**
+ * pk_engine_get_repo_list:
+ **/
+gboolean
+pk_engine_get_repo_list (PkEngine *engine, const gchar *tid, GError **error)
+{
+	gboolean ret;
+	PkTransactionItem *item;
+
+	g_return_val_if_fail (engine != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+
+	/* find pre-requested transaction id */
+	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
+	if (item == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "transaction_id '%s' not found", tid);
+		return FALSE;
+	}
+
+	/* create a new backend */
+	item->backend = pk_engine_new_backend (engine);
+	if (item->backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
+	//ret = pk_backend_get_repo_list (item->backend);
+	ret = FALSE;
+	if (ret == FALSE) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+			     "Operation not yet supported by backend");
+		pk_engine_item_delete (engine, item);
+		return FALSE;
+	}
+	pk_engine_item_add (engine, item);
+	return TRUE;
+}
+
+/**
+ * pk_engine_repo_enable:
+ **/
+void
+pk_engine_repo_enable (PkEngine	*engine, const gchar *rid, gboolean enabled,
+		       DBusGMethodInvocation *context, GError **old_error)
+{
+	gboolean ret;
+	GError *error;
+	PkBackend *backend;
+
+	g_return_if_fail (engine != NULL);
+	g_return_if_fail (PK_IS_ENGINE (engine));
+
+	/* check with PolicyKit if the action is allowed from this client - if not, set an error */
+	ret = pk_engine_action_is_allowed (engine, context, "org.freedesktop.packagekit.repo-change", &error);
+	if (ret == FALSE) {
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
+	/* create a new backend */
+	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+				     "Operation not yet supported by backend");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
+	//ret = pk_backend_repo_enable (item->backend, rid, enabled);
+	ret = FALSE;
+	if (ret == FALSE) {
+		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+				     "Operation not yet supported by backend");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+	dbus_g_method_return (context);
+}
+
+/**
+ * pk_engine_repo_set_data:
+ **/
+void
+pk_engine_repo_set_data (PkEngine *engine, const gchar *rid,
+			 const gchar *parameter, const gchar *value,
+			 DBusGMethodInvocation *context, GError **old_error)
+{
+	gboolean ret;
+	GError *error;
+	PkBackend *backend;
+
+	g_return_if_fail (engine != NULL);
+	g_return_if_fail (PK_IS_ENGINE (engine));
+
+	/* check with PolicyKit if the action is allowed from this client - if not, set an error */
+	ret = pk_engine_action_is_allowed (engine, context, "org.freedesktop.packagekit.repo-change", &error);
+	if (ret == FALSE) {
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
+	/* create a new backend */
+	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+				     "Operation not yet supported by backend");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
+	//ret = pk_backend_repo_set_data (item->backend, rid, parameter, value);
+	ret = FALSE;
+	if (ret == FALSE) {
+		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+				     "Operation not yet supported by backend");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+	dbus_g_method_return (context);
+}
+
+/**
  * pk_engine_get_transaction_list:
  **/
 gboolean
@@ -2196,6 +2320,12 @@ pk_engine_class_init (PkEngineClass *klass)
 			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_BOOL_STRING_UINT_STRING,
 			      G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_STRING,
 			      G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
+	signals [PK_ENGINE_REPO_DETAIL] =
+		g_signal_new ("repo-detail",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_BOOL,
+			      G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING,
+			      G_TYPE_STRING, G_TYPE_BOOLEAN);
 
 	g_type_class_add_private (klass, sizeof (PkEnginePrivate));
 }
diff --git a/src/pk-engine.h b/src/pk-engine.h
index b3e5de8..15d3507 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -205,6 +205,22 @@ gboolean	 pk_engine_get_package			(PkEngine	*engine,
 							 gchar		**package,
 							 GError		**error);
 
+/* repo stuff */
+gboolean	 pk_engine_get_repo_list		(PkEngine	*engine,
+							 const gchar	*tid,
+							 GError		**error);
+void		 pk_engine_repo_enable			(PkEngine	*engine,
+							 const gchar	*rid,
+							 gboolean	 enabled,
+							 DBusGMethodInvocation *context,
+							 GError		**error);
+void		 pk_engine_repo_set_data		(PkEngine	*engine,
+							 const gchar	*rid,
+							 const gchar	*parameter,
+							 const gchar	*value,
+							 DBusGMethodInvocation *context,
+							 GError		**error);
+
 G_END_DECLS
 
 #endif /* __PK_ENGINE_H */
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 1d8e63e..f8fa632 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -149,6 +149,8 @@
     <signal name="Locked">
       <arg type="b" name="is_locked" direction="out"/>
     </signal>
+
+    <!-- Callbacks from repositories -->
     <signal name="RepoSignatureRequired">
       <arg type="s" name="tid" direction="out"/>
       <arg type="s" name="repository_name" direction="out"/>
@@ -160,6 +162,26 @@
       <arg type="s" name="type" direction="out"/> <!-- 'gpg', for now -->
     </signal>
 
+    <!-- Repository stuff -->
+    <method name="GetRepoList">
+      <arg type="s" name="tid" direction="in"/>
+    </method>
+    <method name="RepoEnable">
+      <arg type="s" name="rid" direction="in"/>
+      <arg type="b" name="enabled" direction="in"/>
+    </method>
+    <method name="RepoSetData">
+      <arg type="s" name="rid" direction="in"/>
+      <arg type="s" name="parameter" direction="in"/>
+      <arg type="s" name="value" direction="in"/>
+    </method>
+    <signal name="RepoDetail">
+      <arg type="s" name="tid" direction="out"/>
+      <arg type="s" name="rid" direction="out"/>
+      <arg type="s" name="description" direction="out"/>
+      <arg type="b" name="enabled" direction="out"/>
+    </signal>
+
     <!-- Do things or query transactions -->
     <method name="Cancel"> <!-- might not succeed for all manner or reasons -->
       <!-- throws NoSuchTransaction -->
diff --git a/src/pk-marshal.list b/src/pk-marshal.list
index e5b4f1e..45d2cd8 100644
--- a/src/pk-marshal.list
+++ b/src/pk-marshal.list
@@ -17,6 +17,7 @@ VOID:STRING,STRING,STRING,STRING,STRING,STRING,STRING
 VOID:STRING,STRING,UINT,STRING,STRING,UINT64,STRING
 VOID:STRING,STRING,STRING,STRING,STRING,STRING,UINT64,STRING
 VOID:STRING,STRING,STRING,STRING,STRING,STRING,UINT
+VOID:STRING,STRING,STRING,BOOL
 VOID:STRING,UINT,STRING,STRING
 VOID:STRING,STRING,UINT,UINT,UINT
 VOID:STRING,STRING,BOOL,UINT,UINT,STRING
commit 8be0d237f467a43aa2a200868abc691aee0c9c86
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 14 00:12:51 2007 +0100

    add the enumerated types for the new repo stuff

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index ecb5778..c3baab6 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -76,6 +76,9 @@ static PkTaskEnumMatch task_role[] = {
 	{PK_ROLE_ENUM_INSTALL_FILE,		"install-file"},
 	{PK_ROLE_ENUM_UPDATE_PACKAGE,		"update-package"},
 	{PK_ROLE_ENUM_UPDATE_SYSTEM,		"update-system"},
+	{PK_ROLE_ENUM_GET_REPO_LIST,		"get-repo-list"},
+	{PK_ROLE_ENUM_REPO_ENABLE,		"repo-enable"},
+	{PK_ROLE_ENUM_REPO_SET_DATA,		"repo-set-data"},
 	{0, NULL},
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index bcdc934..4a5376c 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -47,6 +47,9 @@ typedef enum {
 	PK_ROLE_ENUM_INSTALL_PACKAGE,
 	PK_ROLE_ENUM_INSTALL_FILE,
 	PK_ROLE_ENUM_UPDATE_PACKAGE,
+	PK_ROLE_ENUM_GET_REPO_LIST,
+	PK_ROLE_ENUM_REPO_ENABLE,
+	PK_ROLE_ENUM_REPO_SET_DATA,
 	PK_ROLE_ENUM_UNKNOWN
 } PkRoleEnum;
 
commit 3822842ee69bb85b024cf541e94a0cedf18317a5
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 14 00:04:24 2007 +0100

    add the repo changing policy

diff --git a/policy/packagekit.policy b/policy/packagekit.policy
index d41fc3b..10faa24 100644
--- a/policy/packagekit.policy
+++ b/policy/packagekit.policy
@@ -63,5 +63,14 @@ Copyright (c) 2007 Richard Hughes <richard at hughsie.com>
     </defaults>
   </action>
 
+  <action id="org.freedesktop.packagekit.repo-change">
+    <description>Change repository parameters</description>
+    <message>System policy prevents changing repository parameters</message>
+    <defaults>
+      <allow_inactive>no</allow_inactive>
+      <allow_active>auth_admin_keep_always</allow_active>
+    </defaults>
+  </action>
+
 </policyconfig>
 
commit e0901bf3728a7c548385d37f281aa19cf42a15f5
Author: Richard Hughes <richard at hughsie.com>
Date:   Sat Oct 13 22:03:14 2007 +0100

    update TODO

diff --git a/TODO b/TODO
index 43a453f..f1a934b 100644
--- a/TODO
+++ b/TODO
@@ -19,6 +19,5 @@ Have different permissions for signed and unsigned repos.
 
 *** Handle rollbacks for select backends ***
 To do rollbacks sanely in PK we need a few things:
- * emit internal signal for SetTransactionData
  * allow transaction data to be changed in _db
 



More information about the PackageKit mailing list