aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol/irc/UserInfo.java
blob: 69cbf911825bdf8b2c6d293b65bd212bd78b8ca9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package net.java.sip.communicator.impl.protocol.irc;

import java.util.*;

/**
 * Represents the informations we get from a user when we use WHOIS
 * 
 * @author Stephane Remy
 */

public class UserInfo
{
    /**
     * The nickname of this user.
     */
    private String nickName = null;
    
    /**
     * The login of this user.
     */
    private String login = null;
    
    /**
     * The hostname of this user.
     */
    private String hostname = null;
    
    /**
     * A list of the chat rooms this user is in.
     */
    private List joinedChatRoom = new LinkedList();
    
    /**
     * Information about the server.
     */
    private String serverInfo = null;
    
    /**
     * Indicates if this user is an IRC operator.
     */
    private boolean isIrcOp = false;
    
    /**
     * Indicates if this user is idle.
     */
    private long idle = 0;

    /**
     * 
     * @param nickName
     * @param login
     * @param hostname
     */
    public UserInfo(String nickName, String login, String hostname)
    {
        this.nickName = nickName;
        this.login = login;
        this.hostname = hostname;
    }

    /**
     * Adds a chat room to the list of chat rooms joined by this user.
     * 
     * @param chatRoom the name of the chat room we want to add to the list
     */
    public void addJoinedChatRoom(String chatRoom)
    {
        synchronized(joinedChatRoom)
        {
            joinedChatRoom.add(chatRoom);
        }
    }

    /**
     * Removes a chat room from the list of joined chat rooms.
     * 
     * @param chatRoom the chat room we want to remove.
     */
    public void removeJoinedChatRoom(String chatRoom)
    {
        synchronized(joinedChatRoom)
        {
            joinedChatRoom.remove(chatRoom);
        }
    }

    /**
     * Clears the list of joined chat rooms.
     */
    public void clearJoinedChatRoom()
    {
        synchronized(joinedChatRoom)
        {
            joinedChatRoom.clear();
        }
    }

    /**
     * Returns the host name of this user.
     * 
     * @return the hostname of this user
     */
    public String getHostname()
    {
        return hostname;
    }

    /**
     * Returns the time from which this user is idle.
     * 
     * @return the idle time of this user
     */
    public long getIdle()
    {
        return idle;
    }

    /**
     * The list of chat rooms that this user has joined.
     * 
     * @return a list of the joined chat rooms of this user
     */
    public List getJoinedChatRooms()
    {
        return joinedChatRoom;
    }

    /**
     * Returns the login of this user.
     * 
     * @return the login of this user
     */
    public String getLogin()
    {
        return login;
    }

    /**
     * Returns the nickname of this user.
     *  
     * @return the nickname of this user
     */
    public String getNickName()
    {
        return nickName;
    }

    /**
     * Returns TRUE if this user is an IRC operator and false otherwise.
     * 
     * @return true if this user is an IRCOP or false otherwise
     */
    public boolean isIrcOp()
    {
        return isIrcOp;
    }

    /**
     * Returns the server info.
     * 
     * @return a string server information 
     */
    public String getServerInfo()
    {
        return serverInfo;
    }

    /**
     * Set the hostname of this user.
     * 
     * @param hostname the hostname of this user
     */
    protected void setHostname(String hostname)
    {
        this.hostname = hostname;
    }
    
    /**
     * Set the idle time for this user.
     * 
     * @param idle the idle time of this user
     */
    protected void setIdle(long idle)
    {
        this.idle = idle;
    }
    
    /**
     * Set if this user is an IRC operator.
     * 
     * @param isIrcOp TRUE to indicate that the user is an IRC operator and
     * FALSE otherwise
     */
    protected void setIrcOp(boolean isIrcOp)
    {
        this.isIrcOp = isIrcOp;
    }
    
    /**
     * Set the information for the server
     * 
     * @param serverInfo the information for the server
     */
    protected void setServerInfo(String serverInfo)
    {
        this.serverInfo = serverInfo;
    }
}