[packagekit] [RFC] pk_backend_python_repo_set_data
S.Çağlar Onur
caglar at pardus.org.tr
Fri Oct 26 15:41:31 PDT 2007
Hi;
Following patch adds repo-set-data to Python Backend and adds set-repo-data action to pkcon. Could you please review and give ACK/NACK?
If its OK i'll also have a PiSi backend modifications which implements add-repo/remove-repo
backends/pisi/helpers/Makefile.am | 1 +
backends/pisi/helpers/pisiBackend.py | 26 ++++++++++++++++++++++++++
backends/pisi/pk-backend-pisi.c | 2 +-
3 files changed, 28 insertions(+), 1 deletions(-)
client/pk-console.c | 13 +++++++++++++
python/packagekit/backend.py | 8 ++++++++
src/pk-backend-python.c | 11 +++++++++++
src/pk-backend-python.h | 5 +++++
4 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/client/pk-console.c b/client/pk-console.c
index 3b223be..88112e1 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -321,6 +321,7 @@ const gchar *summary =
" get repos\n"
" enable-repo <repo_id>\n"
" disable-repo <repo_id>\n"
+ " set-repo-data <repo_id> <parameter> <value>\n"
"\n"
" package_id is typically gimp;2:2.4.0-0.rc1.1.fc8;i386;development";
@@ -557,6 +558,7 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], gboolean
const gchar *mode;
const gchar *value = NULL;
const gchar *details = NULL;
+ const gchar *parameter = NULL;
gboolean wait = FALSE;
PkEnumList *elist;
@@ -567,6 +569,9 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], gboolean
if (argc > 3) {
details = argv[3];
}
+ if (argc > 4) {
+ parameter = argv[4];
+ }
if (strcmp (mode, "search") == 0) {
if (value == NULL) {
@@ -652,6 +657,14 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], gboolean
} else {
wait = pk_client_repo_enable (client, value, FALSE);
}
+
+ } else if (strcmp (mode, "set-repo-data") == 0) {
+ if (value == NULL || details == NULL || parameter == NULL) {
+ g_set_error (error, 0, 0, "you need to specify a repo name/parameter and a value");
+ return FALSE;
+ } else {
+ wait = pk_client_repo_set_data (client, value, details, parameter);
+ }
} else if (strcmp (mode, "get") == 0) {
if (value == NULL) {
g_set_error (error, 0, 0, "you need to specify a get type");
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index a288a84..773e83d 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -344,6 +344,14 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+ def repo_set_data(self, repoid, parameter, value):
+ '''
+ Implement the {backend}-repo-set-data functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+
def get_repo_list(self):
'''
Implement the {backend}-get-repo-list functionality
diff --git a/src/pk-backend-python.c b/src/pk-backend-python.c
index da53c5d..3a37104 100644
--- a/src/pk-backend-python.c
+++ b/src/pk-backend-python.c
@@ -229,3 +229,14 @@ pk_backend_python_repo_enable (PkBackend *backend, const gchar *rid, gboolean en
pk_backend_spawn_helper (backend, "repo-enable.py", rid, "false", NULL);
}
}
+
+/**
+ * pk_backend_python_repo_set_data:
+ */
+void
+pk_backend_python_repo_set_data (PkBackend *backend, const gchar *rid,
+ const gchar *parameter, const gchar *value)
+{
+ g_return_if_fail (backend != NULL);
+ pk_backend_spawn_helper (backend, "repo-set-data.py", rid, parameter, value, NULL);
+}
diff --git a/src/pk-backend-python.h b/src/pk-backend-python.h
index a9901f9..e293507 100644
--- a/src/pk-backend-python.h
+++ b/src/pk-backend-python.h
@@ -83,6 +83,11 @@ void pk_backend_python_repo_enable (PkBackend *backend,
const gchar *rid,
gboolean enabled);
+void pk_backend_python_repo_set_data (PkBackend *backend,
+ const gchar *rid,
+ const gchar *parameter,
+ const gchar *value);
+
G_END_DECLS
#endif /* __PK_BACKEND_PYTHON_H */
Cheers
--
S.Çağlar Onur <caglar at pardus.org.tr>
http://cekirdek.pardus.org.tr/~caglar/
Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
More information about the PackageKit
mailing list