Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fun.git;a=commitdiff;h=f468b4fa9903b79e5fdab819b8b3c594705357f7

commit f468b4fa9903b79e5fdab819b8b3c594705357f7
Author: Priyank <[EMAIL PROTECTED]>
Date:   Mon Nov 19 18:20:06 2007 +0530

clubbed GetPackageVersion and GetPackageDescription into GetPackageInfo
* This reduces the number of calls to the dameon by half (when an update is 
available)

diff --git a/src/fun-dbus.c b/src/fun-dbus.c
index a97484d..bf9fe74 100644
--- a/src/fun-dbus.c
+++ b/src/fun-dbus.c
@@ -40,7 +40,7 @@ fun_dbus_init (void)
}

gboolean
-fun_dbus_perform_service (guint service, gchar *ip_arg, gchar **op_arg)
+fun_dbus_perform_service (guint service, gchar *ip_arg, gchar **op_arg1, gchar 
**op_arg2)
{
DBusMessage     *message = NULL;
DBusMessage     *reply = NULL;
@@ -64,7 +64,7 @@ fun_dbus_perform_service (guint service, gchar *ip_arg, gchar 
**op_arg)
return FALSE;
}
if (!dbus_message_get_args (reply, &error,
-                                               DBUS_TYPE_STRING, op_arg,
+                                               DBUS_TYPE_STRING, op_arg1,
DBUS_TYPE_INVALID))
{
fprintf (stderr, "ERROR: %s\n", error.message);
@@ -103,13 +103,13 @@ fun_dbus_perform_service (guint service, gchar *ip_arg, 
gchar **op_arg)
dbus_message_unref (message);
break;
}
-               case GET_PACKAGE_VERSION:
+               case GET_PACKAGE_INFO:
{
dbus_error_init (&error);
message = dbus_message_new_method_call ("org.frugalware.FWUpdateNotifier",
"/org/frugalware/FWUpdateNotifier",
"org.frugalware.FWUpdateNotifier",
-                                                               
"GetPackageVersion");
+                                                               
"GetPackageInfo");
dbus_message_append_args (message, DBUS_TYPE_STRING, &ip_arg);
reply = dbus_connection_send_with_reply_and_block (fun_conn, message, 
reply_timeout, &error);
if (dbus_error_is_set(&error))
@@ -119,35 +119,8 @@ fun_dbus_perform_service (guint service, gchar *ip_arg, 
gchar **op_arg)
return FALSE;
}
if (!dbus_message_get_args (reply, &error,
-                                               DBUS_TYPE_STRING, op_arg,
-                                               DBUS_TYPE_INVALID))
-                       {
-                               fprintf (stderr, "ERROR: %s\n", error.message);
-                               dbus_error_free (&error);
-                               return FALSE;
-                       }
-
-                       dbus_message_unref (reply);
-                       dbus_message_unref (message);
-                       break;
-               }
-               case GET_PACKAGE_DESCRIPTION:
-               {
-                       dbus_error_init (&error);
-                       message = dbus_message_new_method_call 
("org.frugalware.FWUpdateNotifier",
-                                                               
"/org/frugalware/FWUpdateNotifier",
-                                                               
"org.frugalware.FWUpdateNotifier",
-                                                               
"GetPackageDescription");
-                       dbus_message_append_args (message, DBUS_TYPE_STRING, 
&ip_arg);
-                       reply = dbus_connection_send_with_reply_and_block 
(fun_conn, message, reply_timeout, &error);
-                       if (dbus_error_is_set(&error))
-                       {
-                               fprintf (stderr, "ERROR: %s\n", error.message);
-                               dbus_error_free (&error);
-                               return FALSE;
-                       }
-                       if (!dbus_message_get_args (reply, &error,
-                                               DBUS_TYPE_STRING, op_arg,
+                                               DBUS_TYPE_STRING, op_arg1,
+                                               DBUS_TYPE_STRING, op_arg2,
DBUS_TYPE_INVALID))
{
fprintf (stderr, "ERROR: %s\n", error.message);
diff --git a/src/fun-dbus.h b/src/fun-dbus.h
index 182cbb9..ab6aeca 100644
--- a/src/fun-dbus.h
+++ b/src/fun-dbus.h
@@ -8,11 +8,10 @@

#define PERFORM_UPDATE                  1
#define TEST_SERVICE                    2
-#define GET_PACKAGE_VERSION            3
-#define GET_PACKAGE_DESCRIPTION        4
+#define GET_PACKAGE_INFO               3

gboolean fun_dbus_init (void);

-gboolean fun_dbus_perform_service (guint, gchar *, gchar **);
+gboolean fun_dbus_perform_service (guint, gchar *, gchar **, gchar **);

#endif
diff --git a/src/fun-ui.c b/src/fun-ui.c
index 858f161..f5f5143 100644
--- a/src/fun-ui.c
+++ b/src/fun-ui.c
@@ -462,7 +462,7 @@ fun_ui_init (void)
fun_main_window_init ();
fun_config_dialog_init ();

-       if (fun_dbus_perform_service (TEST_SERVICE, NULL, NULL) == FALSE)
+       if (fun_dbus_perform_service (TEST_SERVICE, NULL, NULL, NULL) == FALSE)
{
g_print (_("Failed to connect to the fun daemon\n"));
fun_tooltip_set_text2 (tooltip, _("Not connected to fun daemon"), FALSE);
@@ -485,7 +485,7 @@ fun_timeout_conn (void)
{
if (connected == TRUE)
return FALSE;
-       if (fun_dbus_perform_service (TEST_SERVICE, NULL, NULL) == FALSE)
+       if (fun_dbus_perform_service (TEST_SERVICE, NULL, NULL, NULL) == FALSE)
{
connected = FALSE;
}
@@ -514,7 +514,7 @@ fun_timeout_func (void)
* disable the "check" button so that the user doesn't interrupt the
* checking process */
gtk_widget_set_sensitive (fun_check_btn, FALSE);
-       if (fun_dbus_perform_service (PERFORM_UPDATE, NULL, &plist)==TRUE)
+       if (fun_dbus_perform_service (PERFORM_UPDATE, NULL, &plist, NULL)==TRUE)
{
//g_print ("\nlist is\n %s", plist);
fun_tooltip_set_text1 (tooltip, _("Updates are available"), TRUE);
@@ -591,9 +591,8 @@ fun_populate_updates_tvw (gchar *plist)
{
gchar *ver = NULL;
gchar *desc = NULL;
-               fun_dbus_perform_service (GET_PACKAGE_VERSION, l->data, &ver);
+               fun_dbus_perform_service (GET_PACKAGE_INFO, l->data, &ver, 
&desc);
gtk_list_store_append (store, &iter);
-               fun_dbus_perform_service (GET_PACKAGE_DESCRIPTION, l->data, 
&desc);
gtk_list_store_set (store, &iter, 0, NULL, 1, l->data, 2, ver, 3, desc, -1);
}
}
diff --git a/src/fund.c b/src/fund.c
index 8de82fa..8ad2165 100644
--- a/src/fund.c
+++ b/src/fund.c
@@ -167,21 +167,13 @@ gboolean fund_update_database(FWUpdateNotifier *obj, 
gchar **packages, GError **
}
}

-gboolean fund_get_package_version(FWUpdateNotifier *obj, gchar *package, gchar 
**version, GError **error) {
+gboolean fund_get_package_info(FWUpdateNotifier *obj, gchar *package, gchar 
**version, gchar **desc, GError **error) {
PM_PKG *pkg = NULL;
pkg = pacman_db_readpkg (sync_db, (char*)package);
if (pkg == NULL)
return FALSE;
*version = g_strdup ((char*)pacman_pkg_getinfo(pkg,PM_PKG_VERSION));
-       return TRUE;
-}
-
-gboolean fund_get_package_description(FWUpdateNotifier *obj, gchar *package, 
gchar **description, GError **error) {
-       PM_PKG *pkg = NULL;
-       pkg = pacman_db_readpkg (sync_db, (char*)package);
-       if (pkg == NULL)
-               return FALSE;
-       *description = g_strdup ((char*)pacman_pkg_getinfo(pkg,PM_PKG_DESC));
+       *desc = g_strdup ((char*)pacman_pkg_getinfo(pkg,PM_PKG_DESC));
return TRUE;
}

diff --git a/src/fund.h b/src/fund.h
index a86b00d..c230ed4 100644
--- a/src/fund.h
+++ b/src/fund.h
@@ -16,8 +16,7 @@ static void fund_init(FWUpdateNotifier *server);
static void fund_class_init(FWUpdateNotifierClass *class);

gboolean fund_update_database(FWUpdateNotifier *obj, gchar **packages, GError 
**error);
-gboolean fund_get_package_version(FWUpdateNotifier *obj, gchar *package, gchar 
**version, GError **error);
-gboolean fund_get_package_description(FWUpdateNotifier *obj, gchar *package, 
gchar **description, GError **error);
+gboolean fund_get_package_info(FWUpdateNotifier *obj, gchar *package, gchar 
**version, gchar **desc, GError **error);
gboolean fund_test_service(FWUpdateNotifier *obj, gint *ret, GError **error);

#endif
diff --git a/src/fund.xml b/src/fund.xml
index e8d71f0..ffc3427 100644
--- a/src/fund.xml
+++ b/src/fund.xml
@@ -9,14 +9,10 @@
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="fund_test_service"/>
<arg type="i" name="ret" direction="out" />
</method>
-               <method name="GetPackageVersion">
-                       <annotation name="org.freedesktop.DBus.GLib.CSymbol" 
value="fund_get_package_version"/>
+               <method name="GetPackageInfo">
+                       <annotation name="org.freedesktop.DBus.GLib.CSymbol" 
value="fund_get_package_info"/>
<arg type="s" name="package" direction="in" />
<arg type="s" name="version" direction="out" />
-               </method>
-               <method name="GetPackageDescription">
-                       <annotation name="org.freedesktop.DBus.GLib.CSymbol" 
value="fund_get_package_description"/>
-                       <arg type="s" name="package" direction="in" />
<arg type="s" name="description" direction="out" />
</method>
</interface>
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to