Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-mono-tools.git;a=commitdiff;h=e1c3ce541d8f1b61ce2f344aa7ebe59f58904347

commit e1c3ce541d8f1b61ce2f344aa7ebe59f58904347
Author: bouleetbil <bouleet...@frogdev.info>
Date:   Sat Aug 28 15:58:24 2010 +0200

*use only one instance of pacman-g2
*fixes daemon
*added notifications where update is detected
*fixes --update
*some others fixes
*will create a first archive for test :D

diff --git a/frugal-mono-tools/IconSummaryBody.cs 
b/frugal-mono-tools/IconSummaryBody.cs
index 11a302f..41fe597 100644
--- a/frugal-mono-tools/IconSummaryBody.cs
+++ b/frugal-mono-tools/IconSummaryBody.cs
@@ -1,11 +1,3 @@
-////////////////////////////////////////////////////////////////////////////////
-//3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
-//      10        20        30        40        50        60        70        
80
-//
-// Info:
-//    Example of how to use libnotify correctly and at the same time comply to
-//    the new jaunty notification spec (read: visual guidelines)
-//
/*
*  Copyright (C) 2010 by Gaetan Gourdin <bouleet...@frogdev.info>
*
diff --git a/frugal-mono-tools/Main.cs b/frugal-mono-tools/Main.cs
index e90ab14..4ed1f0d 100644
--- a/frugal-mono-tools/Main.cs
+++ b/frugal-mono-tools/Main.cs
@@ -23,17 +23,44 @@ namespace frugalmonotools
{
class MainClass
{
+               //pacman-g2 initialise
+               public static PacmanG2 pacmanG2 = new PacmanG2();
+
+               public static IconSummaryBody notif= new IconSummaryBody();
+
private static void UpdateBDD(object source, ElapsedEventArgs e)
{
Console.WriteLine("update pacman-g2 bdd");
Outils.Excecute("pacman-g2"," -Sy",false);
}
-
+               private static void checkUpdate(object source, ElapsedEventArgs 
e)
+               {
+                       Console.WriteLine("check update packages.");
+                       check();
+               }
+               private static void check()
+               {
+
+                       if (Update.CheckUpdate())
+                       {
+                               if(Debug.ModeDebug)
+                               {
+                                       foreach (packageCheck pkg in 
Update.UpdatePkg)
+                                       {
+                                               
Console.WriteLine(pkg.packagename+" can be updated to "+pkg.packageversion);
+                                       }
+                               }
+                               notif.ShowMessage("Frugalware","Some update are 
available.");
+                               Console.WriteLine("Some packages can be 
updated.");
+                       }
+               }
public static void Main (string[] args)
{
+                       System.Timers.Timer aTimer;
+                       Application.Init ();
if(args.Length==0)
{
-                               Application.Init ();
+                               check();
MainWindow win = new MainWindow ();
win.Show ();
Application.Run ();
@@ -50,27 +77,26 @@ namespace frugalmonotools
System.Environment.Exit(0);
}
//update packages bdd
-                                               System.Timers.Timer aTimer = 
new System.Timers.Timer();
+                                               aTimer = new 
System.Timers.Timer();
aTimer.Elapsed+=new ElapsedEventHandler(UpdateBDD);
// Set the Interval to 1 hour.
aTimer.Interval=3600000;
aTimer.Enabled=true;
-                                               while(true){}
-
+                                               Application.Run ();
+                                               break;
+
case "--update":
//check if an update is avalaible
//started with X session
Console.WriteLine("check update packages.");
-                                               Update update=new Update();
-                                               if (update.CheckUpdate())
-                                               {
-                                                       Console.WriteLine("Some 
packages can be updated.");
-                                                       foreach (packageCheck 
pkg in update.UpdatePkg)
-                                                       {
-                                                               
Console.WriteLine(pkg.packagename+" can be updated to "+pkg.packageversion);
-                                                       }
-                                               }
+                                               check();
+                                               aTimer = new 
System.Timers.Timer();
+                                       aTimer.Elapsed+=new 
ElapsedEventHandler(checkUpdate);
+                                       // Set the Interval to 1 hour.
+                                       aTimer.Interval=3600000;
+                                       aTimer.Enabled=true;
break;
+
default:
Console.WriteLine("Bad parameters exit...");
break;
diff --git a/frugal-mono-tools/MainWindow.cs b/frugal-mono-tools/MainWindow.cs
index 5abff87..be25db7 100644
--- a/frugal-mono-tools/MainWindow.cs
+++ b/frugal-mono-tools/MainWindow.cs
@@ -32,11 +32,8 @@ public partial class MainWindow : Gtk.Window
//pacman-g2
// Create a model for treeview pkg
Gtk.ListStore pkgListStore = new Gtk.ListStore (typeof (string));
-       //pacman-g2 initialise
-       PacmanG2 Pkg = new PacmanG2();
ListStore modelRepoList = new ListStore (typeof (string),typeof (int));

-
//webkit engine
private WebKit.WebView webview=null;
Gtk.ScrolledWindow scroll = new Gtk.ScrolledWindow();
@@ -78,7 +75,7 @@ public partial class MainWindow : Gtk.Window
pkgColumn.AddAttribute (pkgNameCell, "text", 0);

int i = 0 ;
-               foreach (string repo in Pkg.fwRepo)
+               foreach (string repo in  MainClass.pacmanG2.fwRepo)
{
string strRepo=repo;
if (strRepo=="local") strRepo ="Installed";
@@ -100,7 +97,7 @@ public partial class MainWindow : Gtk.Window
this.scroll.ShowAll();

//HW
-               if(!Pkg.IsInstalled("system-config-printer"))
+               if(!MainClass.pacmanG2.IsInstalled("system-config-printer"))
{
BTN_Printer.Visible=false;
LAB_Printer.Visible=true;
@@ -110,7 +107,7 @@ public partial class MainWindow : Gtk.Window
BTN_Printer.Visible=true;
LAB_Printer.Visible=false;
}
-               if(!Pkg.IsInstalled("frugalwareutils"))
+               if(!MainClass.pacmanG2.IsInstalled("frugalwareutils"))
{
BTN_Setup.Visible=false;
LIB_Setup.Visible=true;
@@ -123,7 +120,7 @@ public partial class MainWindow : Gtk.Window
string dmesgOutput=Outils.getoutput("dmesg");
if(dmesgOutput.IndexOf("lirc")>0)
{
-                       if (!Pkg.IsInstalled("lirc"))
+                       if (!MainClass.pacmanG2.IsInstalled("lirc"))
{
LIB_Lirc.Visible=true;
}
@@ -140,7 +137,7 @@ public partial class MainWindow : Gtk.Window

if(dmesgOutput.IndexOf("Bluetooth")>0)
{
-                       if (!Pkg.IsInstalled("bluez"))
+                       if (!MainClass.pacmanG2.IsInstalled("bluez"))
{
LIB_Bluez.Visible=true;
}
@@ -193,7 +190,7 @@ public partial class MainWindow : Gtk.Window
LIB_Lspci.Text=lspci;
LIB_XorgGraphic.Text+= GraphicalDevice()+" driver";
string touchpad=Outils.getoutput("dmesg");
-               if ((touchpad.IndexOf("TouchPad")>0) && 
(!Pkg.IsInstalled("xf86-input-synaptics")))
+               if ((touchpad.IndexOf("TouchPad")>0) && 
(!MainClass.pacmanG2.IsInstalled("xf86-input-synaptics")))
BTN_Synaptics.Visible=true;
else
BTN_Synaptics.Visible=false;
@@ -505,7 +502,7 @@ public partial class MainWindow : Gtk.Window
public void EnableDisable(CheckButton INT_Option,string packageName, Label text)
{
//check if file existe for works more quickly
-               if(!Pkg.IsInstalled(packageName))
+               if(!MainClass.pacmanG2.IsInstalled(packageName))
{
INT_Option.Active=false;
INT_Option.Inconsistent=true;
@@ -605,7 +602,7 @@ public partial class MainWindow : Gtk.Window
protected virtual void OnBTNSearchClicked (object sender, System.EventArgs e)
{
try{
-                       List<Package> 
packages=Pkg.Search(SAI_pkg.Text,Pkg.repoSelected);
+                       List<Package> 
packages=MainClass.pacmanG2.Search(SAI_pkg.Text,MainClass.pacmanG2.repoSelected);
pkgListStore.Clear();
foreach (Package package in packages)
{
@@ -622,7 +619,7 @@ public partial class MainWindow : Gtk.Window
if ((sender as ComboBox).GetActiveIter (out iter))
{
int id =(int)modelRepoList.GetValue (iter,1);
-                       Pkg.SelectRepo(Pkg.fwRepo[id]);
+                       
MainClass.pacmanG2.SelectRepo(MainClass.pacmanG2.fwRepo[id]);
}
}

@@ -635,12 +632,12 @@ public partial class MainWindow : Gtk.Window
if (((TreeSelection)o).GetSelected(out model, out iter))
{
string T =(string)model.GetValue (iter, 0);
-                                       T=Pkg.extractNamePackage(T);
+                                       
T=MainClass.pacmanG2.extractNamePackage(T);
packageSelected=T;
if(boRoot)
{
//installed ?
-                                               if(Pkg.IsInstalled(T))
+                                               
if(MainClass.pacmanG2.IsInstalled(T))
{
BTN_Uninstall.Visible=true;
BTN_Install.Visible=false;
diff --git a/frugal-mono-tools/PacmanG2.cs b/frugal-mono-tools/PacmanG2.cs
index 6929ae6..05ce73c 100644
--- a/frugal-mono-tools/PacmanG2.cs
+++ b/frugal-mono-tools/PacmanG2.cs
@@ -124,6 +124,7 @@ namespace frugalmonotools

private void EnumRepoProc(string section, string lParam)
{
+                       if(Debug.ModeDebug) Console.WriteLine(section);
fwRepo.Add(section);
}

diff --git a/frugal-mono-tools/Update.cs b/frugal-mono-tools/Update.cs
index cf41f90..5626a60 100644
--- a/frugal-mono-tools/Update.cs
+++ b/frugal-mono-tools/Update.cs
@@ -11,19 +11,21 @@ namespace frugalmonotools
public string packageversion;
}

-       public class Update
+       public static class Update
{
-               private List<packageCheck> InstallPkg = new 
List<packageCheck>();
-               private List<packageCheck> Pkg = new List<packageCheck>();
-               public List<packageCheck> UpdatePkg = new List<packageCheck>();
-               private PacmanG2 pacman = new PacmanG2();
+               private static bool _started=false;
+               private static List<packageCheck> InstallPkg = new 
List<packageCheck>();
+               private static List<packageCheck> Pkg = new 
List<packageCheck>();
+               public static List<packageCheck> UpdatePkg = new 
List<packageCheck>();

-               public Update()
+               private static void _init()
{
-                       _init();
+                       if(Debug.ModeDebug) Console.WriteLine("Init update");
+                       _clear();

-                       foreach (string repo in pacman.fwRepo)
+                       foreach (string repo in MainClass.pacmanG2.fwRepo)
{
+                               if(Debug.ModeDebug) Console.WriteLine(repo);
if(repo=="local")
{
addList(InstallPkg,repo);
@@ -39,6 +41,7 @@ namespace frugalmonotools
//TODO : respect Ignorepkg
foreach (packageCheck pkg in Pkg)
{
+
if(pkg.packagename==pkginstall.packagename)
{
//basic test for beginning
@@ -53,22 +56,35 @@ namespace frugalmonotools

}
}
-               public bool CheckUpdate()
+               public static bool CheckUpdate()
{
-                       if(UpdatePkg.Count>0) return true;
+                       if(_started)
+                       {
+                               if(Debug.ModeDebug) Console.WriteLine("already 
started.");
+                               return false;
+                       }
+                       _started=true;
+                       _init();
+                       if(Debug.ModeDebug) Console.WriteLine("Check update");
+                       if(UpdatePkg.Count>0)
+                       {
+                               _started=false;
+                               return true;
+                       }
+                       _started=false;
return false;
}

-               private void _init()
+               private static void _clear()
{
InstallPkg.Clear();
Pkg.Clear();
UpdatePkg.Clear();
}

-               private void addList(List<packageCheck> pkgs,string repo)
+               private static void addList(List<packageCheck> pkgs,string repo)
{
-                       List<Package> packages=pacman.Search("*",repo);
+                       List<Package> 
packages=MainClass.pacmanG2.Search("*",repo);
foreach (Package package in packages)
{
if(repo=="local")
diff --git a/frugal-mono-tools/frugal-mono-tools.csproj 
b/frugal-mono-tools/frugal-mono-tools.csproj
index 4bbf046..f2d2b8d 100644
--- a/frugal-mono-tools/frugal-mono-tools.csproj
+++ b/frugal-mono-tools/frugal-mono-tools.csproj
@@ -41,6 +41,7 @@
<Reference Include="System.Xml" />
<Reference Include="Mono.Posix" />
<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" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="gtk-gui\gui.stetic">
@@ -69,6 +70,7 @@
<Compile Include="OUTILS\Outils.cs" />
<Compile Include="PacmanG2.cs" />
<Compile Include="Update.cs" />
+    <Compile Include="IconSummaryBody.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
diff --git a/frugal-mono-tools/gtk-gui/gui.stetic 
b/frugal-mono-tools/gtk-gui/gui.stetic
index eafced5..7339adb 100644
--- a/frugal-mono-tools/gtk-gui/gui.stetic
+++ b/frugal-mono-tools/gtk-gui/gui.stetic
@@ -8,6 +8,7 @@
<widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, 
PublicKeyToken=35e10195dab3c99f" />
<widget-library name="webkit-sharp, Version=1.1.15.0, Culture=neutral, 
PublicKeyToken=eaa1d335d2e19745" />
<widget-library name="../bin/Debug/frugal-mono-tools.exe" internal="true" />
+    <widget-library name="notify-sharp, Version=0.4.0.0, Culture=neutral, 
PublicKeyToken=2df29c54e245917a" />
</import>
<widget class="Gtk.Window" id="MainWindow" design-size="552 395">
<property name="MemberName" />
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to