%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/gnome-shell/
Upload File :
Create Path :
Current File : //usr/share/gnome-shell/org.gnome.Shell.Notifications.src.gresource

GVariant�(
	=E)��
v��Ե�����L�����
�L�KP�L��$0L�cF�L(l�2(L,<�R+|<vH�|I^�vJv|�JvX�'�Q�'L�'�'��'v�'�<h9!��<	v=}@dbusErrors.js5import GLib from 'gi://GLib';
import Gio from 'gi://Gio';

function camelcase(str) {
    const words = str.toLowerCase().split('_');
    return words.map(w => `${w.at(0).toUpperCase()}${w.substring(1)}`).join('');
}

function decamelcase(str) {
    return str.replace(/(.)([A-Z])/g, '$1-$2');
}

function registerErrorDomain(domain, errorEnum, prefix = 'org.gnome.Shell') {
    const domainName =
        `shell-${decamelcase(domain).toLowerCase()}-error`;
    const quark = GLib.quark_from_string(domainName);

    for (const [name, code] of Object.entries(errorEnum)) {
        Gio.dbus_error_register_error(quark,
            code, `${prefix}.${domain}.Error.${camelcase(name)}`);
    }
    return quark;
}

export const ModalDialogError = {
    UNKNOWN_TYPE: 0,
    GRAB_FAILED: 1,
};
export const ModalDialogErrors =
    registerErrorDomain('ModalDialog', ModalDialogError);

export const NotificationError = {
    INVALID_APP: 0,
};
export const NotificationErrors =
    registerErrorDomain('Notifications', NotificationError, 'org.gtk');

export const ExtensionError = {
    INFO_DOWNLOAD_FAILED: 0,
    DOWNLOAD_FAILED: 1,
    EXTRACT_FAILED: 2,
    ENABLE_FAILED: 3,
    NOT_ALLOWED: 4,
};
export const ExtensionErrors =
    registerErrorDomain('Extensions', ExtensionError);

export const ScreencastError = {
    ALL_PIPELINES_FAILED: 0,
    PIPELINE_ERROR: 1,
    SAVE_TO_DISK_DISABLED: 2,
    ALREADY_RECORDING: 3,
    RECORDER_ERROR: 4,
    SERVICE_CRASH: 5,
    OUT_OF_DISK_SPACE: 6,
};
export const ScreencastErrors =
    registerErrorDomain('Screencast', ScreencastError);
(uuay)/Notifications/org/gnome/
misc/js/	dbusUtils.js�import Gio from 'gi://Gio';
import GLib from 'gi://GLib';

import * as Config from './config.js';

let _ifaceResource = null;

/**
 * @private
 */
function _ensureIfaceResource() {
    if (_ifaceResource)
        return;

    // don't use global.datadir so the method is usable from tests/tools
    let dir = GLib.getenv('GNOME_SHELL_DATADIR') || Config.PKGDATADIR;
    let path = `${dir}/gnome-shell-dbus-interfaces.gresource`;
    _ifaceResource = Gio.Resource.load(path);
    _ifaceResource._register();
}

/**
 * @param {string} iface the interface name
 * @returns {string | null} the XML string or null if it is not found
 */
export function loadInterfaceXML(iface) {
    _ensureIfaceResource();

    let uri = `resource:///org/gnome/shell/dbus-interfaces/${iface}.xml`;
    let f = Gio.File.new_for_uri(uri);

    try {
        let [ok_, bytes] = f.load_contents(null);
        return new TextDecoder().decode(bytes);
    } catch (e) {
        log(`Failed to load D-Bus interface ${iface}`);
    }

    return null;
}

/**
 * @param {string} iface the interface name
 * @param {string} ifaceFile the interface filename
 * @returns {string | null} the XML string or null if it is not found
 */
export function loadSubInterfaceXML(iface, ifaceFile) {
    let xml = loadInterfaceXML(ifaceFile);
    if (!xml)
        return null;

    let ifaceStartTag = `<interface name="${iface}">`;
    let ifaceStopTag = '</interface>';
    let ifaceStartIndex = xml.indexOf(ifaceStartTag);
    let ifaceEndIndex = xml.indexOf(ifaceStopTag, ifaceStartIndex + 1) + ifaceStopTag.length;

    let xmlHeader = '<!DOCTYPE node PUBLIC\n' +
        '\'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\'\n' +
        '\'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\'>\n' +
        '<node>\n';
    let xmlFooter = '</node>';

    return (
        xmlHeader +
        xml.substr(ifaceStartIndex, ifaceEndIndex - ifaceStartIndex) +
        xmlFooter);
}
(uuay)main.js2import {DBusService} from './dbusService.js';
import {NotificationDaemon} from './notificationDaemon.js';

/** @returns {void} */
export async function main() {
    const service = new DBusService(
        'org.gnome.Shell.Notifications',
        new NotificationDaemon());
    await service.runAsync();
}
(uuay)dbusService.jsOimport Gio from 'gi://Gio';
import GLib from 'gi://GLib';

import {programArgs} from 'system';

import './misc/dbusErrors.js';

const Signals = imports.signals;

const IDLE_SHUTDOWN_TIME = 2; // s

export class ServiceImplementation {
    constructor(info, objectPath) {
        this._objectPath = objectPath;
        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(info, this);

        this._injectTracking('return_dbus_error');
        this._injectTracking('return_error_literal');
        this._injectTracking('return_gerror');
        this._injectTracking('return_value');
        this._injectTracking('return_value_with_unix_fd_list');

        this._senders = new Map();
        this._holdCount = 0;

        this._shellName = this._getUniqueShellName();

        this._hasSignals = this._dbusImpl.get_info().signals.length > 0;
        this._shutdownTimeoutId = 0;

        // subclasses may override this to disable automatic shutdown
        this._autoShutdown = true;

        this._queueShutdownCheck();
    }

    // subclasses may override this to own additional names
    register() {
    }

    export() {
        this._dbusImpl.export(Gio.DBus.session, this._objectPath);
    }

    unexport() {
        this._dbusImpl.unexport();
    }

    hold() {
        this._holdCount++;
    }

    release() {
        if (this._holdCount === 0) {
            logError(new Error('Unmatched call to release()'));
            return;
        }

        this._holdCount--;

        if (this._holdCount === 0)
            this._queueShutdownCheck();
    }

    /**
     * Complete @invocation with an appropriate error if @error is set;
     * useful for implementing early returns from method implementations.
     *
     * @param {Gio.DBusMethodInvocation}
     * @param {Error}
     *
     * @returns {bool} - true if @invocation was completed
     */

    _handleError(invocation, error) {
        if (error === null)
            return false;

        if (error instanceof GLib.Error) {
            Gio.DBusError.strip_remote_error(error);
            invocation.return_gerror(error);
        } else {
            let name = error.name;
            if (!name.includes('.')) // likely a normal JS error
                name = `org.gnome.gjs.JSError.${name}`;
            invocation.return_dbus_error(name, error.message);
        }

        return true;
    }

    _maybeShutdown() {
        if (!this._autoShutdown)
            return;

        if (GLib.getenv('SHELL_DBUS_PERSIST'))
            return;

        if (this._holdCount > 0)
            return;

        this.emit('shutdown');
    }

    _queueShutdownCheck() {
        if (this._shutdownTimeoutId)
            GLib.source_remove(this._shutdownTimeoutId);

        this._shutdownTimeoutId = GLib.timeout_add_seconds(
            GLib.PRIORITY_DEFAULT, IDLE_SHUTDOWN_TIME,
            () => {
                this._shutdownTimeoutId = 0;
                this._maybeShutdown();

                return GLib.SOURCE_REMOVE;
            });
    }

    _trackSender(sender) {
        if (this._senders.has(sender))
            return;

        if (sender === this._shellName)
            return; // don't track the shell

        this.hold();
        this._senders.set(sender,
            this._dbusImpl.get_connection().watch_name(
                sender,
                Gio.BusNameWatcherFlags.NONE,
                null,
                () => this._untrackSender(sender)));
    }

    _untrackSender(sender) {
        const id = this._senders.get(sender);

        if (id)
            this._dbusImpl.get_connection().unwatch_name(id);

        if (this._senders.delete(sender))
            this.release();
    }

    _injectTracking(methodName) {
        const {prototype} = Gio.DBusMethodInvocation;
        const origMethod = prototype[methodName];
        const that = this;

        prototype[methodName] = function (...args) {
            origMethod.apply(this, args);

            if (that._hasSignals)
                that._trackSender(this.get_sender());

            that._queueShutdownCheck();
        };
    }

    _getUniqueShellName() {
        try {
            const res = Gio.DBus.session.call_sync(
                'org.freedesktop.DBus',
                '/org/freedesktop/DBus',
                'org.freedesktop.DBus',
                'GetNameOwner',
                new GLib.Variant('(s)', ['org.gnome.Shell']),
                null,
                Gio.DBusCallFlags.NONE,
                -1,
                null);
            const [name] = res.deepUnpack();
            return name;
        } catch (e) {
            console.warn(`Failed to resolve shell name: ${e.message}`);
            return '';
        }
    }
}
Signals.addSignalMethods(ServiceImplementation.prototype);

export class DBusService {
    constructor(name, service) {
        this._name = name;
        this._service = service;
        this._loop = new GLib.MainLoop(null, false);

        this._service.connect('shutdown', () => this._loop.quit());
    }

    async runAsync() {
        // Bail out when not running under gnome-shell
        Gio.DBus.watch_name(Gio.BusType.SESSION,
            'org.gnome.Shell',
            Gio.BusNameWatcherFlags.NONE,
            null,
            () => this._loop.quit());

        this._service.register();

        let flags = Gio.BusNameOwnerFlags.ALLOW_REPLACEMENT;
        if (programArgs.includes('--replace'))
            flags |= Gio.BusNameOwnerFlags.REPLACE;

        Gio.DBus.own_name(Gio.BusType.SESSION,
            this._name,
            flags,
            () => this._service.export(),
            null,
            () => this._loop.quit());

        await this._loop.runAsync();
    }
}
(uuay)Shell/notificationDaemon.js
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';

import {ServiceImplementation} from './dbusService.js';

import {loadInterfaceXML} from './misc/dbusUtils.js';

const NotificationsIface = loadInterfaceXML('org.freedesktop.Notifications');
const NotificationsProxy = Gio.DBusProxy.makeProxyWrapper(NotificationsIface);

Gio._promisify(Gio.DBusConnection.prototype, 'call');

export const NotificationDaemon = class extends ServiceImplementation {
    constructor() {
        super(NotificationsIface, '/org/freedesktop/Notifications');

        this._autoShutdown = false;

        this._activeNotifications = new Map();

        this._proxy = new NotificationsProxy(Gio.DBus.session,
            'org.gnome.Shell',
            '/org/freedesktop/Notifications',
            (proxy, error) => {
                if (error)
                    log(error.message);
            });

        this._proxy.connectSignal('ActivationToken',
            (proxy, sender, params) => {
                const [id] = params;
                this._emitSignal(
                    this._activeNotifications.get(id),
                    'ActivationToken',
                    new GLib.Variant('(us)', params));
            });
        this._proxy.connectSignal('ActionInvoked',
            (proxy, sender, params) => {
                const [id] = params;
                this._emitSignal(
                    this._activeNotifications.get(id),
                    'ActionInvoked',
                    new GLib.Variant('(us)', params));
            });
        this._proxy.connectSignal('NotificationClosed',
            (proxy, sender, params) => {
                const [id] = params;
                this._emitSignal(
                    this._activeNotifications.get(id),
                    'NotificationClosed',
                    new GLib.Variant('(uu)', params));
                this._activeNotifications.delete(id);
            });
    }

    _emitSignal(sender, signalName, params) {
        if (!sender)
            return;
        this._dbusImpl.get_connection()?.emit_signal(
            sender,
            this._dbusImpl.get_object_path(),
            'org.freedesktop.Notifications',
            signalName,
            params);
    }

    _untrackSender(sender) {
        super._untrackSender(sender);

        this._activeNotifications.forEach((value, key) => {
            if (value === sender)
                this._activeNotifications.delete(key);
        });
    }

    _checkNotificationId(invocation, id) {
        if (id === 0)
            return true;

        if (!this._activeNotifications.has(id))
            return true;

        if (this._activeNotifications.get(id) === invocation.get_sender())
            return true;

        const error = new GLib.Error(Gio.DBusError,
            Gio.DBusError.INVALID_ARGS, 'Invalid notification ID');
        this._handleError(invocation, error);
        return false;
    }

    register() {
        Gio.DBus.session.own_name(
            'org.freedesktop.Notifications',
            Gio.BusNameOwnerFlags.REPLACE,
            null, null);
    }

    async NotifyAsync(params, invocation) {
        const sender = invocation.get_sender();
        const pid = await this._getSenderPid(sender);
        const replaceId = params[1];
        const hints = params[6];

        if (!this._checkNotificationId(invocation, replaceId))
            return;

        params[6] = {
            ...hints,
            'x-shell-sender-pid': new GLib.Variant('u', pid),
            'x-shell-sender': new GLib.Variant('s', sender),
        };

        try {
            const [id] = await this._proxy.NotifyAsync(...params);
            this._activeNotifications.set(id, sender);
            invocation.return_value(new GLib.Variant('(u)', [id]));
        } catch (error) {
            this._handleError(invocation, error);
        }
    }

    async CloseNotificationAsync(params, invocation) {
        const [id] = params;
        if (!this._checkNotificationId(invocation, id))
            return;

        try {
            await this._proxy.CloseNotificationAsync(...params);
            invocation.return_value(null);
        } catch (error) {
            this._handleError(invocation, error);
        }
    }

    async GetCapabilitiesAsync(params, invocation) {
        try {
            const res = await this._proxy.GetCapabilitiesAsync(...params);
            invocation.return_value(new GLib.Variant('(as)', res));
        } catch (error) {
            this._handleError(invocation, error);
        }
    }

    async GetServerInformationAsync(params, invocation) {
        try {
            const res = await this._proxy.GetServerInformationAsync(...params);
            invocation.return_value(new GLib.Variant('(ssss)', res));
        } catch (error) {
            this._handleError(invocation, error);
        }
    }

    async _getSenderPid(sender) {
        const res = await Gio.DBus.session.call(
            'org.freedesktop.DBus',
            '/',
            'org.freedesktop.DBus',
            'GetConnectionUnixProcessID',
            new GLib.Variant('(s)', [sender]),
            new GLib.VariantType('(u)'),
            Gio.DBusCallFlags.NONE,
            -1,
            null);
        const [pid] = res.deepUnpack();
        return pid;
    }
};
(uuay)config.jse// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const pkg = imports.package;

/* The name of this package (not localized) */
export const PACKAGE_NAME = 'gnome-shell';
/* The version of this package */
export const PACKAGE_VERSION = '46.0';
/* 1 if networkmanager is available, 0 otherwise */
export const HAVE_NETWORKMANAGER = 1;
/* 1 if portal helper is enabled, 0 otherwise */
export const HAVE_PORTAL_HELPER = 0;
/* gettext package */
export const GETTEXT_PACKAGE = 'gnome-shell';
/* locale dir */
export const LOCALEDIR = '/usr/share/locale';
/* other standard directories */
export const LIBEXECDIR = '/usr/libexec';
export const PKGDATADIR = '/usr/share/gnome-shell';
/* g-i package versions */
export const LIBMUTTER_API_VERSION = '14';

export const HAVE_BLUETOOTH = pkg.checkSymbol('GnomeBluetooth', '3.0',
    'Client.default_adapter_state');
(uuay)

Zerion Mini Shell 1.0