Annotation of sbbs/sbbs3/ctrl/clientformunit.cpp, revision 1.1

1.1     ! root        1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
        !             2: 
        !             3: /* $Id: ClientFormUnit.cpp,v 1.1.1.1 2000/10/10 11:27:06 rswindell Exp $ */
        !             4: 
        !             5: /****************************************************************************
        !             6:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
        !             7:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
        !             8:  *                                                                                                                                                     *
        !             9:  * Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html         *
        !            10:  *                                                                                                                                                     *
        !            11:  * This program is free software; you can redistribute it and/or                       *
        !            12:  * modify it under the terms of the GNU General Public License                         *
        !            13:  * as published by the Free Software Foundation; either version 2                      *
        !            14:  * of the License, or (at your option) any later version.                                      *
        !            15:  * See the GNU General Public License for more details: gpl.txt or                     *
        !            16:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
        !            17:  *                                                                                                                                                     *
        !            18:  * Anonymous FTP access to the most recent released source is available at     *
        !            19:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
        !            20:  *                                                                                                                                                     *
        !            21:  * Anonymous CVS access to the development source and modification history     *
        !            22:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
        !            23:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
        !            24:  *     (just hit return, no password is necessary)                                                     *
        !            25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
        !            26:  *                                                                                                                                                     *
        !            27:  * For Synchronet coding style and modification guidelines, see                                *
        !            28:  * http://www.synchro.net/source.html                                                                          *
        !            29:  *                                                                                                                                                     *
        !            30:  * You are encouraged to submit any modifications (preferably in Unix diff     *
        !            31:  * format) via e-mail to [email protected]                                                                      *
        !            32:  *                                                                                                                                                     *
        !            33:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
        !            34:  ****************************************************************************/
        !            35: 
        !            36: //---------------------------------------------------------------------------
        !            37: 
        !            38: #include <vcl.h>
        !            39: #pragma hdrstop
        !            40: 
        !            41: #include <stdio.h>      // sprintf
        !            42: #include <winsock.h>    // closesocket
        !            43: #include "ClientFormUnit.h"
        !            44: 
        !            45: void socket_open(BOOL open);
        !            46: //---------------------------------------------------------------------------
        !            47: #pragma package(smart_init)
        !            48: #pragma resource "*.dfm"
        !            49: TClientForm *ClientForm;
        !            50: //---------------------------------------------------------------------------
        !            51: __fastcall TClientForm::TClientForm(TComponent* Owner)
        !            52:     : TForm(Owner)
        !            53: {
        !            54:        MainForm=(TMainForm*)Application->MainForm;
        !            55:     ListMutex=CreateMutex(NULL,false,NULL);
        !            56: }
        !            57: //---------------------------------------------------------------------------
        !            58: void __fastcall TClientForm::FormShow(TObject *Sender)
        !            59: {
        !            60:     MainForm->ViewClients->Checked=true;
        !            61: }
        !            62: //---------------------------------------------------------------------------
        !            63: void __fastcall TClientForm::FormHide(TObject *Sender)
        !            64: {
        !            65:     MainForm->ViewClients->Checked=false;
        !            66: }
        !            67: //---------------------------------------------------------------------------
        !            68: void __fastcall TClientForm::TimerTimer(TObject *Sender)
        !            69: {
        !            70:     char    str[64];
        !            71:     int     i;
        !            72:     time_t  t;
        !            73: 
        !            74:     if(WaitForSingleObject(ListMutex,1)!=WAIT_OBJECT_0)
        !            75:         return;
        !            76:     for(i=0;i<ListView->Items->Count;i++) {
        !            77:         t=time(NULL)-(ulong)ListView->Items->Item[i]->Data;
        !            78:         if(t/(60*60))
        !            79:             sprintf(str,"%d:%02d:%02d",t/(60*60),(t/60)%60,t%60);
        !            80:         else
        !            81:             sprintf(str,"%d:%02d",(t/60)%60,t%60);
        !            82:         ListView->Items->Item[i]->SubItems->Strings[5]=str;
        !            83: 
        !            84:     }
        !            85:     ReleaseMutex(ListMutex);
        !            86: 
        !            87: }
        !            88: //---------------------------------------------------------------------------
        !            89: 
        !            90: void __fastcall TClientForm::CloseSocketMenuItemClick(TObject *Sender)
        !            91: {
        !            92:     TListItem* ListItem;
        !            93:     TItemStates State;
        !            94: 
        !            95:     ListItem=ListView->Selected;
        !            96:     State << isSelected;
        !            97: 
        !            98:     while(ListItem!=NULL) {
        !            99:         if(closesocket(atoi(ListItem->Caption.c_str()))==0)
        !           100:             socket_open(FALSE);
        !           101:         ListItem=ListView->GetNextItem(ListItem,sdAll,State);
        !           102:     }
        !           103: }
        !           104: //---------------------------------------------------------------------------
        !           105: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.