~ubuntu-branches/ubuntu/saucy/gnome-shell/saucy-proposed

« back to all changes in this revision

Viewing changes to js/ui/polkitAuthenticationAgent.js

Tags: upstream-3.3.90
ImportĀ upstreamĀ versionĀ 3.3.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
const Clutter = imports.gi.Clutter;
28
28
const St = imports.gi.St;
29
29
const Pango = imports.gi.Pango;
 
30
const GLib = imports.gi.GLib;
30
31
const Gio = imports.gi.Gio;
31
32
const Mainloop = imports.mainloop;
32
33
const Polkit = imports.gi.Polkit;
35
36
const ModalDialog = imports.ui.modalDialog;
36
37
const ShellEntry = imports.ui.shellEntry;
37
38
 
38
 
function AuthenticationDialog(actionId, message, cookie, userNames) {
39
 
    this._init(actionId, message, cookie, userNames);
40
 
}
41
 
 
42
 
AuthenticationDialog.prototype = {
43
 
    __proto__: ModalDialog.ModalDialog.prototype,
 
39
const AuthenticationDialog = new Lang.Class({
 
40
    Name: 'AuthenticationDialog',
 
41
    Extends: ModalDialog.ModalDialog,
44
42
 
45
43
    _init: function(actionId, message, cookie, userNames) {
46
 
        ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'polkit-dialog' });
 
44
        this.parent({ styleClass: 'prompt-dialog' });
47
45
 
48
46
        this.actionId = actionId;
49
47
        this.message = message;
51
49
        this._wasDismissed = false;
52
50
        this._completed = false;
53
51
 
54
 
        let mainContentBox = new St.BoxLayout({ style_class: 'polkit-dialog-main-layout',
 
52
        let mainContentBox = new St.BoxLayout({ style_class: 'prompt-dialog-main-layout',
55
53
                                                vertical: false });
56
54
        this.contentLayout.add(mainContentBox,
57
55
                               { x_fill: true,
64
62
                             x_align: St.Align.END,
65
63
                             y_align: St.Align.START });
66
64
 
67
 
        let messageBox = new St.BoxLayout({ style_class: 'polkit-dialog-message-layout',
 
65
        let messageBox = new St.BoxLayout({ style_class: 'prompt-dialog-message-layout',
68
66
                                            vertical: true });
69
67
        mainContentBox.add(messageBox,
70
68
                           { y_align: St.Align.START });
71
69
 
72
 
        this._subjectLabel = new St.Label({ style_class: 'polkit-dialog-headline',
 
70
        this._subjectLabel = new St.Label({ style_class: 'prompt-dialog-headline',
73
71
                                            text: _("Authentication Required") });
74
72
 
75
73
        messageBox.add(this._subjectLabel,
76
74
                       { y_fill:  false,
77
75
                         y_align: St.Align.START });
78
76
 
79
 
        this._descriptionLabel = new St.Label({ style_class: 'polkit-dialog-description',
 
77
        this._descriptionLabel = new St.Label({ style_class: 'prompt-dialog-description',
80
78
                                                text: message });
81
79
        this._descriptionLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
82
80
        this._descriptionLabel.clutter_text.line_wrap = true;
88
86
        if (userNames.length > 1) {
89
87
            log('polkitAuthenticationAgent: Received ' + userNames.length +
90
88
                ' identities that can be used for authentication. Only ' +
91
 
                'considering the first one.');
 
89
                'considering one.');
92
90
        }
93
91
 
94
 
        let userName = userNames[0];
 
92
        let userName = GLib.get_user_name();
 
93
        if (userNames.indexOf(userName) < 0)
 
94
            userName = 'root';
 
95
        if (userNames.indexOf(userName) < 0)
 
96
            userName = userNames[0];
95
97
 
96
98
        this._user = AccountsService.UserManager.get_default().get_user(userName);
97
99
        let userRealName = this._user.get_real_name()
135
137
 
136
138
        this._passwordBox = new St.BoxLayout({ vertical: false });
137
139
        messageBox.add(this._passwordBox);
138
 
        this._passwordLabel = new St.Label(({ style_class: 'polkit-dialog-password-label' }));
 
140
        this._passwordLabel = new St.Label(({ style_class: 'prompt-dialog-password-label' }));
139
141
        this._passwordBox.add(this._passwordLabel);
140
 
        this._passwordEntry = new St.Entry({ style_class: 'polkit-dialog-password-entry',
 
142
        this._passwordEntry = new St.Entry({ style_class: 'prompt-dialog-password-entry',
141
143
                                             text: "",
142
144
                                             can_focus: true});
143
145
        ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true });
147
149
        this.setInitialKeyFocus(this._passwordEntry);
148
150
        this._passwordBox.hide();
149
151
 
150
 
        this._errorMessageLabel = new St.Label({ style_class: 'polkit-dialog-error-label' });
 
152
        this._errorMessageLabel = new St.Label({ style_class: 'prompt-dialog-error-label' });
151
153
        this._errorMessageLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
152
154
        this._errorMessageLabel.clutter_text.line_wrap = true;
153
155
        messageBox.add(this._errorMessageLabel);
154
156
        this._errorMessageLabel.hide();
155
157
 
156
 
        this._infoMessageLabel = new St.Label({ style_class: 'polkit-dialog-info-label' });
 
158
        this._infoMessageLabel = new St.Label({ style_class: 'prompt-dialog-info-label' });
157
159
        this._infoMessageLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
158
160
        this._infoMessageLabel.clutter_text.line_wrap = true;
159
161
        messageBox.add(this._infoMessageLabel);
163
165
         * infoMessage and errorMessageLabel - but it is still invisible because
164
166
         * gnome-shell.css sets the color to be transparent
165
167
         */
166
 
        this._nullMessageLabel = new St.Label({ style_class: 'polkit-dialog-null-label',
 
168
        this._nullMessageLabel = new St.Label({ style_class: 'prompt-dialog-null-label',
167
169
                                                text: 'abc'});
168
170
        this._nullMessageLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
169
171
        this._nullMessageLabel.clutter_text.line_wrap = true;
330
332
        this.close(global.get_current_time());
331
333
        this._emitDone(false, true);
332
334
    },
333
 
 
334
 
};
 
335
});
335
336
Signals.addSignalMethods(AuthenticationDialog.prototype);
336
337
 
337
 
function AuthenticationAgent() {
338
 
    this._init();
339
 
}
 
338
const AuthenticationAgent = new Lang.Class({
 
339
    Name: 'AuthenticationAgent',
340
340
 
341
 
AuthenticationAgent.prototype = {
342
341
    _init: function() {
343
342
        this._native = new Shell.PolkitAuthenticationAgent();
344
343
        this._native.connect('initiate', Lang.bind(this, this._onInitiate));
394
393
                                 Lang.bind(this,
395
394
                                           function() {
396
395
                                               this._reallyCompleteRequest(wasDismissed);
 
396
                                               return false;
397
397
                                           }));
398
398
        } else {
399
399
            this._reallyCompleteRequest(wasDismissed);
400
400
        }
401
401
    }
402
 
}
 
402
});
403
403
 
404
404
function init() {
405
405
    let agent = new AuthenticationAgent();