Merge lp:~robru/libfriends/valadoc into lp:libfriends

Proposed by Robert Bruce Park
Status: Merged
Merged at revision: 27
Proposed branch: lp:~robru/libfriends/valadoc
Merge into: lp:libfriends
Diff against target: 757 lines (+263/-131)
6 files modified
gtk/account.vala (+84/-20)
gtk/accounts.vala (+0/-6)
gtk/entry.vala (+70/-35)
src/service.vala (+93/-62)
src/urlshorten.vala (+7/-3)
src/utils.vala (+9/-5)
To merge this branch: bzr merge lp:~robru/libfriends/valadoc
Reviewer Review Type Date Requested Status
Ken VanDine Pending
Review via email: mp+141997@code.launchpad.net

Description of the change

Ok, writing this all out was easier than I thought it was gonna be ;-)

Some of the vala constructors looked a little bit weird to me so you should definitely have a look at this and see if you can't chime in with extra info where you feel stuff is missing. But I'd say it's 90% done.

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

This mp also contains a bunch of whitespace cleanup, because you suck at indenting things properly :-P

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gtk/account.vala'
2--- gtk/account.vala 2012-12-10 18:06:49 +0000
3+++ gtk/account.vala 2013-01-05 00:43:20 +0000
4@@ -18,34 +18,86 @@
5 */
6
7
8+ /**
9+ * This is a thin wrapper around {@link Ag.Account}.
10+ *
11+ * @since 0.1
12+ */
13 class FriendsAccount : GLib.Object {
14 private Ag.Account _account = null;
15- [Description(id = "Friends account id", blurb = "This is id Friends uses to identify the account")]
16+
17+ /**
18+ * String that uniquely identifies the account. It takes the
19+ * form of '#/protocol', where # is the {@link Ag.Account.id}
20+ * and protocol is the lowercase name of the social network
21+ * that the account is from. Possible values include
22+ * '6/facebook' or '2/twitter'. The number on it's own is
23+ * unique (so you'd never see '1/twitter' and '1/facebook' on
24+ * the same system), but we do support registering multiple
25+ * accounts per protocol, so finding '1/twitter', '2/twitter',
26+ * and '3/twitter' is perfectly acceptable.
27+ *
28+ * @since 0.1
29+ */
30 public string id {
31 get { return unique_id; }
32 }
33- [Description(username = "username associated with an account", blurb = "This is the account's username assigned by the service")]
34+
35+ /**
36+ * This is the username that the social network uses to
37+ * identify the user. For example on twitter, this is the name
38+ * that people use to @mention you in their tweets.
39+ *
40+ * @since 0.1
41+ */
42 public string username {
43 get { return _account.get_display_name(); }
44 }
45+
46+ /**
47+ * This is the bare name of the protocol. Possible values are
48+ * ``facebook``, ``foursquare``, ``flickr``, ``identica``, and
49+ * ``twitter``.
50+ *
51+ * @since 0.1
52+ */
53 public string service {
54 get { return _account.get_provider_name(); }
55 }
56
57+ /**
58+ * A single, solid color used to represent the given protocol.
59+ * This is stored as a familiar HTML style hex triplet, in the
60+ * form of 'RRGGBB'.
61+ *
62+ * @since 0.1
63+ */
64 private string _color;
65- public string color {
66+ public string color {
67 get {
68 GLib.Value t = "";
69 _account.get_value("friends/color", ref t);
70 _color = t.get_string();
71 return _color;
72 }
73- set {
74+ set {
75 GLib.Value t = value;
76- _account.set_value("friends/color", t);
77+ _account.set_value("friends/color", t);
78 _account.store_blocking();
79 }
80 }
81+
82+ /**
83+ * Controls whether this account should be included in the
84+ * global ``send_message`` call. If you want to send a
85+ * particular message to some, but not all accounts, you can
86+ * use this to effectively 'disable' the account.
87+ *
88+ * Set to the string "1" to enable and the string "0" to disable.
89+ *
90+ * @since 0.1
91+ * @see toggle_send_enabled
92+ */
93 private string? _send_enabled;
94 public string? send_enabled {
95 get {
96@@ -61,7 +113,7 @@
97 _send_enabled = "0";
98 return _send_enabled;
99 }
100- set {
101+ set {
102 GLib.Value t = false;
103 if (value == "1")
104 t = true;
105@@ -73,20 +125,31 @@
106 private Ag.AccountService account_service;
107 private string unique_id;
108
109- /**
110- FriendsAccount::updated:
111-
112- Emitted when the account has changed
113- */
114+ /**
115+ * Emitted when the account has changed, most useful for being
116+ * notified of changes to {@link send_enabled}.
117+ *
118+ * @since 0.1
119+ */
120 public signal void updated();
121
122- /**
123- FriendsAccount::deleted:
124-
125- Emitted when the account has been deleted
126- */
127+ /**
128+ * Emitted when the account has been deleted. This happens
129+ * when the user deletes the account from the Ubuntu Online
130+ * Accounts screen.
131+ *
132+ * @since 0.1
133+ */
134 public signal void deleted();
135
136+ /**
137+ * Construct a new FriendsAccount object.
138+ *
139+ * @params account_service The {@link Ag.AccountService}
140+ * object that our FriendsAccount will be wrapping.
141+ *
142+ * @since 0.1
143+ */
144 public FriendsAccount (Ag.AccountService account_service) {
145 this.account_service = account_service;
146 _account = account_service.get_account();
147@@ -103,10 +166,11 @@
148 }
149
150 /**
151- toggle_send_enabled:
152-
153- Toggle the value of send_enabled for the account.
154- */
155+ * Toggle the value of send_enabled for the account.
156+ *
157+ * @since 0.1
158+ * @see send_enabled
159+ */
160 public void toggle_send_enabled()
161 {
162 if (send_enabled == "1")
163
164=== modified file 'gtk/accounts.vala'
165--- gtk/accounts.vala 2012-12-07 22:01:20 +0000
166+++ gtk/accounts.vala 2013-01-05 00:43:20 +0000
167@@ -23,12 +23,6 @@
168 {
169 private Ag.Manager manager;
170
171- /**
172- FriendsAccounts::created:
173- @arg0: HashTable of an account
174-
175- Emitted when an account has changed
176- */
177 internal signal void created(FriendsAccount account);
178
179 internal FriendsAccounts()
180
181=== modified file 'gtk/entry.vala'
182--- gtk/entry.vala 2013-01-04 22:19:27 +0000
183+++ gtk/entry.vala 2013-01-05 00:43:20 +0000
184@@ -23,16 +23,18 @@
185 {
186 public static const int MAX_MESSAGE_LENGTH = 140;
187
188- /**
189- * Widget that displays an entry which posts status updates to your
190- * social network accounts using friends-service. The entry includes
191- * a text entry, character count, and account selection buttons.
192- */
193+ /**
194+ * Widget that displays an entry which posts status updates to your
195+ * social network accounts using friends-service. The entry includes
196+ * a text entry, character count, and account selection buttons.
197+ *
198+ * @since 0.1
199+ */
200 public class Entry : Gtk.Box
201 {
202- /**
203- * {@link Friends.Service}
204- */
205+ /**
206+ * {@link Friends.Service}
207+ */
208 private Friends.Service service;
209
210 public InputTextView text_view;
211@@ -63,15 +65,26 @@
212 var spacer = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
213 add_with_properties (spacer, "padding", 2, "expand", false);
214
215- text_view.get_buffer ().changed.connect (() =>
216+ text_view.get_buffer ().changed.connect (() =>
217 {
218 target_bar.set_counter(text_view.get_buffer ().get_char_count ());
219 });
220 }
221 }
222
223+ /**
224+ * Widget that displays an entry which posts status updates to
225+ * your social network accounts using friends-service. The entry
226+ * is very simple and does not include any of the frills of {@link
227+ * FriendsGtk.Entry}.
228+ *
229+ * @since 0.1
230+ */
231 public class SimpleEntry : Gtk.Box
232 {
233+ /**
234+ * {@link Friends.Service}
235+ */
236 private Friends.Service service;
237
238 private InputTextView text_view;
239@@ -85,7 +98,7 @@
240 construct
241 {
242 service = new Friends.Service ();
243-
244+
245 text_view = new InputTextView (service);
246 send_bar = new SendBar ();
247 add (text_view);
248@@ -96,11 +109,18 @@
249 text_view.submit ();});
250 }
251
252-
253 }
254
255+ /**
256+ * Just the text box.
257+ *
258+ * @since 0.1
259+ */
260 public class InputTextView : Gtk.TextView
261 {
262+ /**
263+ * {@link Friends.Service}
264+ */
265 private Friends.Service service;
266 private Friends.URLShorten urlshorten;
267
268@@ -188,7 +208,7 @@
269 [Signal (action=true)]
270 public virtual signal void clear() {
271 buffer.set_text("");
272- }
273+ }
274
275 [Signal (action=true)]
276 public virtual signal void submit () {
277@@ -213,9 +233,9 @@
278 }
279
280 private void on_connection_changed (bool is_connected)
281- {
282- set_sensitive(is_connected);
283- }
284+ {
285+ set_sensitive(is_connected);
286+ }
287
288 private void on_text_changed ()
289 {
290@@ -244,10 +264,17 @@
291 }
292 }
293
294+ /**
295+ * This toggle button toggles an individual account on or off.
296+ *
297+ * @since 0.1
298+ */
299 public class AccountToggleButton : Gtk.ToggleButton
300 {
301 /**
302- * color used to differentiate accounts
303+ * The color is used to differentiate accounts.
304+ *
305+ * @since 0.1
306 */
307 public string color { get; construct;}
308 public AccountToggleButton (string color)
309@@ -260,7 +287,7 @@
310 set_size_request (24, 24);
311 }
312
313- internal override bool draw (Cairo.Context context)
314+ internal override bool draw (Cairo.Context context)
315 {
316 double factor = 0.3;
317
318@@ -278,7 +305,7 @@
319
320 Gtk.Allocation a;
321 get_allocation (out a);
322-
323+
324 Gdk.RGBA c = Gdk.RGBA ();
325 c.red = 1.0f;
326 c.green = 1.0f;
327@@ -291,9 +318,9 @@
328 context.rectangle (a.width - 2, a.height - 6, 2, 6);
329 context.rectangle (a.width - 6, a.height - 2, 6, 2);
330 context.fill ();
331-
332+
333 propagate_draw (get_child (), context);
334-
335+
336 context.pop_group_to_source ();
337 context.paint_with_alpha (factor);
338
339@@ -301,13 +328,20 @@
340 }
341 }
342
343+ /**
344+ * The target bar displays a row of {@link AccountToggleButton}s
345+ * to allow the user to choose which accounts to send the message
346+ * to.
347+ *
348+ * @since 0.1
349+ */
350 public class AccountTargetBar : Gtk.Box
351 {
352 private Friends.Service service;
353 private FriendsAccounts accounts_service;
354 private Gtk.Button send;
355 private Gtk.Label count;
356- private Gee.HashMap<string,AccountToggleButton> accounts_buttons_map;
357+ private Gee.HashMap<string,AccountToggleButton> accounts_buttons_map;
358 private Gtk.Box abox;
359 private string _selected = null;
360
361@@ -336,7 +370,7 @@
362 }
363 accounts_buttons_map[_selected].show_all ();
364 }
365- } else
366+ } else
367 {
368 foreach (var k in accounts_buttons_map.keys)
369 accounts_buttons_map[k].sensitive = true;
370@@ -370,7 +404,7 @@
371 accounts_buttons_map = new Gee.HashMap<string,AccountToggleButton> ();
372
373 var accounts_list = accounts_service.list ();
374-
375+
376 abox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
377 abox.set_homogeneous (true);
378 box.pack_start (abox, false, false, 0);
379@@ -411,15 +445,15 @@
380 account_created(accounts_buttons_map, source);});
381 }
382
383- /**
384- * Signal emitted when submitted to the service
385- */
386+ /**
387+ * Signal emitted when submitted to the service.
388+ */
389 public signal void submit ();
390
391 private AccountToggleButton create_button (FriendsAccount account)
392- {
393+ {
394 Gtk.Image icon_service = new Gtk.Image.from_icon_name(account.service, Gtk.IconSize.MENU);
395-
396+
397 icon_service.show();
398 AccountToggleButton account_button = new AccountToggleButton(account.color);
399 account_button.set_active((account.send_enabled == "1")?true:false);
400@@ -459,13 +493,13 @@
401
402 private void on_account_toggled(AccountToggleButton account_button, FriendsAccount account) {
403
404- if (((account.send_enabled == "1")?true:false) != (account_button.get_active()))
405+ if (((account.send_enabled == "1")?true:false) != (account_button.get_active()))
406 {
407 account.toggle_send_enabled();
408 }
409 }
410
411- private void account_updated(Gee.HashMap<string,AccountToggleButton> accounts_buttons_map, FriendsAccount account)
412+ private void account_updated(Gee.HashMap<string,AccountToggleButton> accounts_buttons_map, FriendsAccount account)
413 {
414 if (!accounts_buttons_map.has_key(account.id))
415 return;
416@@ -475,7 +509,7 @@
417 } else {
418 account_button.tooltip_text = (account.service + " (" + account.username + ")");
419 }
420- if (((account.send_enabled == "1")?true:false) != (account_button.get_active())) {
421+ if (((account.send_enabled == "1")?true:false) != (account_button.get_active())) {
422 account_button.set_active((account.send_enabled == "1")?true:false);
423 }
424 }
425@@ -503,7 +537,7 @@
426
427 private void on_connection_changed (bool is_connected) {
428 send.set_sensitive(is_connected);
429- }
430+ }
431 }
432
433 public class SendBar : Gtk.Box
434@@ -525,9 +559,10 @@
435 box.pack_end(send, false, false, 0);
436 add(box);
437 }
438- /**
439- * Signal emitted when submitted to the service
440- */
441+
442+ /**
443+ * Signal emitted when submitted to the service.
444+ */
445 public signal void submit ();
446 }
447 }
448
449=== modified file 'src/service.vala'
450--- src/service.vala 2013-01-04 17:04:59 +0000
451+++ src/service.vala 2013-01-05 00:43:20 +0000
452@@ -46,24 +46,12 @@
453
454 private ServiceInterface service;
455
456- /**
457- Service::is_available:
458- @arg0: The current state
459-
460- Emitted when com.canonical.Friends.Service availability state changes
461- */
462 public signal void is_available(bool is_up);
463
464- /**
465- Service::connection_changed:
466- @arg0: The current state
467-
468- Emitted when network connection state changes
469- */
470 public signal void connection_changed(bool is_online);
471
472 /**
473- * Create a new Service
474+ * Establish a connection to the local Friends Service daemon.
475 */
476 public Service ()
477 {
478@@ -82,16 +70,19 @@
479 }
480 }
481
482- public void service_available(bool is_up)
483- {
484- is_available(is_up);
485- }
486+ public void service_available(bool is_up)
487+ {
488+ is_available(is_up);
489+ }
490
491 /**
492- quit:
493-
494- Tells the friends service to shutdown.
495- */
496+ * Shut down the Friends Service.
497+ *
498+ * You probably shouldn't use this. It causes the whole daemon
499+ * to exit, preventing any other clients from accessing it.
500+ *
501+ * @since 0.1
502+ */
503 public void quit()
504 {
505 try {
506@@ -102,10 +93,10 @@
507 }
508
509 /**
510- refresh:
511-
512- Tells the friends service to perform a refresh.
513- */
514+ * Perform a refresh of all enabled accounts.
515+ *
516+ * @since 0.1
517+ */
518 public void refresh()
519 {
520 try {
521@@ -116,11 +107,18 @@
522 }
523
524 /**
525- do:
526- @action: The action (like, unlike, retweet)
527- @account_id: The account to post from
528- @message_id: The friends message ID
529- */
530+ * Perform any arbitrary action on an individual account. This
531+ * is the primary interface for triggering likes, unlikes,
532+ * etc.
533+ *
534+ * @param action The action to perform, such as 'like',
535+ * 'unlike', 'retweet', etc.
536+ * @param account_id The {@link Ag.Account.id} to post from.
537+ * @param message_id The ID of the message to be liked/unliked/etc.
538+ *
539+ * @since 0.1
540+ * @see features
541+ */
542 public bool do(string action, string account_id, string message_id)
543 {
544 try {
545@@ -134,13 +132,17 @@
546 }
547
548 /**
549- * Upload an image to the specified account_id
550- *
551- * @param account_id The {@link Ag.Account.id} to post from
552- * @param uri local or remote URI to a file to upload
553- * @param description description to include in the post
554- *
555- * @since 0.1
556+ * Upload an image to the specified account_id.
557+ *
558+ * Currently this is only supported on Facebook, but we plan to
559+ * support other protocols soon.
560+ *
561+ * @param account_id The {@link Ag.Account.id} to post from.
562+ * @param uri Local or remote URI of a file to upload.
563+ * @param description Description or caption to include for the
564+ * uploaded photo.
565+ *
566+ * @since 0.1
567 */
568 public bool upload(string account_id, string uri, string description)
569 {
570@@ -157,13 +159,15 @@
571 /**
572 * Upload an image to the specified account_id, asynchronously.
573 *
574- * @param account_id The {@link Ag.Account.id} to post from
575- * @param uri local or remote URI to a file
576- * @param description description to include in the post
577- * @param result_url URL returned in the upload
578- *
579- * @since 0.1
580- * @throws GLib.IOError if uploading the image failed
581+ * @param account_id The {@link Ag.Account.id} to post from.
582+ * @param uri Local or remote URI of a file to upload.
583+ * @param description Description or caption to include for the
584+ * uploaded photo.
585+ * @param result_url The destintion URL of the successfully
586+ * uploaded file.
587+ *
588+ * @since 0.1
589+ * @throws GLib.IOError if uploading the image failed.
590 */
591 public async bool upload_async(string account_id, string uri, string description, out string result_url) throws IOError
592 {
593@@ -179,13 +183,20 @@
594
595
596 /**
597- send_reply:
598- @message: The message to post to Friends
599- @account_id: The account to post from
600- @message_id: The friends message ID
601-
602- Reply or comment on a post
603- */
604+ * Reply to an existing message.
605+ *
606+ * Note that twitter will require you to @mention the name of
607+ * the person you are replying to in order for it to appear
608+ * correctly as a reply. Otherwise, the message will post
609+ * successfully but it will simply appear as a normal message,
610+ * without any conversation threading.
611+ *
612+ * @param message The text of the reply that you want to send.
613+ * @param account_id The {@link Ag.Account.id} to post from.
614+ * @param message_id The ID of the message that you are replying to.
615+ *
616+ * @since 0.1
617+ */
618 public bool send_reply(string message, string account_id, string message_id)
619 {
620 try {
621@@ -200,12 +211,13 @@
622
623
624 /**
625- send_message:
626- @account_id: The account_id to use or null
627- @message: The message to post to Friends
628-
629- Posts a message
630- */
631+ * Write a public message to the specified account.
632+ *
633+ * @param account_id The {@link Ag.Account.id} to post from.
634+ * @param message The text of the message to post publicly.
635+ *
636+ * @since 0.1
637+ */
638 public bool send_message(string? account_id, string message)
639 {
640 try {
641@@ -221,6 +233,20 @@
642 return false;
643 }
644
645+ /**
646+ * This method returns a list of all the possible actions
647+ * supported by a given protocol. This can be used to
648+ * determine what actions can be triggered by the ``do``
649+ * method, although do is not capable of triggering all
650+ * methods returned by this function. Anything that ``do`` isn't
651+ * capable of will have it's own special method for invoking.
652+ *
653+ * @param protocol One of ``facebook``, ``flickr``,
654+ * ``foursquare``, ``identica``, or ``twitter``.
655+ *
656+ * @since 0.1
657+ * @see do
658+ */
659 public string[] features(string protocol)
660 {
661 string[] _features = null;
662@@ -234,13 +260,13 @@
663 warning(e.message);
664 }
665 return _features;
666- }
667+ }
668
669 /**
670- version:
671-
672- Return value: the version of the Gwibber service that is running.
673- */
674+ * Identify the version of Friends Service that is running.
675+ *
676+ * @since 0.1
677+ */
678 public string version()
679 {
680 try {
681@@ -251,6 +277,11 @@
682 return "";
683 }
684
685+ /**
686+ * Clear all notifications from the messaging menu.
687+ *
688+ * @since 0.1
689+ */
690 public void messaging_menu_clear()
691 {
692 try {
693
694=== modified file 'src/urlshorten.vala'
695--- src/urlshorten.vala 2012-12-10 20:46:09 +0000
696+++ src/urlshorten.vala 2013-01-05 00:43:20 +0000
697@@ -48,8 +48,12 @@
698
699
700 /**
701- * com.Friends.URLShorten
702- **/
703+ * Pass any URL to this method and it will shorten it for you.
704+ *
705+ * @param url The long URL you need shortened.
706+ *
707+ * @since 0.1
708+ */
709 public string shorten(string url)
710 {
711 try
712@@ -61,6 +65,6 @@
713 warning (e.message);
714 return "Failed";
715 }
716- }
717+ }
718 }
719 }
720
721=== modified file 'src/utils.vala'
722--- src/utils.vala 2012-12-10 19:21:22 +0000
723+++ src/utils.vala 2013-01-05 00:43:20 +0000
724@@ -27,9 +27,9 @@
725 }
726
727 /**
728- create_time_string:
729- @time: The timestamp as a string
730- */
731+ * Convert the timestamp into a string ending in 'ago'.
732+ * @param time The timestamp as a string.
733+ */
734 public string create_time_string(string t)
735 {
736 string nt = t + "ZZ";
737@@ -50,6 +50,12 @@
738 return ngettext("%i day ago", "%i days ago", (int) d/86400).printf(d/86400);
739 }
740
741+ /**
742+ * Locally cache avatar URLs; if the given URL is already
743+ * cached, then the path to the cached file is returned. If
744+ * the file is missing from the cache, it attempts to download
745+ * the file and cache it.
746+ */
747 public string? get_avatar_path(string url)
748 {
749 string _avatar_cache_image = Path.build_path (Path.DIR_SEPARATOR_S, Environment.get_user_cache_dir(), "friends/avatars", GLib.Checksum.compute_for_string (GLib.ChecksumType.SHA1, url));
750@@ -60,7 +66,5 @@
751 else
752 return null;
753 }
754-
755 }
756 }
757-

Subscribers

People subscribed via source and target branches