Reply
Thread Tools
Posts: 654 | Thanked: 664 times | Joined on Feb 2009 @ Germany
#1
Hi everyone!

I already asked this on the devel-list, but got now answer. Maybe someone here knows an answer...

Is it possible to register my application as an URL handler?
What I would like to do is that whenever a user who is using the browser clicks on a link like myapp://abcdefg my application is launched.

Hints and tips would be very welcome

Thanks!
Conny
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#2
I don't believe there is any (easy) way to do it natively in Maemo, but there is an application for the tablets called dbus switchboard which does this sort of thing.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 

The Following User Says Thank You to qole For This Useful Post:
Posts: 2,802 | Thanked: 4,491 times | Joined on Nov 2007
#3
I think you need to use libhildonmime (see /usr/share/applications/uri-action-defaults.list in particular) but it's undocumented (bug 3890) so you'll probably have to dig in the source to figure out how to use it :-(
 

The Following User Says Thank You to lma For This Useful Post:
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#4
Originally Posted by conny View Post
Hi everyone!

I already asked this on the devel-list, but got now answer. Maybe someone here knows an answer...

Is it possible to register my application as an URL handler?
What I would like to do is that whenever a user who is using the browser clicks on a link like myapp://abcdefg my application is launched.

Hints and tips would be very welcome

Thanks!
Conny
Hello,

NumptyPhysics does this for its loading a level "live" from the browser (using its "nptp" protocol) . The source would be able to tell you more than I but the gist is that it registers a "mime_open" DBus handler with osso which just loads NumptyPhysics with whatever filename (the File manager passes the file name to the handler; not as an argument. Maemo: making it awkward. ), a mime file installed telling the system about these new file types and entries in its desktop file saying what mimetypes and protocols it supports, what method name it should call when opening the file etc. I've probably missed something but you could look at the source

(The Media player, albeit being closed source, also has such entries in its desktop file)

Last edited by qwerty12; 2009-08-13 at 07:08.
 

The Following 6 Users Say Thank You to qwerty12 For This Useful Post:
Posts: 2,802 | Thanked: 4,491 times | Joined on Nov 2007
#5
Originally Posted by qwerty12 View Post
some entries in its desktop file saying what protocols it supports, what method name it should call when opening the file etc.
That's the key I think, and it's documented in docs/hildon-uri-open-rev-2.txt (also inside the libhildonmime source tarball).
 

The Following 5 Users Say Thank You to lma For This Useful Post:
Posts: 432 | Thanked: 645 times | Joined on Mar 2009
#6
Originally Posted by lma View Post
I think you need to use libhildonmime (see /usr/share/applications/uri-action-defaults.list in particular) but it's undocumented (bug 3890)
Thanks for the hint. We are working on a wiki page about that. Combined with the header file it should make it a bit clearer.

Cheers Daniel
 

The Following 7 Users Say Thank You to danielwilms For This Useful Post:
Posts: 654 | Thanked: 664 times | Joined on Feb 2009 @ Germany
#7
Wow, thank you all for the valuable feedback! It looks like some problems really get solved over night
Iīll give it a try in the evening...
 

The Following User Says Thank You to conny For This Useful Post:
Posts: 654 | Thanked: 664 times | Joined on Feb 2009 @ Germany
#8
Thanks again, it works just fine. Here's a small guide

First you should modify your .desktop file. Add a X-Osso-URI-Actions line to the Desktop Entry group and add a X-Osso-URI-Action Handler group to the same file.

Let's say we want to register an url handler for conboy:// urls, our .desktop file would looks somehow like that:

Code:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Conboy
Exec=@prefix@/bin/conboy
Icon=conboy
X-Window-Icon=conboy
X-Window-Icon-Dimmed=conboy
X-Osso-Service=de.zwong.conboy
X-Osso-Type=application/x-executable
X-Osso-URI-Actions=conboy

[X-Osso-URI-Action Handler conboy]
Method=load_url
Name=some_name
TranslationDomain=conboy
EDIT: It's important that you set a value for all three keys ('Method', 'Name' and 'TranslationDomain') otherwise it won't work. Still, the only value of these that you get passed to your callback function is the value of 'Method'.

Now in code you need a callback and you need to register it. The callback needs a signature like that:
Code:
gint dbus_handler(const gchar *interface,
                         const gchar *method,
                         GArray *arguments,
                         gpointer data,
                         osso_rpc_t *retval);
Register the callback like this:
Code:
if (osso_rpc_set_cb_f(osso_context,
        "de.zwong.conboy",
        "/de/zwong/conboy",
        "de.zwong.conboy",
        dbus_handler,
        NULL) != OSSO_OK) {
    g_printerr("Failed to set callback\n");
}
Now lets assume in the browser we click on the following link: conboy://1234567

In this case the application is started and the provided callback is called with the following parameters.

interface = "de.zwong.conboy"
method = "load_url"
first element of arguments = "conboy://1234567"

Oh and after changing the .desktop file, don't forget to call update-desktop-database

Last edited by conny; 2009-08-25 at 18:11. Reason: Added information
 

The Following 9 Users Say Thank You to conny For This Useful Post:
Posts: 14 | Thanked: 5 times | Joined on Jan 2008 @ Finland
#9
Originally Posted by conny View Post
Thanks again, it works just fine. Here's a small guide

First you should modify your .desktop file. Add a X-Osso-URI-Actions line to the Desktop Entry group and add a X-Osso-URI-Action Handler group to the same file.

Let's say we want to register an url handler for conboy:// urls, our .desktop file would looks somehow like that:

Code:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Conboy
Exec=@prefix@/bin/conboy
Icon=conboy
X-Window-Icon=conboy
X-Window-Icon-Dimmed=conboy
X-Osso-Service=de.zwong.conboy
X-Osso-Type=application/x-executable
X-Osso-URI-Actions=conboy

[X-Osso-URI-Action Handler conboy]
Method=load_url
Name=some_name
TranslationDomain=conboy
Now in code you need a callback and you need to register it. The callback needs a signature like that:
Code:
gint dbus_handler(const gchar *interface,
                         const gchar *method,
                         GArray *arguments,
                         gpointer data,
                         osso_rpc_t *retval);
Register the callback like this:
Code:
if (osso_rpc_set_cb_f(osso_context,
        "de.zwong.conboy",
        "/de/zwong/conboy",
        "de.zwong.conboy",
        dbus_handler,
        NULL) != OSSO_OK) {
    g_printerr("Failed to set callback\n");
}
Now lets assume in the browser we click on the following link: conboy://1234567

In this case the application is started and the provided callback is called with the following parameters.

interface = "de.zwong.conboy"
method = "load_url"
first element of arguments = "conboy://1234567"

Oh and after changing the .desktop file, don't forget to call update-desktop-database
Are these really the only steps that are required? I have tried this without success so far. Am I missing URI protocol prefix MIME-type registration or something?
 
Posts: 654 | Thanked: 664 times | Joined on Feb 2009 @ Germany
#10
Originally Posted by lassileevi View Post
Are these really the only steps that are required? I have tried this without success so far. Am I missing URI protocol prefix MIME-type registration or something?
As far as I know thatīs all and it works for me. You could also have a look at the code from numptyphysics which was my main "inspiration". Also if you could post some more info (code) it might be possible to help you
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 04:52.