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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
/*
* 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.plugin.generalconfig;
import net.java.sip.communicator.service.configuration.*;
public class ConfigurationManager
{
public static final String ENTER_COMMAND = "Enter";
public static final String CTRL_ENTER_COMMAND = "Ctrl-Enter";
/**
* Indicates whether the message automatic popup is enabled.
*/
private static boolean autoPopupNewMessage;
private static String sendMessageCommand;
private static boolean isSendTypingNotifications;
private static boolean isMultiChatWindowEnabled;
private static boolean isHistoryLoggingEnabled;
private static boolean isHistoryShown;
private static int chatHistorySize;
private static ConfigurationService configService
= GeneralConfigPluginActivator.getConfigurationService();
/**
*
*/
public static void loadGuiConfigurations()
{
// Load the "auPopupNewMessage" property.
String autoPopupProperty =
"net.java.sip.communicator.impl.gui.autoPopupNewMessage";
String autoPopup = configService.getString(autoPopupProperty);
if(autoPopup == null)
autoPopup = Resources.getApplicationString(autoPopupProperty);
if(autoPopup != null && autoPopup.equalsIgnoreCase("yes"))
autoPopupNewMessage = true;
// Load the "sendMessageCommand" property.
String messageCommandProperty =
"net.java.sip.communicator.impl.gui.sendMessageCommand";
String messageCommand = configService.getString(messageCommandProperty);
if(messageCommand == null)
messageCommand =
Resources.getApplicationString(messageCommandProperty);
if(messageCommand != null && messageCommand.length() > 0)
{
sendMessageCommand = messageCommand;
}
// Load the "sendTypingNotifications" property.
String isSendTypingNotifProperty =
"net.java.sip.communicator.impl.gui.sendTypingNotifications";
String isSendTypingNotif =
configService.getString(isSendTypingNotifProperty);
if(isSendTypingNotif == null)
isSendTypingNotif =
Resources.getApplicationString(isSendTypingNotifProperty);
if(isSendTypingNotif != null && isSendTypingNotif.length() > 0)
{
isSendTypingNotifications
= new Boolean(isSendTypingNotif).booleanValue();
}
// Load the "isMultiChatWindowEnabled" property.
String isMultiChatWindowEnabledStringProperty
= "net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled";
String isMultiChatWindowEnabledString
= configService.getString(isMultiChatWindowEnabledStringProperty);
if(isMultiChatWindowEnabledString == null)
isMultiChatWindowEnabledString =
Resources.
getApplicationString(isMultiChatWindowEnabledStringProperty);
if(isMultiChatWindowEnabledString != null
&& isMultiChatWindowEnabledString.length() > 0)
{
isMultiChatWindowEnabled
= new Boolean(isMultiChatWindowEnabledString)
.booleanValue();
}
// Load the "isHistoryLoggingEnabled" property.
String isHistoryLoggingEnabledPropertyString =
"net.java.sip.communicator.impl.msghistory.isMessageHistoryEnabled";
String isHistoryLoggingEnabledString
= configService.getString(
isHistoryLoggingEnabledPropertyString);
if(isHistoryLoggingEnabledString == null)
isHistoryLoggingEnabledString =
Resources.
getApplicationString(isHistoryLoggingEnabledPropertyString);
if(isHistoryLoggingEnabledString != null
&& isHistoryLoggingEnabledString.length() > 0)
{
isHistoryLoggingEnabled
= new Boolean(isHistoryLoggingEnabledString)
.booleanValue();
}
// Load the "isHistoryShown" property.
String isHistoryShownStringProperty =
"net.java.sip.communicator.impl.gui.isMessageHistoryShown";
String isHistoryShownString
= configService.getString(isHistoryShownStringProperty);
if(isHistoryShownString == null)
isHistoryShownString =
Resources.getApplicationString(isHistoryShownStringProperty);
if(isHistoryShownString != null
&& isHistoryShownString.length() > 0)
{
isHistoryShown
= new Boolean(isHistoryShownString)
.booleanValue();
}
// Load the "chatHistorySize" property.
String chatHistorySizeStringProperty =
"net.java.sip.communicator.impl.gui.messageHistorySize";
String chatHistorySizeString
= configService.getString(chatHistorySizeStringProperty);
if(chatHistorySizeString == null)
chatHistorySizeString =
Resources.getApplicationString(chatHistorySizeStringProperty);
if(chatHistorySizeString != null
&& chatHistorySizeString.length() > 0)
{
chatHistorySize
= new Integer(chatHistorySizeString)
.intValue();
}
}
/**
* Return TRUE if "autoPopupNewMessage" property is true, otherwise - return
* FALSE. Indicates to the user interface whether new messages should be
* opened and bring to front.
* @return TRUE if "autoPopupNewMessage" property is true, otherwise - return
* FALSE.
*/
public static boolean isAutoPopupNewMessage()
{
return autoPopupNewMessage;
}
/**
* Return TRUE if "sendTypingNotifications" property is true, otherwise -
* return FALSE. Indicates to the user interface whether typing
* notifications are enabled or disabled.
* @return TRUE if "sendTypingNotifications" property is true, otherwise -
* return FALSE.
*/
public static boolean isSendTypingNotifications()
{
return isSendTypingNotifications;
}
/**
* Returns <code>true</code> if the "isMultiChatWindowEnabled" property is
* true, otherwise - returns <code>false</code>. Indicates to the user
* interface whether the chat window could contain multiple chats or just
* one chat.
* @return <code>true</code> if the "isMultiChatWindowEnabled" property is
* true, otherwise - returns <code>false</code>.
*/
public static boolean isMultiChatWindowEnabled()
{
return isMultiChatWindowEnabled;
}
/**
* Returns <code>true</code> if the "isHistoryLoggingEnabled" property is
* true, otherwise - returns <code>false</code>. Indicates to the user
* interface whether the history logging is enabled.
* @return <code>true</code> if the "isHistoryLoggingEnabled" property is
* true, otherwise - returns <code>false</code>.
*/
public static boolean isHistoryLoggingEnabled()
{
return isHistoryLoggingEnabled;
}
/**
* Returns <code>true</code> if the "isHistoryShown" property is
* true, otherwise - returns <code>false</code>. Indicates to the user
* whether the history is shown in the chat window.
* @return <code>true</code> if the "isHistoryShown" property is
* true, otherwise - returns <code>false</code>.
*/
public static boolean isHistoryShown()
{
return isHistoryShown;
}
/**
* Returns the number of messages from chat history that would be shown in
* the chat window.
* @return the number of messages from chat history that would be shown in
* the chat window.
*/
public static int getChatHistorySize()
{
return chatHistorySize;
}
/**
* Return the "sendMessageCommand" property that was saved previously
* through the <tt>ConfigurationService</tt>. Indicates to the user
* interface whether the default send message command is Enter or CTRL-Enter.
* @return "Enter" or "CTRL-Enter" message commands.
*/
public static String getSendMessageCommand()
{
return sendMessageCommand;
}
/**
* Updates the "autoPopupNewMessage" property.
*
* @param autoPopupNewMessage indicates to the user interface whether new
* messages should be opened and bring to front.
**/
public static void setAutoPopupNewMessage(boolean autoPopupNewMessage)
{
ConfigurationManager.autoPopupNewMessage = autoPopupNewMessage;
if(autoPopupNewMessage)
configService.setProperty(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage",
"yes");
else
configService.setProperty(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage",
"no");
}
/**
* Updates the "sendTypingNotifications" property through the
* <tt>ConfigurationService</tt>.
*
* @param isSendTypingNotif <code>true</code> to indicate that typing
* notifications are enabled, <code>false</code> otherwise.
*/
public static void setSendTypingNotifications(boolean isSendTypingNotif)
{
isSendTypingNotifications = isSendTypingNotif;
configService.setProperty(
"net.java.sip.communicator.impl.gui.sendTypingNotifications",
Boolean.toString(isSendTypingNotif));
}
/**
* Updates the "sendMessageCommand" property through the
* <tt>ConfigurationService</tt>.
*
* @param newMessageCommand the command used to send a message ( it could be
* ENTER_COMMAND or CTRL_ENTER_COMMAND)
*/
public static void setSendMessageCommand(String newMessageCommand)
{
sendMessageCommand = newMessageCommand;
configService.setProperty(
"net.java.sip.communicator.impl.gui.sendMessageCommand",
newMessageCommand);
}
/**
* Updates the "isMultiChatWindowEnabled" property through the
* <tt>ConfigurationService</tt>.
*
* @param isMultiChatWindowEnabled indicates if the chat window could
* contain multiple chats or only one chat.
*/
public static void setMultiChatWindowEnabled(
boolean isMultiChatWindowEnabled)
{
ConfigurationManager.isHistoryLoggingEnabled = isMultiChatWindowEnabled;
configService.setProperty(
"net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled",
Boolean.toString(isMultiChatWindowEnabled));
}
/**
* Updates the "isHistoryLoggingEnabled" property through the
* <tt>ConfigurationService</tt>.
*
* @param isHistoryLoggingEnabled indicates if the history logging is
* enabled.
*/
public static void setHistoryLoggingEnabled(
boolean isHistoryLoggingEnabled)
{
ConfigurationManager.isHistoryLoggingEnabled = isHistoryLoggingEnabled;
configService.setProperty(
"net.java.sip.communicator.impl.msghistory.isMessageHistoryEnabled",
Boolean.toString(isHistoryLoggingEnabled));
}
/**
* Updates the "isHistoryLoggingEnabled" property through the
* <tt>ConfigurationService</tt>.
*
* @param isHistoryLoggingEnabled indicates if the history logging is
* enabled.
*/
public static void setHistoryShown(boolean isHistoryShown)
{
ConfigurationManager.isHistoryShown = isHistoryShown;
configService.setProperty(
"net.java.sip.communicator.impl.gui.isMessageHistoryShown",
Boolean.toString(isHistoryShown));
}
/**
* Updates the "chatHistorySize" property through the
* <tt>ConfigurationService</tt>.
*
* @param historySize indicates if the history logging is
* enabled.
*/
public static void setChatHistorySize(int historySize)
{
ConfigurationManager.chatHistorySize = historySize;
configService.setProperty(
"net.java.sip.communicator.impl.gui.messageHistorySize",
Integer.toString(chatHistorySize));
}
}
|