Changeset 15


Ignore:
Timestamp:
Feb 18, 2008, 2:00:19 PM (16 years ago)
Author:
george
Message:

Přepracováno: Změna síťových komponent z fundamentals sockets na Indy. Prozatím ne dostatečně funkční.
Typografikcé úpravy.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        66Network.cfg
        77Error.txt
         8ProjectGroup1.bdsgroup
         9ProjectGroup1.bdsgroup.local
  • trunk/SunriseChat.bdsproj

    r9 r15  
    3333                        <Compiler Name="O">1</Compiler>
    3434                        <Compiler Name="P">1</Compiler>
    35                         <Compiler Name="Q">0</Compiler>
    36                         <Compiler Name="R">0</Compiler>
     35                        <Compiler Name="Q">1</Compiler>
     36                        <Compiler Name="R">1</Compiler>
    3737                        <Compiler Name="S">0</Compiler>
    3838                        <Compiler Name="T">0</Compiler>
  • trunk/SunriseChat.dpr

    r13 r15  
    11program SunriseChat;
    22
    3 
     3{$WARN SYMBOL_PLATFORM OFF}
    44
    55uses
  • trunk/SunriseChatCoreUnit.pas

    r13 r15  
    592592      end;
    593593    end;
    594     if Assigned(ProtocolMessageLogForm) then
    595       ProtocolMessageLogForm.Memo1.Lines.Add('SendCommand: ' + Data);
    596     if Assigned(FOnSendCommand) then FOnSendCommand(Data + #13);
     594    //if Assigned(ProtocolMessageLogForm) then
     595    //  ProtocolMessageLogForm.Memo1.Lines.Add('SendCommand: ' + Data);
     596    if Assigned(FOnSendCommand) then FOnSendCommand(Data);
    597597  end;
    598598end;
  • trunk/SunriseChatNetworkCoreUnit.pas

    r13 r15  
    77  Forms, StdCtrls, ExtCtrls, SunriseChatCoreUtils, DateUtils, SunriseChatCoreUnit,
    88  cWindows, cSockets, cSocketsUDP, cTCPClient, cTCPServer, cUtils, WinSock,
    9   cWinSock, Registry, UEthernetAddress;
     9  cWinSock, Registry, UEthernetAddress, IdUDPBase, IdUDPServer, IdUDPClient,
     10  IdBaseComponent, IdComponent, IdGlobal, IdSocketHandle, IdCustomTCPServer,
     11  IdTCPServer, IdTCPConnection, IdTCPClient, IdContext, IdAntiFreeze;
    1012
    1113const
    1214  DefaultUdpPort = 55557;
     15  BroadcastIPAddress = '255.255.255.255';
    1316
    1417type
     
    1619
    1720  TSunriseChatNetworkCore = class;
     21
     22  TReadingThread = class(TThread)
     23  protected
     24    FConnection: TIdTCPConnection;
     25    FParent: TSunriseChatNetworkCore;
     26    procedure Execute; override;
     27  public
     28    constructor Create(AParent: TSunriseChatNetworkCore; AConnection: TIdTCPConnection); reintroduce;
     29  end;
    1830
    1931  TNetworkInterface = class
     
    3345  TSunriseChatNetworkCore = class(TSunriseChatCore)
    3446  private
    35     fndTCPServer1: TfndTCPServer;
    36     fndTCPClient1: TfndTCPClient;
    37     fndUDPClientSocket1: TfndUDPClientSocket;
     47    IdTCPServer1: TIdTCPServer;
     48    IdTCPClient1: TIdTCPClient;
     49    IdUDPServer1: TIdUDPServer;
     50    IdUDPClient1: TIdUDPClient;
    3851    FConnected: Boolean;
    3952    FOnChangeNetworkState: TClassMethod;
     
    4457    FAutoReconnect: Boolean;
    4558    FTimer2: TTimer;
     59    FReadingThread: TReadingThread;
    4660    procedure Timer2Timer(Sender: TObject);
    47     procedure fndTCPServer1DataAvailable(Sender: TTCPServerClient);
    48     procedure fndTCPClient1DataAvailable(Sender: ATCPClient);
    49     procedure fndUDPClientSocket1DataAvailable(Sender: AUDPSocket);
    50     procedure fndTCPClient1Close(Sender: ATCPClient);
    5161    function GetLocalIPAddress: string;
    5262    procedure SetLocalIPAddress(const Value: string);
     
    5565    procedure StopNetwork;
    5666    procedure SendCommandToNetwork(const S: string);
     67    procedure IdUDPServer1UDPRead(Sender: TObject; AData: TIdBytes; ABinding: TIdSocketHandle);
     68    procedure IdTCPServer1Execute(AContext: TIdContext);
     69    procedure IdTCPClient1Connected(Sender: TObject);
     70    procedure IdTCPClient1Disconnect(Sender: TObject);
     71    procedure SetAutoReconnect(const Value: Boolean);
    5772    property OnSendCommand;
    58     procedure SetAutoReconnect(const Value: Boolean);
    5973  public
    60     NetworkInterfaces: TList; // of TNetworkInterface;
     74    NetworkInterfaces: TList; // TList<TNetworkInterface>;
    6175    constructor Create(AOwner: TComponent); override;
    6276    function IPAddrToStr(Addr: Cardinal): string;
     
    8094
    8195uses
    82   IpHlpApi, IpTypes, Dialogs, UProtocolMessageLog;
     96  IpHlpApi, IpTypes, Dialogs, UProtocolMessageLog, IdIOHandlerSocket;
    8397
    8498procedure Register;
    8599begin
    86100  RegisterComponents('Chronosoft', [TSunriseChatNetworkCore]);
     101end;
     102
     103{ TReadingThread }
     104
     105constructor TReadingThread.Create(AParent: TSunriseChatNetworkCore;
     106  AConnection: TIdTCPConnection);
     107begin
     108  FConnection := AConnection;
     109  FParent := AParent;
     110  inherited Create(False);
     111end;
     112
     113procedure TReadingThread.Execute;
     114var
     115  Text: string;
     116begin
     117  try
     118    while not Terminated and FConnection.Connected do
     119    begin
     120      Text := FConnection.IOHandler.Readln;
     121      //ProtocolMessageLogForm.Memo1.Lines.Add('TCPClientDataAvailable: ' + Data);
     122      FParent.ProcessCommand(Text);
     123    end;
     124  except
     125  end;
    87126end;
    88127
     
    93132  inherited;
    94133  NetworkInterfaces := TList.Create;
    95   fndTCPServer1 := TfndTCPServer.Create(Self);
    96   fndTCPServer1.OnDataAvailable := fndTCPServer1DataAvailable;
    97   fndTCPClient1 := TfndTCPClient.Create(Self);
    98   fndTCPClient1.OnDataAvailable := fndTCPClient1DataAvailable;
    99   fndTCPClient1.OnClose := fndTCPClient1Close;
    100   fndUDPClientSocket1 := TfndUDPClientSocket.Create(Self);
    101   fndUDPClientSocket1.OnDataAvailable := fndUDPClientSocket1DataAvailable;
     134  IdTCPServer1 := TIdTCPServer.Create(Self);
     135  IdTCPServer1.OnExecute := IdTCPServer1Execute;
     136  IdTCPClient1 := TIdTCPClient.Create(Self);
     137  IdTCPClient1.OnDisconnected := IdTCPClient1Disconnect;
     138  IdTCPClient1.OnConnected := IdTCPClient1Connected;
     139  IdUDPServer1 := TIdUDPServer.Create(Self);
     140  IdUDPServer1.OnUDPRead := IdUDPServer1UDPRead;
     141  IdUDPClient1 := TIdUDPClient.Create(Self);
    102142  FUdpPort := DefaultUdpPort;
    103143  FActive := False;
     
    112152  I: Integer;
    113153begin
    114   fndTCPClient1.OnClose := nil;
     154//  IdTCPClient1.OnDisconnected := nil;
     155  OnChangeNetworkState := nil;
    115156  Active := False;
    116157  for I := 0 to NetworkInterfaces.Count - 1 do
    117158    TNetworkInterface(NetworkInterfaces[I]).Free;
    118159  NetworkInterfaces.Free;
     160  IdTCPServer1.Destroy;
     161  IdTCPClient1.Destroy;
     162  IdUDPServer1.Destroy;
     163  IdUDPClient1.Destroy;
    119164  inherited;
    120165end;
    121166
    122 procedure TSunriseChatNetworkCore.fndTCPClient1Close(Sender: ATCPClient);
     167procedure TSunriseChatNetworkCore.IdTCPClient1Connected(Sender: TObject);
     168begin
     169  FReadingThread := TReadingThread.Create(Self, IdTCPClient1);
     170  FReadingThread.FreeOnTerminate := True;
     171end;
     172
     173procedure TSunriseChatNetworkCore.IdTCPClient1Disconnect(Sender: TObject);
    123174begin
    124175  FConnected := False;
     
    130181end;
    131182
    132 procedure TSunriseChatNetworkCore.fndTCPClient1DataAvailable(
    133   Sender: ATCPClient);
    134 var
    135   Data, Text: string;
    136 begin
    137   if Sender.Socket.InBufferSize > 0 then begin
    138     Data := Sender.Socket.ReadAvailable;
    139     ProtocolMessageLogForm.Memo1.Lines.Add('TCPClientDataAvailable: ' + Data);
    140     if Pos(#13, Data) > 0 then begin
    141       repeat
    142         Text := Copy(Data, 1, Pos(#13, Data)-1);
    143         Delete(Data, 1, Length(Text)+1);
    144         ProcessCommand(Text);
    145       until (Data = '') or (Pos(#13, Data) = 0);
    146     end else ProcessCommand(Data);
    147   end;
    148 end;
    149 
    150 procedure TSunriseChatNetworkCore.fndTCPServer1DataAvailable(
    151   Sender: TTCPServerClient);
     183procedure TSunriseChatNetworkCore.IdTCPServer1Execute(AContext: TIdContext);
     184var
     185  Text: string;
     186begin
     187  Text := AContext.Connection.IOHandler.ReadLn;
     188 (*
     189  if AContext.Connection.Connected then begin
     190    Text := ''; // AContext.Connection.IOHandler.AllData;
     191  *)
     192//  ProtocolMessageLogForm.Memo1.Lines.Add('TCPServerDataAvailable: ' + Text);
     193    if BroadcastType = btGlobal then
     194      IdUDPClient1.Broadcast(Text, UDPPort) else
     195      IdUDPClient1.Send(FActiveNetworkInterface.BroadcastIPAddress, UDPPort, Text);
     196//  end;
     197end;
     198
     199procedure TSunriseChatNetworkCore.IdUDPServer1UDPRead(Sender: TObject; AData: TIdBytes; ABinding: TIdSocketHandle);
    152200var
    153201  Text: string;
    154202  I: Integer;
    155 begin
    156   if Sender.Socket.InBufferSize > 0 then begin
    157     Text := Sender.Socket.ReadAvailable;
    158     for I := 0 to fndTCPServer1.ClientCount - 1 do
    159       fndTCPServer1.Client[I].Socket.SendStr(Text);
    160     ProtocolMessageLogForm.Memo1.Lines.Add('TCPServerDataAvailable: ' + Text);
    161     if BroadcastType = btGlobal then
    162       fndUDPClientSocket1.Broadcast(IntToStr(UDPPort), Text) else
    163       fndUDPClientSocket1.SendStr(Text);
    164   end;
    165 end;
    166 
    167 procedure TSunriseChatNetworkCore.fndUDPClientSocket1DataAvailable(
    168   Sender: AUDPSocket);
    169 var
    170   Text: string;
    171   Address : TSockAddr;
    172   I: Integer;
    173 begin
    174   ProtocolMessageLogForm.Memo1.Lines.Add('UDBClientDataAvailable: ' + Text);
     203  ClientList: TList;
     204begin
     205  SetLength(Text, Length(AData));
     206  for I := 0 to Length(AData) - 1 do
     207    Text[I + 1] := Chr(AData[I]);
     208  //ProtocolMessageLogForm.Memo1.Lines.Add('UDPServerDataAvailable: ' + Text);
     209
     210  // Send data to all clients
    175211  if FConnected then begin
    176     Sender.ReadPacket(Text, Address);
    177     for I := 0 to fndTCPServer1.ClientCount - 1 do
    178       with fndTCPServer1.Client[I] do Socket.SendStr(Text);
     212    ClientList := IdTCPServer1.Contexts.LockList;
     213    try
     214      for I := 0 to ClientList.Count - 1 do
     215        TIdContext(ClientList.Items[I]).Connection.IOHandler.WriteLn(Text);
     216    finally
     217      IdTCPServer1.Contexts.UnlockList;
     218    end;
    179219  end;
    180220end;
     
    274314procedure TSunriseChatNetworkCore.SendCommandToNetwork(const S: string);
    275315begin
    276   if FConnected then fndTCPClient1.Socket.SendStr(S);
     316  if FConnected then IdTCPClient1.IOHandler.WriteLn(S);
    277317end;
    278318
     
    301341var
    302342  I, II: Integer;
     343  SocketBinding: TIdSocketHandle;
    303344const
    304345  Stav: array [0..6] of string = ('Closed', 'Resolving', 'Resolved', 'Connecting',
    305346                  'Negotiating', 'Connected', 'Listening');
    306347begin
    307   fndTCPClient1.OnClose := nil;
     348  IdTCPClient1.OnDisconnected := nil;
    308349  FConnected := False;
    309350  try
    310     fndTCPClient1.Active := False;
    311     with fndTCPServer1 do begin
     351    IdTCPClient1.Disconnect;
     352    with IdTCPServer1 do begin
    312353      Active := False;
    313       ListenPort := IntToStr(UDPPort+1);
    314       LocalHost := IPAddrToStr(LocalUser.Id.Machine); //'localhost';
     354      SocketBinding := IdTCPServer1.Bindings.Add;
     355      SocketBinding.IP := IPAddrToStr(LocalUser.Id.Machine);
     356      SocketBinding.Port := UDPPort + 1;
    315357      try
    316358        Active := True;
     
    318360      end;
    319361  //  ShowMessage(Stav[Integer(fndTCPServer1.Socket.State)]);
    320 
    321       fndUDPClientSocket1.Terminate;
    322       fndUDPClientSocket1.LocalHost := IPAddrToStr(LocalUser.Id.Machine);
    323       fndUDPClientSocket1.LocalPort := IntToStr(UDPPort);
    324       fndUDPClientSocket1.Host := FActiveNetworkInterface.BroadcastIPAddress;
    325       fndUDPClientSocket1.Port := IntToStr(UDPPort);
    326       fndUDPClientSocket1.BroadcastOption := True;
     362    end;
     363      IdUDPServer1.Active := False;
     364      SocketBinding := IdUDPServer1.Bindings.Add;
     365      SocketBinding.IP := IPAddrToStr(LocalUser.Id.Machine);
     366      SocketBinding.Port := UDPPort;
     367      IdUDPServer1.BroadcastEnabled := True;
    327368      try
    328         fndUDPClientSocket1.Bind;
     369        IdUDPServer1.Active := True;
    329370      except
    330 //      on EWinSock do begin
    331 //        ShowMessage('Nelze inicializovat síť!');
    332 //        Application.Terminate;
    333 //      end;
    334       end;
    335     end;
    336     with fndTCPClient1 do begin
    337       Active := False;
     371      end;
     372      IdUDPClient1.Disconnect;
     373      IdUDPClient1.Host := FActiveNetworkInterface.BroadcastIPAddress;
     374      IdUDPClient1.Port := UdpPort;
     375      IdUDPClient1.BroadcastEnabled := True;
     376      try
     377        IdUDPClient1.Connect;
     378      except
     379      end;
     380    with IdTCPClient1 do begin
     381      Disconnect;
    338382      Host := IPAddrToStr(LocalUser.Id.Machine); // 'localhost';
    339       Port := IntToStr(UDPPort + 1);
    340       LocalHost := IPAddrToStr(LocalUser.Id.Machine); //'localhost';
     383      Port := UDPPort + 1;
     384      BoundIP := IPAddrToStr(LocalUser.Id.Machine); //'localhost';
     385      Connect;
     386(*
    341387      I := 2;
    342388      repeat
    343         Active := False;
    344         LocalPort := IntToStr(UDPPort+I);
     389        Disconnect;
     390        //BoundPort := UDPPort + I;
    345391        I := I + 1;
    346392        try
    347           Active := True;
     393          Connect;
    348394        except
    349395        end;
    350396        II := 0;
    351         while (Socket.State in [ssResolving, ssNegotiating, ssConnecting]) and (II<100) do begin
     397        while (not Connected and (II < 100)) do begin
    352398          Application.ProcessMessages;
    353           //Sleep(10);
     399          Sleep(10);
    354400          II := II + 1;
    355401        end;
    356402  //     ShowMessage(Stav[Integer(fndTCPClient1.Socket.State)]);
    357       until (Socket.State in [ssConnected, ssResolved]) or (I>30); //or (fndTCPServer1.Socket.State = ssClosed);
    358       FConnected := not (fndUDPClientSocket1.Bound xor (fndTCPServer1.Socket.State = ssListening)) and
    359       (fndTCPClient1.Socket.State in [ssConnected, ssResolved]);
     403      until (Connected) or (I > 30); //or (fndTCPServer1.Socket.State = ssClosed);
     404*)
     405      FConnected := IdUDPServer1.Active and IdUDPClient1.Active and
     406        IdTCPServer1.Active and IdTCPClient1.Connected;
    360407      //ShowMessage(IntToStr(Integer(fndTCPClient1.Socket.State))+','+BoolToStr(fndUDPClientSocket1.Bound)
    361408      //+','+BoolToStr(FConnected)+','+BoolToStr(fndTCPClient1.Socket.Connected));
     
    367414    end;
    368415  finally
    369     fndTCPClient1.OnClose := fndTCPClient1Close;
     416    IdTCPClient1.OnDisconnected := IdTCPClient1Disconnect;
    370417  end;
    371418end;
     
    374421begin
    375422  FAutoReconnect := False;
    376   fndTCPClient1.Active := False;;
    377   fndTCPServer1.Active := False;
    378   fndUDPClientSocket1.Bound := False;
     423  if IdTCPClient1.Connected then IdTCPClient1.Disconnect;
     424  IdTCPServer1.Active := False;
     425  IdUDPClient1.Active := False;
     426  IdUDPServer1.Active := False;
    379427end;
    380428
  • trunk/UMainWindow.dfm

    r13 r15  
    33  Top = 296
    44  Caption = 'SunriseChat'
    5   ClientHeight = 372
     5  ClientHeight = 392
    66  ClientWidth = 471
    77  Color = clBtnFace
     
    2828    Top = 0
    2929    Width = 471
    30     Height = 372
     30    Height = 392
    3131    Align = alClient
    3232    BevelOuter = bvNone
    3333    FullRepaint = False
    3434    TabOrder = 0
    35     ExplicitHeight = 352
     35    ExplicitHeight = 372
    3636    object Splitter3: TSplitter
    3737      Left = 323
    3838      Top = 0
    3939      Width = 2
    40       Height = 342
     40      Height = 362
    4141      Align = alRight
    4242      ExplicitLeft = 322
     
    4545    object Panel4: TPanel
    4646      Left = 0
    47       Top = 342
     47      Top = 362
    4848      Width = 471
    4949      Height = 30
     
    5252      FullRepaint = False
    5353      TabOrder = 0
    54       ExplicitTop = 322
     54      ExplicitTop = 342
    5555      DesignSize = (
    5656        471
     
    9191      Top = 0
    9292      Width = 26
    93       Height = 342
     93      Height = 362
    9494      Align = alRight
    9595      BevelOuter = bvNone
    9696      TabOrder = 1
    97       ExplicitHeight = 322
     97      ExplicitHeight = 342
    9898      object ToolBar1: TToolBar
    9999        Left = 0
    100         Top = 188
     100        Top = 208
    101101        Width = 26
    102102        Height = 154
     
    109109        TabOrder = 0
    110110        Transparent = False
    111         ExplicitTop = 168
     111        ExplicitTop = 188
    112112        object ToolButton1: TToolButton
    113113          Left = 0
     
    182182      Top = 0
    183183      Width = 120
    184       Height = 342
     184      Height = 362
    185185      Align = alRight
    186186      BevelOuter = bvNone
    187187      FullRepaint = False
    188188      TabOrder = 2
    189       ExplicitHeight = 322
     189      ExplicitHeight = 342
    190190      DesignSize = (
    191191        120
    192         342)
     192        362)
    193193      object Label1: TLabel
    194194        Left = 2
     
    202202        Top = 20
    203203        Width = 116
    204         Height = 319
     204        Height = 339
    205205        Hint = 'Seznam online u'#382'ivatel'#367
    206206        Anchors = [akLeft, akTop, akRight, akBottom]
     
    217217        OnClick = ListView1Click
    218218        OnInfoTip = ListView1InfoTip
    219         ExplicitHeight = 299
     219        ExplicitHeight = 319
    220220      end
    221221    end
     
    224224      Top = 0
    225225      Width = 323
    226       Height = 342
     226      Height = 362
    227227      Align = alClient
    228228      BevelOuter = bvNone
    229229      FullRepaint = False
    230230      TabOrder = 3
    231       ExplicitHeight = 322
     231      ExplicitHeight = 342
    232232      DesignSize = (
    233233        323
    234         342)
     234        362)
    235235      object Label2: TLabel
    236236        Left = 8
     
    253253        Top = 0
    254254        Width = 317
    255         Height = 250
     255        Height = 270
    256256        ActivePage = TabSheet1
    257257        Anchors = [akLeft, akTop, akRight, akBottom]
     
    266266        TabOrder = 1
    267267        OnChange = TabControl1Change
    268         ExplicitHeight = 230
     268        ExplicitHeight = 250
    269269        object TabSheet1: TTabSheet
    270270          Caption = 'TabSheet1'
     
    276276          ImageIndex = 1
    277277          ParentFont = False
    278           ExplicitHeight = 201
     278          ExplicitHeight = 221
    279279        end
    280280      end
     
    283283        Top = 20
    284284        Width = 317
    285         Height = 320
     285        Height = 340
    286286        Anchors = [akLeft, akTop, akRight, akBottom]
    287287        BevelOuter = bvNone
     
    291291        TabOrder = 0
    292292        OnResize = Panel6Resize
    293         ExplicitHeight = 300
     293        ExplicitHeight = 320
    294294        object ListView2: TListView
    295295          Left = 0
    296296          Top = 0
    297297          Width = 317
    298           Height = 320
     298          Height = 340
    299299          Align = alClient
    300300          Columns = <>
    301301          TabOrder = 1
    302           ExplicitHeight = 300
     302          ExplicitHeight = 320
    303303        end
    304304        object RichView1: TRichView
     
    20182018    Top = 112
    20192019  end
    2020   object fndUDPSocket1: TfndUDPSocket
    2021     Left = 48
    2022     Top = 216
    2023   end
    2024   object fndUDPClientSocket1: TfndUDPClientSocket
    2025     Left = 144
    2026     Top = 232
    2027   end
    20282020end
  • trunk/UMainWindow.pas

    r13 r15  
    1111  StdActns, ULogExceptions, RVScroll, RichView, RVStyle, UTextFileStream,
    1212  ShellAPI, SunriseChatCoreUnit, SunriseChatNetworkCoreUnit, IdBaseComponent,
    13   IdComponent, IdUDPBase, IdUDPServer, XPMan;
     13  IdComponent, IdUDPBase, IdUDPServer, XPMan, IdUDPClient, IdCustomTCPServer,
     14  IdTCPServer, IdTCPConnection, IdTCPClient, IdAntiFreezeBase, IdAntiFreeze;
    1415
    1516const
     
    180181    XPManifest1: TXPManifest;
    181182    Log1: TMenuItem;
    182     fndUDPSocket1: TfndUDPSocket;
    183     fndUDPClientSocket1: TfndUDPClientSocket;
    184183    procedure FormCreate(Sender: TObject);
    185184    procedure FormShow(Sender: TObject);
     
    14221421  Text: string;
    14231422begin
    1424   SetLength(AppEventsOptions,Length(AppEvents));
    1425   for I:= 0 to High(AppEventsOptions) do begin
     1423  SetLength(AppEventsOptions, Length(AppEvents));
     1424  for I := 0 to High(AppEventsOptions) do begin
    14261425    //if not Assigned(AppEventsOptions[I]) then
    1427     AppEventsOptions[I] := TAutoRegistry.Create(RegistryPath+'\'+SettingsName+'\AppEvents\'+IntToStr(I));
     1426    AppEventsOptions[I] := TAutoRegistry.Create(RegistryPath + '\' + SettingsName +
     1427      '\AppEvents\' + IntToStr(I));
    14281428    with AppEventsOptions[I], AppEvents[I] do begin
    1429       Include('ShowWindow',ShowWindow,ShowWindow);
    1430       Include('ShowAlertIcon',ShowAlertIcon,ShowAlertIcon);
    1431       Include('ShowBaloonHint',ShowBalloonHint,ShowBalloonHint);
    1432       Include('PlayBeep',PlayBeep,PlayBeep);
    1433       Include('PlaySound',PlaySound,PlaySound);
    1434       Include('SoundFile',SoundFile,'');
    1435       Include('ExecuteApplication',ExecuteApplication,False);
    1436       Include('ApplicationFile',ApplicationFile,'');
    1437       Include('ShowMessage',ShowMessage,ShowMessage);
    1438       Include('MessageText',MessageText,MessageText);
    1439       Include('IconFile',IconFile,'Envelope.ico');
     1429      Include('ShowWindow', ShowWindow, ShowWindow);
     1430      Include('ShowAlertIcon', ShowAlertIcon, ShowAlertIcon);
     1431      Include('ShowBaloonHint', ShowBalloonHint, ShowBalloonHint);
     1432      Include('PlayBeep', PlayBeep, PlayBeep);
     1433      Include('PlaySound' ,PlaySound, PlaySound);
     1434      Include('SoundFile', SoundFile, '');
     1435      Include('ExecuteApplication', ExecuteApplication, False);
     1436      Include('ApplicationFile', ApplicationFile, '');
     1437      Include('ShowMessage', ShowMessage, ShowMessage);
     1438      Include('MessageText', MessageText, MessageText);
     1439      Include('IconFile', IconFile, 'Envelope.ico');
    14401440      // Font
    1441       Include('FontColor',MessageFontTemp.Color,Integer(clBlack));
    1442       Include('FontStyle',MessageFontTemp.Style,'');
    1443       Include('FontCharset',MessageFontTemp.Charset,1);
     1441      Include('FontColor', MessageFontTemp.Color, Integer(clBlack));
     1442      Include('FontStyle', MessageFontTemp.Style, '');
     1443      Include('FontCharset', MessageFontTemp.Charset, 1);
    14441444      Include('FontSize', MessageFontTemp.Size, 8);
    14451445      Include('FontName', MessageFontTemp.Name, 'MS Sans Serif');
    14461446      LoadFromRegistry;
    14471447      MessageFont.Color := MessageFontTemp.Color;
    1448       while Pos(',', MessageFontTemp.Style)>0 do begin
    1449         Text:= Copy(MessageFontTemp.Style, 1, Pos(',', MessageFontTemp.Style)-1);
    1450         System.Delete(MessageFontTemp.Style, 1, Length(Text)+1);
     1448      while Pos(',', MessageFontTemp.Style) > 0 do begin
     1449        Text := Copy(MessageFontTemp.Style, 1, Pos(',', MessageFontTemp.Style) - 1);
     1450        System.Delete(MessageFontTemp.Style, 1, Length(Text) + 1);
    14511451        if Text = 'Bold' then MessageFont.Style := MessageFont.Style + [fsBold];
    14521452        if Text = 'Italic' then MessageFont.Style := MessageFont.Style + [fsItalic];
     
    14671467  SetLength(AppUserEventsOptions, AppUserEventsCount);
    14681468  SetLength(AppUserEvents, AppUserEventsCount);
    1469   for I := 0 to AppUserEventsCount-1 do begin
     1469  for I := 0 to AppUserEventsCount - 1 do begin
    14701470    //if not Assigned(AppEventsOptions[I]) then
    1471     AppUserEventsOptions[I] := TAutoRegistry.Create(RegistryPath+'\'+SettingsName+'\AppUserEvents\'+IntToStr(I));
     1471    AppUserEventsOptions[I] := TAutoRegistry.Create(RegistryPath + '\' +
     1472      SettingsName + '\AppUserEvents\' + IntToStr(I));
    14721473    with AppUserEventsOptions[I], AppUserEvents[I] do begin
    14731474      Update := UpdateOnly;
     
    14761477      Include('ConditionUserEnable', ConditionUserEnable, ConditionUserEnable);
    14771478      Include('ConditionUser', ConditionUser, ConditionUser);
    1478       Include('ConditionAppEventEnable', ConditionAppEventEnable,ConditionAppEventEnable);
    1479       Include('ConditionAppEvent',ConditionAppEvent,ConditionAppEvent);
    1480       Include('ShowWindow',ShowWindow,ShowWindow);
    1481       Include('ShowAlertIcon',ShowAlertIcon,ShowAlertIcon);
    1482       Include('IconFile',IconFile,'Envelope.ico');
    1483       Include('ShowBaloonHint',ShowBalloonHint,ShowBalloonHint);
    1484       Include('PlayBeep',PlayBeep,PlayBeep);
    1485       Include('PlaySound',PlaySound,PlaySound);
    1486       Include('SoundFile',SoundFile,'');
    1487       Include('ExecuteApplication',ExecuteApplication,False);
    1488       Include('ApplicationFile',ApplicationFile,'');
    1489       Include('ShowImage',ShowImage,ShowImage);
    1490       Include('ImageFile',ImageFile,ImageFile);
    1491       Include('EventName',EventName,EventName);
     1479      Include('ConditionAppEventEnable', ConditionAppEventEnable, ConditionAppEventEnable);
     1480      Include('ConditionAppEvent', ConditionAppEvent, ConditionAppEvent);
     1481      Include('ShowWindow', ShowWindow, ShowWindow);
     1482      Include('ShowAlertIcon', ShowAlertIcon, ShowAlertIcon);
     1483      Include('IconFile', IconFile, 'Envelope.ico');
     1484      Include('ShowBaloonHint', ShowBalloonHint, ShowBalloonHint);
     1485      Include('PlayBeep', PlayBeep, PlayBeep);
     1486      Include('PlaySound', PlaySound, PlaySound);
     1487      Include('SoundFile', SoundFile, '');
     1488      Include('ExecuteApplication', ExecuteApplication, False);
     1489      Include('ApplicationFile', ApplicationFile, '');
     1490      Include('ShowImage', ShowImage, ShowImage);
     1491      Include('ImageFile', ImageFile, ImageFile);
     1492      Include('EventName', EventName, EventName);
    14921493      LoadFromRegistry;
    14931494    end;
     
    15061507  Settings: string;
    15071508begin
    1508   if SettingsName = 'Default' then Settings:= '' else Settings:= '('+SettingsName+')';
    1509   if SunriseChatNetworkCore1.Connected then NewCaption:= '' else NewCaption:= ' (Offline)';
    1510   Caption:= ApplicationName+Settings+' - '+SunriseChatNetworkCore1.LocalUser.Nick+NewCaption;
     1509  if SettingsName = 'Default' then Settings:= '' else Settings:= '(' + SettingsName + ')';
     1510  if SunriseChatNetworkCore1.Connected then NewCaption := ''
     1511    else NewCaption := ' (Offline)';
     1512  Caption := ApplicationName + Settings + ' - ' +
     1513    SunriseChatNetworkCore1.LocalUser.Nick + NewCaption;
    15111514end;
    15121515
     
    15141517  var InfoTip: String);
    15151518begin
    1516   InfoTip:= TUser(SunriseChatNetworkCore1.UserList[Item.Index]).DetailInfo;
     1519  InfoTip := TUser(SunriseChatNetworkCore1.UserList[Item.Index]).DetailInfo;
    15171520end;
    15181521
     
    15261529  //if Pos(':',ComboBox1.Text) = 0 then
    15271530  DoplnitJmeno;
    1528   ComboBox1.SelStart:= ComboBox1.SelStart + 1;
     1531  ComboBox1.SelStart := ComboBox1.SelStart + 1;
    15291532end;
    15301533
     
    15541557procedure TMainWindow.SearchFind1BeforeExecute(Sender: TObject);
    15551558begin
    1556   SearchFind1.Dialog.Options:= [frHideUpDown];
     1559  SearchFind1.Dialog.Options := [frHideUpDown];
    15571560end;
    15581561
     
    15621565begin
    15631566  with SunriseChatNetworkCore1 do begin
    1564     for I := 0 to ActiveRoom.Count-1 do
     1567    for I := 0 to ActiveRoom.Count - 1 do
    15651568      TRoomLine(ActiveRoom.Lines[I]).Font.Free;
    15661569    ActiveRoom.Count := 0;
     
    16941697  I: Integer;
    16951698begin
    1696   ComboBox1.Style:= csDropDown;
     1699  ComboBox1.Style := csDropDown;
    16971700  with SunriseChatNetworkCore1, ComboBox1.Items do begin
    16981701    BeginUpdate;
    16991702    Clear;
    1700     for I := 0 to UserList.Count-1 do with TUser(UserList[I]) do begin
    1701       if Copy(Nick,1,Length(ComboBox1.Text)) = ComboBox1.Text then Add(Nick+': ');
     1703    for I := 0 to UserList.Count - 1 do with TUser(UserList[I]) do begin
     1704      if Copy(Nick, 1, Length(ComboBox1.Text)) = ComboBox1.Text then Add(Nick + ': ');
    17021705    end;
    17031706    Update;
    17041707    EndUpdate;
    1705     if ComboBox1.Items.Count>0 then ComboBox1.DroppedDown:= True;
     1708    if ComboBox1.Items.Count > 0 then ComboBox1.DroppedDown:= True;
    17061709  end;
    17071710end;
     
    17141717procedure TMainWindow.ComboBox1DropDown(Sender: TObject);
    17151718begin
    1716   ComboBox1.Style:= csSimple;
     1719  ComboBox1.Style := csSimple;
    17171720end;
    17181721
    17191722procedure TMainWindow.ComboBox1CloseUp(Sender: TObject);
    17201723begin
    1721   ComboBox1.Style:= csSimple;
    1722   ComboBox1.SelStart:= -1;
     1724  ComboBox1.Style := csSimple;
     1725  ComboBox1.SelStart := -1;
    17231726end;
    17241727
     
    17331736begin
    17341737  RichView1.Clear;
    1735   for I:= 0 to High(AppUserEvents) do
     1738  for I := 0 to High(AppUserEvents) do
    17361739  if Assigned(AppUserEvents[I].Image) then FreeAndNil(AppUserEvents[I].Image);
    17371740  TabControl1Change(Self);
     
    17671770      Clear;
    17681771      AddStrings(StringList);
    1769       if Count>0 then DroppedDown:= True;
     1772      if Count > 0 then DroppedDown:= True;
    17701773      Update;
    17711774      EndUpdate;
     
    18191822  SoundDisable := True;
    18201823  SunriseChatNetworkCore1.SendCommand(scDisconnect);
     1824  SunriseChatNetworkCore1.Free;
    18211825  Options.Free;
    18221826  for I := 0 to High(AppEvents) do
Note: See TracChangeset for help on using the changeset viewer.