From: root <ro...@re...> - 2002-02-03 19:16:57
|
Update of /home/tank_cvs/tank In directory router.bac.net.au:/tmp/cvs-serv29111 Modified Files: Main.pas Log Message: Changed the IRC Chat interface, the panels were to hard to deal with.. added some stuff like channel topic and user count... **We need to fix how it adds a blank user to the top of the listbox... also whne people disconnect the listbox needs to be updated.. and when we switch channels.. oh.. check out the NEW ABOUT FORM Index: Main.pas =================================================================== RCS file: /home/tank_cvs/tank/Main.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Main.pas 2002/01/31 23:28:54 1.3 --- Main.pas 2002/02/03 19:21:24 1.4 *************** *** 66,84 **** LBServers: TListBox; MSearchTraffic: TMemo; - gnuconnect: TIdTCPClient; - download: TIdHTTP; - gnuaccept: TIdTCPServer; - upload: TIdHTTPServer; ircClient: TIdIRC; lbxUsers: TListBox; - pnlChatSplit: TPanel; - redChatSession: TRichEdit; - txtChatSend: TEdit; - btnIRCOnOff: TBitBtn; ActionManager1: TActionManager; actIRCConnect: TAction; actIRCDisconnect: TAction; lblIRCChannel: TLabel; ! cbxIRCChannel: TComboBox; procedure FormCreate(Sender: TObject); procedure Exit1Click(Sender: TObject); --- 66,83 ---- LBServers: TListBox; MSearchTraffic: TMemo; ircClient: TIdIRC; lbxUsers: TListBox; ActionManager1: TActionManager; actIRCConnect: TAction; actIRCDisconnect: TAction; + txtChatSend: TEdit; lblIRCChannel: TLabel; ! CbxIRCChannel: TComboBox; ! redChatSession: TRichEdit; ! lblChannelInfo: TLabel; ! lblChatUserCount: TLabel; ! btnIRCOnOFF: TBitBtn; ! TimerChatUsers: TTimer; ! gnuaccept: TIdTCPClient; procedure FormCreate(Sender: TObject); procedure Exit1Click(Sender: TObject); *************** *** 88,95 **** procedure cmdAddShareDirectoryClick(Sender: TObject); procedure cmdDeleteShareDirClick(Sender: TObject); - procedure Connect1Click(Sender: TObject); procedure ircClientConnected(Sender: TObject); procedure ircClientJoined(Sender: TObject; AChannel: TIdIRCChannel); - procedure Disconnect1Click(Sender: TObject); procedure ircClientConnect(Sender: TObject); procedure ircClientSystem(Sender: TObject; AUser: TIdIRCUser; --- 87,92 ---- *************** *** 111,114 **** --- 108,115 ---- procedure ircClientJoin(Sender: TObject; AUser: TIdIRCUser; AChannel: TIdIRCChannel); + procedure ircClientTopic(Sender: TObject; AUser: TIdIRCUser; + AChannel: TIdIRCChannel); + procedure TimerChatUsersTimer(Sender: TObject); + procedure About1Click(Sender: TObject); private { Private declarations } *************** *** 123,127 **** implementation ! uses NewOptions; {$R *.dfm} --- 124,128 ---- implementation ! uses NewOptions, about; {$R *.dfm} *************** *** 173,202 **** end; - procedure TClient.Connect1Click(Sender: TObject); - var - gnumessage: TStrings; - reply: string; - - begin - gnumessage := TStringList.Create; - {Specify Connection message} - gnumessage.Add('GNUTELLA CONNECT/0.6'); - gnumessage.Add('USER-AGENT:TANK'); - gnumessage.Add(''); - gnuconnect.Connect; - gnuconnect.WriteStrings(gnumessage); - reply := gnuconnect.ReadString(100); - if Pos('OK', reply) > 0 then - begin - // We have a successful connection into the network. - end - else - begin - // Ooopps, we have failed to connect. - end; - - // OK, GNUTella connection is made, we can init the IRC chat session. - end; - procedure TClient.ircClientJoined(Sender: TObject; AChannel: TIdIRCChannel); --- 174,177 ---- *************** *** 209,217 **** end; - procedure TClient.Disconnect1Click(Sender: TObject); - begin - // Disconnect here. - end; - procedure TClient.ircClientConnect(Sender: TObject); begin --- 184,187 ---- *************** *** 221,226 **** procedure TClient.ircClientConnected(Sender: TObject); begin ! AddChatText('Connection Successful.', clBlack); btnIRCOnOff.Action := actIRCDisconnect; end; --- 191,200 ---- procedure TClient.ircClientConnected(Sender: TObject); begin ! {*** this seems to like to add a line of text to the rich text box before ! it is even really connected? hrm ! AddChatText('Connection Successful.', clBlack); ***} btnIRCOnOff.Action := actIRCDisconnect; + //enable our timer so we can keep track of users correctly + TimerChatUsers.Enabled := true; end; *************** *** 270,273 **** --- 244,252 ---- AddChatText('Disconnected from IRC server.', clBlack); btnIRCOnOff.Action := actIRCConnect; + //turn off the timer + TimerChatUsers.Enabled := false; + lblChatUserCount.Caption := 'Users: 0'; + //change the channel info to nothing... + lblChannelInfo.Caption := 'channel info'; end; *************** *** 278,282 **** Key := #0; exit; ! end; if Key = #13 then // Send the text to the IRC channel and clear the editbox. begin --- 257,261 ---- Key := #0; exit; ! end; if Key = #13 then // Send the text to the IRC channel and clear the editbox. begin *************** *** 377,382 **** begin // We are actually closing the App. if ircClient.Connected then actIRCDisconnectExecute(Sender); - if gnuconnect.Connected then Disconnect1Click(Sender); - if gnuaccept.Active then gnuaccept.Active := false; end; end; --- 356,359 ---- *************** *** 395,398 **** --- 372,396 ---- lbxUsers.Items.Add(AUser.Nick); + end; + + procedure TClient.ircClientTopic(Sender: TObject; AUser: TIdIRCUser; + AChannel: TIdIRCChannel); + begin + {add the channel info to lblChannelInfo} + lblChannelInfo.Caption := ircClient.Channels.Items[0].topic; + end; + + procedure TClient.TimerChatUsersTimer(Sender: TObject); + begin + {make sure we are displaying the correct number of users...} + lblChatUserCount.Caption := 'Users: ' + inttostr(lbxUsers.items.count -1); + { -1 because for some reason our code is adding a blank person on top + of the list??? } + end; + + + procedure TClient.About1Click(Sender: TObject); + begin + frmabout.show; end; |