Author: jerome
Date: 2009-07-23 14:30:05 +0200 (Thu, 23 Jul 2009)
New Revision: 5144

Modified:
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.cfg
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.dof
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.dpr
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/TuxUtils.dcu
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/TuxUtils.pas
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dcu
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dfm
   
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas
Log:
* Improved status requests.

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.cfg
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.cfg
      2009-07-23 12:13:00 UTC (rev 5143)
+++ 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.cfg
      2009-07-23 12:30:05 UTC (rev 5144)
@@ -14,8 +14,8 @@
 -$N+
 -$O+
 -$P+
--$Q-
--$R-
+-$Q+
+-$R+
 -$S-
 -$T-
 -$U-
@@ -33,3 +33,7 @@
 -K$00400000
 -LE"c:\program files\borland\delphi6\Projects\Bpl"
 -LN"c:\program files\borland\delphi6\Projects\Bpl"
+-U"c:\program files\borland\delphi6\Lib\Debug"
+-O"c:\program files\borland\delphi6\Lib\Debug"
+-I"c:\program files\borland\delphi6\Lib\Debug"
+-R"c:\program files\borland\delphi6\Lib\Debug"

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.dof
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.dof
      2009-07-23 12:13:00 UTC (rev 5143)
+++ 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.dof
      2009-07-23 12:30:05 UTC (rev 5144)
@@ -17,8 +17,8 @@
 N=1
 O=1
 P=1
-Q=0
-R=0
+Q=1
+R=1
 S=0
 T=0
 U=0
@@ -45,7 +45,7 @@
 UnitOutputDir=
 PackageDLLOutputDir=
 PackageDCPOutputDir=
-SearchPath=
+SearchPath=$(DELPHI)\Lib\Debug
 
Packages=vcl;rtl;vclx;VclSmp;vclshlctrls;Python_d6;PNG_D6;PngComponentsD6;PngComponentsD6D;acntD6;Package4;AdvCircularProgressPkgD6;EmbeddedWebBrowser_D6
 Conditionals=
 DebugSourceDirs=
@@ -70,3 +70,11 @@
 DLL=0
 Locale=1033
 CodePage=1252
+[Version Info Keys]
+FileVersion=1.0.0.0
+[HistoryLists\hlUnitAliases]
+Count=1
+Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+[HistoryLists\hlSearchPath]
+Count=1
+Item0=$(DELPHI)\Lib\Debug

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.dpr
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.dpr
      2009-07-23 12:13:00 UTC (rev 5143)
+++ 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Project2.dpr
      2009-07-23 12:30:05 UTC (rev 5144)
@@ -11,6 +11,7 @@
 begin
   Application.Initialize;
   Application.ShowMainForm:=False;
+  Application.Title := 'TuxBox 2.0';
   Application.CreateForm(TForm1, Form1);
   Application.Run;
 end.

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/TuxUtils.dcu
===================================================================
(Binary files differ)

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/TuxUtils.pas
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/TuxUtils.pas
      2009-07-23 12:13:00 UTC (rev 5143)
+++ 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/TuxUtils.pas
      2009-07-23 12:30:05 UTC (rev 5144)
@@ -9,19 +9,20 @@
     IdHTTP, dialogs;
 
     function DownloadHTTP(const AUrl : string): string;
-    function parseStates(aString : string): TStringList;
-    function getStates(): TStringList;
 
+    procedure parseStates(aString : string; var values : TStringList);
+
+    function getStates(var values : TStringList): boolean;
+
     function isTuxDroidServerStarted() : boolean;
-    function isDongleConnected() : boolean;
-    function isSoundOn() : boolean;
-    function isRadioConnected()  : boolean;
-    function isOnActivity() : boolean;
+    function isDongleConnected(states : TStringList) : boolean;
+    function isSoundOn(states : TStringList) : boolean;
+    function isRadioConnected(states : TStringList)  : boolean;
+    function isOnActivity(states : TStringList) : boolean;
 
 
 var
   XmlScanner1 : TXmlScanner;
-  GlobalState : TStringList;
 
 
 implementation
@@ -99,88 +100,121 @@
 
 
 {####### This function parse a string to retrieve global informations ######}
-function parseStates(aString : string) : TStringList;
+procedure parseStates(aString : string; var values : TStringList);
 var
   beginPos, endPos : Integer;
 begin
 
-  //Searching for dongle state ( <dongleState> )
-  beginPos := Pos('<dongleState>', aString) + Length('<dongleState>');
-  endPos := Pos('</dongleState>', aString);
-  result[1] := Copy(aString, beginPos, endPos - beginPos);
+  values := TStringList.Create;
 
-  //Searching for radio state  ( <radioState>  )
-  beginPos := Pos('<radioState>', aString) + Length('<radioState>');
-  endPos := Pos('</radioState>', aString);
-  result[2] := Copy(aString, beginPos, endPos - beginPos);
+  try
+    //Searching for dongle state ( <dongleState> )
+    beginPos := Pos('<dongleState>', aString) + Length('<dongleState>');
+    endPos := Pos('</dongleState>', aString);
+    values.add(Copy(aString, beginPos, endPos - beginPos));
+  except
+    on e: Exception do
+      values.add('off');
+  end;
 
-  //Searching for sound state  ( <soundState>  )
-  beginPos := Pos('<soundState>', aString) + Length('<soundState>');
-  endPos := Pos('</soundState>', aString);
-  result[3] := Copy(aString, beginPos, endPos - beginPos);
 
-  //Searching for activity state ( <gadgets>   )
-  //beginPos := Pos('<alerts>', aString) + Length('<alerts>');
-  result[4] := 'false';
+  try
+    //Searching for radio state  ( <radioState>  )
+    beginPos := Pos('<radioState>', aString) + Length('<radioState>');
+    endPos := Pos('</radioState>', aString);
+    values.add(Copy(aString, beginPos, endPos - beginPos));
+  except
+    on e : Exception do
+      values.add('off');
+  end;
+
+  try
+    //Searching for sound state  ( <soundState>  )
+    beginPos := Pos('<soundState>', aString) + Length('<soundState>');
+    endPos := Pos('</soundState>', aString);
+    values.add(Copy(aString, beginPos, endPos - beginPos));
+  except
+    on e : Exception do
+      values.Add('off');
+  end;
+
+  try
+    //Searching for activity state ( <gadgets>   )
+    //beginPos := Pos('<alerts>', aString) + Length('<alerts>');
+    values.add('off');
+  except
+    on e : Exception do
+      values.Add('off');
+  end;
 end;
 
 
 {#### Return parsed states ####}
-function getStates() : TStringList;
+function getStates(var values : TStringList) : boolean;
 var
   res : string;
 begin
+
   res := 
TuxUtils.DownloadHTTP('http://127.0.0.1:270/0/wi_user_01/get_states?');
 
   if res <> '' then
     begin
-      GlobalState := TuxUtils.parseStates(res);
-      result := GlobalState;
+        TuxUtils.parseStates(res, values);
+        result := true;
     end
   else
     begin
-      GlobalState := nil;
-      result := nil;
+      values := nil;
+      result := false;
     end;
 
 end;
 
 
 {#### Return the dongle state ####}
-function isDongleConnected() : boolean;
+function isDongleConnected(states : TStringList) : boolean;
 begin
-  if Assigned(GlobalState) then
-     result := StrToBool(GlobalState[1])
+  if states <> nil then
+     if states[1] = 'on' then
+       result := true
+     else
+       result := false
   else
      result := false;
 end;
 
 
 {#### Return the sound state ####}
-function isSoundOn() : boolean;
+function isSoundOn(states : TStringList) : boolean;
 begin
-  if Assigned(GlobalState) then
-     result := StrToBool(GlobalState[3])
+  if states <> nil then
+     if states[3] = 'on' then
+       result := true
+     else
+       result := false
   else
      result := false;
 end;
 
 
 {#### Return the radio connection state ####}
-function isRadioConnected()  : boolean;
+function isRadioConnected(states : TStringList)  : boolean;
 begin
-   if Assigned(GlobalState) then
-     result := StrToBool(GlobalState[2])
+   if states <> nil then
+     if states[2] = 'on' then
+       result := true
+     else
+       result := false
    else
      result := false;
 end;
 
 
 {#### Return true if a gadget is in activity ####}
-function isOnActivity() : boolean;
+function isOnActivity(states : TStringList) : boolean;
 begin
-   if Assigned(GlobalState) then
-     result := StrToBool(GlobalState[4])
+   if states <> nil then
+     result := false
    else
      result := false;
 end;

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dcu
===================================================================
(Binary files differ)

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dfm
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dfm
 2009-07-23 12:13:00 UTC (rev 5143)
+++ 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.dfm
 2009-07-23 12:30:05 UTC (rev 5144)
@@ -59,6 +59,7 @@
     Height = 715
     Align = alClient
     TabOrder = 0
+    Silent = False
     RegisterAsBrowser = True
     RegisterAsDropTarget = False
     OnDocumentComplete = EmbeddedWB1DocumentComplete
@@ -529,7 +530,6 @@
     Top = 8
   end
   object ConnectionChecker: TTimer
-    Enabled = False
     Interval = 2000
     OnTimer = ConnectionCheckerTimer
     Left = 104

Modified: 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas
 2009-07-23 12:13:00 UTC (rev 5143)
+++ 
software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas
 2009-07-23 12:30:05 UTC (rev 5144)
@@ -72,8 +72,6 @@
   url           : String;
   Tray          : TNotifyIconData;
   AppIcon       : TIcon;
-  serverStarted : boolean;
-  radioState    : boolean;
 
 implementation
 
@@ -88,8 +86,7 @@
 procedure TForm1.FormCreate(Sender: TObject);
 begin
   url := 'http://127.0.0.1:270/user/';
-  radioState := false;
-  
+
   //Tray icon initialization.
   Tray.cbSize := SizeOf(Tray);
   Tray.wnd := Handle;
@@ -110,8 +107,6 @@
 
   EmbeddedWB1.Go(url);
 
-  ConnectionChecker.Enabled := True;
-
 end;
 
 
@@ -279,12 +274,20 @@
 procedure TForm1.ConnectionCheckerTimer(Sender: TObject);
 var
   server, dongle : boolean;
+  temp : TStringList;
+  
 begin
-  TuxUtils.getStates();
+  try
+    TuxUtils.getStates(temp);
+    dongle := TuxUtils.isDongleConnected(temp);
+  except
+    dongle := false;
+  end;
+
+  temp.Free;
   server := TuxUtils.isTuxDroidServerStarted();
-  dongle := TuxUtils.isDongleConnected();
-    
-    //Changing tray icon if server isn't started or no radio detected.
+
+  //Changing tray icon if server isn't started or no radio detected.
   if ( server and dongle ) then
     begin
       ImageList1.GetIcon(0, AppIcon);
@@ -298,7 +301,7 @@
       Shell_NotifyIcon(Nim_Modify, @tray);
     end;
   Application.ProcessMessages;
-  self.ConnectionChecker.Enabled := true;
+  
 end;
 
 end.


------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to