VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "PersonInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'NOTE:
'Assume friendly is either email@address or "" for unset

Public SigninName As String

Public Properties As PropBag

Private Const prpRealName As String = "RealName"
Private Const prpFriendly As String = "Friendly"

'ALL NON-RECORDED INFORMATION
'Used by the MsgEvent  module
Public LastStatus As MISTATUS
'Used by BuddyList
Public InList As Boolean
Public SortOrder As Integer 'Set by the Icon code
'Used by Flooding
Public LastMessage As Date
Public AngerStatus As Double '0 = default, n = number of messages

Public Sub Create(UserName As String)
SigninName = UserName
Set Properties = New PropBag
Properties.Create
End Sub

Public Sub ReadIn(UserName As String)
SigninName = UserName

Set Properties = New PropBag
Call Properties.ReadIn(LogPath + SigninName + ".ini")
End Sub

Public Sub WriteOut()
Call Properties.WriteOut(LogPath + SigninName + ".ini")
End Sub

Public Property Let Friendly(Value As String)
Properties.SetVal(prpFriendly) = Value
End Property

Public Property Get Friendly() As String
Friendly = Properties.GetVal(prpFriendly)
End Property

Private Property Get RealName() As String
RealName = Properties.GetVal(prpRealName)
End Property

Public Property Get UniqueName() As String
''Must be unique, i.e. include the email@address.com
''Used for downloading and editing
''ORDER OF PREFERENCE
'signin@name (RealName)
'signin@name (Friendly)
'signin@name

Dim sFriend As String: sFriend = Friendly
Dim sRealName As String: sRealName = RealName
If sRealName <> "" Then
    UniqueName = SigninName + " (" + sRealName + ")"
ElseIf (sFriend <> "") And (sFriend <> SigninName) Then
    UniqueName = SigninName + " (" + sFriend + ")"
Else
    UniqueName = SigninName
End If
End Property

Public Property Get NonFriendly() As String
''Must not include the friendly name
''Used for name change alerts
''ORDER OF PREFERENCE
'RealName
'signin@name
NonFriendly = RealName
If NonFriendly = "" Then
    NonFriendly = SigninName
End If
End Property

Public Property Get ShortName() As String
''Must be short and ideally recognisable
''Used for alerts
''ORDER OF PREFERENCE
'RealName
'Friendly
'signin@name

ShortName = RealName
If ShortName = "" Then
    ShortName = Friendly
    If ShortName = "" Then
        ShortName = SigninName
    End If
End If
End Property

Public Property Get DisplayName() As String
''Must include their friendly name
''Used for buddy list
''ORDER OF PREFERENCE
'RealName (Friendly)
'Friendly | 'RealName
'signin@name

Dim s As String: s = Friendly

DisplayName = RealName
If (s = "") Or (s = SigninName) Then
    If DisplayName = "" Then
        DisplayName = SigninName
    End If
Else
    If DisplayName = "" Then
        DisplayName = s
    Else
        DisplayName = DisplayName + " (" + s + ")"
    End If
End If
End Property

Public Property Get IconFile() As String
IconFile = RealFile(Properties.GetVal("Icon", ""))
End Property

Public Property Let IconFile(Value As String)
Properties.SetVal("Icon") = FakeFile(Value)
End Property

Public Property Get PictureFile() As String
PictureFile = RealFile(Properties.GetVal("Picture", ""))
End Property

Public Property Let PictureFile(Value As String)
Properties.SetVal("Picture") = FakeFile(Value)
End Property

Private Function RealFile(s As String) As String
If s = "" Then
    RealFile = ""
ElseIf Left$(s, 2) = ".\" Then
    RealFile = LogPath + Mid$(s, 3)
Else
    RealFile = s
End If
End Function

Private Function FakeFile(s As String) As String
If s = "" Then
    FakeFile = ""
ElseIf StrCmp(Left$(s, Len(LogPath)), LogPath) = 0 Then
    FakeFile = ".\" + Mid$(s, Len(LogPath) + 1)
Else
    FakeFile = s
End If
End Function

Private Sub Class_Initialize()
LastStatus = MISTATUS_OFFLINE
AngerStatus = 0
LastMessage = Now()
End Sub

Public Sub Forgive()
AngerStatus = 0
End Sub
