Merge lp:~julien-spautz/cable/new-folder-layout into lp:cable
- new-folder-layout
- Merge into trunk
Proposed by
Julien Spautz
Status: | Merged |
---|---|
Merged at revision: | 149 |
Proposed branch: | lp:~julien-spautz/cable/new-folder-layout |
Merge into: | lp:cable |
Diff against target: |
7716 lines (+3640/-3747) 54 files modified
CMakeLists.txt (+41/-43) src/Adapters/Irc/Channel.vala (+279/-0) src/Adapters/Irc/Maki.vala (+278/-0) src/Adapters/Irc/Server.vala (+621/-0) src/Adapters/Irc/Session.vala (+77/-0) src/Adapters/Services/Launcher.vala (+66/-0) src/Adapters/Services/Logger.vala (+7/-0) src/Adapters/Services/Notify.vala (+42/-0) src/Adapters/Settings/Preferences.vala (+58/-0) src/Adapters/Settings/SavedState.vala (+36/-0) src/Adapters/Settings/Settings.vala (+35/-0) src/Adapters/Widgets/Channel.vala (+131/-0) src/Adapters/Widgets/ChatDisplay.vala (+153/-0) src/Adapters/Widgets/Room.vala (+283/-0) src/Adapters/Widgets/Server.vala (+100/-0) src/Adapters/Widgets/TopicBar.vala (+72/-0) src/Adapters/Widgets/User.vala (+36/-0) src/Adapters/Widgets/UserList.vala (+122/-0) src/Adapters/Widgets/Welcome.vala (+143/-0) src/Adapters/Widgets/Window.vala (+293/-0) src/Cable.vala (+2/-2) src/Controller/Channel.vala (+0/-275) src/Controller/PrivateChat.vala (+0/-85) src/Controller/Server.vala (+0/-109) src/Controller/Window.vala (+0/-167) src/Controllers/Channel.vala (+275/-0) src/Controllers/PrivateChat.vala (+85/-0) src/Controllers/Server.vala (+109/-0) src/Controllers/Window.vala (+167/-0) src/Dialogs/Preferences.vala (+2/-2) src/Irc/Channel.vala (+0/-279) src/Irc/Maki.vala (+0/-278) src/Irc/Server.vala (+0/-621) src/Irc/Session.vala (+0/-77) src/Ports/Irc.vala (+3/-3) src/Ports/View.vala (+124/-0) src/Services/Launcher.vala (+0/-66) src/Services/Logger.vala (+0/-7) src/Services/Notify.vala (+0/-42) src/Settings/Preferences.vala (+0/-58) src/Settings/SavedState.vala (+0/-36) src/Settings/Settings.vala (+0/-35) src/View/Channel.vala (+0/-58) src/View/Server.vala (+0/-55) src/View/Window.vala (+0/-119) src/Widgets/Channel.vala (+0/-128) src/Widgets/ChatDisplay.vala (+0/-153) src/Widgets/Room.vala (+0/-283) src/Widgets/Server.vala (+0/-100) src/Widgets/TopicBar.vala (+0/-72) src/Widgets/User.vala (+0/-36) src/Widgets/UserList.vala (+0/-122) src/Widgets/Welcome.vala (+0/-143) src/Widgets/Window.vala (+0/-293) |
To merge this branch: | bzr merge lp:~julien-spautz/cable/new-folder-layout |
Related bugs: | |
Related blueprints: |
The Clean Architecture
(Essential)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Julien Spautz | Approve | ||
Review via email: mp+188201@code.launchpad.net |
Commit message
Description of the change
Creating a new folder layout due to the architectural changes. Additionally some namespaces will be changed accordingly.
To post a comment you must log in.
- 151. By Julien Spautz
-
Put Irc implementation into Adapter namespace
- 152. By Julien Spautz
-
Put GUI implementation into Adapter namespace
Revision history for this message
Julien Spautz (julien-spautz) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2013-09-28 12:37:00 +0000 |
3 | +++ CMakeLists.txt 2013-09-29 09:56:16 +0000 |
4 | @@ -51,54 +51,52 @@ |
5 | |
6 | src/Cable.vala |
7 | |
8 | - src/Utils/Utils.vala |
9 | - src/Utils/AutoScrolled.vala |
10 | - src/Utils/EmbeddedAlert.vala |
11 | - src/Utils/Identity.vala |
12 | - src/Utils/Network.vala |
13 | - src/Utils/MessageHistory.vala |
14 | - src/Utils/UpMarker.vala |
15 | - src/Utils/UrlUpMarker.vala |
16 | - src/Utils/ColorCodeParser.vala |
17 | - |
18 | - src/Irc/Maki.vala |
19 | - src/Irc/Session.vala |
20 | - src/Irc/Server.vala |
21 | - src/Irc/Channel.vala |
22 | - |
23 | - src/Controller/Window.vala |
24 | - src/Controller/Server.vala |
25 | - src/Controller/Channel.vala |
26 | - src/Controller/PrivateChat.vala |
27 | - |
28 | - src/View/Server.vala |
29 | - src/View/Channel.vala |
30 | - src/View/Window.vala |
31 | - |
32 | - src/Settings/Settings.vala |
33 | - src/Settings/Preferences.vala |
34 | - src/Settings/SavedState.vala |
35 | - |
36 | - src/Services/Launcher.vala |
37 | - src/Services/Notify.vala |
38 | - src/Services/Logger.vala |
39 | - |
40 | - src/Widgets/Window.vala |
41 | - src/Widgets/Welcome.vala |
42 | - src/Widgets/Server.vala |
43 | - src/Widgets/Channel.vala |
44 | - src/Widgets/Room.vala |
45 | - src/Widgets/ChatDisplay.vala |
46 | - src/Widgets/User.vala |
47 | - src/Widgets/UserList.vala |
48 | - src/Widgets/TopicBar.vala |
49 | - |
50 | src/Dialogs/JoinChannel.vala |
51 | - src/Dialogs/Preferences.vala |
52 | src/Dialogs/ManageIdentity.vala |
53 | src/Dialogs/ManageNetwork.vala |
54 | + src/Dialogs/Preferences.vala |
55 | + |
56 | + src/Utils/AutoScrolled.vala |
57 | + src/Utils/ColorCodeParser.vala |
58 | + src/Utils/EmbeddedAlert.vala |
59 | + src/Utils/HostMask.vala |
60 | + src/Utils/Identity.vala |
61 | + src/Utils/MessageHistory.vala |
62 | + src/Utils/Network.vala |
63 | + src/Utils/UpMarker.vala |
64 | + src/Utils/UrlUpMarker.vala |
65 | + src/Utils/Utils.vala |
66 | |
67 | src/Ports/Irc.vala |
68 | + src/Ports/View.vala |
69 | + |
70 | + src/Adapters/Widgets/ChatDisplay.vala |
71 | + src/Adapters/Widgets/Room.vala |
72 | + src/Adapters/Widgets/TopicBar.vala |
73 | + src/Adapters/Widgets/User.vala |
74 | + src/Adapters/Widgets/UserList.vala |
75 | + src/Adapters/Widgets/Welcome.vala |
76 | + src/Adapters/Widgets/Channel.vala |
77 | + src/Adapters/Widgets/Window.vala |
78 | + src/Adapters/Widgets/Server.vala |
79 | + |
80 | + src/Adapters/Settings/Preferences.vala |
81 | + src/Adapters/Settings/SavedState.vala |
82 | + src/Adapters/Settings/Settings.vala |
83 | + |
84 | + src/Adapters/Irc/Maki.vala |
85 | + src/Adapters/Irc/Channel.vala |
86 | + src/Adapters/Irc/Server.vala |
87 | + src/Adapters/Irc/Session.vala |
88 | + |
89 | + src/Adapters/Services/Launcher.vala |
90 | + src/Adapters/Services/Logger.vala |
91 | + src/Adapters/Services/Notify.vala |
92 | + |
93 | + src/Controllers/Channel.vala |
94 | + src/Controllers/PrivateChat.vala |
95 | + src/Controllers/Server.vala |
96 | + src/Controllers/Window.vala |
97 | |
98 | ${CMAKE_BINARY_DIR}/src/Config.vala |
99 | PACKAGES |
100 | |
101 | === added directory 'src/Adapters' |
102 | === added directory 'src/Adapters/Irc' |
103 | === added file 'src/Adapters/Irc/Channel.vala' |
104 | --- src/Adapters/Irc/Channel.vala 1970-01-01 00:00:00 +0000 |
105 | +++ src/Adapters/Irc/Channel.vala 2013-09-29 09:56:16 +0000 |
106 | @@ -0,0 +1,279 @@ |
107 | +/*** |
108 | + Copyright (C) 2013 Cable Developers |
109 | + |
110 | + This program or library is free software; you can redistribute it |
111 | + and/or modify it under the terms of the GNU Lesser General Public |
112 | + License as published by the Free Software Foundation; either |
113 | + version 3 of the License, or (at your option) any later version. |
114 | + |
115 | + This library is distributed in the hope that it will be useful, |
116 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
117 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
118 | + Lesser General Public License for more details. |
119 | + |
120 | + You should have received a copy of the GNU Lesser General |
121 | + Public License along with this library; if not, write to the |
122 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
123 | + Boston, MA 02110-1301 USA. |
124 | +***/ |
125 | + |
126 | +public class Cable.Adapter.Irc.Channel : GLib.Object, Port.Irc.Channel { |
127 | + |
128 | + public string server_name { get; private set; } |
129 | + |
130 | + public string name { get; set; } |
131 | + |
132 | + string _topic = ""; |
133 | + public string topic { |
134 | + get { |
135 | + try { |
136 | + _topic = client.channel_topic (server_name, this.name); |
137 | + } catch (GLib.IOError error) { |
138 | + warning (error.message); |
139 | + } |
140 | + |
141 | + return _topic; |
142 | + } |
143 | + } |
144 | + |
145 | + string[] _nicks = {}; |
146 | + public string[] nicks { |
147 | + get { |
148 | + try { |
149 | + client.channel_nicks (server_name, this.name, out _nicks, out _prefixes); |
150 | + } catch (GLib.IOError error) { |
151 | + warning (error.message); |
152 | + } |
153 | + |
154 | + return _nicks; |
155 | + } |
156 | + } |
157 | + |
158 | + string[] _prefixes = {}; |
159 | + public string[] prefixes { |
160 | + get { |
161 | + try { |
162 | + client.channel_nicks (server_name, this.name, out _nicks, out _prefixes); |
163 | + } catch (GLib.IOError error) { |
164 | + warning (error.message); |
165 | + } |
166 | + |
167 | + return _prefixes; |
168 | + } |
169 | + } |
170 | + |
171 | + public bool joined { |
172 | + get { |
173 | + try { |
174 | + return name in client.channels (server_name); |
175 | + } catch (GLib.IOError error) { |
176 | + warning (error.message); |
177 | + } |
178 | + |
179 | + return false; |
180 | + } |
181 | + } |
182 | + |
183 | + public Channel (string channel_name, string server_name) { |
184 | + this.name = channel_name; |
185 | + this.server_name = server_name; |
186 | + setup_signals (); |
187 | + } |
188 | + |
189 | + /** |
190 | + * Send a message displayed in "third person" |
191 | + * @param message The message to be sent. |
192 | + */ |
193 | + public void send_action (string message) { |
194 | + try { |
195 | + client.action (server_name, name, message); |
196 | + } catch (GLib.IOError error) { |
197 | + warning (error.message); |
198 | + } |
199 | + } |
200 | + |
201 | + /** |
202 | + * Invite a person to join this channel. |
203 | + * @param who Nick name of the person to invite. |
204 | + */ |
205 | + public void send_invite (string who) { |
206 | + try { |
207 | + client.invite (server_name, name, who); |
208 | + } catch (GLib.IOError error) { |
209 | + warning (error.message); |
210 | + } |
211 | + } |
212 | + |
213 | + /** |
214 | + * Join this channel. |
215 | + * @param key Password to this channel. Should be "" if there is no password. |
216 | + */ |
217 | + public void send_join (string key = "") { |
218 | + try { |
219 | + client.join (server_name, name, key); |
220 | + } catch (GLib.IOError error) { |
221 | + warning (error.message); |
222 | + } |
223 | + } |
224 | + |
225 | + /** |
226 | + * Kick a user from the channel. Requires operator privileges. |
227 | + * @param who Nick name of the user to be kicked. |
228 | + * @param message Reason why the user has been kicked. |
229 | + */ |
230 | + public void send_kick (string who, string message) { |
231 | + try { |
232 | + client.kick (server_name, name, who, message); |
233 | + } catch (GLib.IOError error) { |
234 | + warning (error.message); |
235 | + } |
236 | + } |
237 | + |
238 | + /** |
239 | + * Request topic and number of users for this channel TODO move somewhere else |
240 | + */ |
241 | + public void send_list () { |
242 | + try { |
243 | + client.list (server_name, name); |
244 | + } catch (GLib.IOError error) { |
245 | + warning (error.message); |
246 | + } |
247 | + } |
248 | + |
249 | + /** |
250 | + * Send a normal message in this channel. |
251 | + * @param message The message. |
252 | + */ |
253 | + public void send_message (string message) { |
254 | + try { |
255 | + client.message (server_name, name, message); |
256 | + } catch (GLib.IOError error) { |
257 | + warning (error.message); |
258 | + } |
259 | + } |
260 | + |
261 | + /** |
262 | + * Request a list of names from the channel. |
263 | + */ |
264 | + public void send_names () { |
265 | + try { |
266 | + client.names (server_name, name); |
267 | + } catch (GLib.IOError error) { |
268 | + warning (error.message); |
269 | + } |
270 | + } |
271 | + |
272 | + /** |
273 | + * Leave this channel. |
274 | + * @param message Part message to be displayed. If null it will be fetched from the identity. |
275 | + */ |
276 | + public void send_part (string? message = null) { |
277 | + try { |
278 | + client.part (server_name, name, message ?? ""); |
279 | + } catch (GLib.IOError error) { |
280 | + warning (error.message); |
281 | + } |
282 | + } |
283 | + |
284 | + /** |
285 | + * Change or request the channel's topic. |
286 | + * @param topic The new topic, or "" if you just want to query the current topic. |
287 | + */ |
288 | + public void send_topic (string topic = "") { |
289 | + try { |
290 | + client.topic (server_name, name, topic); |
291 | + } catch (GLib.IOError error) { |
292 | + warning (error.message); |
293 | + } |
294 | + } |
295 | + |
296 | + /** |
297 | + * Get the channel mode for a given user. |
298 | + * @param nick Nick name of the user. |
299 | + */ |
300 | + public string user_channel_mode (string nick) { |
301 | + try { |
302 | + return client.user_channel_mode (server_name, name, nick); |
303 | + } catch (GLib.IOError error) { |
304 | + warning (error.message); |
305 | + } |
306 | + |
307 | + return ""; |
308 | + } |
309 | + |
310 | + /** |
311 | + * Get the channel prefix ("@", "+") of a given user. |
312 | + * @param nick Nick name of the user. |
313 | + */ |
314 | + public string user_channel_prefix (string nick) { |
315 | + try { |
316 | + return client.user_channel_prefix (server_name, name, nick); |
317 | + } catch (GLib.IOError error) { |
318 | + warning (error.message); |
319 | + } |
320 | + |
321 | + return ""; |
322 | + } |
323 | + |
324 | + void setup_signals () { |
325 | + client.event_action.connect ((time, server, from, target, message) => { |
326 | + if (server == this.server_name && name == target) |
327 | + event_action (from, message); |
328 | + }); |
329 | + |
330 | + client.event_banlist.connect ((time, server, channel, mask, who, when) => { |
331 | + if (server == this.server_name && name == channel) |
332 | + event_banlist (mask, who, when); |
333 | + }); |
334 | + |
335 | + client.event_cannot_join.connect ((time, server, channel, reason) => { |
336 | + if (server == this.server_name && name == channel) |
337 | + event_cannot_join (reason); |
338 | + }); |
339 | + |
340 | + client.event_invite.connect ((time, server, from, channel, who) => { |
341 | + if (server == this.server_name && name == channel) |
342 | + event_invite (from, who); |
343 | + }); |
344 | + |
345 | + client.event_join.connect ((time, server, from, channel) => { |
346 | + if (server == this.server_name && name == channel) |
347 | + event_join (from); |
348 | + }); |
349 | + |
350 | + client.event_kick.connect ((time, server, from, channel, who, message) => { |
351 | + if (server == this.server_name && name == channel) |
352 | + event_kick (from, who, message); |
353 | + }); |
354 | + |
355 | + client.event_list.connect ((time, server, channel, users, topic) => { |
356 | + if (server == this.server_name && name == channel) |
357 | + event_list (users, topic); |
358 | + }); |
359 | + |
360 | + client.event_message.connect ((time, server, from, target, message) => { |
361 | + if (server == this.server_name && name == target) |
362 | + event_message (from, message); |
363 | + }); |
364 | + |
365 | + client.event_names.connect ((time, server, channel, nicks, prefixes) => { |
366 | + if (server == this.server_name && name == channel) |
367 | + event_names (nicks, prefixes); |
368 | + }); |
369 | + |
370 | + client.event_no_such.connect ((time, server, target, type) => { |
371 | + if (server == this.server_name && name == target && type == "c") |
372 | + event_no_such (); |
373 | + }); |
374 | + |
375 | + client.event_part.connect ((time, server, from, channel, message) => { |
376 | + if (server == this.server_name && name == channel) |
377 | + event_part (from, message); |
378 | + }); |
379 | + |
380 | + client.event_topic.connect ((time, server, from, channel, topic) => { |
381 | + if (server == this.server_name && name == channel) |
382 | + event_topic (from, topic); |
383 | + }); |
384 | + } |
385 | +} |
386 | |
387 | === added file 'src/Adapters/Irc/Maki.vala' |
388 | --- src/Adapters/Irc/Maki.vala 1970-01-01 00:00:00 +0000 |
389 | +++ src/Adapters/Irc/Maki.vala 2013-09-29 09:56:16 +0000 |
390 | @@ -0,0 +1,278 @@ |
391 | +/*** |
392 | + Copyright (C) 2013 Cable Developers |
393 | + |
394 | + This program or library is free software; you can redistribute it |
395 | + and/or modify it under the terms of the GNU Lesser General Public |
396 | + License as published by the Free Software Foundation; either |
397 | + version 3 of the License, or (at your option) any later version. |
398 | + |
399 | + This library is distributed in the hope that it will be useful, |
400 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
401 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
402 | + Lesser General Public License for more details. |
403 | + |
404 | + You should have received a copy of the GNU Lesser General |
405 | + Public License along with this library; if not, write to the |
406 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
407 | + Boston, MA 02110-1301 USA. |
408 | +***/ |
409 | + |
410 | +/** |
411 | + * This is a dbus interface to the maki daemon from the SushiIRC project. |
412 | + * Use the methods to send requests or messages to the server and the |
413 | + * signals to react to the server's replies. |
414 | + */ |
415 | +[DBus (name = "de.ikkoku.sushi", timeout = 120000)] |
416 | +public interface Cable.Adapter.Irc.Maki : GLib.Object { |
417 | + |
418 | + [DBus (name = "action")] |
419 | + public abstract void action (string server, string channel, string message) throws GLib.IOError; |
420 | + |
421 | + [DBus (name = "away")] |
422 | + public abstract void away (string server, string message) throws GLib.IOError; |
423 | + |
424 | + [DBus (name = "back")] |
425 | + public abstract void back (string server) throws GLib.IOError; |
426 | + |
427 | + [DBus (name = "channel_nicks")] |
428 | + public abstract void channel_nicks (string server, string channel, out string[] nicks, out string[] prefixes) throws GLib.IOError; |
429 | + |
430 | + [DBus (name = "channel_topic")] |
431 | + public abstract string channel_topic (string server, string channel) throws GLib.IOError; |
432 | + |
433 | + [DBus (name = "channels")] |
434 | + public abstract string[] channels (string server) throws GLib.IOError; |
435 | + |
436 | + [DBus (name = "config_get")] |
437 | + public abstract string config_get (string group, string key) throws GLib.IOError; |
438 | + |
439 | + [DBus (name = "config_set")] |
440 | + public abstract void config_set (string group, string key, string value) throws GLib.IOError; |
441 | + |
442 | + // connect to a server known to maki |
443 | + [DBus (name = "connect")] |
444 | + public abstract void connect (string server) throws GLib.IOError; |
445 | + |
446 | + [DBus (name = "ctcp")] |
447 | + public abstract void ctcp (string server, string target, string message) throws GLib.IOError; |
448 | + |
449 | + [DBus (name = "dcc_send")] |
450 | + public abstract void dcc_send(string server, string target, string path) throws GLib.IOError; |
451 | + |
452 | + [DBus (name = "dcc_sends")] |
453 | + public abstract void dcc_sends (out uint64[] ids, out string[] servers, out string[] froms, out string[] filenames, out uint64[] sizes, out uint64[] progresses, out uint64[] speeds, out uint64[] statuses) throws GLib.IOError; |
454 | + |
455 | + [DBus (name = "dcc_send_accept")] |
456 | + public abstract void dcc_send_accept (uint64 id) throws GLib.IOError; |
457 | + |
458 | + [DBus (name = "dcc_send_get")] |
459 | + public abstract string dcc_send_get (uint64 id, string key) throws GLib.IOError; |
460 | + |
461 | + [DBus (name = "dcc_send_remove")] |
462 | + public abstract void dcc_send_remove (uint64 id) throws GLib.IOError; |
463 | + |
464 | + [DBus (name = "dcc_send_resume")] |
465 | + public abstract void dcc_send_resume (uint64 id) throws GLib.IOError; |
466 | + |
467 | + [DBus (name = "dcc_send_set")] |
468 | + public abstract void dcc_send_set (uint64 id, string key, string value) throws GLib.IOError; |
469 | + |
470 | + [DBus (name = "ignore")] |
471 | + public abstract void ignore (string server, string pattern) throws GLib.IOError; |
472 | + |
473 | + [DBus (name = "ignores")] |
474 | + public abstract string[] ignores (string server) throws GLib.IOError; |
475 | + |
476 | + [DBus (name = "invite")] |
477 | + public abstract void invite (string server, string channel, string who) throws GLib.IOError; |
478 | + |
479 | + [DBus (name = "join")] |
480 | + public abstract void join (string server, string channel, string key) throws GLib.IOError; |
481 | + |
482 | + [DBus (name = "kick")] |
483 | + public abstract void kick (string server, string channel, string who, string message) throws GLib.IOError; |
484 | + |
485 | + [DBus (name = "list")] |
486 | + public abstract void list (string server, string channel) throws GLib.IOError; |
487 | + |
488 | + [DBus (name = "log")] |
489 | + public abstract string[] log (string server, string target, uint64 lines) throws GLib.IOError; |
490 | + |
491 | + [DBus (name = "message")] |
492 | + public abstract void message (string server, string target, string message) throws GLib.IOError; |
493 | + |
494 | + [DBus (name = "mode")] |
495 | + public abstract void mode (string server, string target, string mode) throws GLib.IOError; |
496 | + |
497 | + [DBus (name = "names")] |
498 | + public abstract void names (string server, string channel) throws GLib.IOError; |
499 | + |
500 | + [DBus (name = "nick")] |
501 | + public abstract void nick (string server, string nick) throws GLib.IOError; |
502 | + |
503 | + [DBus (name = "nickserv")] |
504 | + public abstract void nickserv (string server) throws GLib.IOError; |
505 | + |
506 | + [DBus (name = "notice")] |
507 | + public abstract void notice (string server, string target, string message) throws GLib.IOError; |
508 | + |
509 | + [DBus (name = "oper")] |
510 | + public abstract void oper (string server, string name, string password) throws GLib.IOError; |
511 | + |
512 | + [DBus (name = "part")] |
513 | + public abstract void part (string server, string channel, string message) throws GLib.IOError; |
514 | + |
515 | + [DBus (name = "quit")] |
516 | + public abstract void quit (string server, string message) throws GLib.IOError; |
517 | + |
518 | + [DBus (name = "raw")] |
519 | + public abstract void raw (string server, string command) throws GLib.IOError; |
520 | + |
521 | + [DBus (name = "server_get")] |
522 | + public abstract string server_get (string server, string group, string key) throws GLib.IOError; |
523 | + |
524 | + [DBus (name = "server_get_list")] |
525 | + public abstract string[] server_get_list (string server, string group, string key) throws GLib.IOError; |
526 | + |
527 | + // server_list ("", "") gives a list of servers known to maki |
528 | + [DBus (name = "server_list")] |
529 | + public abstract string[] server_list (string server, string group) throws GLib.IOError; |
530 | + |
531 | + [DBus (name = "server_remove")] |
532 | + public abstract void server_remove (string server, string group, string key) throws GLib.IOError; |
533 | + |
534 | + [DBus (name = "server_rename")] |
535 | + public abstract void server_rename (string old, string new_) throws GLib.IOError; |
536 | + |
537 | + [DBus (name = "server_set")] |
538 | + public abstract void server_set (string server, string group, string key, string value) throws GLib.IOError; |
539 | + |
540 | + [DBus (name = "server_set_list")] |
541 | + public abstract void server_set_list (string server, string group, string key, string[] list) throws GLib.IOError; |
542 | + |
543 | + [DBus (name = "servers")] |
544 | + public abstract string[] servers () throws GLib.IOError; |
545 | + |
546 | + [DBus (name = "shutdown")] |
547 | + public abstract void shutdown (string message) throws GLib.IOError; |
548 | + |
549 | + [DBus (name = "support_chantypes")] |
550 | + public abstract string support_chantypes (string server) throws GLib.IOError; |
551 | + |
552 | + [DBus (name = "support_prefix")] |
553 | + public abstract string[] support_prefix (string server) throws GLib.IOError; |
554 | + |
555 | + [DBus (name = "topic")] |
556 | + public abstract void topic (string server, string channel, string topic) throws GLib.IOError; |
557 | + |
558 | + [DBus (name = "unignore")] |
559 | + public abstract void unignore (string server, string pattern) throws GLib.IOError; |
560 | + |
561 | + [DBus (name = "user_away")] |
562 | + public abstract bool user_away (string server, string nick) throws GLib.IOError; |
563 | + |
564 | + [DBus (name = "user_channel_mode")] |
565 | + public abstract string user_channel_mode (string server, string channel, string nick) throws GLib.IOError; |
566 | + |
567 | + [DBus (name = "user_channel_prefix")] |
568 | + public abstract string user_channel_prefix (string server, string channel, string nick) throws GLib.IOError; |
569 | + |
570 | + [DBus (name = "user_from")] |
571 | + public abstract string user_from (string server, string nick) throws GLib.IOError; |
572 | + |
573 | + [DBus (name = "version")] |
574 | + public abstract uint64[] version () throws GLib.IOError; |
575 | + |
576 | + [DBus (name = "who")] |
577 | + public abstract void who (string server, string mask, bool operators_only) throws GLib.IOError; |
578 | + |
579 | + [DBus (name = "whois")] |
580 | + public abstract void whois (string server, string mask) throws GLib.IOError; |
581 | + |
582 | + [DBus (name = "action")] |
583 | + public signal void event_action (int64 time, string server, string from, string target, string message); |
584 | + |
585 | + [DBus (name = "away")] |
586 | + public signal void event_away (int64 time, string server); |
587 | + |
588 | + [DBus (name = "away_message")] |
589 | + public signal void event_away_message (int64 time, string server, string nick, string message); |
590 | + |
591 | + [DBus (name = "back")] |
592 | + public signal void event_back (int64 time, string server); |
593 | + |
594 | + [DBus (name = "banlist")] |
595 | + public signal void event_banlist (int64 time, string server, string channel, string mask, string who, int64 when); |
596 | + |
597 | + [DBus (name = "cannot_join")] |
598 | + public signal void event_cannot_join (int64 time, string server, string channel, string reason); |
599 | + |
600 | + [DBus (name = "connect")] |
601 | + public signal void event_connect (int64 time, string server); |
602 | + |
603 | + [DBus (name = "connected")] |
604 | + public signal void event_connected (int64 time, string server); |
605 | + |
606 | + [DBus (name = "ctcp")] |
607 | + public signal void event_ctcp (int64 time, string server, string from, string target, string message); |
608 | + |
609 | + [DBus (name = "dcc_send")] |
610 | + public signal void event_dcc_send (int64 time, string server, uint64 id, string from, string filename, uint64 size, uint64 progress, uint64 speed, uint64 status); |
611 | + |
612 | + [DBus (name = "error")] |
613 | + public signal void event_error (int64 time, string server, string domain, string reason, string[] arguments); |
614 | + |
615 | + [DBus (name = "invite")] |
616 | + public signal void event_invite (int64 time, string server, string from, string channel, string who); |
617 | + |
618 | + [DBus (name = "join")] |
619 | + public signal void event_join (int64 time, string server, string from, string channel); |
620 | + |
621 | + [DBus (name = "kick")] |
622 | + public signal void event_kick (int64 time, string server, string from, string channel, string who, string message); |
623 | + |
624 | + [DBus (name = "list")] |
625 | + public signal void event_list (int64 time, string server, string channel, int64 users, string topic); |
626 | + |
627 | + [DBus (name = "message")] |
628 | + public signal void event_message (int64 time, string server, string from, string target, string message); |
629 | + |
630 | + [DBus (name = "mode")] |
631 | + public signal void event_mode (int64 time, string server, string from, string target, string mode, string parameter); |
632 | + |
633 | + [DBus (name = "motd")] |
634 | + public signal void event_motd (int64 time, string server, string message); |
635 | + |
636 | + [DBus (name = "names")] |
637 | + public signal void event_names (int64 time, string server, string channel, string[] nicks, string[] prefixes); |
638 | + |
639 | + [DBus (name = "nick")] |
640 | + public signal void event_nick (int64 time, string server, string from, string new_nick); |
641 | + |
642 | + [DBus (name = "no_such")] |
643 | + public signal void event_no_such (int64 time, string server, string target, string type); |
644 | + |
645 | + [DBus (name = "notice")] |
646 | + public signal void event_notice (int64 time, string server, string from, string target, string message); |
647 | + |
648 | + [DBus (name = "oper")] |
649 | + public signal void event_oper (int64 time, string server); |
650 | + |
651 | + [DBus (name = "part")] |
652 | + public signal void event_part (int64 time, string server, string from, string channel, string message); |
653 | + |
654 | + [DBus (name = "quit")] |
655 | + public signal void event_quit (int64 time, string server, string from, string message); |
656 | + |
657 | + [DBus (name = "shutdown")] |
658 | + public signal void event_shutdown (int64 time); |
659 | + |
660 | + [DBus (name = "topic")] |
661 | + public signal void event_topic (int64 time, string server, string from, string channel, string topic); |
662 | + |
663 | + [DBus (name = "user_away")] |
664 | + public signal void event_user_away (int64 time, string server, string from, bool away); |
665 | + |
666 | + [DBus (name = "whois")] |
667 | + public signal void event_whois (int64 time, string server, string nick, string message); |
668 | +} |
669 | |
670 | === added file 'src/Adapters/Irc/Server.vala' |
671 | --- src/Adapters/Irc/Server.vala 1970-01-01 00:00:00 +0000 |
672 | +++ src/Adapters/Irc/Server.vala 2013-09-29 09:56:16 +0000 |
673 | @@ -0,0 +1,621 @@ |
674 | +/*** |
675 | + Copyright (C) 2013 Cable Developers |
676 | + |
677 | + This program or library is free software; you can redistribute it |
678 | + and/or modify it under the terms of the GNU Lesser General Public |
679 | + License as published by the Free Software Foundation; either |
680 | + version 3 of the License, or (at your option) any later version. |
681 | + |
682 | + This library is distributed in the hope that it will be useful, |
683 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
684 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
685 | + Lesser General Public License for more details. |
686 | + |
687 | + You should have received a copy of the GNU Lesser General |
688 | + Public License along with this library; if not, write to the |
689 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
690 | + Boston, MA 02110-1301 USA. |
691 | +***/ |
692 | + |
693 | +/** |
694 | + * Cable.Irc.ServerConfig is a class that allows you to change the configuration of a server. |
695 | + * This configuration is a normal keyfile. Possible keys are: |
696 | + * |
697 | + * autoconnect (should always be true) |
698 | + * port (default, maki takes care of this) |
699 | + * ssl (-> network) |
700 | + * nick (-> identity) |
701 | + * user (automatic) |
702 | + * name (-> identity) |
703 | + * address (-> network) |
704 | + * nickserv (-> server, I guess...) |
705 | + */ |
706 | +private class Cable.Adapter.Irc.ServerConfig : GLib.Object { |
707 | + |
708 | + // The server's name. Used by maki. |
709 | + public string name { get; set; } |
710 | + |
711 | + public ServerConfig (string name) { |
712 | + Object (name: name); |
713 | + } |
714 | + |
715 | + public new string @get (string key) { |
716 | + string result = ""; |
717 | + |
718 | + try { |
719 | + result = client.server_get (this.name, "server", key); |
720 | + } catch (GLib.IOError error) { |
721 | + warning (error.message); |
722 | + } |
723 | + |
724 | + return result; |
725 | + } |
726 | + |
727 | + public new void @set (string key, string value) { |
728 | + try { |
729 | + client.server_set (this.name, "server", key, value); |
730 | + } catch (GLib.IOError error) { |
731 | + warning (error.message); |
732 | + } |
733 | + } |
734 | + |
735 | + /*public void unset (string key) { |
736 | + try { |
737 | + client.server_remove (this.name, "server", key); |
738 | + } catch (GLib.IOError error) { |
739 | + warning (error.message); |
740 | + } |
741 | + }*/ |
742 | +} |
743 | + |
744 | +public class Cable.Adapter.Irc.Server : GLib.Object, Port.Irc.Server { |
745 | + |
746 | + public static Gee.ArrayList <Server> all { get; private set; } |
747 | + |
748 | + public Utils.Network network { |
749 | + owned get { |
750 | + return Utils.Network.get_or_create (config["address"]); |
751 | + } |
752 | + } |
753 | + |
754 | + public Utils.Identity identity { |
755 | + owned get { |
756 | + return Utils.Identity.get_or_create (config["nick"]); |
757 | + } |
758 | + } |
759 | + |
760 | + public string address { |
761 | + owned get { return config["address"]; } |
762 | + } |
763 | + |
764 | + public string nick { |
765 | + owned get { return config["nick"]; } |
766 | + } |
767 | + |
768 | + private ServerConfig config; |
769 | + |
770 | + public string name { get; set; } |
771 | + |
772 | + public bool away { |
773 | + get { |
774 | + try { |
775 | + return client.user_away (this.name, identity.nick_name); |
776 | + } catch (GLib.IOError error) { |
777 | + warning (error.message); |
778 | + } |
779 | + |
780 | + return false; |
781 | + } |
782 | + } |
783 | + |
784 | + public bool connected { |
785 | + get { |
786 | + try { |
787 | + return this.name in client.servers (); |
788 | + } catch (GLib.IOError error) { |
789 | + warning (error.message); |
790 | + } |
791 | + |
792 | + return false; |
793 | + } |
794 | + } |
795 | + |
796 | + public string[] channel_names { |
797 | + owned get { |
798 | + try { |
799 | + return client.channels (this.name); |
800 | + } catch (GLib.IOError error) { |
801 | + warning (error.message); |
802 | + } |
803 | + |
804 | + return {}; |
805 | + } |
806 | + } |
807 | + |
808 | + public string[] supported_prefixes { |
809 | + owned get { |
810 | + try { |
811 | + return client.support_prefix (this.name); |
812 | + } catch (GLib.IOError error) { |
813 | + warning (error.message); |
814 | + } |
815 | + |
816 | + return {}; |
817 | + } |
818 | + } |
819 | + |
820 | + public string supported_channel_types { |
821 | + owned get { |
822 | + try { |
823 | + return client.support_chantypes (this.name); |
824 | + } catch (GLib.IOError error) { |
825 | + warning (error.message); |
826 | + } |
827 | + |
828 | + return ""; |
829 | + } |
830 | + } |
831 | + |
832 | + public string[] ignores { |
833 | + owned get { |
834 | + try { |
835 | + return client.ignores (this.name); |
836 | + } catch (GLib.IOError error) { |
837 | + warning (error.message); |
838 | + } |
839 | + |
840 | + return {}; |
841 | + } |
842 | + } |
843 | + |
844 | + string[] server_names { |
845 | + owned get { |
846 | + try { |
847 | + return client.servers (); |
848 | + } catch (GLib.IOError e) { |
849 | + warning (e.message); |
850 | + } |
851 | + |
852 | + return {}; |
853 | + } |
854 | + } |
855 | + |
856 | + string[] known_server_names { |
857 | + owned get { |
858 | + try { |
859 | + return client.server_list ("", ""); |
860 | + } catch (GLib.IOError e) { |
861 | + warning (e.message); |
862 | + } |
863 | + |
864 | + return {}; |
865 | + } |
866 | + } |
867 | + |
868 | + /* TODO put in channel as property and use unlimited lines: |
869 | + public string[] log (string target, uint64 lines) throws GLib.IOError { |
870 | + return client.log (this.name, target, lines); |
871 | + }*/ |
872 | + |
873 | + /** |
874 | + * A server is uniquely identified by a combination of a network and an identity. |
875 | + */ |
876 | + public Server (string address, string nick) { |
877 | + debug (@"+ IRC SERVER $address"); |
878 | + setup_signals (); |
879 | + |
880 | + foreach (var server in server_names) { |
881 | + var config = new ServerConfig (server); |
882 | + if (config["nick"] == nick && |
883 | + config["address"] == address && |
884 | + config["client"] == "cable") { |
885 | + name = server; |
886 | + break; |
887 | + } |
888 | + } |
889 | + |
890 | + if (name != null) { |
891 | + debug (@"Already connected to $name."); |
892 | + config = new ServerConfig (name); |
893 | + } else { |
894 | + name = "cable|" + GLib.Random.next_int ().to_string (); |
895 | + |
896 | + debug (@"Creating new server $name."); |
897 | + |
898 | + config = new ServerConfig (name); |
899 | + |
900 | + config["nick"] = nick; |
901 | + config["address"] = address; |
902 | + config["nickserv"] = network.password; |
903 | + config["name"] = identity.real_name; |
904 | + config["autoconnect"] = "true"; |
905 | + config["client"] = "cable"; |
906 | + |
907 | + debug ("Successfully set up server.\n"); |
908 | + } |
909 | + |
910 | + //all.add (this); |
911 | + |
912 | + event_nick.connect_after ((from, new_nick) => { |
913 | + if (is_me (from)) |
914 | + config["nick"] = new_nick; |
915 | + }); |
916 | + } |
917 | + |
918 | + /** |
919 | + * Creates a server from its maki name. |
920 | + */ |
921 | + public Server.from_name (string name) { |
922 | + |
923 | + setup_signals (); |
924 | + |
925 | + this.name = name; |
926 | + |
927 | + config = new ServerConfig (name); |
928 | + |
929 | + debug (@"+ IRC SERVER $address (from_name)"); |
930 | + |
931 | + //all.add (this); |
932 | + |
933 | + event_nick.connect_after ((from, new_nick) => { |
934 | + if (is_me (from)) |
935 | + config["nick"] = new_nick; |
936 | + }); |
937 | + } |
938 | + |
939 | + ~Server () { debug (@"- IRC SERVER $address"); } |
940 | + |
941 | + public Port.Irc.Channel get_or_create_channel (string channel_name) { |
942 | + return new Channel (channel_name, this.name) as Port.Irc.Channel; |
943 | + } |
944 | + |
945 | + /** |
946 | + * Check if a command was issued by me. |
947 | + */ |
948 | + public bool is_me (string from) { |
949 | + var nick = from.split ("!")[0]; |
950 | + return nick == identity.nick_name; |
951 | + } |
952 | + |
953 | + /** |
954 | + * Pass on signals from the backend daemon without the time and server parameters. |
955 | + */ |
956 | + void setup_signals () { |
957 | + client.event_away.connect ((time, server) => { |
958 | + if (server == this.name) |
959 | + event_away (); |
960 | + }); |
961 | + |
962 | + client.event_away_message.connect ((time, server, nick, message) => { |
963 | + if (server == this.name) |
964 | + event_away_message (nick, message); |
965 | + }); |
966 | + |
967 | + client.event_back.connect ((time, server) => { |
968 | + if (server == this.name) |
969 | + event_back (); |
970 | + }); |
971 | + |
972 | + client.event_connected.connect ((time, server) => { |
973 | + if (server == this.name) |
974 | + event_connected (); |
975 | + }); |
976 | + |
977 | + /* client.event_ctcp.connect ((time, server, from, target, message) => { |
978 | + if (server == this.name) |
979 | + event_ctcp (from, target, message); |
980 | + }); |
981 | + |
982 | + client.event_dcc_send.connect ((time, server, id, from, filename, size, progress, speed, status) => { |
983 | + if (server == this.name) |
984 | + event_dcc_send (id, from, filename, size, progress, speed, status); |
985 | + });*/ |
986 | + |
987 | + client.event_error.connect ((time, server, domain, reason, arguments) => { |
988 | + if (server == this.name) |
989 | + event_error (domain, reason, arguments); |
990 | + }); |
991 | + |
992 | + client.event_invite.connect ((time, server, from, channel, who) => { |
993 | + if (server == this.name) |
994 | + event_invite (from, channel, who); |
995 | + }); |
996 | + |
997 | + client.event_list.connect ((time, server, channel, users, topic) => { |
998 | + if (server == this.name) |
999 | + event_list (channel, users, topic); |
1000 | + }); |
1001 | + |
1002 | + client.event_message.connect ((time, server, from, target, message) => { |
1003 | + if (server == this.name) |
1004 | + event_message (from, target, message); |
1005 | + }); |
1006 | + |
1007 | + client.event_mode.connect ((time, server, from, target, mode, parameter) => { |
1008 | + if (server == this.name) |
1009 | + event_mode (from, target, mode, parameter); |
1010 | + }); |
1011 | + |
1012 | + client.event_motd.connect ((time, server, message) => { |
1013 | + if (server == this.name) |
1014 | + event_motd (message); |
1015 | + }); |
1016 | + |
1017 | + client.event_nick.connect ((time, server, from, new_nick) => { |
1018 | + if (server == this.name) |
1019 | + event_nick (from, new_nick); |
1020 | + }); |
1021 | + |
1022 | + client.event_no_such.connect ((time, server, target, type) => { |
1023 | + if (server == this.name) |
1024 | + event_no_such (target, type); |
1025 | + }); |
1026 | + |
1027 | + client.event_notice.connect ((time, server, from, target, message) => { |
1028 | + if (server == this.name) |
1029 | + event_notice (from, target, message); |
1030 | + }); |
1031 | + |
1032 | + client.event_oper.connect ((time, server) => { |
1033 | + if (server == this.name) |
1034 | + event_oper (); |
1035 | + }); |
1036 | + |
1037 | + client.event_quit.connect ((time, server, from, message) => { |
1038 | + if (server == this.name) |
1039 | + event_quit (from, message); |
1040 | + }); |
1041 | + |
1042 | + client.event_user_away.connect ((time, server, from, away) => { |
1043 | + if (server == this.name) |
1044 | + event_user_away (from, away); |
1045 | + }); |
1046 | + |
1047 | + client.event_whois.connect ((time, server, nick, message) => { |
1048 | + if (server == this.name) |
1049 | + event_whois (nick, message); |
1050 | + }); |
1051 | + } |
1052 | + |
1053 | + /** |
1054 | + * Set your status to "away" and leave a message. |
1055 | + * @param message Message displayed to users trying to talk to you. |
1056 | + */ |
1057 | + public void send_away (string? message = null) { |
1058 | + try { |
1059 | + client.away (this.name, message ?? identity.away_message); |
1060 | + } catch (GLib.IOError error) { |
1061 | + warning (error.message); |
1062 | + } |
1063 | + } |
1064 | + |
1065 | + /** |
1066 | + * Unsets "away" status. |
1067 | + */ |
1068 | + public void send_back () { |
1069 | + try { |
1070 | + client.back (this.name); |
1071 | + } catch (GLib.IOError error) { |
1072 | + warning (error.message); |
1073 | + } |
1074 | + } |
1075 | + |
1076 | + /** |
1077 | + * Connect to this server. |
1078 | + */ |
1079 | + public new void send_connect () { |
1080 | + try { |
1081 | + client.connect (this.name); |
1082 | + } catch (GLib.IOError error) { |
1083 | + warning (error.message); |
1084 | + } |
1085 | + } |
1086 | + |
1087 | + /*public void ctcp (string target, string message) throws GLib.IOError { |
1088 | + client.ctcp (this.name, target, message); |
1089 | + } |
1090 | + |
1091 | + public void dcc_send (string target, string path) throws GLib.IOError { |
1092 | + client.action (this.name, target, path); |
1093 | + } |
1094 | + |
1095 | + public void dcc_sends (out uint64[] ids, out string[] servers, out string[] froms, out string[] filenames, out uint64[] sizes, out uint64[] progresses, out uint64[] speeds, out uint64[] statuses) throws GLib.IOError { |
1096 | + client.action (this.name, channel, message); |
1097 | + } |
1098 | + |
1099 | + public void dcc_send_accept (uint64 id) throws GLib.IOError { |
1100 | + client.action (this.name, channel, message); |
1101 | + } |
1102 | + |
1103 | + public string dcc_send_get (uint64 id, string key) throws GLib.IOError { |
1104 | + client.action (this.name, channel, message); |
1105 | + } |
1106 | + |
1107 | + public void dcc_send_remove (uint64 id) throws GLib.IOError { |
1108 | + client.action (this.name, channel, message); |
1109 | + } |
1110 | + |
1111 | + public void dcc_send_resume (uint64 id) throws GLib.IOError { |
1112 | + client.action (this.name, channel, message); |
1113 | + } |
1114 | + |
1115 | + public void dcc_send_set (uint64 id, string key, string value) throws GLib.IOError { |
1116 | + client.action (this.name, channel, message); |
1117 | + }*/ |
1118 | + |
1119 | + /** |
1120 | + * Ignore messages from users who fit the given pattern. |
1121 | + * @param pattern The pattern to use. |
1122 | + */ |
1123 | + public void send_ignore (string pattern) { |
1124 | + try { |
1125 | + client.ignore (this.name, pattern); |
1126 | + } catch (GLib.IOError error) { |
1127 | + warning (error.message); |
1128 | + } |
1129 | + } |
1130 | + |
1131 | + /** |
1132 | + * Send a message to a givent target. |
1133 | + * @param target can be a channel or a user. |
1134 | + * @param message Message you want to send. |
1135 | + */ |
1136 | + public void send_message (string target, string message) { |
1137 | + try { |
1138 | + client.message (this.name, target, message); |
1139 | + } catch (GLib.IOError error) { |
1140 | + warning (error.message); |
1141 | + } |
1142 | + } |
1143 | + |
1144 | + public void send_mode (string target, string mode) { |
1145 | + try { |
1146 | + client.mode (this.name, target, mode); |
1147 | + } catch (GLib.IOError error) { |
1148 | + warning (error.message); |
1149 | + } |
1150 | + } |
1151 | + |
1152 | + /** |
1153 | + * Send a NICK request to change your current nick on this network. |
1154 | + * @param nick Your new nick name. |
1155 | + */ |
1156 | + public void send_nick (string nick) { |
1157 | + try { |
1158 | + client.nick (this.name, nick); |
1159 | + } catch (GLib.IOError error) { |
1160 | + warning (error.message); |
1161 | + } |
1162 | + } |
1163 | + |
1164 | + /** |
1165 | + * Identify with nickserv. |
1166 | + */ |
1167 | + public void send_nickserv () { |
1168 | + try { |
1169 | + client.nickserv (this.name); |
1170 | + } catch (GLib.IOError error) { |
1171 | + warning (error.message); |
1172 | + } |
1173 | + } |
1174 | + |
1175 | + /** |
1176 | + * Send a NOTICE. |
1177 | + * @param target Can be a TODO ?? |
1178 | + * @param message The message you want to send. |
1179 | + */ |
1180 | + public void send_notice (string target, string message) { |
1181 | + try { |
1182 | + client.notice (this.name, target, message); |
1183 | + } catch (GLib.IOError error) { |
1184 | + warning (error.message); |
1185 | + } |
1186 | + } |
1187 | + |
1188 | + /** |
1189 | + * Send OPER request. |
1190 | + * @param name TODO |
1191 | + * @param password OP password. |
1192 | + */ |
1193 | + public void send_oper (string name, string password) { |
1194 | + try { |
1195 | + client.oper (this.name, name, password); |
1196 | + } catch (GLib.IOError error) { |
1197 | + warning (error.message); |
1198 | + } |
1199 | + } |
1200 | + |
1201 | + public void send_part (string channel, string? message = null) { |
1202 | + try { |
1203 | + client.part (this.name, channel, message ?? identity.part_message); |
1204 | + } catch (GLib.IOError error) { |
1205 | + warning (error.message); |
1206 | + } |
1207 | + } |
1208 | + |
1209 | + /** |
1210 | + * Disconnect from the server and all channels. |
1211 | + * @param message Message displayed to other users. |
1212 | + */ |
1213 | + public void send_quit (string? message = null) { |
1214 | + try { |
1215 | + client.quit (this.name, message ?? identity.quit_message); |
1216 | + } catch (GLib.IOError error) { |
1217 | + warning (error.message); |
1218 | + } |
1219 | + } |
1220 | + |
1221 | + /** |
1222 | + * Send a raw IRC command. |
1223 | + * @param command The raw command you want to send. |
1224 | + */ |
1225 | + public void send_raw (string command) { |
1226 | + try { |
1227 | + client.raw (this.name, command); |
1228 | + } catch (GLib.IOError error) { |
1229 | + warning (error.message); |
1230 | + } |
1231 | + } |
1232 | + |
1233 | + /** |
1234 | + * Remove a certain pattern from the ignored list. |
1235 | + * @param pattern The pattern. |
1236 | + */ |
1237 | + public void send_unignore (string pattern) { |
1238 | + try { |
1239 | + client.unignore (this.name, pattern); |
1240 | + } catch (GLib.IOError error) { |
1241 | + warning (error.message); |
1242 | + } |
1243 | + } |
1244 | + |
1245 | + /** |
1246 | + * TODO |
1247 | + */ |
1248 | + public void send_who (string mask, bool operators_only) { |
1249 | + try { |
1250 | + client.who (this.name, mask, operators_only); |
1251 | + } catch (GLib.IOError error) { |
1252 | + warning (error.message); |
1253 | + } |
1254 | + } |
1255 | + |
1256 | + /** |
1257 | + * TODO |
1258 | + */ |
1259 | + public void send_whois (string mask) { |
1260 | + try { |
1261 | + client.whois (this.name, mask); |
1262 | + } catch (GLib.IOError error) { |
1263 | + warning (error.message); |
1264 | + } |
1265 | + } |
1266 | + |
1267 | + /*public string server_get (string group, string key) throws GLib.IOError { |
1268 | + return client.server_get (this.name, group, key); |
1269 | + } |
1270 | + |
1271 | + public string[] server_get_list (string group, string key) throws GLib.IOError { |
1272 | + return client.server_get_list (this.name, group, key); |
1273 | + } |
1274 | + |
1275 | + public string[] server_list (string group) throws GLib.IOError { |
1276 | + return client.server_list (this.name, group); |
1277 | + } |
1278 | + |
1279 | + public void server_remove (string group, string key) throws GLib.IOError { |
1280 | + client.server_remove (this.name, group, key); |
1281 | + } |
1282 | + |
1283 | + public void server_rename (string new_name) throws GLib.IOError { |
1284 | + client.server_rename (this.name, new_name); |
1285 | + } |
1286 | + |
1287 | + public void server_set (string group, string key, string value) throws GLib.IOError { |
1288 | + client.server_set (this.name, group, key, value); |
1289 | + } |
1290 | + |
1291 | + public void server_set_list (string group, string key, string[] list) throws GLib.IOError { |
1292 | + client.server_set_list (this.name, group, key, list); |
1293 | + }*/ |
1294 | +} |
1295 | |
1296 | === added file 'src/Adapters/Irc/Session.vala' |
1297 | --- src/Adapters/Irc/Session.vala 1970-01-01 00:00:00 +0000 |
1298 | +++ src/Adapters/Irc/Session.vala 2013-09-29 09:56:16 +0000 |
1299 | @@ -0,0 +1,77 @@ |
1300 | +namespace Cable.Adapter.Irc { |
1301 | + Maki client; |
1302 | +} |
1303 | + |
1304 | +class Cable.Adapter.Irc.Session : Object, Port.Irc.Session { |
1305 | + |
1306 | + Gee.List <Server> servers; |
1307 | + |
1308 | + string[] server_names { |
1309 | + owned get { |
1310 | + try { |
1311 | + return client.servers (); |
1312 | + } catch (GLib.IOError e) { |
1313 | + warning (e.message); |
1314 | + } |
1315 | + |
1316 | + return {}; |
1317 | + } |
1318 | + } |
1319 | + |
1320 | + string[] known_server_names { |
1321 | + owned get { |
1322 | + try { |
1323 | + return client.server_list ("", ""); |
1324 | + } catch (GLib.IOError e) { |
1325 | + warning (e.message); |
1326 | + } |
1327 | + |
1328 | + return {}; |
1329 | + } |
1330 | + } |
1331 | + |
1332 | + public Session () { |
1333 | + init (); |
1334 | + } |
1335 | + |
1336 | + public void init () { |
1337 | + if (client == null) { |
1338 | + try { |
1339 | + client = Bus.get_proxy_sync (GLib.BusType.SESSION, "de.ikkoku.sushi", "/de/ikkoku/sushi"); |
1340 | + } catch (GLib.IOError error) { |
1341 | + warning (error.message); |
1342 | + } |
1343 | + |
1344 | + debug ("Successfully connected to Sushi dbus session.\n"); |
1345 | + } |
1346 | + |
1347 | + servers = new Gee.ArrayList <Server> (); |
1348 | + |
1349 | + // TODO do something more intelligent here |
1350 | + foreach (var server_name in known_server_names) { |
1351 | + var server = new Server.from_name (server_name); |
1352 | + foreach (var channel in server.channel_names) |
1353 | + server.send_part (channel); |
1354 | + servers.add (server); |
1355 | + } |
1356 | + |
1357 | + } |
1358 | + |
1359 | + public Port.Irc.Server get_or_create_server (string address, string nick) { |
1360 | + return (get_server (address, nick) ?? |
1361 | + create_server (address, nick)) as Port.Irc.Server; |
1362 | + } |
1363 | + |
1364 | + Server? get_server (string address, string nick) { |
1365 | + foreach (var server in servers) |
1366 | + if (server.address == address && server.nick == nick) |
1367 | + return server as Server; |
1368 | + return (Server) null; |
1369 | + } |
1370 | + |
1371 | + Server create_server (string address, string nick) { |
1372 | + var server = new Server (address, nick); |
1373 | + servers.add (server); |
1374 | + return server; |
1375 | + } |
1376 | +} |
1377 | |
1378 | === added directory 'src/Adapters/Services' |
1379 | === added file 'src/Adapters/Services/Launcher.vala' |
1380 | --- src/Adapters/Services/Launcher.vala 1970-01-01 00:00:00 +0000 |
1381 | +++ src/Adapters/Services/Launcher.vala 2013-09-29 09:56:16 +0000 |
1382 | @@ -0,0 +1,66 @@ |
1383 | +/*** |
1384 | + Copyright (C) 2013 Cable Developers |
1385 | + |
1386 | + This program or library is free software; you can redistribute it |
1387 | + and/or modify it under the terms of the GNU Lesser General Public |
1388 | + License as published by the Free Software Foundation; either |
1389 | + version 3 of the License, or (at your option) any later version. |
1390 | + |
1391 | + This library is distributed in the hope that it will be useful, |
1392 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
1393 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1394 | + Lesser General Public License for more details. |
1395 | + |
1396 | + You should have received a copy of the GNU Lesser General |
1397 | + Public License along with this library; if not, write to the |
1398 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1399 | + Boston, MA 02110-1301 USA. |
1400 | +***/ |
1401 | + |
1402 | +/** |
1403 | + * Static class for managing the launcher using libunity. |
1404 | + */ |
1405 | +public class Cable.Services.Launcher { |
1406 | + |
1407 | + static Unity.LauncherEntry launcher_entry; |
1408 | + |
1409 | + /** |
1410 | + * Number shown in the badge on the launcher. |
1411 | + * If the value is zero, the badge will be hidden automatically. |
1412 | + */ |
1413 | + public static int64 jobs { |
1414 | + get { return launcher_entry.count; } |
1415 | + set { |
1416 | + assert (value >= 0); |
1417 | + launcher_entry.count = value; |
1418 | + launcher_entry.count_visible = value > 0; |
1419 | + } |
1420 | + } |
1421 | + |
1422 | + /** |
1423 | + * Progress shown on the launcher. Will be hidden when complete. |
1424 | + */ |
1425 | + public static double progress { |
1426 | + get { return launcher_entry.progress; } |
1427 | + set { |
1428 | + assert (0.0 <= value <= 1.0); |
1429 | + launcher_entry.progress = value; |
1430 | + launcher_entry.progress_visible = value < 1.0; |
1431 | + } |
1432 | + } |
1433 | + |
1434 | + /** |
1435 | + * Set launcher to urgent. |
1436 | + */ |
1437 | + public static bool urgent { |
1438 | + get { return launcher_entry.urgent; } |
1439 | + set { launcher_entry.urgent = value; } |
1440 | + } |
1441 | + |
1442 | + /** |
1443 | + * Must be called before anything else. |
1444 | + */ |
1445 | + public static void init () { |
1446 | + launcher_entry = Unity.LauncherEntry.get_for_desktop_id ("cable.desktop"); |
1447 | + } |
1448 | +} |
1449 | |
1450 | === added file 'src/Adapters/Services/Logger.vala' |
1451 | --- src/Adapters/Services/Logger.vala 1970-01-01 00:00:00 +0000 |
1452 | +++ src/Adapters/Services/Logger.vala 2013-09-29 09:56:16 +0000 |
1453 | @@ -0,0 +1,7 @@ |
1454 | +class Cable.Services.Logger { |
1455 | + |
1456 | + public static void init () { |
1457 | + Granite.Services.Logger.initialize ("Cable"); |
1458 | + Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG; |
1459 | + } |
1460 | +} |
1461 | \ No newline at end of file |
1462 | |
1463 | === added file 'src/Adapters/Services/Notify.vala' |
1464 | --- src/Adapters/Services/Notify.vala 1970-01-01 00:00:00 +0000 |
1465 | +++ src/Adapters/Services/Notify.vala 2013-09-29 09:56:16 +0000 |
1466 | @@ -0,0 +1,42 @@ |
1467 | +/*** |
1468 | + Copyright (C) 2013 Cable Developers |
1469 | + |
1470 | + This program or library is free software; you can redistribute it |
1471 | + and/or modify it under the terms of the GNU Lesser General Public |
1472 | + License as published by the Free Software Foundation; either |
1473 | + version 3 of the License, or (at your option) any later version. |
1474 | + |
1475 | + This library is distributed in the hope that it will be useful, |
1476 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
1477 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1478 | + Lesser General Public License for more details. |
1479 | + |
1480 | + You should have received a copy of the GNU Lesser General |
1481 | + Public License along with this library; if not, write to the |
1482 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1483 | + Boston, MA 02110-1301 USA. |
1484 | +***/ |
1485 | + |
1486 | +/** |
1487 | + * Static class to deal with notifications. |
1488 | + */ |
1489 | +public class Cable.Services.Notify : GLib.Object { |
1490 | + |
1491 | + public static void init () { |
1492 | + if (global::Notify.is_initted ()) { |
1493 | + warning ("Trying to reinitialize Notify."); |
1494 | + return; |
1495 | + } |
1496 | + |
1497 | + global::Notify.init ("Cable"); |
1498 | + } |
1499 | + |
1500 | + public static void send (string summary, string body) { |
1501 | + var notify = new global::Notify.Notification (summary, body, "internet-chat"); |
1502 | + try { |
1503 | + notify.show (); |
1504 | + } catch (Error e) { |
1505 | + warning (e.message); |
1506 | + } |
1507 | + } |
1508 | +} |
1509 | |
1510 | === added directory 'src/Adapters/Settings' |
1511 | === added file 'src/Adapters/Settings/Preferences.vala' |
1512 | --- src/Adapters/Settings/Preferences.vala 1970-01-01 00:00:00 +0000 |
1513 | +++ src/Adapters/Settings/Preferences.vala 2013-09-29 09:56:16 +0000 |
1514 | @@ -0,0 +1,58 @@ |
1515 | +/*** |
1516 | + Copyright (C) 2013 Cable Developers |
1517 | + |
1518 | + This program or library is free software; you can redistribute it |
1519 | + and/or modify it under the terms of the GNU Lesser General Public |
1520 | + License as published by the Free Software Foundation; either |
1521 | + version 3 of the License, or (at your option) any later version. |
1522 | + |
1523 | + This library is distributed in the hope that it will be useful, |
1524 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
1525 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1526 | + Lesser General Public License for more details. |
1527 | + |
1528 | + You should have received a copy of the GNU Lesser General |
1529 | + Public License along with this library; if not, write to the |
1530 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1531 | + Boston, MA 02110-1301 USA. |
1532 | +***/ |
1533 | + |
1534 | +public class Cable.Settings.Preferences : Granite.Services.Settings { |
1535 | + |
1536 | + public string[] networks { get; set; } |
1537 | + public string[] identities { get; set; } |
1538 | + public string[] channels { get; set; } |
1539 | + public string last_used_nick { get; set; } |
1540 | + |
1541 | + public Preferences () { |
1542 | + base ("org.pantheon.cable"); |
1543 | + } |
1544 | + /*public override void verify (string key) { |
1545 | + switch (key) { |
1546 | + |
1547 | + case "networks": |
1548 | + string[] new_value = {}; |
1549 | + |
1550 | + foreach (var network in networks) |
1551 | + if (network.split (":").length == 3) |
1552 | + new_value += network; |
1553 | + |
1554 | + if (networks != new_value) |
1555 | + networks = new_value; |
1556 | + |
1557 | + break; |
1558 | + |
1559 | + case "identities": |
1560 | + string[] new_value = {}; |
1561 | + |
1562 | + foreach (var identity in identities) |
1563 | + if (identity.split (":").length == 3) |
1564 | + new_value += identity; |
1565 | + |
1566 | + if (identities != new_value) |
1567 | + identities = new_value; |
1568 | + |
1569 | + break; |
1570 | + } |
1571 | + }*/ |
1572 | +} |
1573 | |
1574 | === added file 'src/Adapters/Settings/SavedState.vala' |
1575 | --- src/Adapters/Settings/SavedState.vala 1970-01-01 00:00:00 +0000 |
1576 | +++ src/Adapters/Settings/SavedState.vala 2013-09-29 09:56:16 +0000 |
1577 | @@ -0,0 +1,36 @@ |
1578 | +/*** |
1579 | + Copyright (C) 2013 Cable Developers |
1580 | + |
1581 | + This program or library is free software; you can redistribute it |
1582 | + and/or modify it under the terms of the GNU Lesser General Public |
1583 | + License as published by the Free Software Foundation; either |
1584 | + version 3 of the License, or (at your option) any later version. |
1585 | + |
1586 | + This library is distributed in the hope that it will be useful, |
1587 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
1588 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1589 | + Lesser General Public License for more details. |
1590 | + |
1591 | + You should have received a copy of the GNU Lesser General |
1592 | + Public License along with this library; if not, write to the |
1593 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1594 | + Boston, MA 02110-1301 USA. |
1595 | +***/ |
1596 | + |
1597 | +public class Cable.Settings.SavedState : Granite.Services.Settings { |
1598 | + |
1599 | + public int window_width { get; set; } |
1600 | + public int window_height { get; set; } |
1601 | + public WindowState window_state { get; set; } |
1602 | + |
1603 | + public int column_server_width { get; set; } |
1604 | + |
1605 | + public SavedState () { |
1606 | + base ("org.pantheon.cable.saved-state"); |
1607 | + } |
1608 | + |
1609 | + public enum WindowState { |
1610 | + NORMAL, |
1611 | + MAXIMIZED |
1612 | + } |
1613 | +} |
1614 | |
1615 | === added file 'src/Adapters/Settings/Settings.vala' |
1616 | --- src/Adapters/Settings/Settings.vala 1970-01-01 00:00:00 +0000 |
1617 | +++ src/Adapters/Settings/Settings.vala 2013-09-29 09:56:16 +0000 |
1618 | @@ -0,0 +1,35 @@ |
1619 | +/*** |
1620 | + Copyright (C) 2013 Cable Developers |
1621 | + |
1622 | + This program or library is free software; you can redistribute it |
1623 | + and/or modify it under the terms of the GNU Lesser General Public |
1624 | + License as published by the Free Software Foundation; either |
1625 | + version 3 of the License, or (at your option) any later version. |
1626 | + |
1627 | + This library is distributed in the hope that it will be useful, |
1628 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
1629 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1630 | + Lesser General Public License for more details. |
1631 | + |
1632 | + You should have received a copy of the GNU Lesser General |
1633 | + Public License along with this library; if not, write to the |
1634 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1635 | + Boston, MA 02110-1301 USA. |
1636 | +***/ |
1637 | + |
1638 | +/** |
1639 | + * Namespace for accessing the app's gsettings. May be used by any part of the app. |
1640 | + */ |
1641 | +namespace Cable.Settings { |
1642 | + |
1643 | + public static Settings.Preferences preferences; |
1644 | + public static Settings.SavedState saved_state; |
1645 | + |
1646 | + /** |
1647 | + * Load values from gsettings. |
1648 | + */ |
1649 | + public static void init () { |
1650 | + preferences = new Settings.Preferences (); |
1651 | + saved_state = new Settings.SavedState (); |
1652 | + } |
1653 | +} |
1654 | |
1655 | === added directory 'src/Adapters/Widgets' |
1656 | === added file 'src/Adapters/Widgets/Channel.vala' |
1657 | --- src/Adapters/Widgets/Channel.vala 1970-01-01 00:00:00 +0000 |
1658 | +++ src/Adapters/Widgets/Channel.vala 2013-09-29 09:56:16 +0000 |
1659 | @@ -0,0 +1,131 @@ |
1660 | +/*** |
1661 | + Copyright (C) 2013 Cable Developers |
1662 | + |
1663 | + This program or library is free software; you can redistribute it |
1664 | + and/or modify it under the terms of the GNU Lesser General Public |
1665 | + License as published by the Free Software Foundation; either |
1666 | + version 3 of the License, or (at your option) any later version. |
1667 | + |
1668 | + This library is distributed in the hope that it will be useful, |
1669 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
1670 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1671 | + Lesser General Public License for more details. |
1672 | + |
1673 | + You should have received a copy of the GNU Lesser General |
1674 | + Public License along with this library; if not, write to the |
1675 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1676 | + Boston, MA 02110-1301 USA. |
1677 | +***/ |
1678 | + |
1679 | +namespace Cable.Adapter.Widgets { |
1680 | + |
1681 | + public class Chat : Granite.Widgets.SourceList.Item { |
1682 | + |
1683 | + public Room room; |
1684 | + |
1685 | + public string nick { get; set; } |
1686 | + public string id { get; set; } |
1687 | + public string entry { get; set; } |
1688 | + |
1689 | + public int unread_messages { |
1690 | + get { return int.parse (badge); } |
1691 | + set { badge = (value <= 0) ? "" : value.to_string (); } |
1692 | + } |
1693 | + |
1694 | + public bool has_focus { |
1695 | + get { return room.text_entry.has_focus; } |
1696 | + } |
1697 | + |
1698 | + public void rename_user (string? old_name, string new_name, UserType type, bool silent = false) { |
1699 | + room.rename_user (old_name, new_name, type, silent); |
1700 | + } |
1701 | + |
1702 | + public void set_away_status (string nick, bool away) { |
1703 | + room.chat.message_away (nick, away); |
1704 | + } |
1705 | + |
1706 | + public void message (owned string from, string message, MessageType type = MessageType.NORMAL) { |
1707 | + room.chat.add_message (from, message, type); |
1708 | + } |
1709 | + } |
1710 | + |
1711 | + public class PrivateChat : Widgets.Chat, Port.View.Chat, Port.View.PrivateChat { |
1712 | + |
1713 | + public PrivateChat (string name, string id) { |
1714 | + GLib.Object (name: name, id: id); |
1715 | + this.room = new Room (name); |
1716 | + |
1717 | + room.send_message.connect ((msg) => send_message (msg)); |
1718 | + room.text_entry.grab_focus.connect (() => { focused (); }); |
1719 | + |
1720 | + // bind properties |
1721 | + bind_property ("nick", room, "nick", GLib.BindingFlags.BIDIRECTIONAL); |
1722 | + bind_property ("name", room, "name", GLib.BindingFlags.BIDIRECTIONAL); |
1723 | + bind_property ("entry", room, "entry", GLib.BindingFlags.BIDIRECTIONAL); |
1724 | + } |
1725 | + } |
1726 | + |
1727 | + public class Channel : Widgets.Chat, Port.View.Chat, Port.View.Channel { |
1728 | + |
1729 | + Gtk.Menu menu; |
1730 | + Gtk.MenuItem leave_menu_item; |
1731 | + |
1732 | + public State state { get; set; } |
1733 | + public string topic { get; set; } |
1734 | + |
1735 | + public Channel (string name, string id) { |
1736 | + GLib.Object (name: name, id: id); |
1737 | + this.room = new Room (name); |
1738 | + |
1739 | + this.menu = new Gtk.Menu (); |
1740 | + this.leave_menu_item = new Gtk.MenuItem.with_label (_("Leave Channel")); |
1741 | + menu.append (leave_menu_item); |
1742 | + menu.show_all (); |
1743 | + |
1744 | + // setup signals |
1745 | + leave_menu_item.activate.connect (() |
1746 | + => part ()); |
1747 | + |
1748 | + room.send_message.connect ((msg) |
1749 | + => send_message (msg)); |
1750 | + |
1751 | + room.rejoin.connect (() |
1752 | + => join ()); |
1753 | + |
1754 | + room.text_entry.grab_focus.connect (() |
1755 | + => { focused (); }); |
1756 | + |
1757 | + room.user_list.private_chat_requested.connect ((name) |
1758 | + => private_chat_requested (name)); |
1759 | + |
1760 | + // bind properties |
1761 | + bind_property ("state", room, "state", GLib.BindingFlags.BIDIRECTIONAL); |
1762 | + bind_property ("nick", room, "nick", GLib.BindingFlags.BIDIRECTIONAL); |
1763 | + bind_property ("name", room, "name", GLib.BindingFlags.BIDIRECTIONAL); |
1764 | + bind_property ("topic", room.topic_bar, "topic", GLib.BindingFlags.BIDIRECTIONAL); |
1765 | + bind_property ("entry", room, "entry", GLib.BindingFlags.BIDIRECTIONAL); |
1766 | + } |
1767 | + |
1768 | + public override Gtk.Menu? get_context_menu () { |
1769 | + if (menu != null && menu.get_attach_widget () != null) |
1770 | + menu.detach (); |
1771 | + return menu; |
1772 | + } |
1773 | + |
1774 | + public bool has_user (string nick) { |
1775 | + return room.has_user (nick); |
1776 | + } |
1777 | + |
1778 | + public void list_users (string[] nicks, string[] prefixes) { |
1779 | + room.list_users (nicks, prefixes); |
1780 | + } |
1781 | + |
1782 | + public void add_user (string name, UserType type, bool silent = false) { |
1783 | + room.add_user (name, type, silent); |
1784 | + } |
1785 | + |
1786 | + public void remove_user (string name, string message, bool silent = false) { |
1787 | + room.remove_user (name, message, silent); |
1788 | + } |
1789 | + } |
1790 | +} |
1791 | \ No newline at end of file |
1792 | |
1793 | === added file 'src/Adapters/Widgets/ChatDisplay.vala' |
1794 | --- src/Adapters/Widgets/ChatDisplay.vala 1970-01-01 00:00:00 +0000 |
1795 | +++ src/Adapters/Widgets/ChatDisplay.vala 2013-09-29 09:56:16 +0000 |
1796 | @@ -0,0 +1,153 @@ |
1797 | +/*** |
1798 | + Copyright (C) 2013 Cable Developers |
1799 | + |
1800 | + This program or library is free software; you can redistribute it |
1801 | + and/or modify it under the terms of the GNU Lesser General Public |
1802 | + License as published by the Free Software Foundation; either |
1803 | + version 3 of the License, or (at your option) any later version. |
1804 | + |
1805 | + This library is distributed in the hope that it will be useful, |
1806 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
1807 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1808 | + Lesser General Public License for more details. |
1809 | + |
1810 | + You should have received a copy of the GNU Lesser General |
1811 | + Public License along with this library; if not, write to the |
1812 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1813 | + Boston, MA 02110-1301 USA. |
1814 | +***/ |
1815 | + |
1816 | +public enum Cable.MessageType { |
1817 | + NORMAL, |
1818 | + ENTER, |
1819 | + LEAVE, |
1820 | + SUGGESTION, |
1821 | + NICK, |
1822 | + AWAY, |
1823 | + PING, |
1824 | + ACTION; |
1825 | + /* QUIT, KICK, BAN, MODE(?), ACTION |
1826 | + */ |
1827 | + |
1828 | + public string color () { |
1829 | + switch (this) { |
1830 | + case NORMAL: |
1831 | + case ACTION: |
1832 | + return "#333"; |
1833 | + case ENTER: |
1834 | + return "#9a9"; |
1835 | + case LEAVE: |
1836 | + return "#a99"; |
1837 | + case SUGGESTION: |
1838 | + case NICK: |
1839 | + case AWAY: |
1840 | + return "#999"; |
1841 | + case PING: |
1842 | + return "#da4d45"; |
1843 | + } |
1844 | + |
1845 | + return ""; |
1846 | + } |
1847 | +} |
1848 | + |
1849 | +public class Cable.Adapter.Widgets.ChatDisplay : Gtk.EventBox { |
1850 | + |
1851 | + private Gtk.Grid main_grid; |
1852 | + private int line = 0; |
1853 | + |
1854 | + public ChatDisplay () { |
1855 | + this.get_style_context ().add_class (Granite.StyleClass.CONTENT_VIEW); |
1856 | + main_grid = new Gtk.Grid (); |
1857 | + main_grid.margin = 12; |
1858 | + main_grid.margin_bottom = 0; |
1859 | + main_grid.column_spacing = 12; |
1860 | + main_grid.row_spacing = 6; |
1861 | + main_grid.expand = true; |
1862 | + expand = true; |
1863 | + this.add (main_grid); |
1864 | + } |
1865 | + |
1866 | + public void add_message (string _user, string _message, MessageType type = MessageType.NORMAL) { |
1867 | + var message = Utils.parse_string_to_markup (_message); |
1868 | + var message_color = type.color (); |
1869 | + var nick_color = get_color_for_nick (_user); |
1870 | + var time = new DateTime.now_local (); |
1871 | + var stamp = time.format ("%T"); |
1872 | + |
1873 | + message = @"<span color='$message_color'>$message</span>"; |
1874 | + var user = @"<span color='$nick_color'>$_user</span>"; |
1875 | + |
1876 | + var user_label = new Gtk.Label (""); |
1877 | + user_label.set_markup (user); |
1878 | + user_label.set_alignment (1, 0); |
1879 | + user_label.width_request = 80; |
1880 | + user_label.ellipsize = Pango.EllipsizeMode.END; |
1881 | + |
1882 | + var message_label = new Granite.Widgets.WrapLabel (""); |
1883 | + message_label.hexpand = true; |
1884 | + message_label.use_markup = true; |
1885 | + message_label.selectable = true; |
1886 | + message_label.set_markup (message); |
1887 | + message_label.wrap_mode = Pango.WrapMode.WORD; |
1888 | + message_label.wrap = true; |
1889 | + |
1890 | + var time_label = new Gtk.Label (""); |
1891 | + time_label.set_markup (@"<span color='#bbb'>$stamp</span>"); |
1892 | + time_label.set_alignment (1, 0); |
1893 | + |
1894 | + main_grid.attach (user_label, 0, line, 1, 1); |
1895 | + main_grid.attach (message_label, 1, line, 1, 1); |
1896 | + main_grid.attach (time_label, 2, line, 1, 1); |
1897 | + |
1898 | + this.show_all (); |
1899 | + |
1900 | + line++; |
1901 | + } |
1902 | + |
1903 | + public void message_part (string nick, string message) { |
1904 | + add_message ("", @"← $nick: $message", MessageType.LEAVE); |
1905 | + } |
1906 | + |
1907 | + public void message_join (string nick) { |
1908 | + add_message ("", @"→ $nick", MessageType.ENTER); |
1909 | + } |
1910 | + |
1911 | + public void message_nick (string old_nick, string new_nick) { |
1912 | + add_message ("", @"$old_nick → $new_nick", MessageType.NICK); |
1913 | + } |
1914 | + |
1915 | + public void message_suggestions (string[] suggestions) { |
1916 | + add_message ("", string.joinv (" - ", suggestions), MessageType.SUGGESTION); |
1917 | + } |
1918 | + |
1919 | + public void message_away (string nick, bool away) { |
1920 | + add_message ("", nick + " " + _("is") + " " + (away ? _("away") : _("back")), MessageType.AWAY); |
1921 | + } |
1922 | + |
1923 | + Gee.HashMap <string, string> color_map = null; |
1924 | + int i = 0; |
1925 | + |
1926 | + string get_color_for_nick (string nick) { |
1927 | + if (color_map == null) |
1928 | + color_map = new Gee.HashMap <string, string> (); |
1929 | + |
1930 | + if (nick == "") |
1931 | + return "#000"; |
1932 | + |
1933 | + string[] colors = { |
1934 | + "#990055", |
1935 | + "#669900", |
1936 | + "#ec6f00", |
1937 | + "#0077aa", |
1938 | + "#dd1144", |
1939 | + "#00a0b3", |
1940 | + "#8f0a0a" |
1941 | + }; |
1942 | + |
1943 | + if (!color_map.has_key (nick)) { |
1944 | + color_map[nick] = colors[i++ % colors.length]; |
1945 | + } |
1946 | + |
1947 | + return color_map[nick]; |
1948 | + } |
1949 | +} |
1950 | |
1951 | === added file 'src/Adapters/Widgets/Room.vala' |
1952 | --- src/Adapters/Widgets/Room.vala 1970-01-01 00:00:00 +0000 |
1953 | +++ src/Adapters/Widgets/Room.vala 2013-09-29 09:56:16 +0000 |
1954 | @@ -0,0 +1,283 @@ |
1955 | +/*** |
1956 | + Copyright (C) 2013 Cable Developers |
1957 | + |
1958 | + This program or library is free software; you can redistribute it |
1959 | + and/or modify it under the terms of the GNU Lesser General Public |
1960 | + License as published by the Free Software Foundation; either |
1961 | + version 3 of the License, or (at your option) any later version. |
1962 | + |
1963 | + This library is distributed in the hope that it will be useful, |
1964 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
1965 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1966 | + Lesser General Public License for more details. |
1967 | + |
1968 | + You should have received a copy of the GNU Lesser General |
1969 | + Public License along with this library; if not, write to the |
1970 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1971 | + Boston, MA 02110-1301 USA. |
1972 | +***/ |
1973 | + |
1974 | +public enum Cable.UserType { |
1975 | + OPERATOR, |
1976 | + VOICED, |
1977 | + REGULAR |
1978 | +} |
1979 | + |
1980 | +public enum Cable.State { |
1981 | + CHAT, |
1982 | + JOINING, |
1983 | + NOT_JOINED, |
1984 | + NO_SUCH; |
1985 | +} |
1986 | + |
1987 | +/** |
1988 | + * This class represents a chat room, i.e, the topic, the message display, |
1989 | + * a list of users and is associated to a channel. |
1990 | + * This class is always accessed through its related channel. |
1991 | + */ |
1992 | +public class Cable.Adapter.Widgets.Room : Gtk.Grid { |
1993 | + |
1994 | + public UserList user_list; |
1995 | + public ChatDisplay chat; |
1996 | + public Gtk.Entry text_entry; |
1997 | + public Widgets.Topic topic_bar; |
1998 | + public Gtk.Label pseudo_label; |
1999 | + |
2000 | + Granite.Widgets.EmbeddedAlert not_joined_alert; |
2001 | + Granite.Widgets.EmbeddedAlert no_such_alert; |
2002 | + Granite.Widgets.EmbeddedAlert loading_screen; |
2003 | + Granite.Widgets.ThinPaned paned; |
2004 | + |
2005 | + Utils.AutoScrolled left_scrolled; |
2006 | + |
2007 | + Gtk.Action action_join; |
2008 | + |
2009 | + public signal void send_message (string message); |
2010 | + // public signal void request_complete (); |
2011 | + public signal void rejoin (); |
2012 | + |
2013 | + public string channel { get; set; } |
2014 | + |
2015 | + public string nick { |
2016 | + get { return pseudo_label.label; } |
2017 | + set { pseudo_label.label = value; } |
2018 | + } |
2019 | + |
2020 | + public string entry { |
2021 | + get { return text_entry.text; } |
2022 | + set { text_entry.text = value; } |
2023 | + } |
2024 | + |
2025 | + public Utils.MessageHistory history { get; private set; } |
2026 | + |
2027 | + State _state; |
2028 | + public State state { |
2029 | + get { return _state; } |
2030 | + set { |
2031 | + _state = value; |
2032 | + |
2033 | + var widget = get_child_at (0, 0); |
2034 | + if (widget != null) |
2035 | + remove (widget); |
2036 | + |
2037 | + switch (_state) { |
2038 | + case State.CHAT: |
2039 | + attach (paned, 0, 0, 1, 1); |
2040 | + break; |
2041 | + case State.JOINING: |
2042 | + attach (loading_screen, 0, 0, 1, 1); |
2043 | + loading_screen.working = true; |
2044 | + break; |
2045 | + case State.NOT_JOINED: |
2046 | + attach (not_joined_alert, 0, 0, 1, 1); |
2047 | + break; |
2048 | + case State.NO_SUCH: |
2049 | + attach (no_such_alert, 0, 0, 1, 1); |
2050 | + break; |
2051 | + default: |
2052 | + assert_not_reached (); |
2053 | + } |
2054 | + |
2055 | + show_all (); |
2056 | + } |
2057 | + } |
2058 | + |
2059 | + public Room (string channel, string nick = "") { |
2060 | + this.channel = channel; |
2061 | + |
2062 | + history = new Utils.MessageHistory (); |
2063 | + |
2064 | + init_layout (); |
2065 | + connect_callbacks (); |
2066 | + } |
2067 | + |
2068 | + void init_layout () { |
2069 | + user_list = new UserList (); |
2070 | + |
2071 | + paned = new Granite.Widgets.ThinPaned (); |
2072 | + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
2073 | + |
2074 | + paned.pack1 (box, true, false); |
2075 | + paned.pack2 (user_list, false, false); |
2076 | + |
2077 | + text_entry = new Gtk.Entry (); |
2078 | + text_entry.hexpand = true; |
2079 | + |
2080 | + left_scrolled = new Utils.AutoScrolled (); |
2081 | + left_scrolled.hscrollbar_policy = Gtk.PolicyType.NEVER; |
2082 | + |
2083 | + chat = new ChatDisplay (); |
2084 | + |
2085 | + topic_bar = new Widgets.Topic (); |
2086 | + |
2087 | + pseudo_label = new Gtk.Label (""); |
2088 | + pseudo_label.set_alignment (1, (float) 0.5); |
2089 | + pseudo_label.width_request = 80; |
2090 | + |
2091 | + var entry_eventbox = new Gtk.EventBox (); |
2092 | + entry_eventbox.get_style_context ().add_class (Granite.StyleClass.CONTENT_VIEW); |
2093 | + var entry_grid = new Gtk.Grid (); |
2094 | + entry_grid.margin = 12; |
2095 | + entry_grid.column_spacing = 12; |
2096 | + entry_eventbox.add (entry_grid); |
2097 | + |
2098 | + entry_grid.attach (pseudo_label, 0, 0, 1, 1); |
2099 | + entry_grid.attach (text_entry, 1, 0, 1, 1); |
2100 | + left_scrolled.add_with_viewport (chat); |
2101 | + |
2102 | + box.pack_start (topic_bar, false); |
2103 | + box.pack_start (left_scrolled); |
2104 | + box.pack_start (entry_eventbox, false); |
2105 | + |
2106 | + loading_screen = new Granite.Widgets.EmbeddedAlert (); |
2107 | + loading_screen.primary_text = _("Joining channel %s").printf (channel); |
2108 | + loading_screen.working = true; |
2109 | + |
2110 | + action_join = new Gtk.Action ("join", "Join Channel", "Join this channel", null); |
2111 | + |
2112 | + not_joined_alert = new Granite.Widgets.EmbeddedAlert (); |
2113 | + not_joined_alert.primary_text = _("Channel is not joined"); |
2114 | + not_joined_alert.secondary_text = _("Join the channel to receive and send messages."); |
2115 | + not_joined_alert.message_type = Gtk.MessageType.WARNING; |
2116 | + not_joined_alert.actions = {action_join}; |
2117 | + |
2118 | + no_such_alert = new Granite.Widgets.EmbeddedAlert (); |
2119 | + no_such_alert.primary_text = _("Cannot join channel"); |
2120 | + no_such_alert.secondary_text = _("An error has occurred, this channel does not exist."); |
2121 | + no_such_alert.message_type = Gtk.MessageType.WARNING; |
2122 | + no_such_alert.show_icon= true; |
2123 | + |
2124 | + state = State.CHAT; |
2125 | + |
2126 | + this.show_all (); |
2127 | + } |
2128 | + |
2129 | + void connect_callbacks () { |
2130 | + text_entry.key_press_event.connect ((ev) => { |
2131 | + if (ev.keyval == Gdk.Key.Tab) { |
2132 | + var text = text_entry.text; |
2133 | + |
2134 | + if (text == null || text == "") |
2135 | + return false; |
2136 | + |
2137 | + var words = text.split (" "); |
2138 | + var word = words[words.length-1]; |
2139 | + |
2140 | + if (word == null || word == "") |
2141 | + return false; |
2142 | + |
2143 | + string[] completion = null; |
2144 | + foreach (var nick in user_list.nicks) |
2145 | + if (word.down () == nick[0:word.length].down ()) |
2146 | + completion += nick; |
2147 | + |
2148 | + if (completion == null) |
2149 | + return true; |
2150 | + |
2151 | + if (completion.length > 1) { |
2152 | + chat.message_suggestions (completion); |
2153 | + return true; |
2154 | + } else { |
2155 | + text_entry.buffer.delete_text (text_entry.cursor_position - word.length, word.length); |
2156 | + |
2157 | + if (text_entry.text != "") { |
2158 | + text_entry.insert_at_cursor (completion[0] + " "); |
2159 | + } else { |
2160 | + text_entry.insert_at_cursor (completion[0] + ": "); |
2161 | + } |
2162 | + return true; |
2163 | + } |
2164 | + } else if (ev.keyval == Gdk.Key.Up) { |
2165 | + if (history.has_older ()) |
2166 | + text_entry.text = history.get_older (); |
2167 | + return true; |
2168 | + } else if (ev.keyval == Gdk.Key.Down) { |
2169 | + if (history.has_newer ()) |
2170 | + text_entry.text = history.get_newer (); |
2171 | + return true; |
2172 | + } |
2173 | + |
2174 | + return false; |
2175 | + }); |
2176 | + |
2177 | + text_entry.activate.connect (() => { |
2178 | + if (text_entry.text != "") { |
2179 | + history.append (text_entry.text); |
2180 | + send_message (text_entry.text); |
2181 | + } |
2182 | + }); |
2183 | + |
2184 | + action_join.activate.connect (() => { |
2185 | + rejoin (); // signal |
2186 | + }); |
2187 | + } |
2188 | + |
2189 | + public void list_users (string[] nicks, string[] prefixes) |
2190 | + requires (nicks.length == prefixes.length) { |
2191 | + |
2192 | + for (int i = 0; i < nicks.length; i++) { |
2193 | + switch (prefixes[i]) { |
2194 | + case "@": |
2195 | + user_list.add_user (nicks[i], UserType.OPERATOR); |
2196 | + break; |
2197 | + case "+": |
2198 | + user_list.add_user (nicks[i], UserType.VOICED); |
2199 | + break; |
2200 | + default: |
2201 | + user_list.add_user (nicks[i], UserType.REGULAR); |
2202 | + break; |
2203 | + } |
2204 | + } |
2205 | + } |
2206 | + |
2207 | + public bool has_user (string name) { |
2208 | + return user_list.has_user (name); |
2209 | + } |
2210 | + |
2211 | + public void rename_user (string? old_name, string new_name, |
2212 | + UserType type, bool silent = false) { |
2213 | + |
2214 | + if (old_name == null) { |
2215 | + add_user (new_name, type, true); |
2216 | + return; |
2217 | + } |
2218 | + |
2219 | + remove_user (old_name, "", true); |
2220 | + add_user (new_name, type, true); |
2221 | + |
2222 | + if (!silent) |
2223 | + chat.message_nick (old_name, new_name); |
2224 | + } |
2225 | + |
2226 | + public void add_user (string name, UserType type, bool silent = false) { |
2227 | + user_list.add_user (name, type); |
2228 | + if (!silent) |
2229 | + chat.message_join (name); |
2230 | + } |
2231 | + |
2232 | + public void remove_user (string name, string message, bool silent = false) { |
2233 | + user_list.remove_user (name); |
2234 | + if (!silent) |
2235 | + chat.message_part (name, message); |
2236 | + } |
2237 | +} |
2238 | |
2239 | === added file 'src/Adapters/Widgets/Server.vala' |
2240 | --- src/Adapters/Widgets/Server.vala 1970-01-01 00:00:00 +0000 |
2241 | +++ src/Adapters/Widgets/Server.vala 2013-09-29 09:56:16 +0000 |
2242 | @@ -0,0 +1,100 @@ |
2243 | +/*** |
2244 | + Copyright (C) 2013 Cable Developers |
2245 | + |
2246 | + This program or library is free software; you can redistribute it |
2247 | + and/or modify it under the terms of the GNU Lesser General Public |
2248 | + License as published by the Free Software Foundation; either |
2249 | + version 3 of the License, or (at your option) any later version. |
2250 | + |
2251 | + This library is distributed in the hope that it will be useful, |
2252 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
2253 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2254 | + Lesser General Public License for more details. |
2255 | + |
2256 | + You should have received a copy of the GNU Lesser General |
2257 | + Public License along with this library; if not, write to the |
2258 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2259 | + Boston, MA 02110-1301 USA. |
2260 | +***/ |
2261 | + |
2262 | +/** |
2263 | + * This class represents a connection to a network. It is an expandable item in the |
2264 | + * source list. |
2265 | + */ |
2266 | +public class Cable.Adapter.Widgets.Server : Granite.Widgets.SourceList.ExpandableItem, Port.View.Server { |
2267 | + |
2268 | + public Gee.ArrayList <Port.View.Chat> chats { |
2269 | + owned get { |
2270 | + var _chats = new Gee.ArrayList <Port.View.Chat> (); |
2271 | + foreach (var child in children) |
2272 | + _chats.add (child as Port.View.Chat); |
2273 | + return _chats; |
2274 | + } |
2275 | + } |
2276 | + |
2277 | + public bool away { |
2278 | + set { |
2279 | + away_menu_item.label = (value) ? _("Mark Present") : _("Mark Away"); |
2280 | + away_menu_item.show_all (); |
2281 | + } |
2282 | + } |
2283 | + |
2284 | + public string id { get; set; } |
2285 | + |
2286 | + Gtk.Menu menu; |
2287 | + Gtk.MenuItem away_menu_item; |
2288 | + Gtk.MenuItem part_menu_item; |
2289 | + |
2290 | + internal Server (string name, string id) { |
2291 | + GLib.Object (name: name, id: id); |
2292 | + setup_contextmenu (); |
2293 | + } |
2294 | + |
2295 | + void setup_contextmenu () |
2296 | + requires (menu == null) |
2297 | + ensures (menu != null) { |
2298 | + |
2299 | + this.menu = new Gtk.Menu (); |
2300 | + |
2301 | + this.away_menu_item = new Gtk.MenuItem.with_label (_("Mark Away")); |
2302 | + this.part_menu_item = new Gtk.MenuItem.with_label (_("Leave All Channels")); |
2303 | + |
2304 | + menu.append (away_menu_item); |
2305 | + menu.append (part_menu_item); |
2306 | + |
2307 | + away_menu_item.activate.connect (() => toggle_away ()); |
2308 | + part_menu_item.activate.connect (() => part_all ()); |
2309 | + |
2310 | + menu.show_all (); |
2311 | + } |
2312 | + |
2313 | + public override Gtk.Menu? get_context_menu () { |
2314 | + if (menu != null && menu.get_attach_widget () != null) |
2315 | + menu.detach (); |
2316 | + return menu; |
2317 | + } |
2318 | + |
2319 | + public void add_channel (string chat_name, string chat_id) |
2320 | + requires (!has_chat (chat_name)) |
2321 | + ensures (has_chat (chat_name)) { |
2322 | + |
2323 | + var chat = new Channel (chat_name, chat_id); |
2324 | + add (chat); |
2325 | + } |
2326 | + |
2327 | + public void add_private_chat (string chat_name, string chat_id) |
2328 | + requires (!has_chat (chat_name)) |
2329 | + ensures (has_chat (chat_name)) { |
2330 | + |
2331 | + var chat = new PrivateChat (chat_name, chat_id); |
2332 | + add (chat); |
2333 | + } |
2334 | + |
2335 | + public void remove_chat (string chat_name) |
2336 | + requires (has_chat (chat_name)) |
2337 | + ensures (!has_chat (chat_name)) { |
2338 | + |
2339 | + var chat = get_chat (chat_name) as Widgets.Chat; |
2340 | + remove (chat); |
2341 | + } |
2342 | +} |
2343 | |
2344 | === added file 'src/Adapters/Widgets/TopicBar.vala' |
2345 | --- src/Adapters/Widgets/TopicBar.vala 1970-01-01 00:00:00 +0000 |
2346 | +++ src/Adapters/Widgets/TopicBar.vala 2013-09-29 09:56:16 +0000 |
2347 | @@ -0,0 +1,72 @@ |
2348 | +/*** |
2349 | + Copyright (C) 2013 Cable Developers |
2350 | + |
2351 | + This program or library is free software; you can redistribute it |
2352 | + and/or modify it under the terms of the GNU Lesser General Public |
2353 | + License as published by the Free Software Foundation; either |
2354 | + version 3 of the License, or (at your option) any later version. |
2355 | + |
2356 | + This library is distributed in the hope that it will be useful, |
2357 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
2358 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2359 | + Lesser General Public License for more details. |
2360 | + |
2361 | + You should have received a copy of the GNU Lesser General |
2362 | + Public License along with this library; if not, write to the |
2363 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2364 | + Boston, MA 02110-1301 USA. |
2365 | +***/ |
2366 | + |
2367 | +public class Cable.Adapter.Widgets.Topic : Gtk.InfoBar { |
2368 | + |
2369 | + /** |
2370 | + * The actual topic. |
2371 | + */ |
2372 | + public string topic { |
2373 | + get { return topic_label.label; } |
2374 | + set { |
2375 | + if (value != "") { |
2376 | + var new_topic = Utils.parse_string_to_markup (value); |
2377 | + topic_label.set_markup (new_topic); |
2378 | + topic_label.set_tooltip_text (new_topic); |
2379 | + no_show_all = false; |
2380 | + show_all (); |
2381 | + } else { |
2382 | + visible = false; |
2383 | + no_show_all = true; |
2384 | + } |
2385 | + } |
2386 | + } |
2387 | + |
2388 | + Gtk.Button arrow_button; |
2389 | + Gtk.Arrow arrow; |
2390 | + Gtk.Label topic_label; |
2391 | + Gtk.Grid grid; |
2392 | + |
2393 | + public Topic () { |
2394 | + arrow_button = new Gtk.Button (); |
2395 | + arrow = new Gtk.Arrow (Gtk.ArrowType.RIGHT, Gtk.ShadowType.ETCHED_IN); |
2396 | + arrow_button.valign = Gtk.Align.START; |
2397 | + arrow_button.relief = Gtk.ReliefStyle.NONE; |
2398 | + arrow_button.add (arrow); |
2399 | + |
2400 | + topic_label = new Gtk.Label (""); |
2401 | + topic_label.hexpand = true; |
2402 | + topic_label.margin_left = 12; |
2403 | + topic_label.margin_right = 12; |
2404 | + topic_label.ellipsize = Pango.EllipsizeMode.END; |
2405 | + topic_label.wrap_mode = Pango.WrapMode.WORD; |
2406 | + |
2407 | + grid = new Gtk.Grid (); |
2408 | + grid.attach (arrow_button, 0, 0, 1, 1); |
2409 | + grid.attach (topic_label, 1, 0, 1, 1); |
2410 | + |
2411 | + (get_content_area () as Gtk.Container).add (grid); |
2412 | + no_show_all = true; |
2413 | + |
2414 | + arrow_button.clicked.connect (() => { |
2415 | + topic_label.wrap = !topic_label.wrap; |
2416 | + arrow.arrow_type = (topic_label.wrap) ? Gtk.ArrowType.DOWN : Gtk.ArrowType.RIGHT; |
2417 | + }); |
2418 | + } |
2419 | +} |
2420 | |
2421 | === added file 'src/Adapters/Widgets/User.vala' |
2422 | --- src/Adapters/Widgets/User.vala 1970-01-01 00:00:00 +0000 |
2423 | +++ src/Adapters/Widgets/User.vala 2013-09-29 09:56:16 +0000 |
2424 | @@ -0,0 +1,36 @@ |
2425 | +/*** |
2426 | + Copyright (C) 2013 Cable Developers |
2427 | + |
2428 | + This program or library is free software; you can redistribute it |
2429 | + and/or modify it under the terms of the GNU Lesser General Public |
2430 | + License as published by the Free Software Foundation; either |
2431 | + version 3 of the License, or (at your option) any later version. |
2432 | + |
2433 | + This library is distributed in the hope that it will be useful, |
2434 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
2435 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2436 | + Lesser General Public License for more details. |
2437 | + |
2438 | + You should have received a copy of the GNU Lesser General |
2439 | + Public License along with this library; if not, write to the |
2440 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2441 | + Boston, MA 02110-1301 USA. |
2442 | +***/ |
2443 | + |
2444 | +// TODO Implement Kick, Ban, Ignore items ! |
2445 | +/*Gtk.MenuItem kick_item; |
2446 | +Gtk.MenuItem ban_item; |
2447 | +Gtk.MenuItem ignore_item;*/ |
2448 | + |
2449 | +public class Cable.Adapter.Widgets.User : Granite.Widgets.SourceList.Item { |
2450 | + |
2451 | + public signal void private_chat_requested (); |
2452 | + |
2453 | + public User (string name) { |
2454 | + base (name); |
2455 | + |
2456 | + activated.connect (() => { |
2457 | + private_chat_requested (); // signal |
2458 | + }); |
2459 | + } |
2460 | +} |
2461 | |
2462 | === added file 'src/Adapters/Widgets/UserList.vala' |
2463 | --- src/Adapters/Widgets/UserList.vala 1970-01-01 00:00:00 +0000 |
2464 | +++ src/Adapters/Widgets/UserList.vala 2013-09-29 09:56:16 +0000 |
2465 | @@ -0,0 +1,122 @@ |
2466 | +/*** |
2467 | + Copyright (C) 2013 Cable Developers |
2468 | + |
2469 | + This program or library is free software; you can redistribute it |
2470 | + and/or modify it under the terms of the GNU Lesser General Public |
2471 | + License as published by the Free Software Foundation; either |
2472 | + version 3 of the License, or (at your option) any later version. |
2473 | + |
2474 | + This library is distributed in the hope that it will be useful, |
2475 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
2476 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2477 | + Lesser General Public License for more details. |
2478 | + |
2479 | + You should have received a copy of the GNU Lesser General |
2480 | + Public License along with this library; if not, write to the |
2481 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2482 | + Boston, MA 02110-1301 USA. |
2483 | +***/ |
2484 | + |
2485 | +public class Cable.Adapter.Widgets.UserList : Granite.Widgets.SourceList { |
2486 | + |
2487 | + Granite.Widgets.SourceList.ExpandableItem operators; |
2488 | + Granite.Widgets.SourceList.ExpandableItem voiced; |
2489 | + Granite.Widgets.SourceList.ExpandableItem regular; |
2490 | + |
2491 | + delegate void ForeachFunction (User user); |
2492 | + |
2493 | + public Gee.Set <string> nicks { |
2494 | + owned get { |
2495 | + var _nicks = new Gee.HashSet <string> (); |
2496 | + @foreach ((child) => _nicks.add (child.name)); |
2497 | + return _nicks as Gee.Set; |
2498 | + } |
2499 | + } |
2500 | + |
2501 | + public signal void private_chat_requested (string user_name); |
2502 | + |
2503 | + public UserList () { |
2504 | + operators = new Granite.Widgets.SourceList.ExpandableItem (_("Operators")); |
2505 | + voiced = new Granite.Widgets.SourceList.ExpandableItem (_("Voiced")); |
2506 | + regular = new Granite.Widgets.SourceList.ExpandableItem (_("Regular")); |
2507 | + |
2508 | + regular.expanded = true; |
2509 | + operators.expanded = true; |
2510 | + voiced.expanded = true; |
2511 | + |
2512 | + hscrollbar_policy = Gtk.PolicyType.NEVER; |
2513 | + width_request = 150; |
2514 | + set_sort_func ((a,b) => { |
2515 | + return a.name.collate (b.name); |
2516 | + }); |
2517 | + |
2518 | + root.add (operators); |
2519 | + root.add (voiced); |
2520 | + root.add (regular); |
2521 | + |
2522 | + no_show_all = true; |
2523 | + visible = false; |
2524 | + } |
2525 | + |
2526 | + public bool has_user (string name) { |
2527 | + return name in nicks; |
2528 | + } |
2529 | + |
2530 | + public void add_user (string name, UserType user_type = UserType.REGULAR) { |
2531 | + var user = new User (name); |
2532 | + user.selectable = false; |
2533 | + |
2534 | + switch (user_type) { |
2535 | + case UserType.OPERATOR: |
2536 | + operators.add (user); |
2537 | + break; |
2538 | + case UserType.VOICED: |
2539 | + voiced.add (user); |
2540 | + break; |
2541 | + default: |
2542 | + regular.add (user); |
2543 | + break; |
2544 | + } |
2545 | + |
2546 | + user.private_chat_requested.connect (() => { |
2547 | + private_chat_requested (user.name); |
2548 | + }); |
2549 | + |
2550 | + update_user_counts (); |
2551 | + |
2552 | + if (visible == false) { |
2553 | + no_show_all = false; |
2554 | + visible = true; |
2555 | + } |
2556 | + } |
2557 | + |
2558 | + public void remove_user (string name) { |
2559 | + @foreach ((child) => { |
2560 | + if (child.name != name) |
2561 | + return; |
2562 | + child.parent.remove (child); |
2563 | + update_user_counts (); |
2564 | + }); |
2565 | + |
2566 | + if (nicks.size == 0) { |
2567 | + no_show_all = true; |
2568 | + visible = false; |
2569 | + } |
2570 | + } |
2571 | + |
2572 | + void update_user_counts () { |
2573 | + regular.name = _("Regular") + @" ($(regular.n_children.to_string ()))"; |
2574 | + operators.name = _("Operators") + @" ($(operators.n_children.to_string ()))"; |
2575 | + voiced.name = _("Voiced") + @" ($(voiced.n_children.to_string ()))"; |
2576 | + } |
2577 | + |
2578 | + new void @foreach (ForeachFunction func) { |
2579 | + Granite.Widgets.SourceList.ExpandableItem[] lists = { |
2580 | + voiced, operators, regular |
2581 | + }; |
2582 | + |
2583 | + foreach (var list in lists) |
2584 | + foreach (var child in list.children) |
2585 | + func (child as User); |
2586 | + } |
2587 | +} |
2588 | |
2589 | === added file 'src/Adapters/Widgets/Welcome.vala' |
2590 | --- src/Adapters/Widgets/Welcome.vala 1970-01-01 00:00:00 +0000 |
2591 | +++ src/Adapters/Widgets/Welcome.vala 2013-09-29 09:56:16 +0000 |
2592 | @@ -0,0 +1,143 @@ |
2593 | +/*** |
2594 | + Copyright (C) 2013 Cable Developers |
2595 | + |
2596 | + This program or library is free software; you can redistribute it |
2597 | + and/or modify it under the terms of the GNU Lesser General Public |
2598 | + License as published by the Free Software Foundation; either |
2599 | + version 3 of the License, or (at your option) any later version. |
2600 | + |
2601 | + This library is distributed in the hope that it will be useful, |
2602 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
2603 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2604 | + Lesser General Public License for more details. |
2605 | + |
2606 | + You should have received a copy of the GNU Lesser General |
2607 | + Public License along with this library; if not, write to the |
2608 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2609 | + Boston, MA 02110-1301 USA. |
2610 | +***/ |
2611 | + |
2612 | +public class Cable.Adapter.Widgets.Welcome : Granite.Widgets.Welcome { |
2613 | + |
2614 | + public signal void done (string address, string nick, string channel); |
2615 | + |
2616 | + Gtk.Entry channel_entry; |
2617 | + Gtk.Button connect_button; |
2618 | + Gtk.ComboBoxText server_entry; |
2619 | + Gtk.ComboBoxText id_entry; |
2620 | + |
2621 | + public Welcome () { |
2622 | + base (_("Connect to IRC"), _("Select a channel to join and begin to talk.")); |
2623 | + |
2624 | + var grid = new Gtk.Grid (); |
2625 | + grid.margin = 12; |
2626 | + grid.column_spacing = 6; |
2627 | + grid.row_spacing = 6; |
2628 | + |
2629 | + // Labels |
2630 | + var server_label = new Gtk.Label (_("Network:")); |
2631 | + server_label.halign = Gtk.Align.END; |
2632 | + server_label.valign = Gtk.Align.CENTER; |
2633 | + |
2634 | + var id_label = new Gtk.Label (_("Identity:")); |
2635 | + id_label.halign = Gtk.Align.END; |
2636 | + id_label.valign = Gtk.Align.CENTER; |
2637 | + |
2638 | + var channel_label = new Gtk.Label (_("Channel:")); |
2639 | + channel_label.halign = Gtk.Align.END; |
2640 | + channel_label.valign = Gtk.Align.CENTER; |
2641 | + |
2642 | + connect_button = new Gtk.Button.with_label (_("Connect")); |
2643 | + connect_button.get_style_context ().add_class ("suggested-action"); |
2644 | + connect_button.sensitive = false; |
2645 | + |
2646 | + var connect_button_grid = new Gtk.Grid (); |
2647 | + var connect_fake_label = new Gtk.Label (""); |
2648 | + connect_fake_label.hexpand = true; |
2649 | + connect_button_grid.attach (connect_fake_label, 0, 0, 1, 1); |
2650 | + connect_button_grid.attach (connect_button, 1, 0, 1, 1); |
2651 | + |
2652 | + // Entries/Comboboxes |
2653 | + server_entry = new Gtk.ComboBoxText.with_entry (); |
2654 | + for (int i = 0; i < Utils.Network.all.size; i++) |
2655 | + server_entry.append (i.to_string (), Utils.Network.all[i].name); |
2656 | + server_entry.active = 0; |
2657 | + |
2658 | + id_entry = new Gtk.ComboBoxText.with_entry (); |
2659 | + for (int i = 0; i < Utils.Identity.all.size; i++) { |
2660 | + id_entry.append (i.to_string (), Utils.Identity.all[i].nick_name); |
2661 | + if (Utils.Identity.all[i].nick_name == Settings.preferences.last_used_nick) |
2662 | + id_entry.active = i; |
2663 | + } |
2664 | + |
2665 | + if (Settings.preferences.last_used_nick == "") |
2666 | + id_entry.active = 0; |
2667 | + |
2668 | + channel_entry = new Gtk.Entry (); |
2669 | + channel_entry.text = "#"; |
2670 | + channel_entry.width_request = 250; |
2671 | + |
2672 | + grid.attach (server_label, 0, 0, 1, 1); |
2673 | + grid.attach (server_entry, 1, 0, 1, 1); |
2674 | + |
2675 | + grid.attach (id_label, 0, 1, 1, 1); |
2676 | + grid.attach (id_entry, 1, 1, 1, 1); |
2677 | + grid.attach (channel_label, 0, 2, 1, 1); |
2678 | + grid.attach (channel_entry, 1, 2, 1, 1); |
2679 | + grid.attach (connect_button_grid, 1, 3, 1, 1); |
2680 | + grid.margin = 6; |
2681 | + |
2682 | + channel_entry.insert_text.connect ((text) => { |
2683 | + Utils.filter (channel_entry, text, {" ", ":"}); |
2684 | + }); |
2685 | + id_entry.changed.connect (() => { |
2686 | + if (channel_entry.text.length > 1 && server_entry.get_active_text ().length > 0 && id_entry.get_active_text ().length > 0) { |
2687 | + connect_button.sensitive = true; |
2688 | + } else { |
2689 | + connect_button.set_sensitive (false); |
2690 | + }; |
2691 | + }); |
2692 | + server_entry.changed.connect (() => { |
2693 | + if (channel_entry.text.length > 1 && server_entry.get_active_text ().length > 0 && id_entry.get_active_text ().length > 0) { |
2694 | + connect_button.sensitive = true; |
2695 | + } else { |
2696 | + connect_button.set_sensitive (false); |
2697 | + }; |
2698 | + }); |
2699 | + channel_entry.changed.connect (() => { |
2700 | + if (channel_entry.text.length > 1 && server_entry.get_active_text ().length > 0 && id_entry.get_active_text ().length > 0) { |
2701 | + connect_button.sensitive = true; |
2702 | + } else { |
2703 | + connect_button.set_sensitive (false); |
2704 | + }; |
2705 | + }); |
2706 | + |
2707 | + connect_button.clicked.connect (() => channel_entry.activate ()); |
2708 | + channel_entry.activate.connect (() => { |
2709 | + Utils.Network network; |
2710 | + Utils.Identity identity; |
2711 | + |
2712 | + if (server_entry.active_id == null) { |
2713 | + network = new Utils.Network (server_entry.get_active_text ()); |
2714 | + } else { |
2715 | + network = Utils.Network.all[int.parse (server_entry.active_id)]; |
2716 | + } |
2717 | + |
2718 | + if (id_entry.active_id == null) { |
2719 | + identity = new Utils.Identity (id_entry.get_active_text ()); |
2720 | + } else { |
2721 | + identity = Utils.Identity.all[int.parse (id_entry.active_id)]; |
2722 | + } |
2723 | + |
2724 | + done (network.address, identity.nick_name, channel_entry.text); |
2725 | + }); |
2726 | + |
2727 | + options.add (grid); |
2728 | + this.show_all (); |
2729 | + } |
2730 | + |
2731 | + public void focus_channel_entry () { |
2732 | + channel_entry.grab_focus (); |
2733 | + channel_entry.set_position (-1); |
2734 | + } |
2735 | +} |
2736 | |
2737 | === added file 'src/Adapters/Widgets/Window.vala' |
2738 | --- src/Adapters/Widgets/Window.vala 1970-01-01 00:00:00 +0000 |
2739 | +++ src/Adapters/Widgets/Window.vala 2013-09-29 09:56:16 +0000 |
2740 | @@ -0,0 +1,293 @@ |
2741 | +/*** |
2742 | + Copyright (C) 2013 Cable Developers |
2743 | + |
2744 | + This program or library is free software; you can redistribute it |
2745 | + and/or modify it under the terms of the GNU Lesser General Public |
2746 | + License as published by the Free Software Foundation; either |
2747 | + version 3 of the License, or (at your option) any later version. |
2748 | + |
2749 | + This library is distributed in the hope that it will be useful, |
2750 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
2751 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2752 | + Lesser General Public License for more details. |
2753 | + |
2754 | + You should have received a copy of the GNU Lesser General |
2755 | + Public License along with this library; if not, write to the |
2756 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2757 | + Boston, MA 02110-1301 USA. |
2758 | +***/ |
2759 | + |
2760 | +namespace Cable { |
2761 | + public Gtk.ActionGroup main_actions; |
2762 | +} |
2763 | + |
2764 | +public class Cable.Adapter.Widgets.Window : Gtk.Window, Port.View.Window { |
2765 | + |
2766 | + Granite.Widgets.SourceList server_list; |
2767 | + Gtk.EventBox display_box; |
2768 | + Gtk.Grid layout; |
2769 | + Gtk.Grid server_grid; |
2770 | + Granite.Widgets.ThinPaned paned; |
2771 | + Widgets.Welcome welcome; |
2772 | + |
2773 | + Gtk.Toolbar channel_control; |
2774 | + Gtk.ToolButton join_button; |
2775 | + Gtk.ToolButton leave_button; |
2776 | + Gtk.ToolButton prefs_button; |
2777 | + |
2778 | + Gtk.UIManager ui; |
2779 | + |
2780 | + private bool window_maximized = false; |
2781 | + private int window_width = 0; |
2782 | + private int window_height = 0; |
2783 | + |
2784 | + const string ui_string = """ |
2785 | + <ui> |
2786 | + <popup name="MenuItemTool"> |
2787 | + <menuitem name="Join Channel" action="JoinChannel"/> |
2788 | + <menuitem name="Leave Channel" action="LeaveChannel"/> |
2789 | + <menuitem name="Edit Identity" action="EditCurrentId"/> |
2790 | + </popup> |
2791 | + </ui> |
2792 | + """; |
2793 | + |
2794 | + public const string TITLE = "Cable"; |
2795 | + |
2796 | + /** |
2797 | + * Get or set the widget displayed next to the source list. |
2798 | + */ |
2799 | + Gtk.Widget display_widget { |
2800 | + get { return display_box.get_children ().nth_data (0); } |
2801 | + set { |
2802 | + var content = display_box.get_children ().nth_data (0); |
2803 | + |
2804 | + if (content != null) |
2805 | + display_box.remove (content); |
2806 | + |
2807 | + display_box.add (value); |
2808 | + display_box.show_all (); |
2809 | + } |
2810 | + } |
2811 | + |
2812 | + /** |
2813 | + * Wether the welcome screen is shown or not. |
2814 | + */ |
2815 | + public bool welcome_shown { |
2816 | + get { return layout.get_child_at (0, 1) == welcome; } |
2817 | + set { |
2818 | + if (value) { |
2819 | + var widget = layout.get_child_at (0, 1); |
2820 | + if (widget != null) |
2821 | + layout.remove (widget); |
2822 | + layout.attach (welcome, 0, 1, 1, 1); |
2823 | + title = TITLE; |
2824 | + welcome.focus_channel_entry (); |
2825 | + this.show_all (); |
2826 | + } else { |
2827 | + var widget = layout.get_child_at (0, 1); |
2828 | + if (widget != null) |
2829 | + layout.remove (widget); |
2830 | + layout.attach (paned, 0, 1, 1, 1); |
2831 | + this.show_all (); |
2832 | + } |
2833 | + } |
2834 | + } |
2835 | + |
2836 | + public Gee.ArrayList <Port.View.Server> servers { |
2837 | + owned get { |
2838 | + var _servers = new Gee.ArrayList <Port.View.Server> (); |
2839 | + foreach (var child in server_list.root.children) |
2840 | + _servers.add (child as Port.View.Server); |
2841 | + return _servers; |
2842 | + } |
2843 | + } |
2844 | + |
2845 | + /** |
2846 | + * Get the server of the currently selected channel. |
2847 | + */ |
2848 | + public Port.View.Server? current_server { |
2849 | + get { return server_list.selected.parent as Port.View.Server; } |
2850 | + } |
2851 | + |
2852 | + /** |
2853 | + * Get the currently selected channel. |
2854 | + */ |
2855 | + public Port.View.Chat? current_chat { |
2856 | + get { return server_list.selected as Port.View.Chat; } |
2857 | + set { server_list.selected = value as Widgets.Chat; } |
2858 | + } |
2859 | + |
2860 | + //public signal void edit_identity (); |
2861 | + |
2862 | + public Window (Cable.App app) { |
2863 | + GLib.Object (application: app); |
2864 | + init_actions (); |
2865 | + init_layout (); |
2866 | + |
2867 | + server_list.item_selected.connect ((item) => { |
2868 | + if (item != null) { |
2869 | + display_widget = (current_chat as Widgets.Chat).room; |
2870 | + selected (current_chat); |
2871 | + } |
2872 | + }); |
2873 | + |
2874 | + welcome.done.connect ((a,n,c) => { |
2875 | + join (a,n,c); |
2876 | + }); |
2877 | + |
2878 | + destroy.connect (() => { |
2879 | + close (); |
2880 | + }); |
2881 | + } |
2882 | + |
2883 | + void init_actions () { |
2884 | + main_actions = new Gtk.ActionGroup ("MainActionGroup"); |
2885 | + main_actions.set_translation_domain (Constants.GETTEXT_PACKAGE); |
2886 | + main_actions.add_actions (main_entries, this); |
2887 | + |
2888 | + ui = new Gtk.UIManager (); |
2889 | + |
2890 | + try { |
2891 | + ui.add_ui_from_string (ui_string, -1); |
2892 | + } catch (Error e) { |
2893 | + error ("Couldn't load the UI: %s", e.message); |
2894 | + } |
2895 | + |
2896 | + Gtk.AccelGroup accel_group = ui.get_accel_group (); |
2897 | + add_accel_group (accel_group); |
2898 | + |
2899 | + ui.insert_action_group (main_actions, 0); |
2900 | + ui.ensure_update (); |
2901 | + } |
2902 | + |
2903 | + void init_layout () { |
2904 | + this.title = TITLE; |
2905 | + this.icon_name = "internet-chat"; |
2906 | + this.set_default_size (Settings.saved_state.window_width, Settings.saved_state.window_height); |
2907 | + this.window_position = Gtk.WindowPosition.CENTER; |
2908 | + |
2909 | + switch (Settings.saved_state.window_state) { |
2910 | + case Settings.SavedState.WindowState.MAXIMIZED: |
2911 | + window_maximized = true; |
2912 | + this.maximize (); |
2913 | + break; |
2914 | + } |
2915 | + |
2916 | + layout = new Gtk.Grid (); |
2917 | + |
2918 | + server_list = new Granite.Widgets.SourceList (); |
2919 | + server_list.width_request = 150; |
2920 | + |
2921 | + display_box = new Gtk.EventBox (); |
2922 | + paned = new Granite.Widgets.ThinPaned (); |
2923 | + |
2924 | + channel_control = new Gtk.Toolbar (); |
2925 | + channel_control.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR); |
2926 | + |
2927 | + join_button = main_actions.get_action ("JoinChannel").create_tool_item() as Gtk.ToolButton; |
2928 | + leave_button = main_actions.get_action ("LeaveChannel").create_tool_item() as Gtk.ToolButton; |
2929 | + prefs_button = main_actions.get_action ("Preferences").create_tool_item() as Gtk.ToolButton; |
2930 | + |
2931 | + var expander = new Gtk.SeparatorToolItem (); |
2932 | + expander.set_draw (true); |
2933 | + expander.set_expand (true); |
2934 | + |
2935 | + welcome = new Widgets.Welcome (); |
2936 | + welcome.hexpand = true; |
2937 | + welcome.vexpand = true; |
2938 | + |
2939 | + channel_control.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR); |
2940 | + channel_control.add (join_button); |
2941 | + channel_control.add (leave_button); |
2942 | + channel_control.add (expander); |
2943 | + channel_control.add (prefs_button); |
2944 | + |
2945 | + server_grid = new Gtk.Grid (); |
2946 | + server_grid.attach (server_list, 0, 0, 1, 1); |
2947 | + server_grid.attach (channel_control, 0, 1, 1, 1); |
2948 | + |
2949 | + paned.position = Settings.saved_state.column_server_width; |
2950 | + paned.pack1 (server_grid, false, false); |
2951 | + paned.pack2 (display_box, true, false); |
2952 | + |
2953 | + this.add (layout); |
2954 | + this.show_all (); |
2955 | + } |
2956 | + |
2957 | + /*private void close () { |
2958 | + Settings.saved_state.window_width = window_width; |
2959 | + Settings.saved_state.window_height = window_height; |
2960 | + Settings.saved_state.column_server_width = paned.position; |
2961 | + |
2962 | + if (window_maximized) |
2963 | + Settings.saved_state.window_state = Settings.SavedState.WindowState.MAXIMIZED; |
2964 | + else |
2965 | + Settings.saved_state.window_state = Settings.SavedState.WindowState.NORMAL; |
2966 | + }*/ |
2967 | + |
2968 | + void action_join_channel () { |
2969 | + add_channel (); |
2970 | + } |
2971 | + |
2972 | + void action_leave_channel () { |
2973 | + remove_channel (); |
2974 | + } |
2975 | + |
2976 | + void action_edit_identity () { |
2977 | + /*edit_identity (); |
2978 | + var dialog = new Dialogs.ManageIdentity (server_list.current_server.backend.identity); |
2979 | + dialog.show_all ();*/ |
2980 | + } |
2981 | + |
2982 | + void action_preferences () { |
2983 | + show_preferences (); |
2984 | + } |
2985 | + |
2986 | + |
2987 | + /** |
2988 | + * Removes a server from the List. |
2989 | + */ |
2990 | + public void remove_server (string server_id) |
2991 | + /*requires (has_server (server_id))*/ |
2992 | + ensures (!has_server (server_id)) { |
2993 | + |
2994 | + var server = get_server_by_id (server_id); |
2995 | + return_if_fail (server is Widgets.Server); |
2996 | + server_list.root.remove (server as Widgets.Server); |
2997 | + } |
2998 | + |
2999 | + /** |
3000 | + * Add server. |
3001 | + */ |
3002 | + public Port.View.Server? add_server (string server_name, string server_id) |
3003 | + requires (!has_server (server_id)) |
3004 | + ensures (has_server (server_id)) { |
3005 | + |
3006 | + var server = new Widgets.Server (server_name, server_id); |
3007 | + server.expanded = true; |
3008 | + server_list.root.add (server); |
3009 | + return (Port.View.Server) server; |
3010 | + } |
3011 | + |
3012 | + static const Gtk.ActionEntry[] main_entries = { |
3013 | + { "JoinChannel", "list-add-symbolic", N_("Join Channel…"), "<Control>j", |
3014 | + N_("Join Channel…"), action_join_channel }, |
3015 | + |
3016 | + { "LeaveChannel", "list-remove-symbolic", N_("Leave current Channel"), "<Control>l", |
3017 | + N_("Leave current Channel"), action_leave_channel }, |
3018 | + |
3019 | + { "EditCurrentId", "avatar-default-symbolic", N_("Edit current Identity…"), "<Control>i", |
3020 | + N_("Edit current Identity…"), action_edit_identity }, |
3021 | + |
3022 | + { "Preferences", "document-properties-symbolic", N_("Preferences"), null, |
3023 | + N_("Preferences"), action_preferences } |
3024 | + }; |
3025 | + |
3026 | + public override bool configure_event (Gdk.EventConfigure event) { |
3027 | + window_maximized = (get_window ().get_state () == Gdk.WindowState.MAXIMIZED); |
3028 | + |
3029 | + get_size (out window_width, out window_height); |
3030 | + |
3031 | + return base.configure_event (event); |
3032 | + } |
3033 | +} |
3034 | |
3035 | === modified file 'src/Cable.vala' |
3036 | --- src/Cable.vala 2013-09-28 12:37:00 +0000 |
3037 | +++ src/Cable.vala 2013-09-29 09:56:16 +0000 |
3038 | @@ -84,8 +84,8 @@ |
3039 | } |
3040 | |
3041 | public override void activate () { |
3042 | - var window = new Widgets.Window (this); |
3043 | - var irc = new Irc.Session (); |
3044 | + var window = new Adapter.Widgets.Window (this); |
3045 | + var irc = new Adapter.Irc.Session (); |
3046 | var controller = new Controller.Window (window, irc); |
3047 | |
3048 | add_window (window); |
3049 | |
3050 | === removed directory 'src/Controller' |
3051 | === removed file 'src/Controller/Channel.vala' |
3052 | --- src/Controller/Channel.vala 2013-09-28 12:37:00 +0000 |
3053 | +++ src/Controller/Channel.vala 1970-01-01 00:00:00 +0000 |
3054 | @@ -1,275 +0,0 @@ |
3055 | -/*** |
3056 | - Copyright (C) 2013 Cable Developers |
3057 | - |
3058 | - This program or library is free software; you can redistribute it |
3059 | - and/or modify it under the terms of the GNU Lesser General Public |
3060 | - License as published by the Free Software Foundation; either |
3061 | - version 3 of the License, or (at your option) any later version. |
3062 | - |
3063 | - This library is distributed in the hope that it will be useful, |
3064 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
3065 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3066 | - Lesser General Public License for more details. |
3067 | - |
3068 | - You should have received a copy of the GNU Lesser General |
3069 | - Public License along with this library; if not, write to the |
3070 | - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
3071 | - Boston, MA 02110-1301 USA. |
3072 | -***/ |
3073 | - |
3074 | -public class Cable.Controller.Channel : GLib.Object { |
3075 | - |
3076 | - public weak Server server; |
3077 | - public View.Channel view; |
3078 | - public Port.Irc.Channel backend; |
3079 | - |
3080 | - public string name; //TODO id |
3081 | - |
3082 | - public Channel (Server server, string name) { |
3083 | - this.server = server; |
3084 | - this.name = name; |
3085 | - |
3086 | - if (server.view.has_chat (name) == false) |
3087 | - server.view.add_channel (name, name); |
3088 | - |
3089 | - view = server.view.get_chat (name) as View.Channel; |
3090 | - view.nick = server.nick; |
3091 | - backend = server.backend.get_or_create_channel (name); |
3092 | - |
3093 | - connect_frontend_signals (); |
3094 | - connect_backend_signals (); |
3095 | - |
3096 | - load_state (); |
3097 | - } |
3098 | - |
3099 | - void load_state () { |
3100 | - /*if (backend.joined) { |
3101 | - view.room.state = Widgets.Room.State.CHAT; |
3102 | - FIXME some bug in maki returns garbage here: |
3103 | - -> view.room.list_users (backend.nicks, backend.prefixes); |
3104 | - backend.event_topic (backend.topic, ""); |
3105 | - } else { |
3106 | - view.room.state = Widgets.Room.State.JOINING; |
3107 | - }*/ |
3108 | - // part and rejoin to workaround bug |
3109 | - view.state = State.JOINING; |
3110 | - |
3111 | - if (server.backend.connected == false) { |
3112 | - server.backend.event_connected.connect (() => { |
3113 | - if (backend.joined) |
3114 | - backend.send_part (); |
3115 | - backend.send_join (); |
3116 | - }); |
3117 | - } else { |
3118 | - if (backend.joined) |
3119 | - backend.send_part (); |
3120 | - backend.send_join (); |
3121 | - } |
3122 | - } |
3123 | - |
3124 | - // GUI signals |
3125 | - void connect_frontend_signals () { |
3126 | - view.part.connect (() => { |
3127 | - backend.send_part (); |
3128 | - }); |
3129 | - |
3130 | - server.window.view.selected.connect ((item) => { |
3131 | - if (item == view) |
3132 | - view.unread_messages = 0; |
3133 | - }); |
3134 | - |
3135 | - view.join.connect (() => { |
3136 | - view.state = State.JOINING; |
3137 | - backend.send_join (); |
3138 | - }); |
3139 | - |
3140 | - view.send_message.connect ((message) => { |
3141 | - if (message.has_prefix ("/")) |
3142 | - send_command (message.replace ("/", "")); |
3143 | - else |
3144 | - server.backend.send_message (name, message); |
3145 | - |
3146 | - view.entry = ""; |
3147 | - }); |
3148 | - |
3149 | - view.focused.connect (() => { |
3150 | - Services.Launcher.jobs = 0; |
3151 | - Services.Launcher.urgent = false; |
3152 | - return false; |
3153 | - }); |
3154 | - |
3155 | - view.private_chat_requested.connect ((name) => { |
3156 | - server.open_new_chat_with (name); |
3157 | - if (server.private_chats.has_key (name)) |
3158 | - server.window.view.current_chat = server.private_chats [name].view; |
3159 | - }); |
3160 | - } |
3161 | - |
3162 | - // IRC signals |
3163 | - void connect_backend_signals () { |
3164 | - backend.event_message.connect ((from, message) => { |
3165 | - if (server.window.view.current_chat != view) |
3166 | - view.unread_messages++; |
3167 | - }); |
3168 | - |
3169 | - backend.event_topic.connect ((from, topic) => { |
3170 | - view.topic = topic; |
3171 | - }); |
3172 | - |
3173 | - server.backend.event_nick.connect ((from, new_nick) => { |
3174 | - if (server.backend.is_me (from)) { |
3175 | - view.nick = new_nick; |
3176 | - } |
3177 | - |
3178 | - assert (new_nick != null); |
3179 | - |
3180 | - var name = from.split ("!")[0]; |
3181 | - |
3182 | - if (!view.has_user (name)) |
3183 | - return; |
3184 | - |
3185 | - if (name.has_prefix ("@")) |
3186 | - view.rename_user (name.replace ("@", ""), new_nick, UserType.OPERATOR); |
3187 | - else if (name.has_prefix ("+")) |
3188 | - view.rename_user (name.replace ("+", ""), new_nick, UserType.VOICED); |
3189 | - else |
3190 | - view.rename_user (name, new_nick, UserType.REGULAR); |
3191 | - }); |
3192 | - |
3193 | - backend.event_part.connect ((from, message) => { |
3194 | - if (server.backend.is_me (from)) { |
3195 | - view.state = State.NOT_JOINED; |
3196 | - } else { |
3197 | - var name = from.split ("!")[0]; |
3198 | - |
3199 | - if (name.has_prefix ("@")) |
3200 | - view.remove_user (name.replace ("@", ""), message); |
3201 | - else if (name.has_prefix ("+")) |
3202 | - view.remove_user (name.replace ("+", ""), message); |
3203 | - else |
3204 | - view.remove_user (name, message); |
3205 | - } |
3206 | - }); |
3207 | - |
3208 | - backend.event_join.connect ((from) => { |
3209 | - if (server.backend.is_me (from)) { |
3210 | - view.state = State.CHAT; |
3211 | - } else { |
3212 | - var name = from.split ("!")[0]; |
3213 | - |
3214 | - if (name.has_prefix ("@")) |
3215 | - view.add_user (name.replace ("@", ""), UserType.OPERATOR); |
3216 | - else if (name.has_prefix ("+")) |
3217 | - view.add_user (name.replace ("+", ""), UserType.VOICED); |
3218 | - else |
3219 | - view.add_user (name, UserType.REGULAR); |
3220 | - } |
3221 | - }); |
3222 | - |
3223 | - backend.event_no_such.connect (() => { |
3224 | - view.state = State.NO_SUCH; |
3225 | - }); |
3226 | - |
3227 | - backend.event_message.connect ((from, message) => { |
3228 | - var nick = from.split ("!") [0]; |
3229 | - |
3230 | - if (message.contains (server.nick)) { |
3231 | - |
3232 | - if (view.has_focus == false) { |
3233 | - Services.Notify.send (nick, message); |
3234 | - Services.Launcher.jobs++; |
3235 | - Services.Launcher.urgent = true; |
3236 | - } |
3237 | - |
3238 | - view.message (nick, message, MessageType.PING); |
3239 | - } else { |
3240 | - view.message (nick, message); |
3241 | - } |
3242 | - }); |
3243 | - |
3244 | - backend.event_action.connect ((from, message) => { |
3245 | - var nick = from.split ("!")[0]; |
3246 | - view.message ("", "* " + nick + " " + message, MessageType.ACTION); |
3247 | - }); |
3248 | - |
3249 | - backend.event_names.connect (view.list_users); |
3250 | - } |
3251 | - |
3252 | - void send_command (string command) { |
3253 | - |
3254 | - var args = command.split (" "); |
3255 | - |
3256 | - switch (args[0]) { |
3257 | - case "join": |
3258 | - return_if_fail (args.length > 1); |
3259 | - var channel_with_hash = args[1]; |
3260 | - if (channel_with_hash.slice(0, 1) != "#") { |
3261 | - channel_with_hash = "#" + args[1]; |
3262 | - } |
3263 | - var channel = new Channel (server, channel_with_hash); |
3264 | - server.channels[channel_with_hash] = channel; |
3265 | - server.window.view.current_chat = channel.view; |
3266 | - break; |
3267 | - |
3268 | - case "part": |
3269 | - backend.send_part (); |
3270 | - break; |
3271 | - |
3272 | - case "quit": |
3273 | - server.backend.send_quit (); |
3274 | - break; |
3275 | - |
3276 | - case "nick": |
3277 | - return_if_fail (args.length > 1); |
3278 | - server.backend.send_nick (args[1]); |
3279 | - break; |
3280 | - |
3281 | - case "topic": |
3282 | - return_if_fail (args.length > 1); |
3283 | - backend.send_topic (string.joinv (" ", args[1:-1])); |
3284 | - break; |
3285 | - |
3286 | - case "me": |
3287 | - case "action": |
3288 | - return_if_fail (args.length > 1); |
3289 | - backend.send_action (string.joinv (" ", args[1:-1])); |
3290 | - break; |
3291 | - |
3292 | - case "kick": |
3293 | - return_if_fail (args.length > 2); |
3294 | - backend.send_kick (args[1], string.joinv (" ", args[2:-1])); |
3295 | - break; |
3296 | - |
3297 | - case "ignore": |
3298 | - return_if_fail (args.length > 1); |
3299 | - server.backend.send_ignore (string.joinv (" ", args[1:-1])); |
3300 | - break; |
3301 | - |
3302 | - case "unignore": |
3303 | - return_if_fail (args.length > 1); |
3304 | - server.backend.send_unignore (string.joinv (" ", args[1:-1])); |
3305 | - break; |
3306 | - |
3307 | - case "msg": |
3308 | - return_if_fail (args.length > 2); |
3309 | - server.backend.send_message (args[1], string.joinv (" ", args[2:-1])); |
3310 | - break; |
3311 | - |
3312 | - case "notice": |
3313 | - return_if_fail (args.length > 2); |
3314 | - server.backend.send_notice (args[1], string.joinv (" ", args[2:-1])); |
3315 | - break; |
3316 | - |
3317 | - case "away": |
3318 | - if (args.length < 2) |
3319 | - server.backend.send_back (); |
3320 | - else |
3321 | - server.backend.send_away (string.joinv (" ", args[1:-1])); |
3322 | - break; |
3323 | - |
3324 | - default: |
3325 | - server.backend.send_raw (command); |
3326 | - break; |
3327 | - } |
3328 | - } |
3329 | -} |
3330 | |
3331 | === removed file 'src/Controller/PrivateChat.vala' |
3332 | --- src/Controller/PrivateChat.vala 2013-09-27 16:37:41 +0000 |
3333 | +++ src/Controller/PrivateChat.vala 1970-01-01 00:00:00 +0000 |
3334 | @@ -1,85 +0,0 @@ |
3335 | -/*** |
3336 | - Copyright (C) 2013 Cable Developers |
3337 | - |
3338 | - This program or library is free software; you can redistribute it |
3339 | - and/or modify it under the terms of the GNU Lesser General Public |
3340 | - License as published by the Free Software Foundation; either |
3341 | - version 3 of the License, or (at your option) any later version. |
3342 | - |
3343 | - This library is distributed in the hope that it will be useful, |
3344 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
3345 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3346 | - Lesser General Public License for more details. |
3347 | - |
3348 | - You should have received a copy of the GNU Lesser General |
3349 | - Public License along with this library; if not, write to the |
3350 | - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
3351 | - Boston, MA 02110-1301 USA. |
3352 | -***/ |
3353 | - |
3354 | -public class Cable.Controller.PrivateChat : GLib.Object { |
3355 | - |
3356 | - public weak Server server; |
3357 | - public View.PrivateChat view; |
3358 | - string id; |
3359 | - |
3360 | - public PrivateChat (Server server, string id, string message = "") { |
3361 | - this.id = id; |
3362 | - this.server = server; |
3363 | - |
3364 | - server.view.add_private_chat (id, id); |
3365 | - view = server.view.get_chat (id) as View.PrivateChat; |
3366 | - view.nick = server.nick; |
3367 | - |
3368 | - if (message != "") |
3369 | - display_message_and_notify (id, server.nick, message); |
3370 | - |
3371 | - connect_signals (); |
3372 | - } |
3373 | - |
3374 | - void connect_signals () { |
3375 | - server.backend.event_message.connect (display_message_and_notify); |
3376 | - view.send_message.connect (send_message_and_display); |
3377 | - server.window.view.selected.connect (clear_unread_messages); |
3378 | - } |
3379 | - |
3380 | - void display_message_and_notify (string from, string target, string message) { |
3381 | - if (is_not_me (target)) |
3382 | - return; |
3383 | - |
3384 | - if (is_not_correspondent (from)) |
3385 | - return; |
3386 | - |
3387 | - var nick_from = from.split ("!")[0]; |
3388 | - |
3389 | - view.message (nick_from, message); |
3390 | - |
3391 | - if (view.has_focus == false) { |
3392 | - Services.Notify.send (nick_from, message); |
3393 | - Services.Launcher.jobs++; |
3394 | - Services.Launcher.urgent = true; |
3395 | - } |
3396 | - |
3397 | - if (server.window.view.current_chat != view) |
3398 | - view.unread_messages++; |
3399 | - } |
3400 | - |
3401 | - void send_message_and_display (string message) { |
3402 | - server.backend.send_message (id.split("!")[0], message); |
3403 | - view.message (server.nick, message); |
3404 | - view.entry = ""; |
3405 | - } |
3406 | - |
3407 | - void clear_unread_messages (View.Chat chat) { |
3408 | - if (chat == view) |
3409 | - view.unread_messages = 0; |
3410 | - } |
3411 | - |
3412 | - bool is_not_me (string nick) { |
3413 | - return nick != server.nick; |
3414 | - } |
3415 | - |
3416 | - bool is_not_correspondent (string from) { |
3417 | - return from.split ("!")[0] != id; |
3418 | - } |
3419 | -} |
3420 | |
3421 | === removed file 'src/Controller/Server.vala' |
3422 | --- src/Controller/Server.vala 2013-09-28 12:37:00 +0000 |
3423 | +++ src/Controller/Server.vala 1970-01-01 00:00:00 +0000 |
3424 | @@ -1,109 +0,0 @@ |
3425 | -/*** |
3426 | - Copyright (C) 2013 Cable Developers |
3427 | - |
3428 | - This program or library is free software; you can redistribute it |
3429 | - and/or modify it under the terms of the GNU Lesser General Public |
3430 | - License as published by the Free Software Foundation; either |
3431 | - version 3 of the License, or (at your option) any later version. |
3432 | - |
3433 | - This library is distributed in the hope that it will be useful, |
3434 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
3435 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3436 | - Lesser General Public License for more details. |
3437 | - |
3438 | - You should have received a copy of the GNU Lesser General |
3439 | - Public License along with this library; if not, write to the |
3440 | - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
3441 | - Boston, MA 02110-1301 USA. |
3442 | -***/ |
3443 | - |
3444 | -public class Cable.Controller.Server : GLib.Object { |
3445 | - |
3446 | - public weak Window window; |
3447 | - public View.Server view; |
3448 | - public Port.Irc.Server backend; |
3449 | - |
3450 | - public string nick; // FIXME not reliable |
3451 | - public string address; // FIXME not reliable |
3452 | - public string name; |
3453 | - |
3454 | - public Gee.HashMap <string, Channel> channels { |
3455 | - get; set; default = new Gee.HashMap <string, Channel> (); |
3456 | - } |
3457 | - |
3458 | - public Gee.HashMap <string, PrivateChat> private_chats { |
3459 | - get; set; default = new Gee.HashMap <string, PrivateChat> (); |
3460 | - } |
3461 | - |
3462 | - public Server (string address, string nick, Window window) { |
3463 | - this.backend = window.backend.get_or_create_server (address, nick); |
3464 | - |
3465 | - this.name = backend.name; |
3466 | - this.window = window; |
3467 | - this.nick = nick; |
3468 | - this.address = address; |
3469 | - |
3470 | - if (!backend.connected) |
3471 | - backend.send_connect (); |
3472 | - |
3473 | - this.view = window.view.add_server (@"$(backend.address) - $(nick)", backend.name); |
3474 | - |
3475 | - connect_frontend_signals (); |
3476 | - connect_backend_signals (); |
3477 | - } |
3478 | - |
3479 | - void connect_frontend_signals () { |
3480 | - view.toggle_away.connect (() => { |
3481 | - if (backend.away) { |
3482 | - backend.send_back (); |
3483 | - } else { |
3484 | - backend.send_away (); |
3485 | - } |
3486 | - }); |
3487 | - |
3488 | - view.part_all.connect (() => { |
3489 | - foreach (var channel in channels.values) |
3490 | - channel.backend.send_part (); |
3491 | - }); |
3492 | - } |
3493 | - |
3494 | - void connect_backend_signals () { |
3495 | - backend.event_user_away.connect ((from, away) => { |
3496 | - if (backend.is_me (from)) { |
3497 | - view.away = away; |
3498 | - } |
3499 | - |
3500 | - var nick = from.split("!")[0]; |
3501 | - |
3502 | - foreach (var channel in channels.values) |
3503 | - if ( nick in channel.backend.nicks ) |
3504 | - channel.view.set_away_status (nick, away); |
3505 | - }); |
3506 | - |
3507 | - backend.event_quit.connect ((from, message) => { |
3508 | - var nick = from.split ("!")[0]; |
3509 | - |
3510 | - foreach (var channel in channels.values) |
3511 | - channel.view.remove_user (nick, message); |
3512 | - }); |
3513 | - |
3514 | - backend.event_message.connect ((from, target, message) => { |
3515 | - if (target != nick) |
3516 | - return; |
3517 | - |
3518 | - var from_nick = from.split ("!")[0]; |
3519 | - |
3520 | - open_new_chat_with (from_nick, message); |
3521 | - }); |
3522 | - } |
3523 | - |
3524 | - public void open_new_chat_with (string from_nick, string message = "") { |
3525 | - if (from_nick == backend.nick) |
3526 | - return; |
3527 | - |
3528 | - if (!private_chats.has_key (from_nick)) { |
3529 | - var chat = new PrivateChat (this, from_nick, message); |
3530 | - private_chats [from_nick] = chat; |
3531 | - } |
3532 | - } |
3533 | -} |
3534 | |
3535 | === removed file 'src/Controller/Window.vala' |
3536 | --- src/Controller/Window.vala 2013-09-28 12:37:00 +0000 |
3537 | +++ src/Controller/Window.vala 1970-01-01 00:00:00 +0000 |
3538 | @@ -1,167 +0,0 @@ |
3539 | -/*** |
3540 | - Copyright (C) 2013 Cable Developers |
3541 | - |
3542 | - This program or library is free software; you can redistribute it |
3543 | - and/or modify it under the terms of the GNU Lesser General Public |
3544 | - License as published by the Free Software Foundation; either |
3545 | - version 3 of the License, or (at your option) any later version. |
3546 | - |
3547 | - This library is distributed in the hope that it will be useful, |
3548 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
3549 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3550 | - Lesser General Public License for more details. |
3551 | - |
3552 | - You should have received a copy of the GNU Lesser General |
3553 | - Public License along with this library; if not, write to the |
3554 | - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
3555 | - Boston, MA 02110-1301 USA. |
3556 | -***/ |
3557 | - |
3558 | -public class Cable.Controller.Window : GLib.Object { |
3559 | - |
3560 | - public View.Window view { get; set; } |
3561 | - public Port.Irc.Session backend { get; construct; } |
3562 | - |
3563 | - public Gee.HashMap <string, Server> servers { |
3564 | - get; set; |
3565 | - default = new Gee.HashMap <string, Server> (); |
3566 | - } |
3567 | - |
3568 | - public Window (View.Window window, Port.Irc.Session session) { |
3569 | - GLib.Object (view: window, backend: session); |
3570 | - |
3571 | - connect_frontend_signals (); |
3572 | - connect_backend_signals (); |
3573 | - initialize (); |
3574 | - } |
3575 | - |
3576 | - // restore saved state |
3577 | - void initialize () { |
3578 | - var channels = Settings.preferences.channels; |
3579 | - |
3580 | - // check for channels from last session |
3581 | - if (channels.length > 0) { |
3582 | - foreach (var channel in channels) { |
3583 | - var parts = channel.split (":"); |
3584 | - return_if_fail (parts.length == 3); |
3585 | - join_channel (parts[0], parts[1], parts[2]); |
3586 | - } |
3587 | - } |
3588 | - |
3589 | - if (servers.size == 0) |
3590 | - view.welcome_shown = true; |
3591 | - } |
3592 | - |
3593 | - // backend events that affect the window's state |
3594 | - void connect_backend_signals () { |
3595 | - /*Irc.client.event_nick.connect ((time, server, from, nick) => { |
3596 | - var current_chat = view.current_chat; |
3597 | - var current_server = view.current_server; |
3598 | - |
3599 | - if (server == current_server.id) |
3600 | - view.title = string.join (" — ", current_chat.name, nick); |
3601 | - });*/ |
3602 | - } |
3603 | - |
3604 | - // frontend signals from the window |
3605 | - void connect_frontend_signals () { |
3606 | - view.selected.connect ((item) => { |
3607 | - if (item is View.Channel) { |
3608 | - var channel = item as View.Channel; |
3609 | - view.title = string.join (" — ", channel.name); |
3610 | - Settings.preferences.last_used_nick = channel.nick; |
3611 | - } |
3612 | - }); |
3613 | - |
3614 | - view.join.connect ((a,n,c) => { |
3615 | - join_channel (a,n,c); |
3616 | - }); |
3617 | - |
3618 | - view.remove_channel.connect (() => { |
3619 | - var channel_id = view.current_chat.id; |
3620 | - var server_id = view.current_server.id; |
3621 | - |
3622 | - if (view.current_chat == null) { |
3623 | - warning ("No channel selected, cannot leave."); |
3624 | - } else if (view.current_chat is View.Channel) { |
3625 | - part_channel (servers[server_id].channels[channel_id]); |
3626 | - } else if (view.current_chat is View.PrivateChat) { |
3627 | - var channel = servers[server_id].private_chats[channel_id]; |
3628 | - var server = channel.server; |
3629 | - server.view.remove_chat (channel.view.id); |
3630 | - server.private_chats.unset (channel.view.id); |
3631 | - |
3632 | - if (server.channels.size == 0) |
3633 | - servers.unset (server.view.id); |
3634 | - |
3635 | - if (servers.size == 0) { |
3636 | - view.title = App.TITLE; |
3637 | - view.welcome_shown = true; |
3638 | - } |
3639 | - } |
3640 | - }); |
3641 | - |
3642 | - view.add_channel.connect (() => { |
3643 | - var dialog = new Dialogs.JoinChannel (); |
3644 | - dialog.done.connect ((a,b,c) => join_channel (a.address,b.nick_name,c)); |
3645 | - dialog.show_all (); |
3646 | - }); |
3647 | - |
3648 | - view.show_preferences.connect (() => { |
3649 | - var dialog = new Dialogs.Preferences (); |
3650 | - dialog.show_all (); |
3651 | - }); |
3652 | - |
3653 | - view.close.connect (() => { |
3654 | - string[] chans = {}; |
3655 | - |
3656 | - foreach (var server in servers.values) { |
3657 | - foreach (var channel in server.channels.values) { |
3658 | - chans += string.join (":", server.address, server.nick, channel.name); |
3659 | - channel.backend.send_part (); |
3660 | - } |
3661 | - } |
3662 | - |
3663 | - Settings.preferences.channels = chans; |
3664 | - }); |
3665 | - } |
3666 | - |
3667 | - void join_channel (string address, string nick, string channel_name) { |
3668 | - Server server = null; |
3669 | - foreach (var s in servers.values) |
3670 | - if (s.address == address && s.nick == nick) |
3671 | - server = s; |
3672 | - |
3673 | - if (server == null) { |
3674 | - server = new Server (address, nick, this); |
3675 | - servers[server.backend.name] = server; |
3676 | - } |
3677 | - |
3678 | - if (server.view.has_chat (channel_name)) { |
3679 | - warning ("Channel is already joined"); |
3680 | - return; |
3681 | - } |
3682 | - |
3683 | - var channel = new Channel (server, channel_name); |
3684 | - server.channels[channel_name] = channel; |
3685 | - |
3686 | - view.current_chat = channel.view; |
3687 | - view.welcome_shown = false; |
3688 | - } |
3689 | - |
3690 | - void part_channel (Channel channel) { |
3691 | - var server = channel.server; |
3692 | - |
3693 | - channel.backend.send_part (); |
3694 | - server.view.remove_chat (channel.view.id); |
3695 | - server.channels.unset (channel.view.id); |
3696 | - |
3697 | - if (server.channels.size == 0) |
3698 | - servers.unset (server.view.id); |
3699 | - |
3700 | - if (servers.size == 0) { |
3701 | - view.title = App.TITLE; |
3702 | - view.welcome_shown = true; |
3703 | - } |
3704 | - } |
3705 | -} |
3706 | |
3707 | === added directory 'src/Controllers' |
3708 | === added file 'src/Controllers/Channel.vala' |
3709 | --- src/Controllers/Channel.vala 1970-01-01 00:00:00 +0000 |
3710 | +++ src/Controllers/Channel.vala 2013-09-29 09:56:16 +0000 |
3711 | @@ -0,0 +1,275 @@ |
3712 | +/*** |
3713 | + Copyright (C) 2013 Cable Developers |
3714 | + |
3715 | + This program or library is free software; you can redistribute it |
3716 | + and/or modify it under the terms of the GNU Lesser General Public |
3717 | + License as published by the Free Software Foundation; either |
3718 | + version 3 of the License, or (at your option) any later version. |
3719 | + |
3720 | + This library is distributed in the hope that it will be useful, |
3721 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
3722 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3723 | + Lesser General Public License for more details. |
3724 | + |
3725 | + You should have received a copy of the GNU Lesser General |
3726 | + Public License along with this library; if not, write to the |
3727 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
3728 | + Boston, MA 02110-1301 USA. |
3729 | +***/ |
3730 | + |
3731 | +public class Cable.Controller.Channel : GLib.Object { |
3732 | + |
3733 | + public weak Server server; |
3734 | + public Port.View.Channel view; |
3735 | + public Port.Irc.Channel backend; |
3736 | + |
3737 | + public string name; //TODO id |
3738 | + |
3739 | + public Channel (Server server, string name) { |
3740 | + this.server = server; |
3741 | + this.name = name; |
3742 | + |
3743 | + if (server.view.has_chat (name) == false) |
3744 | + server.view.add_channel (name, name); |
3745 | + |
3746 | + view = server.view.get_chat (name) as Port.View.Channel; |
3747 | + view.nick = server.nick; |
3748 | + backend = server.backend.get_or_create_channel (name); |
3749 | + |
3750 | + connect_frontend_signals (); |
3751 | + connect_backend_signals (); |
3752 | + |
3753 | + load_state (); |
3754 | + } |
3755 | + |
3756 | + void load_state () { |
3757 | + /*if (backend.joined) { |
3758 | + view.room.state = Widgets.Room.State.CHAT; |
3759 | + FIXME some bug in maki returns garbage here: |
3760 | + -> view.room.list_users (backend.nicks, backend.prefixes); |
3761 | + backend.event_topic (backend.topic, ""); |
3762 | + } else { |
3763 | + view.room.state = Widgets.Room.State.JOINING; |
3764 | + }*/ |
3765 | + // part and rejoin to workaround bug |
3766 | + view.state = State.JOINING; |
3767 | + |
3768 | + if (server.backend.connected == false) { |
3769 | + server.backend.event_connected.connect (() => { |
3770 | + if (backend.joined) |
3771 | + backend.send_part (); |
3772 | + backend.send_join (); |
3773 | + }); |
3774 | + } else { |
3775 | + if (backend.joined) |
3776 | + backend.send_part (); |
3777 | + backend.send_join (); |
3778 | + } |
3779 | + } |
3780 | + |
3781 | + // GUI signals |
3782 | + void connect_frontend_signals () { |
3783 | + view.part.connect (() => { |
3784 | + backend.send_part (); |
3785 | + }); |
3786 | + |
3787 | + server.window.view.selected.connect ((item) => { |
3788 | + if (item == view) |
3789 | + view.unread_messages = 0; |
3790 | + }); |
3791 | + |
3792 | + view.join.connect (() => { |
3793 | + view.state = State.JOINING; |
3794 | + backend.send_join (); |
3795 | + }); |
3796 | + |
3797 | + view.send_message.connect ((message) => { |
3798 | + if (message.has_prefix ("/")) |
3799 | + send_command (message.replace ("/", "")); |
3800 | + else |
3801 | + server.backend.send_message (name, message); |
3802 | + |
3803 | + view.entry = ""; |
3804 | + }); |
3805 | + |
3806 | + view.focused.connect (() => { |
3807 | + Services.Launcher.jobs = 0; |
3808 | + Services.Launcher.urgent = false; |
3809 | + return false; |
3810 | + }); |
3811 | + |
3812 | + view.private_chat_requested.connect ((name) => { |
3813 | + server.open_new_chat_with (name); |
3814 | + if (server.private_chats.has_key (name)) |
3815 | + server.window.view.current_chat = server.private_chats [name].view; |
3816 | + }); |
3817 | + } |
3818 | + |
3819 | + // IRC signals |
3820 | + void connect_backend_signals () { |
3821 | + backend.event_message.connect ((from, message) => { |
3822 | + if (server.window.view.current_chat != view) |
3823 | + view.unread_messages++; |
3824 | + }); |
3825 | + |
3826 | + backend.event_topic.connect ((from, topic) => { |
3827 | + view.topic = topic; |
3828 | + }); |
3829 | + |
3830 | + server.backend.event_nick.connect ((from, new_nick) => { |
3831 | + if (server.backend.is_me (from)) { |
3832 | + view.nick = new_nick; |
3833 | + } |
3834 | + |
3835 | + assert (new_nick != null); |
3836 | + |
3837 | + var name = from.split ("!")[0]; |
3838 | + |
3839 | + if (!view.has_user (name)) |
3840 | + return; |
3841 | + |
3842 | + if (name.has_prefix ("@")) |
3843 | + view.rename_user (name.replace ("@", ""), new_nick, UserType.OPERATOR); |
3844 | + else if (name.has_prefix ("+")) |
3845 | + view.rename_user (name.replace ("+", ""), new_nick, UserType.VOICED); |
3846 | + else |
3847 | + view.rename_user (name, new_nick, UserType.REGULAR); |
3848 | + }); |
3849 | + |
3850 | + backend.event_part.connect ((from, message) => { |
3851 | + if (server.backend.is_me (from)) { |
3852 | + view.state = State.NOT_JOINED; |
3853 | + } else { |
3854 | + var name = from.split ("!")[0]; |
3855 | + |
3856 | + if (name.has_prefix ("@")) |
3857 | + view.remove_user (name.replace ("@", ""), message); |
3858 | + else if (name.has_prefix ("+")) |
3859 | + view.remove_user (name.replace ("+", ""), message); |
3860 | + else |
3861 | + view.remove_user (name, message); |
3862 | + } |
3863 | + }); |
3864 | + |
3865 | + backend.event_join.connect ((from) => { |
3866 | + if (server.backend.is_me (from)) { |
3867 | + view.state = State.CHAT; |
3868 | + } else { |
3869 | + var name = from.split ("!")[0]; |
3870 | + |
3871 | + if (name.has_prefix ("@")) |
3872 | + view.add_user (name.replace ("@", ""), UserType.OPERATOR); |
3873 | + else if (name.has_prefix ("+")) |
3874 | + view.add_user (name.replace ("+", ""), UserType.VOICED); |
3875 | + else |
3876 | + view.add_user (name, UserType.REGULAR); |
3877 | + } |
3878 | + }); |
3879 | + |
3880 | + backend.event_no_such.connect (() => { |
3881 | + view.state = State.NO_SUCH; |
3882 | + }); |
3883 | + |
3884 | + backend.event_message.connect ((from, message) => { |
3885 | + var nick = from.split ("!") [0]; |
3886 | + |
3887 | + if (message.contains (server.nick)) { |
3888 | + |
3889 | + if (view.has_focus == false) { |
3890 | + Services.Notify.send (nick, message); |
3891 | + Services.Launcher.jobs++; |
3892 | + Services.Launcher.urgent = true; |
3893 | + } |
3894 | + |
3895 | + view.message (nick, message, MessageType.PING); |
3896 | + } else { |
3897 | + view.message (nick, message); |
3898 | + } |
3899 | + }); |
3900 | + |
3901 | + backend.event_action.connect ((from, message) => { |
3902 | + var nick = from.split ("!")[0]; |
3903 | + view.message ("", "* " + nick + " " + message, MessageType.ACTION); |
3904 | + }); |
3905 | + |
3906 | + backend.event_names.connect (view.list_users); |
3907 | + } |
3908 | + |
3909 | + void send_command (string command) { |
3910 | + |
3911 | + var args = command.split (" "); |
3912 | + |
3913 | + switch (args[0]) { |
3914 | + case "join": |
3915 | + return_if_fail (args.length > 1); |
3916 | + var channel_with_hash = args[1]; |
3917 | + if (channel_with_hash.slice(0, 1) != "#") { |
3918 | + channel_with_hash = "#" + args[1]; |
3919 | + } |
3920 | + var channel = new Channel (server, channel_with_hash); |
3921 | + server.channels[channel_with_hash] = channel; |
3922 | + server.window.view.current_chat = channel.view; |
3923 | + break; |
3924 | + |
3925 | + case "part": |
3926 | + backend.send_part (); |
3927 | + break; |
3928 | + |
3929 | + case "quit": |
3930 | + server.backend.send_quit (); |
3931 | + break; |
3932 | + |
3933 | + case "nick": |
3934 | + return_if_fail (args.length > 1); |
3935 | + server.backend.send_nick (args[1]); |
3936 | + break; |
3937 | + |
3938 | + case "topic": |
3939 | + return_if_fail (args.length > 1); |
3940 | + backend.send_topic (string.joinv (" ", args[1:-1])); |
3941 | + break; |
3942 | + |
3943 | + case "me": |
3944 | + case "action": |
3945 | + return_if_fail (args.length > 1); |
3946 | + backend.send_action (string.joinv (" ", args[1:-1])); |
3947 | + break; |
3948 | + |
3949 | + case "kick": |
3950 | + return_if_fail (args.length > 2); |
3951 | + backend.send_kick (args[1], string.joinv (" ", args[2:-1])); |
3952 | + break; |
3953 | + |
3954 | + case "ignore": |
3955 | + return_if_fail (args.length > 1); |
3956 | + server.backend.send_ignore (string.joinv (" ", args[1:-1])); |
3957 | + break; |
3958 | + |
3959 | + case "unignore": |
3960 | + return_if_fail (args.length > 1); |
3961 | + server.backend.send_unignore (string.joinv (" ", args[1:-1])); |
3962 | + break; |
3963 | + |
3964 | + case "msg": |
3965 | + return_if_fail (args.length > 2); |
3966 | + server.backend.send_message (args[1], string.joinv (" ", args[2:-1])); |
3967 | + break; |
3968 | + |
3969 | + case "notice": |
3970 | + return_if_fail (args.length > 2); |
3971 | + server.backend.send_notice (args[1], string.joinv (" ", args[2:-1])); |
3972 | + break; |
3973 | + |
3974 | + case "away": |
3975 | + if (args.length < 2) |
3976 | + server.backend.send_back (); |
3977 | + else |
3978 | + server.backend.send_away (string.joinv (" ", args[1:-1])); |
3979 | + break; |
3980 | + |
3981 | + default: |
3982 | + server.backend.send_raw (command); |
3983 | + break; |
3984 | + } |
3985 | + } |
3986 | +} |
3987 | |
3988 | === added file 'src/Controllers/PrivateChat.vala' |
3989 | --- src/Controllers/PrivateChat.vala 1970-01-01 00:00:00 +0000 |
3990 | +++ src/Controllers/PrivateChat.vala 2013-09-29 09:56:16 +0000 |
3991 | @@ -0,0 +1,85 @@ |
3992 | +/*** |
3993 | + Copyright (C) 2013 Cable Developers |
3994 | + |
3995 | + This program or library is free software; you can redistribute it |
3996 | + and/or modify it under the terms of the GNU Lesser General Public |
3997 | + License as published by the Free Software Foundation; either |
3998 | + version 3 of the License, or (at your option) any later version. |
3999 | + |
4000 | + This library is distributed in the hope that it will be useful, |
4001 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
4002 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4003 | + Lesser General Public License for more details. |
4004 | + |
4005 | + You should have received a copy of the GNU Lesser General |
4006 | + Public License along with this library; if not, write to the |
4007 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
4008 | + Boston, MA 02110-1301 USA. |
4009 | +***/ |
4010 | + |
4011 | +public class Cable.Controller.PrivateChat : GLib.Object { |
4012 | + |
4013 | + public weak Server server; |
4014 | + public Port.View.PrivateChat view; |
4015 | + string id; |
4016 | + |
4017 | + public PrivateChat (Server server, string id, string message = "") { |
4018 | + this.id = id; |
4019 | + this.server = server; |
4020 | + |
4021 | + server.view.add_private_chat (id, id); |
4022 | + view = server.view.get_chat (id) as Port.View.PrivateChat; |
4023 | + view.nick = server.nick; |
4024 | + |
4025 | + if (message != "") |
4026 | + display_message_and_notify (id, server.nick, message); |
4027 | + |
4028 | + connect_signals (); |
4029 | + } |
4030 | + |
4031 | + void connect_signals () { |
4032 | + server.backend.event_message.connect (display_message_and_notify); |
4033 | + view.send_message.connect (send_message_and_display); |
4034 | + server.window.view.selected.connect (clear_unread_messages); |
4035 | + } |
4036 | + |
4037 | + void display_message_and_notify (string from, string target, string message) { |
4038 | + if (is_not_me (target)) |
4039 | + return; |
4040 | + |
4041 | + if (is_not_correspondent (from)) |
4042 | + return; |
4043 | + |
4044 | + var nick_from = from.split ("!")[0]; |
4045 | + |
4046 | + view.message (nick_from, message); |
4047 | + |
4048 | + if (view.has_focus == false) { |
4049 | + Services.Notify.send (nick_from, message); |
4050 | + Services.Launcher.jobs++; |
4051 | + Services.Launcher.urgent = true; |
4052 | + } |
4053 | + |
4054 | + if (server.window.view.current_chat != view) |
4055 | + view.unread_messages++; |
4056 | + } |
4057 | + |
4058 | + void send_message_and_display (string message) { |
4059 | + server.backend.send_message (id.split("!")[0], message); |
4060 | + view.message (server.nick, message); |
4061 | + view.entry = ""; |
4062 | + } |
4063 | + |
4064 | + void clear_unread_messages (Port.View.Chat chat) { |
4065 | + if (chat == view) |
4066 | + view.unread_messages = 0; |
4067 | + } |
4068 | + |
4069 | + bool is_not_me (string nick) { |
4070 | + return nick != server.nick; |
4071 | + } |
4072 | + |
4073 | + bool is_not_correspondent (string from) { |
4074 | + return from.split ("!")[0] != id; |
4075 | + } |
4076 | +} |
4077 | |
4078 | === added file 'src/Controllers/Server.vala' |
4079 | --- src/Controllers/Server.vala 1970-01-01 00:00:00 +0000 |
4080 | +++ src/Controllers/Server.vala 2013-09-29 09:56:16 +0000 |
4081 | @@ -0,0 +1,109 @@ |
4082 | +/*** |
4083 | + Copyright (C) 2013 Cable Developers |
4084 | + |
4085 | + This program or library is free software; you can redistribute it |
4086 | + and/or modify it under the terms of the GNU Lesser General Public |
4087 | + License as published by the Free Software Foundation; either |
4088 | + version 3 of the License, or (at your option) any later version. |
4089 | + |
4090 | + This library is distributed in the hope that it will be useful, |
4091 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
4092 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4093 | + Lesser General Public License for more details. |
4094 | + |
4095 | + You should have received a copy of the GNU Lesser General |
4096 | + Public License along with this library; if not, write to the |
4097 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
4098 | + Boston, MA 02110-1301 USA. |
4099 | +***/ |
4100 | + |
4101 | +public class Cable.Controller.Server : GLib.Object { |
4102 | + |
4103 | + public weak Window window; |
4104 | + public Port.View.Server view; |
4105 | + public Port.Irc.Server backend; |
4106 | + |
4107 | + public string nick; // FIXME not reliable |
4108 | + public string address; // FIXME not reliable |
4109 | + public string name; |
4110 | + |
4111 | + public Gee.HashMap <string, Channel> channels { |
4112 | + get; set; default = new Gee.HashMap <string, Channel> (); |
4113 | + } |
4114 | + |
4115 | + public Gee.HashMap <string, PrivateChat> private_chats { |
4116 | + get; set; default = new Gee.HashMap <string, PrivateChat> (); |
4117 | + } |
4118 | + |
4119 | + public Server (string address, string nick, Window window) { |
4120 | + this.backend = window.backend.get_or_create_server (address, nick); |
4121 | + |
4122 | + this.name = backend.name; |
4123 | + this.window = window; |
4124 | + this.nick = nick; |
4125 | + this.address = address; |
4126 | + |
4127 | + if (!backend.connected) |
4128 | + backend.send_connect (); |
4129 | + |
4130 | + this.view = window.view.add_server (@"$(backend.address) - $(nick)", backend.name); |
4131 | + |
4132 | + connect_frontend_signals (); |
4133 | + connect_backend_signals (); |
4134 | + } |
4135 | + |
4136 | + void connect_frontend_signals () { |
4137 | + view.toggle_away.connect (() => { |
4138 | + if (backend.away) { |
4139 | + backend.send_back (); |
4140 | + } else { |
4141 | + backend.send_away (); |
4142 | + } |
4143 | + }); |
4144 | + |
4145 | + view.part_all.connect (() => { |
4146 | + foreach (var channel in channels.values) |
4147 | + channel.backend.send_part (); |
4148 | + }); |
4149 | + } |
4150 | + |
4151 | + void connect_backend_signals () { |
4152 | + backend.event_user_away.connect ((from, away) => { |
4153 | + if (backend.is_me (from)) { |
4154 | + view.away = away; |
4155 | + } |
4156 | + |
4157 | + var nick = from.split("!")[0]; |
4158 | + |
4159 | + foreach (var channel in channels.values) |
4160 | + if ( nick in channel.backend.nicks ) |
4161 | + channel.view.set_away_status (nick, away); |
4162 | + }); |
4163 | + |
4164 | + backend.event_quit.connect ((from, message) => { |
4165 | + var nick = from.split ("!")[0]; |
4166 | + |
4167 | + foreach (var channel in channels.values) |
4168 | + channel.view.remove_user (nick, message); |
4169 | + }); |
4170 | + |
4171 | + backend.event_message.connect ((from, target, message) => { |
4172 | + if (target != nick) |
4173 | + return; |
4174 | + |
4175 | + var from_nick = from.split ("!")[0]; |
4176 | + |
4177 | + open_new_chat_with (from_nick, message); |
4178 | + }); |
4179 | + } |
4180 | + |
4181 | + public void open_new_chat_with (string from_nick, string message = "") { |
4182 | + if (from_nick == backend.nick) |
4183 | + return; |
4184 | + |
4185 | + if (!private_chats.has_key (from_nick)) { |
4186 | + var chat = new PrivateChat (this, from_nick, message); |
4187 | + private_chats [from_nick] = chat; |
4188 | + } |
4189 | + } |
4190 | +} |
4191 | |
4192 | === added file 'src/Controllers/Window.vala' |
4193 | --- src/Controllers/Window.vala 1970-01-01 00:00:00 +0000 |
4194 | +++ src/Controllers/Window.vala 2013-09-29 09:56:16 +0000 |
4195 | @@ -0,0 +1,167 @@ |
4196 | +/*** |
4197 | + Copyright (C) 2013 Cable Developers |
4198 | + |
4199 | + This program or library is free software; you can redistribute it |
4200 | + and/or modify it under the terms of the GNU Lesser General Public |
4201 | + License as published by the Free Software Foundation; either |
4202 | + version 3 of the License, or (at your option) any later version. |
4203 | + |
4204 | + This library is distributed in the hope that it will be useful, |
4205 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
4206 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4207 | + Lesser General Public License for more details. |
4208 | + |
4209 | + You should have received a copy of the GNU Lesser General |
4210 | + Public License along with this library; if not, write to the |
4211 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
4212 | + Boston, MA 02110-1301 USA. |
4213 | +***/ |
4214 | + |
4215 | +public class Cable.Controller.Window : GLib.Object { |
4216 | + |
4217 | + public Port.View.Window view { get; set; } |
4218 | + public Port.Irc.Session backend { get; construct; } |
4219 | + |
4220 | + public Gee.HashMap <string, Server> servers { |
4221 | + get; set; |
4222 | + default = new Gee.HashMap <string, Server> (); |
4223 | + } |
4224 | + |
4225 | + public Window (Port.View.Window window, Port.Irc.Session session) { |
4226 | + GLib.Object (view: window, backend: session); |
4227 | + |
4228 | + connect_frontend_signals (); |
4229 | + connect_backend_signals (); |
4230 | + initialize (); |
4231 | + } |
4232 | + |
4233 | + // restore saved state |
4234 | + void initialize () { |
4235 | + var channels = Settings.preferences.channels; |
4236 | + |
4237 | + // check for channels from last session |
4238 | + if (channels.length > 0) { |
4239 | + foreach (var channel in channels) { |
4240 | + var parts = channel.split (":"); |
4241 | + return_if_fail (parts.length == 3); |
4242 | + join_channel (parts[0], parts[1], parts[2]); |
4243 | + } |
4244 | + } |
4245 | + |
4246 | + if (servers.size == 0) |
4247 | + view.welcome_shown = true; |
4248 | + } |
4249 | + |
4250 | + // backend events that affect the window's state |
4251 | + void connect_backend_signals () { |
4252 | + /*Irc.client.event_nick.connect ((time, server, from, nick) => { |
4253 | + var current_chat = view.current_chat; |
4254 | + var current_server = view.current_server; |
4255 | + |
4256 | + if (server == current_server.id) |
4257 | + view.title = string.join (" — ", current_chat.name, nick); |
4258 | + });*/ |
4259 | + } |
4260 | + |
4261 | + // frontend signals from the window |
4262 | + void connect_frontend_signals () { |
4263 | + view.selected.connect ((item) => { |
4264 | + if (item is Port.View.Channel) { |
4265 | + var channel = item as Port.View.Channel; |
4266 | + view.title = string.join (" — ", channel.name); |
4267 | + Settings.preferences.last_used_nick = channel.nick; |
4268 | + } |
4269 | + }); |
4270 | + |
4271 | + view.join.connect ((a,n,c) => { |
4272 | + join_channel (a,n,c); |
4273 | + }); |
4274 | + |
4275 | + view.remove_channel.connect (() => { |
4276 | + var channel_id = view.current_chat.id; |
4277 | + var server_id = view.current_server.id; |
4278 | + |
4279 | + if (view.current_chat == null) { |
4280 | + warning ("No channel selected, cannot leave."); |
4281 | + } else if (view.current_chat is Port.View.Channel) { |
4282 | + part_channel (servers[server_id].channels[channel_id]); |
4283 | + } else if (view.current_chat is Port.View.PrivateChat) { |
4284 | + var channel = servers[server_id].private_chats[channel_id]; |
4285 | + var server = channel.server; |
4286 | + server.view.remove_chat (channel.view.id); |
4287 | + server.private_chats.unset (channel.view.id); |
4288 | + |
4289 | + if (server.channels.size == 0) |
4290 | + servers.unset (server.view.id); |
4291 | + |
4292 | + if (servers.size == 0) { |
4293 | + view.title = App.TITLE; |
4294 | + view.welcome_shown = true; |
4295 | + } |
4296 | + } |
4297 | + }); |
4298 | + |
4299 | + view.add_channel.connect (() => { |
4300 | + var dialog = new Dialogs.JoinChannel (); |
4301 | + dialog.done.connect ((a,b,c) => join_channel (a.address,b.nick_name,c)); |
4302 | + dialog.show_all (); |
4303 | + }); |
4304 | + |
4305 | + view.show_preferences.connect (() => { |
4306 | + var dialog = new Dialogs.Preferences (); |
4307 | + dialog.show_all (); |
4308 | + }); |
4309 | + |
4310 | + view.close.connect (() => { |
4311 | + string[] chans = {}; |
4312 | + |
4313 | + foreach (var server in servers.values) { |
4314 | + foreach (var channel in server.channels.values) { |
4315 | + chans += string.join (":", server.address, server.nick, channel.name); |
4316 | + channel.backend.send_part (); |
4317 | + } |
4318 | + } |
4319 | + |
4320 | + Settings.preferences.channels = chans; |
4321 | + }); |
4322 | + } |
4323 | + |
4324 | + void join_channel (string address, string nick, string channel_name) { |
4325 | + Server server = null; |
4326 | + foreach (var s in servers.values) |
4327 | + if (s.address == address && s.nick == nick) |
4328 | + server = s; |
4329 | + |
4330 | + if (server == null) { |
4331 | + server = new Server (address, nick, this); |
4332 | + servers[server.backend.name] = server; |
4333 | + } |
4334 | + |
4335 | + if (server.view.has_chat (channel_name)) { |
4336 | + warning ("Channel is already joined"); |
4337 | + return; |
4338 | + } |
4339 | + |
4340 | + var channel = new Channel (server, channel_name); |
4341 | + server.channels[channel_name] = channel; |
4342 | + |
4343 | + view.current_chat = channel.view; |
4344 | + view.welcome_shown = false; |
4345 | + } |
4346 | + |
4347 | + void part_channel (Channel channel) { |
4348 | + var server = channel.server; |
4349 | + |
4350 | + channel.backend.send_part (); |
4351 | + server.view.remove_chat (channel.view.id); |
4352 | + server.channels.unset (channel.view.id); |
4353 | + |
4354 | + if (server.channels.size == 0) |
4355 | + servers.unset (server.view.id); |
4356 | + |
4357 | + if (servers.size == 0) { |
4358 | + view.title = App.TITLE; |
4359 | + view.welcome_shown = true; |
4360 | + } |
4361 | + } |
4362 | +} |
4363 | |
4364 | === modified file 'src/Dialogs/Preferences.vala' |
4365 | --- src/Dialogs/Preferences.vala 2013-09-23 17:29:15 +0000 |
4366 | +++ src/Dialogs/Preferences.vala 2013-09-29 09:56:16 +0000 |
4367 | @@ -20,14 +20,14 @@ |
4368 | namespace Cable.Dialogs { |
4369 | |
4370 | public bool identity_is_in_use (Utils.Identity identity) { |
4371 | - foreach (var server in Irc.Server.all) |
4372 | + foreach (var server in Adapter.Irc.Server.all) // FIXME |
4373 | if (server.identity == identity && server.channel_names.length > 0) |
4374 | return true; |
4375 | return false; |
4376 | } |
4377 | |
4378 | public bool network_is_in_use (Utils.Network network) { |
4379 | - foreach (var server in Irc.Server.all) |
4380 | + foreach (var server in Adapter.Irc.Server.all) // FIXME |
4381 | if (server.network == network && server.channel_names.length > 0) |
4382 | return true; |
4383 | return false; |
4384 | |
4385 | === removed directory 'src/Irc' |
4386 | === removed file 'src/Irc/Channel.vala' |
4387 | --- src/Irc/Channel.vala 2013-09-26 18:14:11 +0000 |
4388 | +++ src/Irc/Channel.vala 1970-01-01 00:00:00 +0000 |
4389 | @@ -1,279 +0,0 @@ |
4390 | -/*** |
4391 | - Copyright (C) 2013 Cable Developers |
4392 | - |
4393 | - This program or library is free software; you can redistribute it |
4394 | - and/or modify it under the terms of the GNU Lesser General Public |
4395 | - License as published by the Free Software Foundation; either |
4396 | - version 3 of the License, or (at your option) any later version. |
4397 | - |
4398 | - This library is distributed in the hope that it will be useful, |
4399 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
4400 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4401 | - Lesser General Public License for more details. |
4402 | - |
4403 | - You should have received a copy of the GNU Lesser General |
4404 | - Public License along with this library; if not, write to the |
4405 | - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
4406 | - Boston, MA 02110-1301 USA. |
4407 | -***/ |
4408 | - |
4409 | -public class Cable.Irc.Channel : GLib.Object, Port.Irc.Channel { |
4410 | - |
4411 | - public string server_name { get; private set; } |
4412 | - |
4413 | - public string name { get; set; } |
4414 | - |
4415 | - string _topic = ""; |
4416 | - public string topic { |
4417 | - get { |
4418 | - try { |
4419 | - _topic = client.channel_topic (server_name, this.name); |
4420 | - } catch (GLib.IOError error) { |
4421 | - warning (error.message); |
4422 | - } |
4423 | - |
4424 | - return _topic; |
4425 | - } |
4426 | - } |
4427 | - |
4428 | - string[] _nicks = {}; |
4429 | - public string[] nicks { |
4430 | - get { |
4431 | - try { |
4432 | - client.channel_nicks (server_name, this.name, out _nicks, out _prefixes); |
4433 | - } catch (GLib.IOError error) { |
4434 | - warning (error.message); |
4435 | - } |
4436 | - |
4437 | - return _nicks; |
4438 | - } |
4439 | - } |
4440 | - |
4441 | - string[] _prefixes = {}; |
4442 | - public string[] prefixes { |
4443 | - get { |
4444 | - try { |
4445 | - client.channel_nicks (server_name, this.name, out _nicks, out _prefixes); |
4446 | - } catch (GLib.IOError error) { |
4447 | - warning (error.message); |
4448 | - } |
4449 | - |
4450 | - return _prefixes; |
4451 | - } |
4452 | - } |
4453 | - |
4454 | - public bool joined { |
4455 | - get { |
4456 | - try { |
4457 | - return name in client.channels (server_name); |
4458 | - } catch (GLib.IOError error) { |
4459 | - warning (error.message); |
4460 | - } |
4461 | - |
4462 | - return false; |
4463 | - } |
4464 | - } |
4465 | - |
4466 | - public Channel (string channel_name, string server_name) { |
4467 | - this.name = channel_name; |
4468 | - this.server_name = server_name; |
4469 | - setup_signals (); |
4470 | - } |
4471 | - |
4472 | - /** |
4473 | - * Send a message displayed in "third person" |
4474 | - * @param message The message to be sent. |
4475 | - */ |
4476 | - public void send_action (string message) { |
4477 | - try { |
4478 | - client.action (server_name, name, message); |
4479 | - } catch (GLib.IOError error) { |
4480 | - warning (error.message); |
4481 | - } |
4482 | - } |
4483 | - |
4484 | - /** |
4485 | - * Invite a person to join this channel. |
4486 | - * @param who Nick name of the person to invite. |
4487 | - */ |
4488 | - public void send_invite (string who) { |
4489 | - try { |
4490 | - client.invite (server_name, name, who); |
4491 | - } catch (GLib.IOError error) { |
4492 | - warning (error.message); |
4493 | - } |
4494 | - } |
4495 | - |
4496 | - /** |
4497 | - * Join this channel. |
4498 | - * @param key Password to this channel. Should be "" if there is no password. |
4499 | - */ |
4500 | - public void send_join (string key = "") { |
4501 | - try { |
4502 | - client.join (server_name, name, key); |
4503 | - } catch (GLib.IOError error) { |
4504 | - warning (error.message); |
4505 | - } |
4506 | - } |
4507 | - |
4508 | - /** |
4509 | - * Kick a user from the channel. Requires operator privileges. |
4510 | - * @param who Nick name of the user to be kicked. |
4511 | - * @param message Reason why the user has been kicked. |
4512 | - */ |
4513 | - public void send_kick (string who, string message) { |
4514 | - try { |
4515 | - client.kick (server_name, name, who, message); |
4516 | - } catch (GLib.IOError error) { |
4517 | - warning (error.message); |
4518 | - } |
4519 | - } |
4520 | - |
4521 | - /** |
4522 | - * Request topic and number of users for this channel TODO move somewhere else |
4523 | - */ |
4524 | - public void send_list () { |
4525 | - try { |
4526 | - client.list (server_name, name); |
4527 | - } catch (GLib.IOError error) { |
4528 | - warning (error.message); |
4529 | - } |
4530 | - } |
4531 | - |
4532 | - /** |
4533 | - * Send a normal message in this channel. |
4534 | - * @param message The message. |
4535 | - */ |
4536 | - public void send_message (string message) { |
4537 | - try { |
4538 | - client.message (server_name, name, message); |
4539 | - } catch (GLib.IOError error) { |
4540 | - warning (error.message); |
4541 | - } |
4542 | - } |
4543 | - |
4544 | - /** |
4545 | - * Request a list of names from the channel. |
4546 | - */ |
4547 | - public void send_names () { |
4548 | - try { |
4549 | - client.names (server_name, name); |
4550 | - } catch (GLib.IOError error) { |
4551 | - warning (error.message); |
4552 | - } |
4553 | - } |
4554 | - |
4555 | - /** |
4556 | - * Leave this channel. |
4557 | - * @param message Part message to be displayed. If null it will be fetched from the identity. |
4558 | - */ |
4559 | - public void send_part (string? message = null) { |
4560 | - try { |
4561 | - client.part (server_name, name, message ?? ""); |
4562 | - } catch (GLib.IOError error) { |
4563 | - warning (error.message); |
4564 | - } |
4565 | - } |
4566 | - |
4567 | - /** |
4568 | - * Change or request the channel's topic. |
4569 | - * @param topic The new topic, or "" if you just want to query the current topic. |
4570 | - */ |
4571 | - public void send_topic (string topic = "") { |
4572 | - try { |
4573 | - client.topic (server_name, name, topic); |
4574 | - } catch (GLib.IOError error) { |
4575 | - warning (error.message); |
4576 | - } |
4577 | - } |
4578 | - |
4579 | - /** |
4580 | - * Get the channel mode for a given user. |
4581 | - * @param nick Nick name of the user. |
4582 | - */ |
4583 | - public string user_channel_mode (string nick) { |
4584 | - try { |
4585 | - return client.user_channel_mode (server_name, name, nick); |
4586 | - } catch (GLib.IOError error) { |
4587 | - warning (error.message); |
4588 | - } |
4589 | - |
4590 | - return ""; |
4591 | - } |
4592 | - |
4593 | - /** |
4594 | - * Get the channel prefix ("@", "+") of a given user. |
4595 | - * @param nick Nick name of the user. |
4596 | - */ |
4597 | - public string user_channel_prefix (string nick) { |
4598 | - try { |
4599 | - return client.user_channel_prefix (server_name, name, nick); |
4600 | - } catch (GLib.IOError error) { |
4601 | - warning (error.message); |
4602 | - } |
4603 | - |
4604 | - return ""; |
4605 | - } |
4606 | - |
4607 | - void setup_signals () { |
4608 | - client.event_action.connect ((time, server, from, target, message) => { |
4609 | - if (server == this.server_name && name == target) |
4610 | - event_action (from, message); |
4611 | - }); |
4612 | - |
4613 | - client.event_banlist.connect ((time, server, channel, mask, who, when) => { |
4614 | - if (server == this.server_name && name == channel) |
4615 | - event_banlist (mask, who, when); |
4616 | - }); |
4617 | - |
4618 | - client.event_cannot_join.connect ((time, server, channel, reason) => { |
4619 | - if (server == this.server_name && name == channel) |
4620 | - event_cannot_join (reason); |
4621 | - }); |
4622 | - |
4623 | - client.event_invite.connect ((time, server, from, channel, who) => { |
4624 | - if (server == this.server_name && name == channel) |
4625 | - event_invite (from, who); |
4626 | - }); |
4627 | - |
4628 | - client.event_join.connect ((time, server, from, channel) => { |
4629 | - if (server == this.server_name && name == channel) |
4630 | - event_join (from); |
4631 | - }); |
4632 | - |
4633 | - client.event_kick.connect ((time, server, from, channel, who, message) => { |
4634 | - if (server == this.server_name && name == channel) |
4635 | - event_kick (from, who, message); |
4636 | - }); |
4637 | - |
4638 | - client.event_list.connect ((time, server, channel, users, topic) => { |
4639 | - if (server == this.server_name && name == channel) |
4640 | - event_list (users, topic); |
4641 | - }); |
4642 | - |
4643 | - client.event_message.connect ((time, server, from, target, message) => { |
4644 | - if (server == this.server_name && name == target) |
4645 | - event_message (from, message); |
4646 | - }); |
4647 | - |
4648 | - client.event_names.connect ((time, server, channel, nicks, prefixes) => { |
4649 | - if (server == this.server_name && name == channel) |
4650 | - event_names (nicks, prefixes); |
4651 | - }); |
4652 | - |
4653 | - client.event_no_such.connect ((time, server, target, type) => { |
4654 | - if (server == this.server_name && name == target && type == "c") |
4655 | - event_no_such (); |
4656 | - }); |
4657 | - |
4658 | - client.event_part.connect ((time, server, from, channel, message) => { |
4659 | - if (server == this.server_name && name == channel) |
4660 | - event_part (from, message); |
4661 | - }); |
4662 | - |
4663 | - client.event_topic.connect ((time, server, from, channel, topic) => { |
4664 | - if (server == this.server_name && name == channel) |
4665 | - event_topic (from, topic); |
4666 | - }); |
4667 | - } |
4668 | -} |
4669 | |
4670 | === removed file 'src/Irc/Maki.vala' |
4671 | --- src/Irc/Maki.vala 2013-07-30 00:52:16 +0000 |
4672 | +++ src/Irc/Maki.vala 1970-01-01 00:00:00 +0000 |
4673 | @@ -1,278 +0,0 @@ |
4674 | -/*** |
4675 | - Copyright (C) 2013 Cable Developers |
4676 | - |
4677 | - This program or library is free software; you can redistribute it |
4678 | - and/or modify it under the terms of the GNU Lesser General Public |
4679 | - License as published by the Free Software Foundation; either |
4680 | - version 3 of the License, or (at your option) any later version. |
4681 | - |
4682 | - This library is distributed in the hope that it will be useful, |
4683 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
4684 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4685 | - Lesser General Public License for more details. |
4686 | - |
4687 | - You should have received a copy of the GNU Lesser General |
4688 | - Public License along with this library; if not, write to the |
4689 | - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
4690 | - Boston, MA 02110-1301 USA. |
4691 | -***/ |
4692 | - |
4693 | -/** |
4694 | - * This is a dbus interface to the maki daemon from the SushiIRC project. |
4695 | - * Use the methods to send requests or messages to the server and the |
4696 | - * signals to react to the server's replies. |
4697 | - */ |
4698 | -[DBus (name = "de.ikkoku.sushi", timeout = 120000)] |
4699 | -public interface Cable.Irc.Maki : GLib.Object { |
4700 | - |
4701 | - [DBus (name = "action")] |
4702 | - public abstract void action (string server, string channel, string message) throws GLib.IOError; |
4703 | - |
4704 | - [DBus (name = "away")] |
4705 | - public abstract void away (string server, string message) throws GLib.IOError; |
4706 | - |
4707 | - [DBus (name = "back")] |
4708 | - public abstract void back (string server) throws GLib.IOError; |
4709 | - |
4710 | - [DBus (name = "channel_nicks")] |
4711 | - public abstract void channel_nicks (string server, string channel, out string[] nicks, out string[] prefixes) throws GLib.IOError; |
4712 | - |
4713 | - [DBus (name = "channel_topic")] |
4714 | - public abstract string channel_topic (string server, string channel) throws GLib.IOError; |
4715 | - |
4716 | - [DBus (name = "channels")] |
4717 | - public abstract string[] channels (string server) throws GLib.IOError; |
4718 | - |
4719 | - [DBus (name = "config_get")] |
4720 | - public abstract string config_get (string group, string key) throws GLib.IOError; |
4721 | - |
4722 | - [DBus (name = "config_set")] |
4723 | - public abstract void config_set (string group, string key, string value) throws GLib.IOError; |
4724 | - |
4725 | - // connect to a server known to maki |
4726 | - [DBus (name = "connect")] |
4727 | - public abstract void connect (string server) throws GLib.IOError; |
4728 | - |
4729 | - [DBus (name = "ctcp")] |
4730 | - public abstract void ctcp (string server, string target, string message) throws GLib.IOError; |
4731 | - |
4732 | - [DBus (name = "dcc_send")] |
4733 | - public abstract void dcc_send(string server, string target, string path) throws GLib.IOError; |
4734 | - |
4735 | - [DBus (name = "dcc_sends")] |
4736 | - public abstract void dcc_sends (out uint64[] ids, out string[] servers, out string[] froms, out string[] filenames, out uint64[] sizes, out uint64[] progresses, out uint64[] speeds, out uint64[] statuses) throws GLib.IOError; |
4737 | - |
4738 | - [DBus (name = "dcc_send_accept")] |
4739 | - public abstract void dcc_send_accept (uint64 id) throws GLib.IOError; |
4740 | - |
4741 | - [DBus (name = "dcc_send_get")] |
4742 | - public abstract string dcc_send_get (uint64 id, string key) throws GLib.IOError; |
4743 | - |
4744 | - [DBus (name = "dcc_send_remove")] |
4745 | - public abstract void dcc_send_remove (uint64 id) throws GLib.IOError; |
4746 | - |
4747 | - [DBus (name = "dcc_send_resume")] |
4748 | - public abstract void dcc_send_resume (uint64 id) throws GLib.IOError; |
4749 | - |
4750 | - [DBus (name = "dcc_send_set")] |
4751 | - public abstract void dcc_send_set (uint64 id, string key, string value) throws GLib.IOError; |
4752 | - |
4753 | - [DBus (name = "ignore")] |
4754 | - public abstract void ignore (string server, string pattern) throws GLib.IOError; |
4755 | - |
4756 | - [DBus (name = "ignores")] |
4757 | - public abstract string[] ignores (string server) throws GLib.IOError; |
4758 | - |
4759 | - [DBus (name = "invite")] |
4760 | - public abstract void invite (string server, string channel, string who) throws GLib.IOError; |
4761 | - |
4762 | - [DBus (name = "join")] |
4763 | - public abstract void join (string server, string channel, string key) throws GLib.IOError; |
4764 | - |
4765 | - [DBus (name = "kick")] |
4766 | - public abstract void kick (string server, string channel, string who, string message) throws GLib.IOError; |
4767 | - |
4768 | - [DBus (name = "list")] |
4769 | - public abstract void list (string server, string channel) throws GLib.IOError; |
4770 | - |
4771 | - [DBus (name = "log")] |
4772 | - public abstract string[] log (string server, string target, uint64 lines) throws GLib.IOError; |
4773 | - |
4774 | - [DBus (name = "message")] |
4775 | - public abstract void message (string server, string target, string message) throws GLib.IOError; |
4776 | - |
4777 | - [DBus (name = "mode")] |
4778 | - public abstract void mode (string server, string target, string mode) throws GLib.IOError; |
4779 | - |
4780 | - [DBus (name = "names")] |
4781 | - public abstract void names (string server, string channel) throws GLib.IOError; |
4782 | - |
4783 | - [DBus (name = "nick")] |
4784 | - public abstract void nick (string server, string nick) throws GLib.IOError; |
4785 | - |
4786 | - [DBus (name = "nickserv")] |
4787 | - public abstract void nickserv (string server) throws GLib.IOError; |
4788 | - |
4789 | - [DBus (name = "notice")] |
4790 | - public abstract void notice (string server, string target, string message) throws GLib.IOError; |
4791 | - |
4792 | - [DBus (name = "oper")] |
4793 | - public abstract void oper (string server, string name, string password) throws GLib.IOError; |
4794 | - |
4795 | - [DBus (name = "part")] |
4796 | - public abstract void part (string server, string channel, string message) throws GLib.IOError; |
4797 | - |
4798 | - [DBus (name = "quit")] |
4799 | - public abstract void quit (string server, string message) throws GLib.IOError; |
4800 | - |
4801 | - [DBus (name = "raw")] |
4802 | - public abstract void raw (string server, string command) throws GLib.IOError; |
4803 | - |
4804 | - [DBus (name = "server_get")] |
4805 | - public abstract string server_get (string server, string group, string key) throws GLib.IOError; |
4806 | - |
4807 | - [DBus (name = "server_get_list")] |
4808 | - public abstract string[] server_get_list (string server, string group, string key) throws GLib.IOError; |
4809 | - |
4810 | - // server_list ("", "") gives a list of servers known to maki |
4811 | - [DBus (name = "server_list")] |
4812 | - public abstract string[] server_list (string server, string group) throws GLib.IOError; |
4813 | - |
4814 | - [DBus (name = "server_remove")] |
4815 | - public abstract void server_remove (string server, string group, string key) throws GLib.IOError; |
4816 | - |
4817 | - [DBus (name = "server_rename")] |
4818 | - public abstract void server_rename (string old, string new_) throws GLib.IOError; |
4819 | - |
4820 | - [DBus (name = "server_set")] |
4821 | - public abstract void server_set (string server, string group, string key, string value) throws GLib.IOError; |
4822 | - |
4823 | - [DBus (name = "server_set_list")] |
4824 | - public abstract void server_set_list (string server, string group, string key, string[] list) throws GLib.IOError; |
4825 | - |
4826 | - [DBus (name = "servers")] |
4827 | - public abstract string[] servers () throws GLib.IOError; |
4828 | - |
4829 | - [DBus (name = "shutdown")] |
4830 | - public abstract void shutdown (string message) throws GLib.IOError; |
4831 | - |
4832 | - [DBus (name = "support_chantypes")] |
4833 | - public abstract string support_chantypes (string server) throws GLib.IOError; |
4834 | - |
4835 | - [DBus (name = "support_prefix")] |
4836 | - public abstract string[] support_prefix (string server) throws GLib.IOError; |
4837 | - |
4838 | - [DBus (name = "topic")] |
4839 | - public abstract void topic (string server, string channel, string topic) throws GLib.IOError; |
4840 | - |
4841 | - [DBus (name = "unignore")] |
4842 | - public abstract void unignore (string server, string pattern) throws GLib.IOError; |
4843 | - |
4844 | - [DBus (name = "user_away")] |
4845 | - public abstract bool user_away (string server, string nick) throws GLib.IOError; |
4846 | - |
4847 | - [DBus (name = "user_channel_mode")] |
4848 | - public abstract string user_channel_mode (string server, string channel, string nick) throws GLib.IOError; |
4849 | - |
4850 | - [DBus (name = "user_channel_prefix")] |
4851 | - public abstract string user_channel_prefix (string server, string channel, string nick) throws GLib.IOError; |
4852 | - |
4853 | - [DBus (name = "user_from")] |
4854 | - public abstract string user_from (string server, string nick) throws GLib.IOError; |
4855 | - |
4856 | - [DBus (name = "version")] |
4857 | - public abstract uint64[] version () throws GLib.IOError; |
4858 | - |
4859 | - [DBus (name = "who")] |
4860 | - public abstract void who (string server, string mask, bool operators_only) throws GLib.IOError; |
4861 | - |
4862 | - [DBus (name = "whois")] |
4863 | - public abstract void whois (string server, string mask) throws GLib.IOError; |
4864 | - |
4865 | - [DBus (name = "action")] |
4866 | - public signal void event_action (int64 time, string server, string from, string target, string message); |
4867 | - |
4868 | - [DBus (name = "away")] |
4869 | - public signal void event_away (int64 time, string server); |
4870 | - |
4871 | - [DBus (name = "away_message")] |
4872 | - public signal void event_away_message (int64 time, string server, string nick, string message); |
4873 | - |
4874 | - [DBus (name = "back")] |
4875 | - public signal void event_back (int64 time, string server); |
4876 | - |
4877 | - [DBus (name = "banlist")] |
4878 | - public signal void event_banlist (int64 time, string server, string channel, string mask, string who, int64 when); |
4879 | - |
4880 | - [DBus (name = "cannot_join")] |
4881 | - public signal void event_cannot_join (int64 time, string server, string channel, string reason); |
4882 | - |
4883 | - [DBus (name = "connect")] |
4884 | - public signal void event_connect (int64 time, string server); |
4885 | - |
4886 | - [DBus (name = "connected")] |
4887 | - public signal void event_connected (int64 time, string server); |
4888 | - |
4889 | - [DBus (name = "ctcp")] |
4890 | - public signal void event_ctcp (int64 time, string server, string from, string target, string message); |
4891 | - |
4892 | - [DBus (name = "dcc_send")] |
4893 | - public signal void event_dcc_send (int64 time, string server, uint64 id, string from, string filename, uint64 size, uint64 progress, uint64 speed, uint64 status); |
4894 | - |
4895 | - [DBus (name = "error")] |
4896 | - public signal void event_error (int64 time, string server, string domain, string reason, string[] arguments); |
4897 | - |
4898 | - [DBus (name = "invite")] |
4899 | - public signal void event_invite (int64 time, string server, string from, string channel, string who); |
4900 | - |
4901 | - [DBus (name = "join")] |
4902 | - public signal void event_join (int64 time, string server, string from, string channel); |
4903 | - |
4904 | - [DBus (name = "kick")] |
4905 | - public signal void event_kick (int64 time, string server, string from, string channel, string who, string message); |
4906 | - |
4907 | - [DBus (name = "list")] |
4908 | - public signal void event_list (int64 time, string server, string channel, int64 users, string topic); |
4909 | - |
4910 | - [DBus (name = "message")] |
4911 | - public signal void event_message (int64 time, string server, string from, string target, string message); |
4912 | - |
4913 | - [DBus (name = "mode")] |
4914 | - public signal void event_mode (int64 time, string server, string from, string target, string mode, string parameter); |
4915 | - |
4916 | - [DBus (name = "motd")] |
4917 | - public signal void event_motd (int64 time, string server, string message); |
4918 | - |
4919 | - [DBus (name = "names")] |
4920 | - public signal void event_names (int64 time, string server, string channel, string[] nicks, string[] prefixes); |
4921 | - |
4922 | - [DBus (name = "nick")] |
4923 | - public signal void event_nick (int64 time, string server, string from, string new_nick); |
4924 | - |
4925 | - [DBus (name = "no_such")] |
4926 | - public signal void event_no_such (int64 time, string server, string target, string type); |
4927 | - |
4928 | - [DBus (name = "notice")] |
4929 | - public signal void event_notice (int64 time, string server, string from, string target, string message); |
4930 | - |
4931 | - [DBus (name = "oper")] |
4932 | - public signal void event_oper (int64 time, string server); |
4933 | - |
4934 | - [DBus (name = "part")] |
4935 | - public signal void event_part (int64 time, string server, string from, string channel, string message); |
4936 | - |
4937 | - [DBus (name = "quit")] |
4938 | - public signal void event_quit (int64 time, string server, string from, string message); |
4939 | - |
4940 | - [DBus (name = "shutdown")] |
4941 | - public signal void event_shutdown (int64 time); |
4942 | - |
4943 | - [DBus (name = "topic")] |
4944 | - public signal void event_topic (int64 time, string server, string from, string channel, string topic); |
4945 | - |
4946 | - [DBus (name = "user_away")] |
4947 | - public signal void event_user_away (int64 time, string server, string from, bool away); |
4948 | - |
4949 | - [DBus (name = "whois")] |
4950 | - public signal void event_whois (int64 time, string server, string nick, string message); |
4951 | -} |
4952 | |
4953 | === removed file 'src/Irc/Server.vala' |
4954 | --- src/Irc/Server.vala 2013-09-28 16:47:27 +0000 |
4955 | +++ src/Irc/Server.vala 1970-01-01 00:00:00 +0000 |
4956 | @@ -1,621 +0,0 @@ |
4957 | -/*** |
4958 | - Copyright (C) 2013 Cable Developers |
4959 | - |
4960 | - This program or library is free software; you can redistribute it |
4961 | - and/or modify it under the terms of the GNU Lesser General Public |
4962 | - License as published by the Free Software Foundation; either |
4963 | - version 3 of the License, or (at your option) any later version. |
4964 | - |
4965 | - This library is distributed in the hope that it will be useful, |
4966 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
4967 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4968 | - Lesser General Public License for more details. |
4969 | - |
4970 | - You should have received a copy of the GNU Lesser General |
4971 | - Public License along with this library; if not, write to the |
4972 | - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
4973 | - Boston, MA 02110-1301 USA. |
4974 | -***/ |
4975 | - |
4976 | -/** |
4977 | - * Cable.Irc.ServerConfig is a class that allows you to change the configuration of a server. |
4978 | - * This configuration is a normal keyfile. Possible keys are: |
4979 | - * |
4980 | - * autoconnect (should always be true) |
4981 | - * port (default, maki takes care of this) |
4982 | - * ssl (-> network) |
4983 | - * nick (-> identity) |
4984 | - * user (automatic) |
4985 | - * name (-> identity) |
4986 | - * address (-> network) |
4987 | - * nickserv (-> server, I guess...) |
4988 | - */ |
4989 | -private class Cable.Irc.ServerConfig : GLib.Object { |
4990 | - |
4991 | - // The server's name. Used by maki. |
4992 | - public string name { get; set; } |
4993 | - |
4994 | - public ServerConfig (string name) { |
4995 | - Object (name: name); |
4996 | - } |
4997 | - |
4998 | - public new string @get (string key) { |
4999 | - string result = ""; |
5000 | - |
The diff has been truncated for viewing.