22 Class implementing the IRC identity object. |
22 Class implementing the IRC identity object. |
23 """ |
23 """ |
24 DefaultIdentityName = "0default" |
24 DefaultIdentityName = "0default" |
25 DefaultIdentityDisplay = QCoreApplication.translate("IrcIdentity", "Default Identity") |
25 DefaultIdentityDisplay = QCoreApplication.translate("IrcIdentity", "Default Identity") |
26 |
26 |
|
27 DefaultAwayMessage = QCoreApplication.translate("IrcIdentity", "Gone away for now.") |
27 DefaultQuitMessage = QCoreApplication.translate("IrcIdentity", "IRC for eric5 IDE") |
28 DefaultQuitMessage = QCoreApplication.translate("IrcIdentity", "IRC for eric5 IDE") |
28 DefaultPartMessage = QCoreApplication.translate("IrcIdentity", "IRC for eric5 IDE") |
29 DefaultPartMessage = QCoreApplication.translate("IrcIdentity", "IRC for eric5 IDE") |
29 |
30 |
30 def __init__(self, name): |
31 def __init__(self, name): |
31 """ |
32 """ |
40 self.__nickNames = [] |
41 self.__nickNames = [] |
41 self.__serviceName = "" |
42 self.__serviceName = "" |
42 self.__password = "" |
43 self.__password = "" |
43 self.__ident = Utilities.getUserName() |
44 self.__ident = Utilities.getUserName() |
44 |
45 |
45 # TODO: add AWAY handling |
46 self.__rememberPosOnAway = True |
|
47 self.__awayMessage = IrcIdentity.DefaultAwayMessage |
|
48 self.__autoAway = False |
|
49 self.__autoAwayTimeout = 1 |
|
50 self.__autoReturn = False |
46 |
51 |
47 self.__quitMessage = IrcIdentity.DefaultQuitMessage |
52 self.__quitMessage = IrcIdentity.DefaultQuitMessage |
48 self.__partMessage = IrcIdentity.DefaultPartMessage |
53 self.__partMessage = IrcIdentity.DefaultPartMessage |
49 |
54 |
50 def save(self, settings): |
55 def save(self, settings): |
59 settings.setValue("NickNames", self.__nickNames) |
64 settings.setValue("NickNames", self.__nickNames) |
60 settings.setValue("ServiceName", self.__serviceName) |
65 settings.setValue("ServiceName", self.__serviceName) |
61 settings.setValue("Password", self.__password) |
66 settings.setValue("Password", self.__password) |
62 settings.setValue("QuitMessage", self.__quitMessage) |
67 settings.setValue("QuitMessage", self.__quitMessage) |
63 settings.setValue("PartMessage", self.__partMessage) |
68 settings.setValue("PartMessage", self.__partMessage) |
|
69 settings.setValue("RememberAwayPosition", self.__rememberPosOnAway) |
|
70 settings.setValue("AwayMessage", self.__awayMessage) |
|
71 settings.setValue("AutoAway", self.__autoAway) |
|
72 settings.setValue("AwayTimeout", self.__autoAwayTimeout) |
|
73 settings.setValue("AutoReturn", self.__autoReturn) |
64 |
74 |
65 def load(self, settings): |
75 def load(self, settings): |
66 """ |
76 """ |
67 Public method to load the identity data. |
77 Public method to load the identity data. |
68 |
78 |
73 self.__nickNames = Preferences.toList(settings.value("NickNames", [])) |
83 self.__nickNames = Preferences.toList(settings.value("NickNames", [])) |
74 self.__serviceName = settings.value("ServiceName", "") |
84 self.__serviceName = settings.value("ServiceName", "") |
75 self.__password = settings.value("Password", "") |
85 self.__password = settings.value("Password", "") |
76 self.__quitMessage = settings.value("QuitMessage", IrcIdentity.DefaultQuitMessage) |
86 self.__quitMessage = settings.value("QuitMessage", IrcIdentity.DefaultQuitMessage) |
77 self.__partMessage = settings.value("PartMessage", IrcIdentity.DefaultPartMessage) |
87 self.__partMessage = settings.value("PartMessage", IrcIdentity.DefaultPartMessage) |
|
88 self.__rememberPosOnAway = Preferences.toBool( |
|
89 settings.value("RememberAwayPosition", True)) |
|
90 self.__awayMessage = settings.value("AwayMessage", IrcIdentity.DefaultAwayMessage) |
|
91 self.__autoAway = Preferences.toBool(settings.value("AutoAway", False)) |
|
92 self.__autoAwayTimeout = int(settings.value("AwayTimeout", 1)) |
|
93 self.__autoReturn = Preferences.toBool(settings.value("AutoReturn", False)) |
78 |
94 |
79 def setName(self, name): |
95 def setName(self, name): |
80 """ |
96 """ |
81 Public method to set the identity name. |
97 Public method to set the identity name. |
82 |
98 |
207 Public method to get the PART message. |
223 Public method to get the PART message. |
208 |
224 |
209 @return PART message (string) |
225 @return PART message (string) |
210 """ |
226 """ |
211 return self.__partMessage |
227 return self.__partMessage |
|
228 |
|
229 def setRememberAwayPosition(self, remember): |
|
230 """ |
|
231 Public method to set to remember the chat position upon AWAY. |
|
232 |
|
233 @param remember flag indicating to remember the chat position (boolean) |
|
234 """ |
|
235 self.__rememberPosOnAway = remember |
|
236 |
|
237 def rememberAwayPosition(self): |
|
238 """ |
|
239 Public method to get a flag indicating to remember the chat position upon AWAY. |
|
240 |
|
241 @return flag indicating to remember the chat position (boolean) |
|
242 """ |
|
243 return self.__rememberPosOnAway |
|
244 |
|
245 def setAwayMessage(self, message): |
|
246 """ |
|
247 Public method to set the AWAY message. |
|
248 |
|
249 @param message AWAY message (string) |
|
250 """ |
|
251 if message: |
|
252 self.__awayMessage = message |
|
253 else: |
|
254 self.__awayMessage = IrcIdentity.DefaultAwayMessage |
|
255 |
|
256 def getAwayMessage(self): |
|
257 """ |
|
258 Public method to get the AWAY message. |
|
259 |
|
260 @return AWAY message (string) |
|
261 """ |
|
262 return self.__awayMessage |
|
263 |
|
264 def setAutoAway(self, on): |
|
265 """ |
|
266 Public method to set the auto away function. |
|
267 |
|
268 @param on flag indicating to enable the auto away function (boolean) |
|
269 """ |
|
270 self.__autoAway = on |
|
271 |
|
272 def autoAway(self): |
|
273 """ |
|
274 Public method to get the auto away flag. |
|
275 |
|
276 @return auto away flag (boolean) |
|
277 """ |
|
278 return self.__autoAway |
|
279 |
|
280 def setAutoAwayTimeout(self, minutes): |
|
281 """ |
|
282 Public method to set the auto away timeout. |
|
283 |
|
284 @param minutes auto away timeout in minutes (integer) |
|
285 """ |
|
286 self.__autoAwayTimeout = minutes |
|
287 |
|
288 def getAutoAwayTimeout(self): |
|
289 """ |
|
290 Public method to get the auto away timeout. |
|
291 |
|
292 @return auto away timeout in minutes (integer) |
|
293 """ |
|
294 return self.__autoAwayTimeout |
|
295 |
|
296 def setAutoReturn(self, on): |
|
297 """ |
|
298 Public method to set the auto return function. |
|
299 |
|
300 @param on flag indicating to enable the auto return function (boolean) |
|
301 """ |
|
302 self.__autoReturn = on |
|
303 |
|
304 def autoReturn(self): |
|
305 """ |
|
306 Public method to get the auto return flag. |
|
307 |
|
308 @return auto return flag (boolean) |
|
309 """ |
|
310 return self.__autoReturn |
212 |
311 |
213 @classmethod |
312 @classmethod |
214 def createDefaultIdentity(cls): |
313 def createDefaultIdentity(cls): |
215 """ |
314 """ |
216 Class method to create the default identity. |
315 Class method to create the default identity. |