|
@@ -0,0 +1,93 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (c) 2006-2015 DMDirc Developers
|
|
3
|
+ *
|
|
4
|
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+ * of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+ * in the Software without restriction, including without limitation the rights
|
|
7
|
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+ * copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+ * furnished to do so, subject to the following conditions:
|
|
10
|
+ *
|
|
11
|
+ * The above copyright notice and this permission notice shall be included in
|
|
12
|
+ * all copies or substantial portions of the Software.
|
|
13
|
+ *
|
|
14
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+ * SOFTWARE.
|
|
21
|
+ */
|
|
22
|
+
|
|
23
|
+package com.dmdirc.parser.events;
|
|
24
|
+
|
|
25
|
+import com.dmdirc.parser.interfaces.ClientInfo;
|
|
26
|
+import com.dmdirc.parser.interfaces.Parser;
|
|
27
|
+
|
|
28
|
+import java.util.Date;
|
|
29
|
+import java.util.EnumMap;
|
|
30
|
+import java.util.Map;
|
|
31
|
+import java.util.Optional;
|
|
32
|
+
|
|
33
|
+/**
|
|
34
|
+ * Event raised when detailed user info has been received for a user.
|
|
35
|
+ */
|
|
36
|
+public class UserInfoEvent extends ParserEvent {
|
|
37
|
+
|
|
38
|
+ private final ClientInfo client;
|
|
39
|
+ private final Map<UserInfoType, String> info;
|
|
40
|
+
|
|
41
|
+ public UserInfoEvent(final Parser parser, final Date date, final ClientInfo client,
|
|
42
|
+ final Map<UserInfoType, String> info) {
|
|
43
|
+ super(parser, date);
|
|
44
|
+ this.client = client;
|
|
45
|
+ this.info = new EnumMap<>(info);
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ /**
|
|
49
|
+ * Gets the client that the event is for.
|
|
50
|
+ *
|
|
51
|
+ * @return The client this event is for.
|
|
52
|
+ */
|
|
53
|
+ public ClientInfo getClient() {
|
|
54
|
+ return client;
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ /**
|
|
58
|
+ * Gets a specific piece of information about the user.
|
|
59
|
+ *
|
|
60
|
+ * @param type The type of information to return.
|
|
61
|
+ * @return An optional containing the information, if it was provided.
|
|
62
|
+ */
|
|
63
|
+ public Optional<String> getInfo(final UserInfoType type) {
|
|
64
|
+ return Optional.ofNullable(info.get(type));
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ /**
|
|
68
|
+ * The types of user info that may be returned by the server.
|
|
69
|
+ */
|
|
70
|
+ public enum UserInfoType {
|
|
71
|
+
|
|
72
|
+ /** The user's full address. */
|
|
73
|
+ ADDRESS,
|
|
74
|
+ /** The user's real name. */
|
|
75
|
+ REAL_NAME,
|
|
76
|
+ /** The list of group chats the user is in. */
|
|
77
|
+ GROUP_CHAT_LIST,
|
|
78
|
+ /** Information about the server the user is connected to. */
|
|
79
|
+ SERVER_INFO,
|
|
80
|
+ /** The account the user is authenticated as. */
|
|
81
|
+ ACCOUNT_NAME,
|
|
82
|
+ /** The current idle time for the user. */
|
|
83
|
+ IDLE_TIME,
|
|
84
|
+ /** The time the user connected at. */
|
|
85
|
+ CONNECTION_TIME,
|
|
86
|
+ /** The user's current away message. */
|
|
87
|
+ AWAY_MESSAGE,
|
|
88
|
+ /** The user's server operator status. */
|
|
89
|
+ SERVER_OPER,
|
|
90
|
+
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+}
|