[tuxdroid-svn] r5155 - software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_br
Status: Beta
Brought to you by:
ks156
|
From: jerome <c2m...@c2...> - 2009-07-24 10:05:03
|
Author: jerome
Date: 2009-07-24 12:04:43 +0200 (Fri, 24 Jul 2009)
New Revision: 5155
Modified:
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.pas
Log:
* Improved the way to referesh tray icons.
* Added a global function to retrieve server command results.
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 21:26:20 UTC (rev 5154)
+++ software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/TuxUtils.pas 2009-07-24 10:04:43 UTC (rev 5155)
@@ -18,16 +18,32 @@
function getUserLanguage() : String;
function toggleMute() : boolean;
function stopServer() : boolean;
-
+ procedure initKnowedVars();
procedure parseStates(aString : string; var values : TStringList);
+ function getResult(request : string) : boolean;
var
XmlScanner1 : TXmlScanner;
- mute_value : boolean;
+ knowed_mute : boolean;
+ knowed_radio : boolean;
+ knowed_dongle : boolean;
+ knowed_server : boolean;
+ knowed_activity : boolean;
+
implementation
+{#### Initialization of knowed states ####}
+procedure initKnowedVars();
+begin
+ knowed_mute := false;
+ knowed_radio := false;
+ knowed_dongle := false;
+ knowed_server := false;
+ knowed_activity := false;
+end;
+
//Return true if the tuxdroidserver is started, false if not.
function isTuxDroidServerStarted() : boolean;
var
@@ -90,10 +106,16 @@
end;
except
On e : Exception do
- result := '';
+ begin
+ result := '';
+ output.Free;
+ end;
end;
finally
+ begin
+ output.Free;
Free;
+ end;
end;
end;
@@ -235,9 +257,7 @@
temp : TStringList;
sound_on : boolean;
request_result : string;
- beginPos, endPos : Integer;
begin
- temp := TStringList.Create;
TuxUtils.getStates(temp);
sound_on := TuxUtils.isSoundOn(temp);
@@ -255,39 +275,44 @@
//proceeding to mute.
request_result := TuxUtils.DownloadHTTP(command_unmute);
end;
+ result := TuxUtils.getResult(request_result);
+end;
- try
- //Getting the request result <result>.
- beginPos := Pos('<result>', request_result) + Length('<result>');
- endPos := Pos('</result>', request_result);
- if Copy(request_result, beginPos, endPos - beginPos) = 'Success' then
- result := true
- else
- result := false;
- except
- on e : Exception do
- result := false;
- end;
-end;
-
{#### This function stops the tux droid server. ####}
function stopServer() : boolean;
const
command_stop = 'http://127.0.0.1:270/0/server/stop?';
var
request_result : string;
- beginPos, endPos : Integer;
begin
request_result := TuxUtils.DownloadHTTP(command_stop);
+ result := TuxUtils.getResult(request_result);
+end;
+
+{#### Gets the current user language. ####}
+function getUserLanguage() : String;
+const
+ command_language = '';
+begin
+ {TODO}
+end;
+
+
+
+{#### Return the result of a function .####}
+function getResult(request : string) : boolean;
+var
+ beginPos, endPos : Integer;
+begin
try
//Getting the request result <result>.
- beginPos := Pos('<result>', request_result) + Length('<result>');
- endPos := Pos('</result>', request_result);
+ beginPos := Pos('<result>', request) + Length('<result>');
+ endPos := Pos('</result>', request);
- if Copy(request_result, beginPos, endPos - beginPos) = 'Success' then
+ if Copy(request, beginPos, endPos - beginPos) = 'Success' then
result := true
else
result := false;
@@ -297,13 +322,5 @@
end;
end;
-{#### Gets the current user language. ####}
-function getUserLanguage() : String;
-const
- command_language = '';
-begin
- {TODO}
-end;
-
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.pas
===================================================================
--- software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas 2009-07-23 21:26:20 UTC (rev 5154)
+++ software_suite_v3/software/tool/tux_droid_browser/windows/trunk/tux_droid_browser/Unit1.pas 2009-07-24 10:04:43 UTC (rev 5155)
@@ -72,6 +72,7 @@
url : String;
Tray : TNotifyIconData;
AppIcon : TIcon;
+ started : boolean;
implementation
@@ -87,6 +88,8 @@
begin
url := 'http://127.0.0.1:270/user/';
+ started := false;
+
//Tray icon initialization.
Tray.cbSize := SizeOf(Tray);
Tray.wnd := Handle;
@@ -105,6 +108,9 @@
//Adding tray icon to the system tray.
Shell_NotifyIcon(Nim_ADD, @Tray);
+ //states initialization
+ TuxUtils.initKnowedVars();
+ //Starting status pooling.
EmbeddedWB1.Go(url);
end;
@@ -310,29 +316,38 @@
connection := server and dongle and radio;
- //Changing tray icon if server isn't started or no radio detected.
- if connection and sound and ( not activity ) then
+ //Changing tray icon 'connection' if server isn't started or no radio detected and
+ //State has changed since last knowledge register.
+ if connection and sound and ( not activity ) and ( ( TuxUtils.knowed_mute
+ and ( not TuxUtils.knowed_activity )) <> ( sound and (not activity) )) then
begin
ImageList1.GetIcon(0, AppIcon);
Tray.hIcon := AppIcon.Handle;
Shell_NotifyIcon(Nim_Modify, @tray);
end
- else if connection and ( not sound ) and ( not activity ) then
+ //Changing tray icon 'mute' only if last registered values <> new sound and
+ //activity values.
+ else if connection and ( not sound ) and ( not activity ) and
+ ( ( ( not sound ) and ( not activity ) ) <> ( ( not TuxUtils.knowed_mute )
+ and ( not TuxUtils.knowed_activity ) ) )then
begin
ImageList1.GetIcon(4, AppIcon);
Tray.hIcon := AppIcon.Handle;
Shell_NotifyIcon(Nim_Modify, @tray);
end
- else if connection and activity and sound then
+ else if connection and activity and sound and ( ( sound and activity ) <>
+ ( TuxUtils.knowed_mute and TuxUtils.knowed_activity ) ) then
begin
ImageList1.GetIcon(3, AppIcon);
Tray.hIcon := AppIcon.Handle;
Shell_NotifyIcon(Nim_Modify, @tray);
end
- else
+ //Changing icon only if last state <> new state.
+ else if connection <> ( TuxUtils.knowed_server and TuxUtils.knowed_radio and TuxUtils.knowed_dongle)
+ or ( not started ) then
begin
ImageList1.GetIcon(1, AppIcon);
Tray.hIcon := AppIcon.Handle;
@@ -345,7 +360,17 @@
else
//Updating tick from popup menu ( sound off ).
Mute1.ImageIndex := 5;
-
+
+ //Registering new values.
+ TuxUtils.knowed_mute := sound;
+ TuxUtils.knowed_radio := radio;
+ TuxUtils.knowed_dongle := dongle;
+ TuxUtils.knowed_server := server;
+ TuxUtils.knowed_activity := activity;
+
+ if not started then
+ started := true;
+
Application.ProcessMessages;
end;
|