VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form FrmMain 
   BackColor       =   &H8000000A&
   Caption         =   "BWW-IRC"
   ClientHeight    =   5160
   ClientLeft      =   4020
   ClientTop       =   2055
   ClientWidth     =   4080
   LinkTopic       =   "Form1"
   ScaleHeight     =   5160
   ScaleWidth      =   4080
   Begin TabDlg.SSTab SSTab1 
      Height          =   4695
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   4125
      _ExtentX        =   7276
      _ExtentY        =   8281
      _Version        =   393216
      Style           =   1
      TabHeight       =   520
      BackColor       =   -2147483638
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      TabCaption(0)   =   "Connection"
      TabPicture(0)   =   "frmMain.frx":0000
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "rtbServer"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "cmdConnect"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "cmdJoin"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "Frame3"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).ControlCount=   4
      TabCaption(1)   =   "Contacts"
      TabPicture(1)   =   "frmMain.frx":039A
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "Frame4"
      Tab(1).Control(0).Enabled=   0   'False
      Tab(1).ControlCount=   1
      TabCaption(2)   =   "Options"
      TabPicture(2)   =   "frmMain.frx":0734
      Tab(2).ControlEnabled=   0   'False
      Tab(2).Control(0)=   "Frame2"
      Tab(2).Control(0).Enabled=   0   'False
      Tab(2).Control(1)=   "Frame1"
      Tab(2).Control(1).Enabled=   0   'False
      Tab(2).ControlCount=   2
      Begin VB.Frame Frame4 
         Caption         =   " Friends "
         Height          =   2295
         Left            =   -74880
         TabIndex        =   25
         Top             =   480
         Width           =   3855
         Begin VB.CommandButton Command3 
            Caption         =   "Ignore"
            Height          =   375
            Left            =   120
            TabIndex        =   30
            Top             =   1440
            Width           =   1095
         End
         Begin VB.CommandButton Command1 
            Caption         =   "Add"
            Height          =   375
            Left            =   120
            TabIndex        =   29
            Top             =   480
            Width           =   1095
         End
         Begin VB.CommandButton Command2 
            Caption         =   "Remove"
            Height          =   375
            Left            =   120
            TabIndex        =   28
            Top             =   960
            Width           =   1095
         End
         Begin VB.ListBox lstOnline 
            Height          =   1620
            Left            =   1320
            TabIndex        =   27
            Top             =   480
            Width           =   1095
         End
         Begin VB.ListBox lstOffline 
            Height          =   1620
            Left            =   2520
            TabIndex        =   26
            Top             =   480
            Width           =   1095
         End
         Begin VB.Label Label7 
            Caption         =   "Offline"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   2520
            TabIndex        =   32
            Top             =   240
            Width           =   735
         End
         Begin VB.Label Label6 
            Caption         =   "Online"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   1320
            TabIndex        =   31
            Top             =   240
            Width           =   1095
         End
      End
      Begin VB.Frame Frame3 
         Caption         =   "Connection Infomation"
         Height          =   2535
         Left            =   120
         TabIndex        =   13
         Top             =   360
         Width           =   3855
         Begin VB.TextBox txtAlternative 
            Height          =   285
            Left            =   960
            TabIndex        =   19
            Top             =   1080
            Width           =   2775
         End
         Begin VB.TextBox txtNick 
            Height          =   285
            Left            =   960
            TabIndex        =   18
            Top             =   720
            Width           =   2775
         End
         Begin VB.TextBox txtUser 
            Height          =   285
            Left            =   960
            TabIndex        =   17
            Top             =   1800
            Width           =   2775
         End
         Begin VB.TextBox txtPass 
            Height          =   285
            IMEMode         =   3  'DISABLE
            Left            =   960
            PasswordChar    =   "*"
            TabIndex        =   16
            Top             =   2160
            Width           =   2775
         End
         Begin VB.CommandButton cmdAdd 
            Caption         =   "Add"
            Height          =   375
            Left            =   3120
            TabIndex        =   15
            Top             =   240
            Width           =   615
         End
         Begin VB.ComboBox cboServer 
            Height          =   315
            Left            =   960
            TabIndex        =   14
            Text            =   "sterling.openprojects.net"
            Top             =   240
            Width           =   2055
         End
         Begin VB.Label Label5 
            Caption         =   "Alternative"
            Height          =   255
            Left            =   120
            TabIndex        =   24
            Top             =   1080
            Width           =   1335
         End
         Begin VB.Label Label1 
            Caption         =   "Server:"
            Height          =   255
            Left            =   240
            TabIndex        =   23
            Top             =   240
            Width           =   1215
         End
         Begin VB.Label Label2 
            Caption         =   "Nickname"
            Height          =   255
            Left            =   120
            TabIndex        =   22
            Top             =   720
            Width           =   1095
         End
         Begin VB.Label Label3 
            Caption         =   "Username"
            Height          =   255
            Left            =   120
            TabIndex        =   21
            Top             =   1800
            Width           =   1335
         End
         Begin VB.Label Label4 
            Caption         =   "Password"
            Height          =   255
            Left            =   120
            TabIndex        =   20
            Top             =   2160
            Width           =   1455
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "Communications"
         Height          =   975
         Left            =   -74880
         TabIndex        =   8
         Top             =   3000
         Width           =   3855
         Begin VB.CheckBox chkAutoPriv 
            Caption         =   "Automatically accept private messages"
            Height          =   495
            Left            =   120
            TabIndex        =   9
            Top             =   240
            Width           =   3375
         End
      End
      Begin VB.Frame Frame1 
         Caption         =   "Message Display"
         Height          =   2415
         Left            =   -74880
         TabIndex        =   4
         Top             =   480
         Width           =   3855
         Begin VB.CheckBox chkAway 
            Caption         =   "Display away messages"
            Height          =   255
            Left            =   240
            TabIndex        =   12
            Top             =   1800
            Width           =   3015
         End
         Begin VB.CheckBox chkUserstaus 
            Caption         =   "Display kick, part and join  messages"
            Height          =   375
            Left            =   240
            TabIndex        =   11
            Top             =   1440
            Width           =   3015
         End
         Begin VB.CheckBox chkChannelInfo 
            Caption         =   "Display channel infomation"
            Height          =   255
            Left            =   240
            TabIndex        =   10
            Top             =   1200
            Width           =   2895
         End
         Begin VB.CheckBox chkGreyOut 
            Caption         =   "Display your own messages in grey"
            Height          =   375
            Left            =   240
            TabIndex        =   7
            Top             =   840
            Value           =   1  'Checked
            Width           =   2895
         End
         Begin VB.CheckBox chkBlock 
            Caption         =   "Remove blocked words"
            Height          =   495
            Left            =   240
            TabIndex        =   6
            Top             =   480
            Value           =   1  'Checked
            Width           =   2655
         End
         Begin VB.CheckBox chksenderBold 
            Caption         =   "Display senders name in bold"
            Height          =   375
            Left            =   240
            TabIndex        =   5
            Top             =   240
            Value           =   1  'Checked
            Width           =   3015
         End
      End
      Begin VB.CommandButton cmdJoin 
         Caption         =   "Join Channel"
         Enabled         =   0   'False
         Height          =   375
         Left            =   2040
         TabIndex        =   3
         Top             =   3000
         Width           =   1935
      End
      Begin VB.CommandButton cmdConnect 
         Caption         =   "Connect"
         Height          =   375
         Left            =   120
         TabIndex        =   1
         Tag             =   "1"
         Top             =   3000
         Width           =   1815
      End
      Begin RichTextLib.RichTextBox rtbServer 
         Height          =   1095
         Left            =   120
         TabIndex        =   2
         Top             =   3480
         Width           =   3855
         _ExtentX        =   6800
         _ExtentY        =   1931
         _Version        =   393217
         Enabled         =   -1  'True
         ScrollBars      =   2
         TextRTF         =   $"frmMain.frx":0ACE
      End
   End
   Begin MSWinsockLib.Winsock Winsock1 
      Left            =   0
      Top             =   0
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Begin VB.Menu mnuJoin 
         Caption         =   "J&oin Channel"
         Enabled         =   0   'False
      End
      Begin VB.Menu sep1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "&Exit"
      End
   End
   Begin VB.Menu mnuOptions 
      Caption         =   "Op&tions"
      Begin VB.Menu mnuServer 
         Caption         =   "Servers"
         Begin VB.Menu mnuAddServer 
            Caption         =   "Add Server"
         End
         Begin VB.Menu mnuRemoveServer 
            Caption         =   "Remove Server"
         End
      End
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "Help"
      NegotiatePosition=   1  'Left
   End
End
Attribute VB_Name = "frmmain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public IsConnected As Boolean
Public Nick, User As String
Public allChannels As New Scripting.Dictionary
Public allPrivates As New Scripting.Dictionary
Public ContactsFriendly As New Scripting.Dictionary

Private Sub cmdAdd_Click()
'calls AddServer()
AddServer (cboServer.text)
End Sub

Private Sub cmdJoin_Click()
    Dim TempChannel As String
    'Get channel from User
    TempChannel = Trim(InputBox("Enter channel (# is optional)", "Enter Channel", GetValue("lastchannel")))
    'If user clicked cancel
    If TempChannel = "" Then Exit Sub
    'Make sure the channel name is formatted with the # at the start
    If Mid(TempChannel, 1, 1) <> "#" Then TempChannel = "#" + TempChannel
    'Writes last channel joined
    WriteValue "lastChannel", TempChannel
    'Makes sure user entered channel and then calls joinchannel()
    If TempChannel <> "" Or 0 Then JoinChannel (TempChannel)

End Sub


Private Sub Form_Load()
    
    'load frmvents (its invisible - only used to separate IRC event code - to make the code more easier to read :-))
    Load frmEvents
    'load blocked words
    getWords
    'update Server list
    UpdateServerList
    'get options
    SetOptions
    'Makes sure the connection tab is showing
    SSTab1.Tab = 0



End Sub

'CONNECT COMMAND
Private Sub cmdConnect_Click()
    Connect
End Sub

Private Sub Form_Resize()
'resize controls when resized
ResizeForm Me
End Sub




Private Sub lstOffline_Click()
lstOnline.text = ""
End Sub

Private Sub lstOnline_Click()
lstOffline.text = ""
End Sub

Private Sub mnuAddServer_Click()
AddServer (InputBox("Enter Server Address", "Add Server"))
End Sub

Private Sub mnuHelp_Click()
MsgBox "BWW-IRC" + vbCrLf + vbCrLf + "BWW-IRC is a Open Source IRC Chat client program dstributed under the GPL." + vbCrLf + vbCrLf + "Our Homepages is bww-irc.sourceforge.net", , "BWW-IRC"
End Sub

'When person removes a user
Private Sub mnuRemoveServer_Click()
RemoveServer (cboServer.text)
End Sub



'On winsock conenct
Private Sub Winsock1_Connect()
    Nick = Trim(txtNick.text)
    User = Trim(txtUser.text)
    'User info
    SendData "USER " + User + " " + User + " " + User + " :" + User
    'Send nickanme
    SendData "NICK " + Nick
End Sub

'DATA ARRIVAL
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim data As String
    'gets data
    Winsock1.GetData data
    'prints to intermediate window for debuggin
    Debug.Print data
    'phase the data
    frmEvents.phaseIRC (data)
    
    'If auth is asked then authenticate
    If InStr(1, data, "NOTICE AUTH :*** No", vbTextCompare) > 0 Then
        Winsock1.SendData "NICK " + txtNick.text
        Winsock1.SendData vbCrLf
    End If
    'A backup if the phaser dosnt pick up that MOTD is finished
    If InStr(1, data, "/MOTD", vbTextCompare) > 0 And IsConnected = False Then Connected
        

End Sub

'DISPLAY TEXT SUB OBSULETE
Public Sub Display(ByVal s As String, Optional color As Long = vbBlue)
    
    With rtbServer
        If Len(.text) + Len(s) > 15000 Then
            .SelStart = 0
            .SelLength = InStrRev(.text, vbCrLf, Len(.text) - 2000, vbTextCompare) + 1
            .SelText = ""
        End If
        .SelStart = Len(.text)
        .SelColor = color
        .SelText = s & vbCrLf
        .SelStart = Len(.text)
    End With
End Sub

'SEND DATA SUB
Public Sub SendData(text As String)
    'If connected then send data and a CRLF
    If Winsock1.State = sckConnected Then
        Winsock1.SendData text
        Winsock1.SendData vbCrLf
    End If
End Sub

Public Sub Quit()
    'Quit from Server
    SendData "QUIT"
End Sub


Public Sub Connect()

    'if not connected then connect and set cmdcommand as disconnect
    If cmdConnect.Tag = 1 Then
        'If txtnick and username are not set
        If Trim(txtNick.text) = "" Then
        MsgBox "No Nickname"
        Exit Sub
        End If
        If Trim(txtUser.text) = "" Then
        MsgBox ("No Username")
        Exit Sub
        End If
        
        Display "Connecting...", vbBlue
        Winsock1.Connect cboServer.text, 6667
        cmdConnect.Tag = 2
        cmdConnect.Caption = "Disconnect"
        Exit Sub
    End If

    'if conneted then disconnect and change cmdcommand to connect
    If cmdConnect.Tag = 2 Then
        Winsock1.Close
        Display "Disconnected by user", vbRed
        cmdConnect.Caption = "Connect"
        cmdConnect.Tag = 1
        cmdJoin.Enabled = False
        Exit Sub
    End If
    
End Sub

'WHen form is unloaded
Private Sub Form_Unload(Cancel As Integer)
    'Update defult values
    Call WriteOptions
    End
End Sub

'When you are conncted and the server is waiting for commands
Public Sub Connected()
    IsConnected = True
    'Tells users to join a channel
    frmmain.Display "Please Join a Channel..", vbRed
    'allow the join to click cmdJoin
    frmmain.cmdJoin.Enabled = True
End Sub