Merge lp:~philip.scott/capnet-assist/debug-arguments into lp:~elementary-apps/capnet-assist/trunk

Proposed by Felipe Escoto
Status: Merged
Approved by: Danielle Foré
Approved revision: 96
Merged at revision: 96
Proposed branch: lp:~philip.scott/capnet-assist/debug-arguments
Merge into: lp:~elementary-apps/capnet-assist/trunk
Prerequisite: lp:~philip.scott/capnet-assist/capnet-app-uniqueness
Diff against target: 74 lines (+31/-5)
2 files modified
src/Application.vala (+29/-3)
src/CaptiveLogin.vala (+2/-2)
To merge this branch: bzr merge lp:~philip.scott/capnet-assist/debug-arguments
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+305263@code.launchpad.net

Commit message

Add debug arguments

Description of the change

adds --url and --force-window for debugging purposes

To post a comment you must log in.
96. By Felipe Escoto

Add debug arguments

Revision history for this message
Danielle Foré (danrabbit) wrote :

works for me :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Application.vala'
2--- src/Application.vala 2016-09-08 19:32:04 +0000
3+++ src/Application.vala 2016-09-08 19:32:04 +0000
4@@ -18,9 +18,11 @@
5 */
6
7 public class Captive.Application : Gtk.Application {
8+ private bool force_show = false;
9+ private string? debug_url = null;
10
11 public Application () {
12- Object (application_id: "org.pantheon.captive-login");
13+ Object (application_id: "org.pantheon.captive-login", flags: ApplicationFlags.HANDLES_COMMAND_LINE);
14 }
15
16 public override void activate () {
17@@ -28,9 +30,9 @@
18 mark_busy ();
19
20 var browser = new ValaBrowser (this);
21- if (browser.is_captive_portal ()) {
22+ if (browser.is_captive_portal () || force_show) {
23 debug ("Opening browser to login");
24- browser.start ();
25+ browser.start (debug_url);
26 } else {
27 debug ("Already logged in and connected, or no internet connection. Shutting down.");
28 quit ();
29@@ -38,6 +40,30 @@
30 }
31 }
32
33+ public override int command_line (ApplicationCommandLine command_line) {
34+ OptionEntry[] options = new OptionEntry[2];
35+ options[0] = { "force-window", 'f', 0, OptionArg.NONE, ref force_show, "Force the browser window to appear", null };
36+ options[1] = { "url", 'u', 0, OptionArg.STRING, ref debug_url, "Load the folowing URL on the browser window", "URL" };
37+
38+ string[] args = command_line.get_arguments ();
39+
40+ try {
41+ var opt_context = new OptionContext ("- OptionContext example");
42+ opt_context.set_help_enabled (true);
43+ opt_context.add_main_entries (options, null);
44+ unowned string[] tmp = args;
45+ opt_context.parse (ref tmp);
46+ } catch (OptionError e) {
47+ command_line.print ("error: %s\n", e.message);
48+ command_line.print ("Run '%s --help' to see a full list of available command line options.\n", args[0]);
49+ return -1;
50+ }
51+
52+ activate ();
53+
54+ return 0;
55+ }
56+
57 public static int main (string[] args) {
58 Environment.set_application_name (Constants.APP_NAME);
59 Environment.set_prgname (Constants.APP_NAME);
60
61=== modified file 'src/CaptiveLogin.vala'
62--- src/CaptiveLogin.vala 2016-09-08 19:32:04 +0000
63+++ src/CaptiveLogin.vala 2016-09-08 19:32:04 +0000
64@@ -331,8 +331,8 @@
65 });
66 }
67
68- public void start () {
69+ public void start (string? browser_url) {
70 show_all ();
71- web_view.load_uri (ValaBrowser.DUMMY_URL);
72+ web_view.load_uri (browser_url ?? ValaBrowser.DUMMY_URL);
73 }
74 }

Subscribers

People subscribed via source and target branches

to all changes: