on dc11045 help sign in
110 lines 3.9 kB history raw
1/*
2 * Copyright (C) 2014-2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "UsersModelPrivate.h"
18#include "UsersModel.h"
20namespace QLightDM
23UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
24 : mockMode("single")
25 , q_ptr(parent)
27 char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE");
28 if (envMockMode) {
29 mockMode = envMockMode;
30 }
31 resetEntries();
34void UsersModelPrivate::resetEntries()
36 Q_Q(UsersModel);
38 q->beginResetModel();
40 if (mockMode == "single") {
41 resetEntries_single();
42 } else if (mockMode == "single-passphrase") {
43 resetEntries_singlePassphrase();
44 } else if (mockMode == "single-pin") {
45 resetEntries_singlePin();
46 } else if (mockMode == "full") {
47 resetEntries_full();
48 }
50 // Assign uids in a loop, just to avoid having to muck with them when
51 // adding or removing test users.
52 for (int i = 0; i < entries.size(); i++) {
53 entries[i].uid = i + 1;
54 }
56 q->endResetModel();
59void UsersModelPrivate::resetEntries_single()
61 entries =
62 {
63 { "single", "Single User", 0, 0, false, false, "ubuntu", 0 },
64 };
67void UsersModelPrivate::resetEntries_singlePassphrase()
69 entries =
70 {
71 { "single", "Single User", 0, 0, false, false, "ubuntu", 0 },
72 };
75void UsersModelPrivate::resetEntries_singlePin()
77 entries =
78 {
79 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
80 };
83void UsersModelPrivate::resetEntries_full()
85 entries =
86 {
87 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },
88 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
89 { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
90 { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
91 { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
92 { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
93 { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
94 { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0 },
95 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
96 { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 },
97 { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
98 { "long-name", "Long name (far far too long to fit, seriously this would never fit on the screen, you will never see this part of the name)", 0, 0, false, false, "ubuntu", 0 },
99 { "color-background", "Color Background", "#dd4814", 0, false, false, "ubuntu", 0 },
100 // white and black are a bit redundant, but useful for manually testing if UI is still readable
101 { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
102 { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
103 { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 },
104 { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
105 { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 },
106 { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
107 };
110} // namespace QLightDM