davemds pushed a commit to branch master.

http://git.enlightenment.org/enlightenment/modules/packagekit.git/commit/?id=76442d673ee4d9a42c181b9875eee04ce66a4e9d

commit 76442d673ee4d9a42c181b9875eee04ce66a4e9d
Author: davemds <d...@gurumeditation.it>
Date:   Mon Nov 4 20:54:10 2013 +0100

    And now the module is also compatible with PackageKit 0.7
---
 src/e_mod_packagekit.c | 48 ++++++++++++++++++++++++++++++++++++++++--------
 src/e_mod_packagekit.h |  4 ++++
 2 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/src/e_mod_packagekit.c b/src/e_mod_packagekit.c
index 1a0a3ec..d63f73d 100644
--- a/src/e_mod_packagekit.c
+++ b/src/e_mod_packagekit.c
@@ -209,6 +209,8 @@ signal_cache_finished_cb(void *data, const Eldbus_Message 
*msg)
    Eldbus_Object *obj = eldbus_proxy_object_get(ctxt->transaction);
    E_FREE_FUNC(ctxt->transaction, eldbus_proxy_unref);
    E_FREE_FUNC(obj, eldbus_object_unref);
+
+   packagekit_create_transaction_and_exec(ctxt, packagekit_get_updates);
 }
 
 void
@@ -238,23 +240,31 @@ packagekit_refresh_cache(E_PackageKit_Module_Context 
*ctxt, const char *transact
 static void
 _signal_package_cb(void *data, const Eldbus_Message *msg)
 {  /* Package ('u'info, 's'package_id, 's'summary) */
-   const char *error, *error_msg, *pkg_id, *summary;
+   const char *error, *error_msg, *pkg_id, *summary, *info_str;
    E_PackageKit_Module_Context *ctxt = data;
    PackageKit_Package_Info info;
    unsigned num_elements = 0;
    char **splitted;
+   Eina_Bool ret;
 
    if (eldbus_message_error_get(msg, &error, &error_msg))
      {
         _store_error(ctxt, error_msg);
         return;
      }
-   if (!eldbus_message_arguments_get(msg, "uss", &info, &pkg_id, &summary))
+   if (PKITV07)
+     ret = eldbus_message_arguments_get(msg, "sss", &info_str, &pkg_id, 
&summary);
+   else
+     ret = eldbus_message_arguments_get(msg, "uss", &info, &pkg_id, &summary);
+   if (!ret)
      {
-        _store_error(ctxt, "could not get arguments (uss)");
+        _store_error(ctxt, "could not get package arguments");
         return;
      }
-   DBG("PKGKIT: Package: (%d) %s [ %s ]", info, pkg_id, summary);
+   if (PKITV07)
+     { DBG("PKGKIT: Package: (%s) %s [ %s ]", info_str, pkg_id, summary); }
+   else
+     { DBG("PKGKIT: Package: (%d) %s [ %s ]", info, pkg_id, summary); }
 
    splitted = eina_str_split_full(pkg_id, ";", 2, &num_elements);
    if (num_elements == 2)
@@ -262,7 +272,20 @@ _signal_package_cb(void *data, const Eldbus_Message *msg)
         E_PackageKit_Package *pkg = E_NEW(E_PackageKit_Package, 1);
         pkg->name = eina_stringshare_add(splitted[0]);
         pkg->version = eina_stringshare_add(splitted[1]);
-        pkg->info = info;
+        if (PKITV07)
+          {
+             if (!info_str) pkg->info = PK_INFO_ENUM_NORMAL;
+             else if (!strcmp(info_str, "normal"))      pkg->info = 
PK_INFO_ENUM_NORMAL;
+             else if (!strcmp(info_str, "security"))    pkg->info = 
PK_INFO_ENUM_SECURITY;
+             else if (!strcmp(info_str, "blocked"))     pkg->info = 
PK_INFO_ENUM_BLOCKED;
+             else if (!strcmp(info_str, "low"))         pkg->info = 
PK_INFO_ENUM_LOW;
+             else if (!strcmp(info_str, "enhancement")) pkg->info = 
PK_INFO_ENUM_ENHANCEMENT;
+             else if (!strcmp(info_str, "bugfix"))      pkg->info = 
PK_INFO_ENUM_BUGFIX;
+             else if (!strcmp(info_str, "important"))   pkg->info = 
PK_INFO_ENUM_IMPORTANT;
+             else pkg->info = PK_INFO_ENUM_UNKNOWN;
+          }
+        else
+          pkg->info = info;
         ctxt->packages = eina_list_append(ctxt->packages, pkg);
      }
    if (splitted)
@@ -325,7 +348,10 @@ packagekit_get_updates(E_PackageKit_Module_Context *ctxt, 
const char *transactio
 
    obj = eldbus_object_get(ctxt->conn, "org.freedesktop.PackageKit", 
transaction);
    proxy = eldbus_proxy_get(obj, "org.freedesktop.PackageKit.Transaction");
-   pending = eldbus_proxy_call(proxy, "GetUpdates", null_cb, NULL, -1, "t", 1);
+   if (PKITV07)
+     pending = eldbus_proxy_call(proxy, "GetUpdates", null_cb, NULL, -1, "s", 
"none");
+   else
+     pending = eldbus_proxy_call(proxy, "GetUpdates", null_cb, NULL, -1, "t", 
1);
    if (!pending)
      {
         _store_error(ctxt, "could not call GetUpdates()");
@@ -351,6 +377,7 @@ _transaction_created_cb(void *data, const Eldbus_Message 
*msg, Eldbus_Pending *p
    const char *error, *error_msg, *trans_path;
    E_PackageKit_Module_Context *ctxt = data;
    E_PackageKit_Transaction_Func func;
+   Eina_Bool ret;
 
    if (eldbus_message_error_get(msg, &error, &error_msg))
      {
@@ -358,7 +385,11 @@ _transaction_created_cb(void *data, const Eldbus_Message 
*msg, Eldbus_Pending *p
         return;
      }
 
-   if (!eldbus_message_arguments_get(msg, "o", &trans_path))
+   if (PKITV07)
+     ret = eldbus_message_arguments_get(msg, "s", &trans_path);
+   else
+     ret = eldbus_message_arguments_get(msg, "o", &trans_path);
+   if (!ret)
      {
         _store_error(ctxt, "could not get transaction path");
         return;
@@ -384,7 +415,8 @@ 
packagekit_create_transaction_and_exec(E_PackageKit_Module_Context *ctxt,
         return;
      }
 
-   pending = eldbus_proxy_call(ctxt->packagekit, "CreateTransaction",
+   pending = eldbus_proxy_call(ctxt->packagekit,
+                               PKITV07 ? "GetTid" : "CreateTransaction",
                                _transaction_created_cb, ctxt, -1, "");
    if (!pending)
      {
diff --git a/src/e_mod_packagekit.h b/src/e_mod_packagekit.h
index fb8424d..c710389 100644
--- a/src/e_mod_packagekit.h
+++ b/src/e_mod_packagekit.h
@@ -3,6 +3,10 @@
 
 #include <Eldbus.h>
 
+
+#define PKITV07 (ctxt->v_maj == 0) && (ctxt->v_min == 7)
+#define PKITV08 (ctxt->v_maj == 0) && (ctxt->v_min == 8)
+
 typedef enum {
    PK_INFO_ENUM_UNKNOWN,
    PK_INFO_ENUM_INSTALLED,

-- 


Reply via email to