Author: remi
Date: 2008-12-24 13:29:52 +0100 (Wed, 24 Dec 2008)
New Revision: 3307
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.ddp
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.dfm
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.pas
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.cfg
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dof
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dpr
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.res
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/IMMonitoring.pas
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/InternetConnection.pas
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/Logger.pas
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/signInstaller.bat
Removed:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/tmp_smiley_list.txt
Modified:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/HTTPRessource/ResourceChatterTux.py
software_suite_v2/software/http_server_resources/chatter_tux/trunk/VERSION
software_suite_v2/software/http_server_resources/chatter_tux/trunk/installer.nsi
Log:
* refactored the project
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.ddp
===================================================================
(Binary files differ)
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.ddp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.dfm
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.dfm
(rev 0)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.dfm
2008-12-24 12:29:52 UTC (rev 3307)
@@ -0,0 +1,11 @@
+object Service1: TService1
+ OldCreateOrder = False
+ OnCreate = ServiceCreate
+ AllowPause = False
+ DisplayName = 'ChatterTux'
+ OnExecute = ServiceExecute
+ Left = 198
+ Top = 107
+ Height = 150
+ Width = 215
+end
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.dfm
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.pas
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.pas
(rev 0)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.pas
2008-12-24 12:29:52 UTC (rev 3307)
@@ -0,0 +1,228 @@
+{*
+ * Tuxdroid Chatter Tux network sniffer Service for windows
+ *
+ * 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, 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.
+ *}
+
+unit ChatterTuxMain;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs,
+ Logger, InternetConnection, IMMonitoring,
+ IdBaseComponent, IdComponent, IdHTTP, IdException;
+
+const
+ MSN_MSG_REQ =
'http://127.0.0.1:270/0/status/send?name=chatter&value=MSN|MSG|Nickname|%s';
+
+type
+ TService1 = class(TService)
+ procedure ServiceExecute(Sender: TService);
+ procedure ServiceCreate(Sender: TObject);
+ private
+ { D�clarations priv�es }
+ public
+ function GetServiceController: TServiceController; override;
+ { D�clarations publiques }
+ end;
+
+var
+ Service1: TService1;
+ internetConn : TInternetConnection;
+ ImMonitor : TIMMonitoring;
+
+implementation
+
+{$R *.DFM}
+
+{*
+ * \brief Encode a string with the URL format.
+ * \param AStr String to encode.
+ * \return The encoded string.
+ *}
+function HTTPUrlEncode(const AStr: string): string;
+const
+ NoConversion = ['A'..'Z', 'a'..'z', '*', '@', '.', '_', '-'];
+var
+ Sp, Rp: PChar;
+begin
+ SetLength(Result, Length(AStr) * 3);
+ Sp := PChar(AStr);
+ Rp := PChar(Result);
+ while Sp^ <> #0 do
+ begin
+ if Sp^ in NoConversion then
+ Rp^ := Sp^
+ else if Sp^ = ' ' then
+ Rp^ := '+'
+ else
+ begin
+ FormatBuf(Rp^, 3, '%%%.2x', 6, [Ord(Sp^)]);
+ Inc(Rp, 2);
+ end;
+ Inc(Rp);
+ Inc(Sp);
+ end;
+ SetLength(Result, Rp - PChar(Result));
+end;
+
+{*
+ * \brief Send a message to the HTTP server.
+ * \param msg Message to send.
+ *}
+procedure sendToHTTPServer(msg : string);
+var
+ idHTTP : TIdHTTP;
+begin
+ idHTTP := TIdHTTP.Create(nil);
+ idHTTP.ConnectTimeout := 30000;
+ idHTTP.Request.CacheControl := 'no-cache';
+ idHTTP.Request.UserAgent:= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1)';
+ idHTTP.HandleRedirects := true;
+ idHTTP.RedirectMaximum := 100;
+ try
+ idHTTP.Get(format(MSN_MSG_REQ, [HTTPUrlEncode(msg)]));
+ except
+ end;
+ idHttp.Disconnect;
+ idHTTP.Free;
+end;
+
+{*
+ * \brief Callback on monitoring error message.
+ * \param msg The message.
+ *}
+procedure onMonitoringError(msg : string);
+begin
+ LogError(msg);
+end;
+
+{*
+ * \brief Callback on monitoring info message.
+ * \param msg The message.
+ *}
+procedure onMonitoringInfo(msg : string);
+begin
+ LogInfo(msg);
+end;
+
+{*
+ * \brief Callback on monitoring IM message.
+ * \param msg The message.
+ *}
+procedure onMonitoringIMMessage(msg : string);
+begin
+ LogInfo('IMChat : ' + msg);
+ sendToHTTPServer(msg);
+end;
+
+{*
+ * \brief Callback on monitoring connected.
+ *}
+procedure onMonitoringConnected;
+begin
+ // Not used yet ...
+end;
+
+{*
+ * \brief Callback on monitoring disconnected.
+ *}
+procedure onMonitoringDisconnected;
+begin
+ internetConn.setDisconnected;
+end;
+
+{*
+ * \brief Return a pointer to a parameter of the service.
+ *}
+procedure ServiceController(CtrlCode: DWord); stdcall;
+begin
+ Service1.Controller(CtrlCode);
+end;
+
+{*
+ * \brief Return a pointer to the service controller.
+ *}
+function TService1.GetServiceController: TServiceController;
+begin
+ Result := ServiceController;
+end;
+
+{*
+ * \brief Execute the service.
+ *}
+procedure TService1.ServiceExecute(Sender: TService);
+begin
+ internetConn.Resume;
+
+ while not Terminated do
+ begin
+ ServiceThread.ProcessRequests(True);
+ end;
+
+ internetConn.Terminate;
+ if ImMonitor.connected then
+ ImMonitor.Terminate;
+end;
+
+{*
+ * \brief Callback on internet connected.
+ * \param ip The IP address of the connected network adaptator.
+ *}
+procedure onInternetConnected(ip : string);
+begin
+ LogInfo('Internet connection detected with IP : ' + ip);
+
+ if assigned(ImMonitor) then
+ ImMonitor.Free;
+
+ ImMonitor := TIMMonitoring.create;
+ ImMonitor.FreeOnTerminate := false;
+ ImMonitor.onError := @onMonitoringError;
+ ImMonitor.onInfo := @onMonitoringInfo;
+ ImMonitor.onIMMessage := @onMonitoringIMMessage;
+ ImMonitor.onDisconnected := @onMonitoringDisconnected;
+
+ ImMonitor.setIp(ip);
+ ImMonitor.Resume;
+end;
+
+{*
+ * \brief Callback on internet disconnected.
+ * \param ip The IP address of the disconnected network adaptator.
+ *}
+procedure onInternetDisconnected(ip : string);
+begin
+ LogInfo('Disconnected from internet');
+ ImMonitor.Terminate;
+end;
+
+{*
+ * \brief Create the service.
+ *}
+procedure TService1.ServiceCreate(Sender: TObject);
+begin
+ LogInit('ChatterTux.log');
+ LogInfo('ChatterTux started');
+
+ internetConn := TInternetConnection.Create(true);
+ internetConn.FreeOnTerminate := false;
+ internetConn.onConnected := @onInternetConnected;
+ internetConn.onDisconnected := @onInternetDisconnected;
+end;
+
+end.
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxMain.pas
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.cfg
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.cfg
(rev 0)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.cfg
2008-12-24 12:29:52 UTC (rev 3307)
@@ -0,0 +1,38 @@
+-$A8
+-$B-
+-$C+
+-$D+
+-$E-
+-$F-
+-$G+
+-$H+
+-$I+
+-$J-
+-$K-
+-$L+
+-$M-
+-$N+
+-$O+
+-$P+
+-$Q-
+-$R-
+-$S-
+-$T-
+-$U-
+-$V+
+-$W-
+-$X+
+-$YD
+-$Z1
+-cg
+-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+-H+
+-W+
+-M
+-$M16384,1048576
+-K$00400000
+-LE"e:\programs\delphi7\Projects\Bpl"
+-LN"e:\programs\delphi7\Projects\Bpl"
+-w-UNSAFE_TYPE
+-w-UNSAFE_CODE
+-w-UNSAFE_CAST
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dof
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dof
(rev 0)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dof
2008-12-24 12:29:52 UTC (rev 3307)
@@ -0,0 +1,136 @@
+[FileVersion]
+Version=7.0
+[Compiler]
+A=8
+B=0
+C=1
+D=1
+E=0
+F=0
+G=1
+H=1
+I=1
+J=0
+K=0
+L=1
+M=0
+N=1
+O=1
+P=1
+Q=0
+R=0
+S=0
+T=0
+U=0
+V=1
+W=0
+X=1
+Y=1
+Z=1
+ShowHints=1
+ShowWarnings=1
+UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+NamespacePrefix=
+SymbolDeprecated=1
+SymbolLibrary=1
+SymbolPlatform=1
+UnitLibrary=1
+UnitPlatform=1
+UnitDeprecated=1
+HResultCompat=1
+HidingMember=1
+HiddenVirtual=1
+Garbage=1
+BoundsError=1
+ZeroNilCompat=1
+StringConstTruncated=1
+ForLoopVarVarPar=1
+TypedConstVarPar=1
+AsgToTypedConst=1
+CaseLabelRange=1
+ForVariable=1
+ConstructingAbstract=1
+ComparisonFalse=1
+ComparisonTrue=1
+ComparingSignedUnsigned=1
+CombiningSignedUnsigned=1
+UnsupportedConstruct=1
+FileOpen=1
+FileOpenUnitSrc=1
+BadGlobalSymbol=1
+DuplicateConstructorDestructor=1
+InvalidDirective=1
+PackageNoLink=1
+PackageThreadVar=1
+ImplicitImport=1
+HPPEMITIgnored=1
+NoRetVal=1
+UseBeforeDef=1
+ForLoopVarUndef=1
+UnitNameMismatch=1
+NoCFGFileFound=1
+MessageDirective=1
+ImplicitVariants=1
+UnicodeToLocale=1
+LocaleToUnicode=1
+ImagebaseMultiple=1
+SuspiciousTypecast=1
+PrivatePropAccessor=1
+UnsafeType=0
+UnsafeCode=0
+UnsafeCast=0
+[Linker]
+MapFile=0
+OutputObjs=0
+ConsoleApp=1
+DebugInfo=0
+RemoteSymbols=0
+MinStackSize=16384
+MaxStackSize=1048576
+ImageBase=4194304
+ExeDescription=
+[Directories]
+OutputDir=
+UnitOutputDir=
+PackageDLLOutputDir=
+PackageDCPOutputDir=
+SearchPath=
+Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP
+Conditionals=
+DebugSourceDirs=
+UsePackages=0
+[Parameters]
+RunParams=
+HostApplication=
+Launcher=
+UseLauncher=0
+DebugCWD=
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=E:\Programs\Delphi7\Bin\
+[Version Info]
+IncludeVerInfo=0
+AutoIncBuild=0
+MajorVer=1
+MinorVer=0
+Release=0
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=2060
+CodePage=1252
+[Version Info Keys]
+CompanyName=
+FileDescription=
+FileVersion=1.0.0.0
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=1.0.0.0
+Comments=
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dof
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dpr
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dpr
(rev 0)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dpr
2008-12-24 12:29:52 UTC (rev 3307)
@@ -0,0 +1,33 @@
+{*
+ * Tuxdroid Chatter Tux network sniffer Service for windows
+ *
+ * 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, 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.
+ *}
+
+program ChatterTuxService;
+
+uses
+ SvcMgr,
+ ChatterTuxMain in 'ChatterTuxMain.pas' {Service1: TService};
+
+{$R *.RES}
+
+begin
+ Application.Initialize;
+ Application.Title := 'ChatterTuxService';
+ Application.CreateForm(TService1, Service1);
+ Application.Run;
+end.
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.dpr
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.res
===================================================================
(Binary files differ)
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/ChatterTuxService.res
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/IMMonitoring.pas
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/IMMonitoring.pas
(rev 0)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/IMMonitoring.pas
2008-12-24 12:29:52 UTC (rev 3307)
@@ -0,0 +1,341 @@
+{*
+ * Tuxdroid Chatter Tux network sniffer Service for windows
+ *
+ * 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, 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.
+ *}
+
+unit IMMonitoring;
+
+interface
+
+uses
+ Classes, Windows, SysUtils,
+ MagentaMonsock, MagentaMonpcap, MagentaPacket32, MagentaPcap,
+ MagentaPackhdrs, Magsubs1, MagClasses;
+
+type
+
+ TMonMessage = procedure (msg : string);
+ TMonConnectionChanged = procedure;
+
+ TIMMonitoring = class(TThread)
+ private
+ P_connected : boolean;
+ P_ip : string;
+ P_CardName : string;
+ P_splitedFrame : TStringList;
+ P_monitor : TMonitorPcap;
+ P_onError : TMonMessage;
+ P_onInfo : TMonMessage;
+ p_onConnected : TMonConnectionChanged;
+ p_onDisconnected : TMonConnectionChanged;
+ P_onIMMessage : TMonMessage;
+
+ procedure PacketEvent(Sender: TObject; PacketInfo: TPacketInfo);
+ protected
+ procedure Execute; override;
+ public
+ constructor create; overload;
+ procedure setIp(ip : string);
+ procedure Terminate; overload;
+
+ property onError : TMonMessage
+ read P_onError
+ write P_onError;
+ property onInfo : TMonMessage
+ read P_onInfo
+ write P_onInfo;
+ property onConnected : TMonConnectionChanged
+ read p_onConnected
+ write p_onConnected;
+ property onDisconnected : TMonConnectionChanged
+ read p_onDisconnected
+ write p_onDisconnected;
+ property onIMMessage : TMonMessage
+ read P_onIMMessage
+ write P_onIMMessage;
+ property connected : boolean
+ read P_connected;
+ end;
+
+implementation
+
+//
=============================================================================
+// Misc functions
+//
=============================================================================
+
+{**
+ * \brief Match the MSN messages.
+ * \return The parsed message or and mpty string.
+ *}
+function parseMsnMessage(splitedFrame : TStrings) : string;
+begin
+ result := '';
+ // MSN messages matching
+ if pos('MSG', splitedFrame[0]) <> 1 then exit;
+ if length(splitedFrame[splitedFrame.Count - 2]) <> 0 then exit;
+ // Return the message text
+ result := splitedFrame[splitedFrame.Count - 1];
+end;
+
+//
=============================================================================
+// TIMMonitoring class
+//
=============================================================================
+
+{**
+ * \brief Create the thread.
+ *}
+constructor TIMMonitoring.create;
+begin
+ inherited create(true);
+ P_ip := '';
+ P_connected := false;
+ P_CardName := '';
+ P_splitedFrame := TStringList.Create;
+end;
+
+{**
+ * \brief Set the IP address to monitoring.
+ * \param ip IP address
+ *}
+procedure TIMMonitoring.setIp(ip : string);
+begin
+ P_ip := ip;
+end;
+
+{**
+ * \brief Terminate the thread.
+ *}
+procedure TIMMonitoring.Terminate;
+begin
+ if P_monitor.Connected then
+ begin
+ P_monitor.StopMonitor;
+ P_connected := false;
+ P_CardName := '';
+ if assigned(P_onInfo) then P_onInfo('Monitoring Successfuly stopped');
+ sleep(500);
+ end;
+ inherited Terminate;
+end;
+
+{**
+ * \brief Execute the thread.
+ * \param ip IP address.
+ *}
+procedure TIMMonitoring.Execute;
+var
+ retryCounter : integer;
+ IpList : TStringList;
+ BcastList : TStringList;
+ MaskList : TStringList;
+ AdaptList : TStringList;
+ i, j, c : integer;
+begin
+ P_connected := false;
+ P_CardName := '';
+ // Wait for dll
+ retryCounter := 0;
+ while not self.Terminated do
+ begin
+ retryCounter := retryCounter + 1;
+ if retryCounter > 60 then
+ begin
+ if assigned(P_onError) then P_onError('PCap DLL not found');
+ exit;
+ end;
+ if LoadPacketDll then
+ begin
+ if assigned(P_onInfo) then P_onInfo('PCap DLL found');
+ break;
+ end;
+ sleep(1000);
+ end;
+ if self.Terminated then exit;
+ // Init some var
+ IpList := TStringList.Create;
+ BcastList := TStringList.Create;
+ MaskList := TStringList.Create;
+ AdaptList := TStringList.Create;
+ // Init the pcap monitor object
+ P_monitor := TMonitorPcap.Create(nil);
+ P_monitor.onPacketEvent := PacketEvent;
+ // Retrieve the correct network card
+ retryCounter := 0;
+ while not self.Terminated do
+ begin
+ retryCounter := retryCounter + 1;
+ if retryCounter > 60 then
+ begin
+ if assigned(P_onError) then P_onError('Adaptor not found');
+ exit;
+ end;
+ AdaptList.Clear;
+ AdaptList.AddStrings(P_monitor.AdapterDescList);
+ if AdaptList.Count > 0 then
+ begin
+ for i := 0 to AdaptList.Count - 1 do
+ begin
+ IpList.Clear;
+ MaskList.Clear;
+ BcastList.Clear;
+ c := P_monitor.GetIPAddresses(P_monitor.AdapterNameList[i], IpList,
+ MaskList, BcastList);
+ if assigned(P_onInfo) then
+ begin
+ P_onInfo('Adaptor found : ' + P_monitor.AdapterDescList[i]);
+ P_onInfo('Adaptor description : ');
+ P_onInfo(P_monitor.AdapterNameList[i]);
+ P_onInfo(IpList.Text);
+ P_onInfo(MaskList.Text);
+ P_onInfo(BcastList.Text);
+ end;
+ if c = 0 then continue;
+ for j := 0 to c - 1 do
+ begin
+ if IpList[j] = P_ip then
+ begin
+ P_CardName := P_monitor.AdapterNameList[i];
+ if assigned(P_onInfo) then
+ begin
+ P_onInfo('Adaptor work : ' + P_monitor.AdapterDescList[i]);
+ P_onInfo('Symbolic name : ' + P_CardName);
+ P_onInfo('Mask address : ' + MaskList[j]);
+ break;
+ end;
+ end;
+ end;
+ if P_CardName <> '' then break;
+ end;
+ if P_CardName <> '' then break;
+ end;
+ sleep(1000);
+ end;
+ if self.Terminated then exit;
+ // Configure the monitoring
+ P_monitor.MonAdapter := P_CardName;
+ P_monitor.Addr := P_ip;
+ P_monitor.AddrMask := '255.255.255.0';
+ P_monitor.IgnoreData := false;
+ P_monitor.IgnoreLAN := false;
+ P_monitor.IgnoreNonIP := true;
+ P_monitor.Promiscuous := true;
+ P_monitor.ClearIgnoreIP;
+ // Attempt to start the capture
+ retryCounter := 0;
+ while not self.Terminated do
+ begin
+ retryCounter := retryCounter + 1;
+ if retryCounter > 10 then
+ begin
+ if assigned(P_onError) then P_onError('Can''t start the monitoring');
+ exit;
+ end;
+ P_monitor.StartMonitor;
+ if P_monitor.Connected then
+ begin
+ if assigned(P_onInfo) then P_onInfo('Monitoring Successfuly started');
+ if assigned(p_onConnected) then p_onConnected;
+ break;
+ end;
+ sleep(1000);
+ end;
+ if self.Terminated then exit;
+ // ... Monitoring work
+ while not self.Terminated do
+ begin
+ if not P_monitor.Connected then
+ begin
+ break;
+ end;
+
+ if P_monitor.LastError = 'Error while reading' then
+ begin
+ if assigned(P_onInfo) then P_onInfo('Adaptor has been disconnected !');
+ if assigned(p_onDisconnected) then
+ p_onDisconnected;
+ self.Terminate;
+ end;
+
+ sleep(1000);
+ end;
+
+ IpList.Free;
+ BcastList.Free;
+ MaskList.Free;
+ AdaptList.Free;
+end;
+
+{**
+ * \brief Callback on packet event.
+ *}
+procedure TIMMonitoring.PacketEvent(Sender: TObject; PacketInfo: TPacketInfo);
+var
+ frame, text: string ;
+begin
+ try
+ with PacketInfo do
+ begin
+ // Get the buffer frame
+ frame := String(DataBuf);
+
+ // Only IP protocol
+ if EtherProto = PROTO_IP then
+ begin
+ if length(frame) < 64 then exit;
+ if length(frame) > 1024 then exit;
+ if pos('MSG', frame) <> 1 then exit;
+
+ // Only messages for me
+ if pos(P_ip, IPToStr(AddrDest)) = 0 then exit;
+
+ // Split the frame
+ frame := StringReplace(frame, ' ', '*$*',
+ [rfReplaceAll, rfIgnoreCase]);
+ frame := StringReplace(frame, chr(13)+chr(10), '�',
+ [rfReplaceAll, rfIgnoreCase]);
+ P_splitedFrame.Clear;
+ P_splitedFrame.Delimiter := '�';
+ P_splitedFrame.DelimitedText := frame;
+ if assigned(P_onInfo) then
+ P_onInfo('Received IP frame : Size = ' +
inttostr(length(frame)));
+ // If MSN
+ text := parseMsnMessage(P_splitedFrame);
+ if text <> '' then
+ begin
+ text := StringReplace(text, '*$*', ' ',
+ [rfReplaceAll, rfIgnoreCase]);
+ //Memo1.Lines.Add(text);
+ // Replace the chars ('|' , '&', '+') before to send the status
+ // to the HTTP server.
+ text := StringReplace(text, '|', '������',
+ [rfReplaceAll, rfIgnoreCase]);
+ text := StringReplace(text, '&', '�����',
+ [rfReplaceAll, rfIgnoreCase]);
+ text := StringReplace(text, '+', '����',
+ [rfReplaceAll, rfIgnoreCase]);
+ if assigned(P_onIMMessage) then
+ P_onIMMessage(text);
+ end;
+ end;
+ end;
+ except
+ if assigned(P_onInfo) then
+ P_onInfo('Bad frame');
+ end;
+end;
+
+end.
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/IMMonitoring.pas
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/InternetConnection.pas
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/InternetConnection.pas
(rev 0)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/InternetConnection.pas
2008-12-24 12:29:52 UTC (rev 3307)
@@ -0,0 +1,137 @@
+unit InternetConnection;
+
+interface
+
+uses
+ Classes, Windows,
+ IdBaseComponent, IdComponent, IdHTTP, IdException;
+
+type
+
+ TOnConnectionChanged = procedure (ip : string);
+
+ TInternetConnection = class(TThread)
+ private
+ P_connected : boolean;
+ P_ip : string;
+ P_onConnected : TOnConnectionChanged;
+ P_onDisconnected : TOnConnectionChanged;
+ protected
+ procedure Execute; override;
+ public
+ procedure waitFor;
+ procedure setDisconnected;
+
+ property onConnected : TOnConnectionChanged
+ read P_onConnected
+ write P_onConnected;
+ property onDisconnected : TOnConnectionChanged
+ read P_onDisconnected
+ write P_onDisconnected;
+ end;
+
+implementation
+
+//
=============================================================================
+// Misc functions
+//
=============================================================================
+
+{*
+ * \brief Check if the internet connection is available.
+ * \return the working ip or None.
+ *}
+function getInternetConnectionAvailable : string;
+var
+ idHTTP : TIdHTTP;
+begin
+ idHTTP := TIdHTTP.Create(nil);
+ idHTTP.ConnectTimeout := 30000;
+ idHTTP.Request.CacheControl := 'no-cache';
+ idHTTP.Request.UserAgent:= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1)';
+ idHTTP.HandleRedirects := true;
+ idHTTP.RedirectMaximum := 100;
+ result := 'None';
+ try
+ idHTTP.Head('http://www.google.com/');
+ result := idHTTP.Socket.Binding.IP;
+ except
+ end;
+ idHttp.Disconnect;
+ idHTTP.Free;
+end;
+
+//
=============================================================================
+// TInternetConnection class
+//
=============================================================================
+
+{*
+ * \brief Execute the thread.
+ *}
+procedure TInternetConnection.Execute;
+var
+ myIp : string;
+ accu : byte;
+begin
+ P_connected := false;
+ P_ip := 'None';
+
+ while not self.Terminated do
+ begin
+ // If not connected
+ if not P_connected then
+ begin
+ sleep(2000);
+ // Check connection available
+ myIp := getInternetConnectionAvailable;
+ if myIp <> 'None' then
+ begin
+ P_ip := myIp;
+ if assigned(P_onConnected) then
+ P_onConnected(myIp);
+ P_connected := true;
+ continue;
+ end;
+ end else
+ // If Connected
+ begin
+ sleep(500);
+ accu := accu + 1;
+ if accu >= 120 then
+ begin
+ accu := 0;
+ // Check connection available
+ myIp := getInternetConnectionAvailable;
+ if myIp = 'None' then
+ begin
+ if assigned(P_onDisconnected) then
+ P_onDisconnected(P_ip);
+ P_connected := false;
+ P_ip := '';
+ continue;
+ end;
+ end;
+ end;
+ end;
+end;
+
+{*
+ * \brief Set the internet connection as disconnected.
+ *}
+procedure TInternetConnection.setDisconnected;
+begin
+ P_connected := false;
+ P_ip := '';
+end;
+
+{*
+ * \brief Wait that the thread has finished.
+ *}
+procedure TInternetConnection.waitFor;
+begin
+ while not self.Terminated do
+ begin
+ sleep(1000);
+ end;
+end;
+
+end.
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/InternetConnection.pas
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/Logger.pas
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/Logger.pas
(rev 0)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/Logger.pas
2008-12-24 12:29:52 UTC (rev 3307)
@@ -0,0 +1,125 @@
+{*
+ * Tuxdroid Chatter Tux network sniffer Service for windows
+ *
+ * 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, 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.
+ *}
+
+unit Logger;
+
+interface
+
+uses
+ SysUtils, Windows, FileCtrl, SHFolder;
+
+procedure LogInit(fileName : string);
+procedure LogError(msg : string);
+procedure LogInfo(msg : string);
+
+implementation
+
+var
+ filePath : string;
+
+{*
+ * \brief Get the last position of a substring within a string.
+ * \param SubStr Substring to find.
+ * \param S String how to find.
+ * \return The last substring position or 0.
+ *}
+function LastPos(SubStr, S: string): Integer;
+var
+ Found, Len, Pos: integer;
+begin
+ Pos := Length(S);
+ Len := Length(SubStr);
+ Found := 0;
+ while (Pos > 0) and (Found = 0) do
+ begin
+ if Copy(S, Pos, Len) = SubStr then
+ Found := Pos;
+ Dec(Pos);
+ end;
+ LastPos := Found;
+end;
+
+{*
+ * \brief Get the user directory.
+ * \return The user directory.
+ *}
+function GetUserDir : string;
+const
+ SHGFP_TYPE_CURRENT = 0;
+var
+ thePath : array [0..MAX_PATH] of char;
+ path : string;
+begin
+ SHGetFolderPath(0, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, @thePath[0]);
+ path := thePath;
+ delete(path, LastPos('\', path) + 1, length(path));
+ result := path;
+end;
+
+{*
+ * \brief Initialise the log file
+ * \param fileName File name.
+ *}
+procedure LogInit(fileName : string);
+var
+ f : TextFile;
+begin
+ filePath := GetUserDir + fileName;
+ AssignFile(f, filePath);
+ Rewrite(f);
+ CloseFile(f);
+end;
+
+{*
+ * \brief Log a message.
+ * \param level Log level.
+ * \param msg Message to log.
+ *}
+procedure LogMessage(level : string; msg : string);
+var
+ f : TextFile;
+ nowStr : string;
+begin
+ AssignFile(f, filePath);
+ Append(f);
+ nowStr := TimeToStr(now);
+ msg := format('[%s] at (%s) : %s', [level, nowStr, msg]);
+ Writeln(f, msg);
+ CloseFile(f);
+end;
+
+{*
+ * \brief Log an error message.
+ * \param msg Message to log.
+ *}
+procedure LogError(msg : string);
+begin
+ LogMessage('Error', msg);
+end;
+
+{*
+ * \brief Log an info message.
+ * \param msg Message to log.
+ *}
+procedure LogInfo(msg : string);
+begin
+ LogMessage('Info', msg);
+end;
+
+end.
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/Logger.pas
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/signInstaller.bat
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/signInstaller.bat
(rev 0)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/signInstaller.bat
2008-12-24 12:29:52 UTC (rev 3307)
@@ -0,0 +1,8 @@
+set strFile=ChatterTuxService.exe
+
+...@echo off
+set strSignCode=E:\Programs\codesigning\signcode.exe
+set strSpc=E:\Programs\codesigning\myCredential.spc
+set strPvk=E:\Programs\codesigning\myPrivateKey.pvk
+set strTimeStampUrl=http://timestamp.verisign.com/scripts/timstamp.dll
+%strSignCode% %strFile% -spc %strSpc% -v %strPvk% -t %strTimeStampUrl%
\ No newline at end of file
Property changes on:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/ChatterTux/signInstaller.bat
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/HTTPRessource/ResourceChatterTux.py
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/HTTPRessource/ResourceChatterTux.py
2008-12-24 12:27:18 UTC (rev 3306)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/HTTPRessource/ResourceChatterTux.py
2008-12-24 12:29:52 UTC (rev 3307)
@@ -56,13 +56,7 @@
}
CTEmoticonsKeys = CTEmoticonToAttitune.keys()
-if os.name == 'nt':
- # Chatter tux exe commands
- CTChatterTuxStart = '"%s"' % os.path.join(TUXDROID_BASE_PATH, "resources",
- "tuxhttpserver", "chatterTux", "chattertux_start.exe")
- CTChatterTuxStop = '"%s"' % os.path.join(TUXDROID_BASE_PATH, "resources",
- "tuxhttpserver", "chatterTux", "chattertux_stop.exe")
-else:
+if os.name != 'nt':
CTChatterTuxStart = "%s %s" %((os.path.join(TUXDROID_BASE_PATH,
"tuxhttpserver", "chatterTux", "chattertux_start")),
(os.path.join(TUXDROID_BASE_PATH,
@@ -76,8 +70,9 @@
# If the service is active then load it at the server launch
if CTMyConf['active']:
- ret = os.system(CTChatterTuxStart)
- Glb_ResourcesLog.logInfo("%d"%ret)
+ if os.name != 'nt':
+ ret = os.system(CTChatterTuxStart)
+ Glb_ResourcesLog.logInfo("%d"%ret)
# Function to play emoticon asynchronously
@@ -96,6 +91,11 @@
# Callback function on chattertux status
def CTOnChatterStatus(stName, chatName, cmd, value1, value2):
global CTLocutor
+ global CTMyConf
+
+ if not CTMyConf['active']:
+ return;
+
# reencode the text.
try:
u = value2.decode("utf-8")
@@ -166,7 +166,8 @@
content_struct['root']['result'] = getStrError(E_TDREST_SUCCESS)
Glb_ResourcesLog.logInfo("Start ChatterTux service.")
- os.system(CTChatterTuxStart)
+ if os.name != 'nt':
+ os.system(CTChatterTuxStart)
CTMyConf['active'] = True
# Save the configuration
@@ -194,7 +195,8 @@
content_struct['root']['result'] = getStrError(E_TDREST_SUCCESS)
Glb_ResourcesLog.logInfo("Stop ChatterTux service.")
- os.system(CTChatterTuxStop)
+ if os.name != 'nt':
+ os.system(CTChatterTuxStop)
CTMyConf['active'] = False
# Save the configuration
Modified:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/VERSION
===================================================================
--- software_suite_v2/software/http_server_resources/chatter_tux/trunk/VERSION
2008-12-24 12:27:18 UTC (rev 3306)
+++ software_suite_v2/software/http_server_resources/chatter_tux/trunk/VERSION
2008-12-24 12:29:52 UTC (rev 3307)
@@ -1 +1 @@
-0.1.1
\ No newline at end of file
+0.2.1
\ No newline at end of file
Modified:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/installer.nsi
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/installer.nsi
2008-12-24 12:27:18 UTC (rev 3306)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/installer.nsi
2008-12-24 12:29:52 UTC (rev 3307)
@@ -4,7 +4,7 @@
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "ChatterTux"
-!define PRODUCT_VERSION "0.1.1"
+!define PRODUCT_VERSION "0.2.1"
; The files to write
!define FINAL_INSTALLER_EXE "ChatterTuxInstaller_${PRODUCT_VERSION}.exe"
@@ -47,10 +47,39 @@
; Copy the executables
CreateDirectory "$TUXDROID_PATH\resources\tuxhttpserver\chatterTux"
SetOutPath "$TUXDROID_PATH\resources\tuxhttpserver\chatterTux"
- File "ChatterTux\ChatterTux.exe"
- File "ChatterTuxStart\chattertux_start.exe"
- File "ChatterTuxStop\chattertux_stop.exe"
+ File "ChatterTux\ChatterTuxService.exe"
+ ; Create the bat files
+ Delete
"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\install_service.bat"
+ Push
'"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\ChatterTuxService.exe"
/INSTALL /SILENT'
+ Push
"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\install_service.bat"
+ Call WriteToFile
+
+ Delete
"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\uninstall_service.bat"
+ Push
'"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\ChatterTuxService.exe"
/UNINSTALL /SILENT'
+ Push
"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\uninstall_service.bat"
+ Call WriteToFile
+
+ Delete
"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\start_service.bat"
+ Push 'net start "ChatterTux"'
+ Push "$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\start_service.bat"
+ Call WriteToFile
+
+ Delete "$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\stop_service.bat"
+ Push 'net stop "ChatterTux"'
+ Push "$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\stop_service.bat"
+ Call WriteToFile
+
+ ; Install the service
+ ExecDos::exec /NOUNLOAD /ASYNC /TIMEOUT=5000
"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\install_service.bat"
+ Pop $0
+ ExecDos::wait $0
+
+ ; Load the service
+ ExecDos::exec /NOUNLOAD /ASYNC /TIMEOUT=5000
"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\start_service.bat"
+ Pop $0
+ ExecDos::wait $0
+
; Write the uninstaller file
WriteUninstaller "$UNINSTALLERS_SUB_PATH\${UNINSTALLER_EXE}"
SectionEnd
@@ -62,6 +91,16 @@
; Get the Tuxdroid installation paths
ReadRegStr $TUXDROID_PATH HKLM "SOFTWARE\Tuxdroid\TuxdroidSetup"
"Install_Dir"
StrCpy $UNINSTALLERS_SUB_PATH "$TUXDROID_PATH\uninstallers\sub"
+
+ ; Stop the service
+ ExecDos::exec /NOUNLOAD /ASYNC /TIMEOUT=5000
"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\stop_service.bat"
+ Pop $0
+ ExecDos::wait $0
+
+ ; Uninstall the service
+ ExecDos::exec /NOUNLOAD /ASYNC /TIMEOUT=5000
"$TUXDROID_PATH\resources\tuxhttpserver\chatterTux\uninstall_service.bat"
+ Pop $0
+ ExecDos::wait $0
; Remove files and uninstaller
Delete
"$TUXDROID_PATH\softwares\tuxhttpserver\resources\ResourceChatterTux.py"
@@ -69,3 +108,28 @@
RMDir /r "$TUXDROID_PATH\resources\attitunes\chatterTux"
RMDir /r "$TUXDROID_PATH\resources\tuxhttpserver\chatterTux"
SectionEnd
+
+; -----------------------------------------------------------------------------
+; Function to write a file
+; -----------------------------------------------------------------------------
+Function WriteToFile
+ Exch $0 ;file to write to
+ Exch
+ Exch $1 ;text to write
+
+ FileOpen $0 $0 a #open file
+ FileSeek $0 0 END #go to end
+ FileWrite $0 $1 #write to file
+ FileClose $0
+
+ Pop $1
+ Pop $0
+FunctionEnd
+
+!macro WriteToFile String File
+ Push "${String}"
+ Push "${File}"
+ Call WriteToFile
+!macroend
+
+!define WriteToFile "!insertmacro WriteToFile"
Deleted:
software_suite_v2/software/http_server_resources/chatter_tux/trunk/tmp_smiley_list.txt
===================================================================
---
software_suite_v2/software/http_server_resources/chatter_tux/trunk/tmp_smiley_list.txt
2008-12-24 12:27:18 UTC (rev 3306)
+++
software_suite_v2/software/http_server_resources/chatter_tux/trunk/tmp_smiley_list.txt
2008-12-24 12:29:52 UTC (rev 3307)
@@ -1,34 +0,0 @@
-:) Visage
-:D Rire (Hahaha)
-;) Clin d'oeil
-:-O Surpris (hooooo)
-:P Tire la langue (tire la langue)
-(H) Star (Y�hhh)
-:@ F�ch� (hummm f�ch�)
-:S Confus (hum confus)
-:$ Embarass� (ho ho ho)
-:( Triste (hum soupir)
-:'( En pleurs (pleurs)
-:| D��u (pfffff)
-(A) Ange
-8o| Agressif (grrrrr)
-8-| Premier de la classe (hum satifait)
-+o( Malade (beurrr)
-<:o) C'est la f�te (serpentin)
-|-) Endormi (bail)
-*-) Pensif (hum pensif)
-:-# Motus et bouche cousue (tirette)
-:-* Confiant un secret (chuttte)
-^o) Sarcastique (hum sarcastique)
-8-) yeux roulant
-(L) Coeur
-(U) Coeur bris�
-(M) Messenger
-(@) Chat (miaou)
-(&) Chien (waff)
-(sn) Escargot
-(bah) Mouton (b�ee)
-(S) Lune
-(*) Etoile
-(#) Soleil
-(K) Kiss (bisou)
------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn