Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Not compatible with GNOME 43 #181

Closed
scottbeamer opened this issue Sep 16, 2022 · 12 comments · Fixed by #177
Closed

[BUG] Not compatible with GNOME 43 #181

scottbeamer opened this issue Sep 16, 2022 · 12 comments · Fixed by #177

Comments

@scottbeamer
Copy link

I'm running GNOME 43 beta. The final release is out on September 21. Could you update this extension to work with GNOME 43 at your earliest convenience? Thank you.

This was referenced Sep 17, 2022
@neffo
Copy link
Owner

neffo commented Sep 17, 2022

Similar to #180, this is breaking as GNOME 43 uses Soup 3 (for fetching www data) which is materially different from Soup 2. Thanks for reporting I am currently looking into it.

@neffo neffo linked a pull request Sep 17, 2022 that will close this issue
10 tasks
@neffo neffo changed the title [BUG] Not comatible with GNOME 43. [BUG] Not compatible with GNOME 43 Sep 17, 2022
@kflihan
Copy link

kflihan commented Sep 17, 2022

Hi,
I tried upgrading the soup code to soup-3 and its working for me now, and getting the new images from site.
hope this help :)

changes to utils.js

removed this line:
var BingImageURL = 'https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=8&mbl=1&mkt=';

adding those lines:
var BingImageURL = 'https://www.bing.com/HPImageArchive.aspx';
var BingParams = { format: 'js', idx: '0' , n: '8' , mbl: '1' , mkt: '' } ;

===============

changes to extension.js updated both _refresh & _downloadImage :


    _refresh() {
        if (this._updatePending)
            return;
        this._updatePending = true;
        this._restartTimeout();
        let market = this._settings.get_string('market');
        // create an http message
        let session = new Soup.Session();
        let url = BingImageURL ;
        log('fetching: ' + url);

        let params = Utils.BingParams;
        params['mkt'] = ( market != 'auto' ? market : '' ) ;
        log('-----------params: ' + JSON.stringify(params));

        let message = Soup.Message.new_from_encoded_form(
            'GET',
            url  ,   
            Soup.form_encode_hash(params)
            );

        session.send_and_read_async(
            message,
            GLib.PRIORITY_DEFAULT,
            null,
            (session, result) => {
                if (message.status_code === Soup.Status.OK) {
                    let bytes = session.send_and_read_finish(result);
                    console.log(`bytes: ${bytes}`);

                    let decoder = new TextDecoder('utf-8');
                    let data = decoder.decode(bytes.get_data());

                    console.log(`data: ${data}`);
                    log('Recieved ' + data.length + ' bytes');
                    this._parseData(data);
                    if (this.selected_image != 'random')
                         this._selectImage();
                } else if (message.status_code == 403) {
                    log('Access denied: ' + message.status_code);
                    this._updatePending = false;
                    this._restartTimeout(TIMEOUT_SECONDS_ON_HTTP_ERROR);
                } else {
                    log('Network error occured: ' + message.status_code);
                    this._updatePending = false;
                    this._restartTimeout(TIMEOUT_SECONDS_ON_HTTP_ERROR);
                }

            }
        );       

    }





_downloadImage(url, file) {
    let session = new Soup.Session();
    let message = Soup.Message.new(
        'GET',
        url     
        );  
    session.send_and_read_async(
        message,
        GLib.PRIORITY_DEFAULT,
        null,
        (session, result) =>  {
            // request completed
            this._updatePending = false;
            let bytes = session.send_and_read_finish(result);
            console.log(`bytes: ${bytes}`);
            let data = bytes.get_data();
           console.log(`status_code: ${message.status_code}`);
            if (message.status_code == 200) {
                file.replace_contents_bytes_async(
                    data,
                null,
                false,
                Gio.FileCreateFlags.REPLACE_DESTINATION,
                null,
                (file, res) => {
                        try {
                            file.replace_contents_finish(res);
                            this._setBackground();
                            log('Download successful');
                        } catch(e) {
                            log('Error writing file: ' + e);
                        }
                    }
                )  ;
            } else {
            log('Couldn\'t fetch image from ' + url);
            file.delete(null);
        }
         });
}
    

@neffo
Copy link
Owner

neffo commented Sep 17, 2022

Thanks heaps @kflihan , very helpful. I've implemented some of the above code in #177 (extension version 42). It's not quite as clean as I'm still trying to retain support for GNOME Shell versions < 43. (I also cleaned up your post to help me read it :))

@neffo
Copy link
Owner

neffo commented Sep 18, 2022

Ok, I have a working version in the test branch 'version 42' now. Very fiddly... the documentation for Soup 3 doesn't reflect what works in GJS. Should be possible to push this before GNOME 43 is released.

@kflihan
Copy link

kflihan commented Sep 18, 2022

thanks,
I'm testing 'version 42' under Fedora 37 Beta (Wayland session), I had to add support to Gnome "43.rc" to metadata.json.

@kode54
Copy link
Contributor

kode54 commented Sep 20, 2022

Attempted testing this on the Gnome 43 which is in the gnome-unstable Arch custom repository, but attempting to refresh the wallpaper locks up that option indefinitely, and disables all of the menu entries normally disabled while the extension is busy. I even turned on debug logging, but I don't know where it's logging to, because version 42 isn't emitting anything into the system journal.

@neffo
Copy link
Owner

neffo commented Sep 20, 2022

Hmm, I can't test that myself (unless there are ISOs I can boot in a VM, but doesn't look like it). It's possible it's failing that early it's not emitting any messages itself. However GNOME itself should output errors, something like this:
image

Can you post a screenshot or so I can better understand? Like what is the menu doing as well? (And thanks for the report @kode54)

@kode54
Copy link
Contributor

kode54 commented Sep 20, 2022

Sep 19 21:05:01 mrgency gnome-shell[1264006]: BingWallpaper extension: next check in 86400 seconds @ local time 2022-09-20 21:05 -0700
Sep 19 21:05:01 mrgency gnome-shell[1264006]: BingWallpaper extension: unable to send libsoup json message ReferenceError: message is not defined
Sep 20 00:49:20 mrgency gnome-shell[1475732]: BingWallpaper extension: next check in 86400 seconds @ local time 2022-09-21 00:49 -0700
Sep 20 00:49:20 mrgency gnome-shell[1475732]: BingWallpaper extension: unable to send libsoup json message ReferenceError: message is not defined

I also get the following if I open the Settings:

Sep 20 00:57:37 mrgency gjs[1497806]: JS WARNING: [/home/chris/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/prefs.js 10]: Requiring Soup but it has 2 versions available; use imports.gi.versions to pick one
Sep 20 00:57:37 mrgency org.gnome.Shell.Extensions[1497806]: BingWallpaper extension: create carousel...

@kode54
Copy link
Contributor

kode54 commented Sep 20, 2022

Oh, I get it. You made a transposition error with the code for libsoup3, and replaced the first parameter to send_and_read_async, which should be request, with message, which is a parameter to the callback you're passing to it for response handling. Oops.

@kode54
Copy link
Contributor

kode54 commented Sep 20, 2022

Oh, never mind, I misread. You forgot to also declare message like the above snippet does for libsoup3.

@kode54
Copy link
Contributor

kode54 commented Sep 20, 2022

There we go, I got it working. Only missed two days worth of wallpapers.

@neffo
Copy link
Owner

neffo commented Sep 20, 2022

FYI, if you hit the back button, you can download up to a week of Bing wallpapers (if you missed them). And thanks for PR, testing GNOME 43 is a pain as I can use VM on my desktop atm. I didn't realise I broke something.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants