Coder Social home page Coder Social logo

Comments (25)

Dax89 avatar Dax89 commented on August 31, 2024

I will try to do it for the version 0.8.7 :)

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

Now it is possible to open links with WebPirate using the link that you have provided (https://together.jolla.com/question/1836/set-default-browser)

I have investigated in order to open a new tab when the browser is already opened: the default browser creates a D-Bus service with an "openUrl" method (the name can be seen in open-url.desktop)

I have managed to create a service for WebPirate too, and I have modified open-url.desktop so it points to the WebPirate's one, but it doesn't works (I don't know why), calling it manually, when the browser is opened, works correctly and opens a new tab with the requested url.

I will close this issue when the browser can load links even if it is already opened.

from webpirate.

MoritzJT avatar MoritzJT commented on August 31, 2024

Is there any progresss on this?

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

It's a Sailfish issue, I can't do anything atm.
The only workaround available is that one linked in this issue!

from webpirate.

Mikaela avatar Mikaela commented on August 31, 2024

I have done the workaround, but it appears that there is another issue:

If Webpirate is already open and there is only one tab (more not tested) and you click a link in another application WebPirate is opened, but nothing more happens. I think it should open a new tab including whatever link was clicked.

I think this might be #7 (comment) in less technical words.

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

It's a known issue, and it is related to the default browser issue in Sailfish.

In order to open a new tab, WebPirate needs a DBus service, this one is present in the source code, but is disabled (and untested from about 10 releases) because it is not allowed in the harbour.

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

I have news about this issue!

The commit ce0bded restores DBus service and it's only running when WebPirate is active (it seems to be allowed in the harbour, because Tweetian does the same thing), but, now the problem is different:

Case 1 (edit harbour-webpirate.desktop)

MimeType=text/html;x-maemo-urischeme/http;x-maemo-urischeme/https;

works as always: executing WebPirate instead of Sailfish Browser BUT it does not open new tabs.

Case 2 (edit open-url.desktop)

# MimeType=text/html;x-maemo-urischeme/http;x-maemo-urischeme/https;

# X-Maemo-Service=org.sailfishos.browser
# X-Maemo-Method=org.sailfishos.browser.openUrl
X-Maemo-Service=org.harbour.webpirate
X-Maemo-Method=org.harbour.webpirate.openUrl

If WebPirate is running it creates a new tab BUT when an external link is clicked from another application and the browser is NOT running, nothing happens.

I have tried to do Case 1 + Case 2, but Saiflish fallbacks to Case 1.
I'll leave this service active in 1.5 (IF it passes the validation!) so anyone is free to make tests!

from webpirate.

Mikaela avatar Mikaela commented on August 31, 2024

Is there something preventing the line in harbour-webpirate.desktop from being uncommented by default (something in harbour submission rules?)? Currently I must always remember to edit the file after updating Web Pirate.

(Also what is the proper spelling for Web Pirate? I think I change how I spell/write/type it a lot.)

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

Yes, it's about harbour restrictions!

(Also what is the proper spelling for Web Pirate? I think I change how I spell/write/type it a lot.)

It's ok "WebPirate" and "Web Pirate" too :D

from webpirate.

benaryorg avatar benaryorg commented on August 31, 2024

If this is fixed, feel free to close this issue.

from webpirate.

Mikaela avatar Mikaela commented on August 31, 2024

It's not, because that one line must always be uncommented after update (even if I am unsure can anything be done to it) and new tabs cannot be opened from external applications if Web Pirate is already open (it only opens Web Pirate with whatever tab you have active).

from webpirate.

llelectronics avatar llelectronics commented on August 31, 2024

I think the dbus solution works fine for WebPirate if it would have a "daemon" like dbus service running waiting in the background to start WebPirate even if the UI part is closed.
This is exactly how Sailfish-Browser does it. The booster-browser is basically listening all the time to the dbus requests.

from webpirate.

llelectronics avatar llelectronics commented on August 31, 2024

I have to correct me there. Actually the booster-browser has nothing todo with the dbus calls. Its just a form of preloading the browser libraries for faster startup times.
What actually is needed is simply a dbus service file describing the dbus service and which file to execute if the service call is made but the application itself is not opened (so basically when WebPirate is closed)
I was able to make it run just like sailfish-browser with my latest commit in Webcat.
See: llelectronics/webcat@c09911b
This commit is a bit messy and big as I basically copied over your dbus receiver libraries Dax89 which is btw great work again :)
The actual interesting file is this one: https://github.com/llelectronics/webcat/blob/c09911b4d1abc4a3dd67116994bf315c29825861/org.harbour.webcat.service
This can be easily adapted for webpirate aswell and needs to go into /usr/share/dbus-1/services/ .
Sadly harbour does not allow to put any file into that directory or even /usr/local/share/dbus-1/services/ for that matter. So even if I managed to make a workable solution here we cannot upload it to the Jolla Store. :(

PS: So basically Method 1 and 2 can work together by adding that dbus service file and open-url.desktop then can look like this

[Desktop Entry]
Type=Application
Name=Browser
NotShowIn=X-MeeGo;
MimeType=text/html;x-maemo-urischeme/http;x-maemo-urischeme/https;
X-Maemo-Service=org.harbour.webpirate
X-Maemo-Method=org.harbour.webpirate.openUrl

P.P.S: I think I found another interesting thing. If I did nothing wrong you can also put the dbus service file in ~/.local/share/dbus-1/services . This would make it possible at least to add an option in the browser itself (under settings or somewhere) to make it the default.

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

@llelectronics Thanks for the extra info!!! :)

Writing the .service file in /.local/share/dbus-1/services overrides sailfish-browser settings too? And it is allowed, in the Harbour?

from webpirate.

llelectronics avatar llelectronics commented on August 31, 2024

The .service file does not need to override sailfish-browser settings.
The only thing that needs to override the open-url.desktop file is the open-url.desktop file with the webpirate dbus calls in ~/.local/share/applications/open-url.desktop

As for harbour. I don't think it can be shipped in the rpm directly as it would need to ship a hardcoded path /home/nemo which isn't allowed.
But as you are able in c++ to determine the home directory you could of course just add a button in settings that copies or creates the dbus service file in ~/.local/share/dbus-1/services/ and copies or creates the open-url.desktop file with the dbus X-Maemo-Service and -Method adapted in ~/.local/share/applications
This open-url.desktop file will then override the global one :)

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

Ok, now is crystal clear!
It's pretty easy to implement.

Thanks for your research @llelectronics :)

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

@llelectronics:
This is the implementation: 2ed95d9
Fell free to use it in Webcat :)

The problem is: Jolla allows those type of "local" services?

from webpirate.

llelectronics avatar llelectronics commented on August 31, 2024

At least th harbour checker should not complain.
And about the implementation. I think I will use xdg-mime to register a default html handler and create a open-url-webcat.desktop file. That is in my opinion a more correct way of doing it.
You can take a look at https://github.com/llelectronics/mimer/blob/master/src/helper.hpp
To see how I use xdg-mime.
Currently it needs a linking from mimeapps.list to defaults.list due to an error in the SailfishOS/Mer version of xdg-mime tool.

In general maybe we could work out a standard somehow so that the mimer application will be able to set default apps (not only a webbrowser) with the dbus service file creation.

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

It's ok for me.

About the MIME, do you mean something like this? (thanks for the helper.cpp btw :) )

void DefaultBrowser::overwriteMime()
{
    this->setBusy(true);

    QString desktopfilename = QString("%1.desktop").arg(qApp->applicationName());

    this->setMime("text/html", desktopfilename);
    this->setMime("x-maemo-urischeme/http", desktopfilename);
    this->setMime("x-maemo-urischeme/https", desktopfilename);

    this->setBusy(false);
}

void DefaultBrowser::restoreMime()
{
    this->setBusy(true);

    this->setMime("text/html", "open-url.desktop");
    this->setMime("x-maemo-urischeme/http", "open-url.desktop");
    this->setMime("x-maemo-urischeme/https", "open-url.desktop");

    this->setBusy(false);
}

void DefaultBrowser::setMime(const QString &mimetype, const QString &desktopfile) const
{
    QDir localappsdir = this->localApplicationsDirectory();

    if(!localappsdir.exists("defaults.list"))
    {
        QProcess symlink;
        symlink.start(QString("ln -sf %1 %2").arg(localappsdir.absoluteFilePath("mimeapps.list"), localappsdir.absoluteFilePath("defaults.list")));
        symlink.waitForFinished();
    }

    QProcess xdgmime;
    xdgmime.start(QString("xdg-mime default %1 %2").arg(desktopfile, mimetype));
    xdgmime.waitForFinished();
}

from webpirate.

llelectronics avatar llelectronics commented on August 31, 2024

Yeah exactly :)

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

Ok, the commit 3590e31 uses xdg-mime.

At the current state openUrl() DBus method is called correctly, but if I press a link when the browser is not started nothing happens.

text/html, x-maemo-urischeme/http and x-maemo-urischeme/https MIME types are set to "open-url-webpirate.desktop"

And openurl-webpirate.desktop contains:

[Desktop Entry]
Type=Application
Name=Browser
NotShownIn=X-MeeGo;
MimeType=text/html;x-maemo-urischeme/http;x-maemo-urischeme/https;
X-Maemo-Service=org.harbour.webpirate
X-Maemo-Method=org.harbour.webpirate.openUrl

The .service is in .local/share/dbus-1/service, and in .local/share/applications I have open-url-webpirate.desktop

Am I missing something?

from webpirate.

llelectronics avatar llelectronics commented on August 31, 2024

The folder should be ~/.local/share/dbus-1/services though in your source I think it is correct.
Hmm... maybe it cached that stuff on my device somehow. Does it work when you put the .service file in /usr/share/dbus-1/services ?
If it is then its really a caching thing. I would wonder if then it will still work if you remove that file from there.

PS: OK small update. Its not a caching issue. I tested it on my device by removing the .local/share/dbus-1/services/ directory and it stopped working. So it has to be something else.

PPS: Try perhaps editing the exec line in your service file to see if you can call harbour-webpirate directly without using the invoker.

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

Ok fixed in 01b70a4

.service files are case sensitive :D

from webpirate.

carmenfdezb avatar carmenfdezb commented on August 31, 2024

Great!!! I'm testing v1.7-5 and it seems it's working fine ;)

from webpirate.

Dax89 avatar Dax89 commented on August 31, 2024

Perfect! 👍
So I can close this issue.

(Implemented in: 2ed95d9 3590e31 01b70a4)

from webpirate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.