Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-tweak.git;a=commitdiff;h=8d8b5e2928a32fbd0aa0ea048ba7c2450b25198d

commit 8d8b5e2928a32fbd0aa0ea048ba7c2450b25198d
Author: bouleetbil <[email protected]>
Date:   Thu Dec 30 18:23:58 2010 +0100

*added dbus to daemon

diff --git a/frugal-tweak-vala/DbusServer.vala 
b/frugal-tweak-vala/DbusServer.vala
new file mode 100644
index 0000000..6b93483
--- /dev/null
+++ b/frugal-tweak-vala/DbusServer.vala
@@ -0,0 +1,39 @@
+/*
+ *
+ * (C) 2010 bouleetbil <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+ */
+
+
+[DBus (name = "org.frugal.tweak")]
+public class DbusServer : Object {
+
+           private int counter;
+
+           public int ping (string msg) {
+               stdout.printf ("%s\n", msg);
+               return counter++;
+           }
+       }
+
+       void on_bus_aquired (DBusConnection conn) {
+           try {
+               conn.register_object ("/org/frugal/tweak", new DbusServer ());
+           } catch (IOError e) {
+               stderr.printf ("Could not register service\n");
+           }
+       }
+
diff --git a/frugal-tweak-vala/daemon.vala b/frugal-tweak-vala/daemon.vala
index 9b401f5..79b1145 100644
--- a/frugal-tweak-vala/daemon.vala
+++ b/frugal-tweak-vala/daemon.vala
@@ -17,6 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
*/
using GLib;
+using DbusServer;
using pacman;

class Deamon : GLib.Object {
@@ -25,7 +26,11 @@ class Deamon : GLib.Object {

public static int main(string[] args) {
Tools.ConsoleDebug("Start Frugalware Tweak Daemon\n");
-
+       //dbus
+       Bus.own_name (BusType.SESSION, "org.frugal.tweak", 
BusNameOwnerFlags.NONE,
+                         on_bus_aquired,
+                         () => {},
+                         () => stderr.printf ("Could not aquire name\n"));

pacmang2 = new pacman();
UpdateAllDatabase();
@@ -49,3 +54,4 @@ class Deamon : GLib.Object {

}
}
+
diff --git a/frugal-tweak-vala/pacman.vala b/frugal-tweak-vala/pacman.vala
index b2e0db2..0038974 100644
--- a/frugal-tweak-vala/pacman.vala
+++ b/frugal-tweak-vala/pacman.vala
@@ -89,8 +89,10 @@ public class pacman

}

-       public void CheckUpdate()
+       public void bool CheckUpdate()
{
+               PM_LIST *i = null;
+
if (pacman_trans_init(Pacman.OptionTrans.TYPE_SYNC, 0, null, null, null) == -1) 
{
Tools.ConsoleDebug("pacman_trans_init  failed \n");
return ;
@@ -110,7 +112,7 @@ public class pacman
{
Tools.ConsoleDebug("Updates are available\n");
//TODO send event
-                       PM_LIST *i = null;
+
for (i=pacman_list_first(packages);i!=null;i=pacman_list_next(i)) {
PM_SYNCPKG *spkg = pacman_list_getdata (i);
PM_PKG *pkg = pacman_sync_getinfo (spkg, OptionPMSYNC.PKG);
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to