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

commit 73daec34249948922076344b5c10235767411272
Author: bouleetbil <bouleet...@frogdev.info>
Date:   Tue Sep 7 21:55:22 2010 +0200

*begin to use dbus(ndesk)

diff --git a/frugal-mono-tools/DbusObject.cs b/frugal-mono-tools/DbusObject.cs
new file mode 100644
index 0000000..2b46b7e
--- /dev/null
+++ b/frugal-mono-tools/DbusObject.cs
@@ -0,0 +1,39 @@
+// /*
+//  *  Copyright (C) 2010 by Gaetan Gourdin <bouleet...@frogdev.info>
+//  *
+//  *  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
USA.
+//  */
+using System;
+using NDesk.DBus;
+using org.freedesktop.DBus;
+
+namespace frugalmonotools
+{
+       [Interface ("com.frugalware.tweak")]
+       public class DbusObject : MarshalByRefObject
+       {
+               public void Hello (string arg0)
+               {
+                       Console.WriteLine ("Got a Hello" + arg0);
+               }
+
+               public void GiveNoReply ()
+               {
+                       Console.WriteLine ("Asked to give no reply");
+               }
+       }
+
+}
+
diff --git a/frugal-mono-tools/Main.cs b/frugal-mono-tools/Main.cs
index 2304224..2c4dbed 100644
--- a/frugal-mono-tools/Main.cs
+++ b/frugal-mono-tools/Main.cs
@@ -24,6 +24,8 @@ using System.Timers;
using Gdk;
using Gtk;

+using NDesk.DBus;
+using org.freedesktop.DBus;


namespace frugalmonotools
@@ -121,10 +123,31 @@ namespace frugalmonotools
popupMenu.Popup();
}

-               private static MainWindow Fen ;
+               public static MainWindow Fen ;
public static bool StartedAutomatic=false;
+
+               public static Bus bus;
+               public static string DbusName="com.frugalware.tweak";
+               public static ObjectPath DbusPath = new ObjectPath 
("com/frugalware/tweak");
+               public static DbusObject DbusCom;
+
public static void Main (string[] args)
{
+                       try{
+                                       bus = Bus.Session;
+                                       if (bus.RequestName (DbusName) == 
RequestNameReply.PrimaryOwner) {
+                                               //create a new instance of the 
object to be exported
+                                               DbusCom = new DbusObject ();
+                                               bus.Register (DbusPath, 
DbusCom);
+                                               //EXEMPLE : 
MainClass.DbusCom.Hello("test");
+                                       }
+
+                       }
+                       catch(Exception exe)
+                       {
+                               Console.WriteLine("Can't register :"+DbusName);
+                               Console.WriteLine(exe.Message);
+                       }

System.Timers.Timer aTimer;
if(args.Length==0)
diff --git a/frugal-mono-tools/frugal-mono-tools.csproj 
b/frugal-mono-tools/frugal-mono-tools.csproj
index 98c5551..9df00a8 100644
--- a/frugal-mono-tools/frugal-mono-tools.csproj
+++ b/frugal-mono-tools/frugal-mono-tools.csproj
@@ -50,6 +50,7 @@
<Reference Include="webkit-sharp, Version=1.1.15.0, Culture=neutral, 
PublicKeyToken=eaa1d335d2e19745" />
<Reference Include="notify-sharp, Version=0.4.0.0, Culture=neutral, 
PublicKeyToken=2df29c54e245917a" />
<Reference Include="System.ServiceProcess" />
+    <Reference Include="NDesk.DBus, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=f6716e4f9b2ed099" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="gtk-gui\gui.stetic">
@@ -86,6 +87,7 @@
<Compile Include="Services.cs" />
<Compile Include="WebkitBrowser.cs" />
<Compile Include="ConfSystem.cs" />
+    <Compile Include="DbusObject.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to