Author: jerome
Date: 2009-07-29 17:55:19 +0200 (Wed, 29 Jul 2009)
New Revision: 5230

Modified:
   
software_suite_v3/software/tool/tux_droid_browser_launcher/trunk/tux_droid_browser_launcher/launcher.dpr
Log:
* Stopping the server first before restarting TuxBox 2.0

Modified: 
software_suite_v3/software/tool/tux_droid_browser_launcher/trunk/tux_droid_browser_launcher/launcher.dpr
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser_launcher/trunk/tux_droid_browser_launcher/launcher.dpr
    2009-07-29 15:23:59 UTC (rev 5229)
+++ 
software_suite_v3/software/tool/tux_droid_browser_launcher/trunk/tux_droid_browser_launcher/launcher.dpr
    2009-07-29 15:55:19 UTC (rev 5230)
@@ -17,9 +17,8 @@
   Messages;
 
 
-
-{#### Return true if TuxBox 2.0 is running ####}
-function isTuxBoxRunning() : boolean;
+{#### Return true if the targeted process is running ####}
+function isProcessRunning(process : string) : boolean;
 var
   ContinueLoop: BOOL;
   FSnapshotHandle: THandle;
@@ -34,8 +33,8 @@
   while Integer(ContinueLoop) <> 0 do
     begin
       if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
-           UpperCase('TuxBox.exe')) or (UpperCase(FProcessEntry32.szExeFile) =
-           UpperCase('TuxBox.exe'))) then
+           UpperCase(process)) or (UpperCase(FProcessEntry32.szExeFile) =
+           UpperCase(process))) then
         begin
           Result := True;
         end;
@@ -48,6 +47,19 @@
 end;
 
 
+function isSmartCoreRunning() : boolean;
+begin
+  result := isProcessRunning('pythonForTuxdroid.exe');
+end;
+
+
+{#### Return true if TuxBox 2.0 is running ####}
+function isTuxBoxRunning() : boolean;
+begin
+   result := isProcessRunning('TuxBox.exe');
+end;
+
+
 {#### Set TuxBox 2.0 Foreground ####}
 procedure setForeground(wParam : Integer; mess : string);
 var
@@ -58,11 +70,26 @@
 end;
 
 
+
 {#### Start smart-core and TuxBox ####}
 procedure startAll();
 var
   APPLICATION : string;
+  timeout : byte;
 begin
+  //Stop Tuxdroid server if it is started. ( Start all function starts the 
server too ).
+  if isSmartCoreRunning() then
+    begin
+       timeout := 30;
+       ShellExecute(HWND(nil), 'open', 'smart_server_stop', 'show', nil, 
SW_HIDE);
+
+       repeat
+         sleep(1000);
+         dec(timeout, 1);
+       until ( ( not isSmartCoreRunning() ) or ( timeout = 0 ) );
+
+    end;
+
   //Starting Application.
   APPLICATION := '"' + GetEnvironmentVariable('PROGRAMFILES') + '\Kysoh\Tux 
Droid\softwares\TuxBox 2.0\TuxBox.exe"';
   ShellExecute(HWND(nil), 'open', PChar(APPLICATION), 'show', nil, SW_HIDE);


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to