-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIChatWPFPlugin.cs
181 lines (155 loc) · 6.34 KB
/
IChatWPFPlugin.cs
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
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Controls;
namespace ChatModule
{
public abstract class IChatWPFPlugin : UserControl, IChatSource
{
private Color textColor;
private SourceStatus status;
/// <summary>
/// Property for the status on this chat source.
/// </summary>
/// <remarks>This will notify user of its current status.</remarks>
public SourceStatus Status
{
get
{
return status;
}
set
{
status = value;
if (StatusChanged != null)
StatusChanged(this, new PropertyChangedEventArgs("Status"));
}
}
/// <summary>
/// An event that must be triggered whenever Status is changed.
/// </summary>
public event PropertyChangedEventHandler StatusChanged;
public IChatWPFPlugin()
{
Muted = false;
Status = SourceStatus.Offline;
}
/// <summary>
/// Connect to this chat source.
/// </summary>
/// <returns>True if successful.</returns>
/// <remarks>Only if there is a valid call to setup method will this method be executed.</remarks>
public abstract bool connect();
/// <summary>
/// Disconnect from this chat source.
/// </summary>
/// <returns>True if successful.</returns>
/// <remarks>Only if there is a valid call to setup method will this method be executed.</remarks>
public abstract bool disconnect();
#region Method from the IChatSource interface
/// <summary>
/// Property for chat source name.
/// </summary>
/// <remarks>This name will be used as the name of tab item generated.</remarks>
public abstract string SourceName { get; }
/// <summary>
/// Property for the text color used for contents from this chat source in ALL tab.
/// </summary>
/// <remarks>This text color will be used for contents from this chat source in ALL tab.</remarks>
public Color TextColor
{
get
{
return textColor;
}
set
{
textColor = value;
if (TextColorChanged != null)
TextColorChanged(this, new PropertyChangedEventArgs("TextColor"));
}
}
/// <summary>
/// Property for whether the contents are muted from this chat source from the ALL tab.
/// </summary>
/// <remarks>This mute option will be determined whether contents from this chat source will be updated in ALL tab.</remarks>
public bool Muted { get; set; }
/// <summary>
/// Property for the master user account.
/// </summary>
/// <remarks>This user account cannot be modified except through the setup method.</remarks>
public UserAccount MasterAccount { get; private set; }
/// <summary>
/// Property for the list of user accounts in this chat source.
/// </summary>
public abstract IList<UserAccount> Accounts { get; }
/// <summary>
/// An event that is triggered when there is a new incoming message from this chat source.
/// </summary>
public abstract event IncomingMessageEventHandler IncomingMessage;
/// <summary>
/// An event that must be triggered whenever TextColor is changed.
/// </summary>
public event PropertyChangedEventHandler TextColorChanged;
/// <summary>
/// Add the new user to this chat source.
/// </summary>
/// <param name="account">User account to be added.</param>
/// <remarks>This will be called whenever a new chat user joins this chat source.</remarks>
public abstract void addUser(UserAccount account);
/// <summary>
/// Create the user account with the specified username.
/// </summary>
/// <param name="username">Username to use.</param>
/// <returns>New user account.</returns>
/// <remarks>Note that this method will not add the new user account to this chat source automatically.</remarks>
public abstract UserAccount createUser(string username);
/// <summary>
/// Find the user account with the specified username.
/// </summary>
/// <param name="username">Username to search by.</param>
/// <returns>Matching user account</returns>
/// <remarks>This will return null if no matching username is found.</remarks>
public abstract UserAccount findUser(string username);
/// <summary>
/// Send the message to this chat source.
/// </summary>
/// <param name="message">Message to be send.</param>
/// <param name="sender">User account of the sender.</param>
public abstract void send(string message, UserAccount sender);
/// <summary>
/// Setup the account to be master account for this chat source.
/// </summary>
/// <param name="account">Account to be used as master in this chat source.</param>
/// <returns>True if successful.</returns>
/// <remarks>This will modify the property value of MasterAcount.</remarks>
public bool setup(UserAccount account)
{
if (!SourceName.Equals(account.SourceName) || !account.canLog())
return false;
else
{
MasterAccount = account;
return true;
}
}
#endregion
#region Methods from the IPlugin interface
/// <summary>
/// Property for plugin author's name.
/// </summary>
/// <returns>Returns the name of the author who created the plugin.</returns>
public abstract string AuthorName { get; }
/// <summary>
/// Property for plugin name.
/// </summary>
/// <returns>Returns the name of the plugin.</returns>
public abstract string PluginName { get; }
/// <summary>
/// Property for plugin version.
/// </summary>
/// <returns>Returns the version of the plugin.</returns>
public abstract string PluginVersion { get; }
#endregion
}
}