~jocave/checkbox/hybrid-amd-gpu-mods

« back to all changes in this revision

Viewing changes to checkbox-touch/components/CheckboxTouchApplication.qml

  • Committer: Zygmunt Krynicki
  • Date: 2013-05-17 13:54:25 UTC
  • mto: This revision was merged to the branch mainline in revision 2130.
  • Revision ID: zygmunt.krynicki@canonical.com-20130517135425-cxcenxx5t0qrtbxd
checkbox-ng: add CheckBoxNG sub-project

CheckBoxNG (or lowercase as checkbox-ng, pypi:checkbox-ng) is a clean
implementation of CheckBox on top of PlainBox. It provides a new
executable, 'checkbox' that has some of the same commands that were
previously implemented in the plainbox package.

In particular CheckBoxNG comes with the 'checkbox sru' command
(the same one as in plainbox). Later on this sub-command will be removed
from plainbox.

CheckBoxNG depends on plainbox >= 0.3

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of Checkbox
3
 
 *
4
 
 * Copyright 2014-2015 Canonical Ltd.
5
 
 *
6
 
 * Authors:
7
 
 * - Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
8
 
 * - Maciej Kisielewski <maciej.kisielewski@canonical.com>
9
 
 *
10
 
 * This program is free software; you can redistribute it and/or modify
11
 
 * it under the terms of the GNU General Public License as published by
12
 
 * the Free Software Foundation; version 3.
13
 
 *
14
 
 * This program is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU General Public License for more details.
18
 
 *
19
 
 * You should have received a copy of the GNU General Public License
20
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 
 */
22
 
 
23
 
import QtQuick 2.0
24
 
import Ubuntu.Components 1.1
25
 
import "ErrorLogic.js" as ErrorLogic
26
 
 
27
 
 
28
 
PythonObjectRef {
29
 
    id: app
30
 
    // Version of the application
31
 
    property string applicationVersion
32
 
    // Version of the plainbox library
33
 
    property string plainboxVersion
34
 
    // path to session storage directory
35
 
    property string sessionDir
36
 
 
37
 
    // Signal sent when the application becomes ready
38
 
    signal appReady();
39
 
 
40
 
    // Signal sent when a session becomes ready
41
 
    signal sessionReady()
42
 
 
43
 
    // Create a new session
44
 
    //
45
 
    // Starts session in plainbox and runs all necessary setup actions.
46
 
    // Calling this function will signal sessionReady() once it's finished
47
 
    // doing setup.
48
 
    function startSession() {
49
 
        request("start_session", [], function(result) {
50
 
            sessionDir = result['session_dir'];
51
 
            sessionReady();
52
 
        }, function(error) {
53
 
            console.error("Unable to start session: " + error);
54
 
            ErrorLogic.showError(mainView,
55
 
                                 i18n.tr("Could not start a session.  Reason:\n" + error),
56
 
                                 Qt.quit,
57
 
                                 i18n.tr("Quit"));
58
 
        });
59
 
    }
60
 
    function resumeSession(rerunLastTest, continuation) {
61
 
        request("resume_session", [rerunLastTest], function(result) {
62
 
            if (!result["session_id"]) {
63
 
                pageStack.pop();
64
 
                ErrorLogic.showError(mainView,
65
 
                                     i18n.tr("Could not resume session"),
66
 
                                     function() {
67
 
                                         startSession();
68
 
                                         return;
69
 
                                     },
70
 
                                     i18n.tr("Start new session"));
71
 
            } else {
72
 
                sessionDir = result['session_dir'];
73
 
                sessionReady();
74
 
                continuation();
75
 
            }
76
 
 
77
 
        }, function(error) {
78
 
            console.error("Unable to resume session: " + error);
79
 
        });
80
 
    }
81
 
    function clearSession(continuation) {
82
 
        request("clear_session", [], continuation, function(error) {
83
 
            console.error("Unable to clear session: " + error);
84
 
        });
85
 
    }
86
 
 
87
 
    function isSessionResumable(continuation) {
88
 
        request("is_session_resumable", [], continuation, function(error) {
89
 
            console.error("Unable to check session resumability");
90
 
        });
91
 
    }
92
 
 
93
 
    function getTestplans(continuation) {
94
 
        request("get_testplans", [], continuation, function(error) {
95
 
            console.error("Unable to get testplans");
96
 
        });
97
 
    }
98
 
    function rememberTestplan(testplan, continuation) {
99
 
        var handleResult = function(result) {
100
 
            sessionDir = result['session_dir'];
101
 
            continuation();
102
 
        }
103
 
        request("remember_testplan", [testplan], handleResult, function(error) {
104
 
            console.error("Unable to save testplan selection");
105
 
        });
106
 
    }
107
 
 
108
 
    function getCategories(continuation) {
109
 
        request("get_categories", [], continuation, function(error) {
110
 
            console.error("Unable to get categories");
111
 
        });
112
 
    }
113
 
 
114
 
    function rememberCategorySelection(categories, continuation) {
115
 
        request("remember_categories", [categories], continuation, function(error) {
116
 
            console.error("Unable to save category selection");
117
 
        });
118
 
    }
119
 
 
120
 
    function getTests(continuation) {
121
 
        request("get_available_tests", [], continuation, function(error) {
122
 
            console.error("Unable to get tests");
123
 
        });
124
 
    }
125
 
 
126
 
    function rememberTestSelection(tests, continuation) {
127
 
        request("remember_tests", [tests], continuation, function(error) {
128
 
            console.error("Unable to save test selection");
129
 
        });
130
 
    }
131
 
 
132
 
    function getNextTest(continuation) {
133
 
        request("get_next_test", [], continuation, function(error) {
134
 
            console.error("Unable to get next test");
135
 
        });
136
 
    }
137
 
 
138
 
    function registerTestResult(test, continuation) {
139
 
        request("register_test_result", [test], continuation, function(error) {
140
 
            console.error("Unable to save test result");
141
 
        });
142
 
    }
143
 
 
144
 
    function runTestActivity(test, continuation) {
145
 
        request("run_test_activity", [test], continuation, function(error) {
146
 
            console.error("Unable to run test activity");
147
 
        });
148
 
    }
149
 
 
150
 
    function getRerunCandidates(continuation) {
151
 
        request("get_rerun_candidates", [], continuation, function(error) {
152
 
            console.error("Unable to get rerun candidates");
153
 
        });
154
 
    }
155
 
 
156
 
    function getResults(continuation) {
157
 
        request("get_results", [], continuation, function(error) {
158
 
            console.error("Unable to get test results");
159
 
        });
160
 
    }
161
 
 
162
 
    function exportResults(output_format, option_list, continuation) {
163
 
        request("export_results", [output_format, option_list], continuation, function(error) {
164
 
            console.error("Unable to export test results");
165
 
        });
166
 
    }
167
 
    function submitResults(config, continuation, continuation_error) {
168
 
        // Use low-level call as the config may contain sensitive information.
169
 
        var callable = py.getattr(object, "submit_results");
170
 
        if (!callable) {
171
 
            console.error("Unable to invoke submit_results!");
172
 
            throw "trying to invoke not existing method";
173
 
        }
174
 
        py.call(callable, [config], function(response) {
175
 
            if (response.code == 200) {
176
 
                continuation(response.result);
177
 
            } else {
178
 
                continuation_error(response.error)
179
 
            }
180
 
        });
181
 
    }
182
 
    function dropPermissions(appId, services, continuation, continuation_error) {
183
 
        request("drop_permissions", [appId, services], continuation, function(error) {
184
 
            console.error("Unable to remove permissions");
185
 
            if (continuation_error) continuation_error(error);
186
 
        });
187
 
    }
188
 
    function getIncompleteSessions(continuation) {
189
 
        request("get_incomplete_sessions", [], continuation, function(error) {
190
 
            console.error("Unable to get incomplete sessions")
191
 
        });
192
 
    }
193
 
    function deleteOldSessions(sessionIds, continuation) {
194
 
        request("delete_old_sessions", [sessionIds], continuation, function(error) {
195
 
            console.error("Unable to remove old sessions")
196
 
        });
197
 
    }
198
 
 
199
 
    function rememberPassword(password, continuation) {
200
 
        // using low-level py.call() to 'silently' pass password string through pyotherside
201
 
        var callable = py.getattr(object, "remember_password");
202
 
        if (!callable) {
203
 
            console.error("Unable to invoke remember_password!");
204
 
            throw "trying to invoke not existing method";
205
 
        }
206
 
        py.call(callable, [password], function(response) {
207
 
            continuation(response);
208
 
        });
209
 
    }
210
 
 
211
 
    // A wrapper around invoke() that works with the @view decorator. The fn_ok
212
 
    // and fn_err are called on a normal reply and on error, respectively.
213
 
    function request(name, args, fn_ok, fn_err) {
214
 
        invoke(name, args, function(response) {
215
 
            if (response.code == 200) {
216
 
                fn_ok(response.result);
217
 
            } else {
218
 
                fn_err(response.error);
219
 
            }
220
 
        });
221
 
    }
222
 
 
223
 
    // Internal handler that triggers a call to python to query for runtime and
224
 
    // application versions.
225
 
    onObjectReady: {
226
 
        request("load_providers", [appSettings["providersDir"]], function(result) {
227
 
            request("get_version_pair", [], function(result) {
228
 
                app.applicationVersion = result.application_version;
229
 
                app.plainboxVersion = result.plainbox_version;
230
 
                appReady();
231
 
            }, function(error) {
232
 
                console.error("Unable to query for version: " + error);
233
 
            });
234
 
 
235
 
        }, function(error) {
236
 
                console.error("Unable to load providers: " + error);
237
 
                ErrorLogic.showError(mainView, i18n.tr("No providers available!"), Qt.quit);
238
 
        });
239
 
    }
240
 
}