|
2009-08-12
, 19:25
|
|
Moderator |
Posts: 7,109 |
Thanked: 8,820 times |
Joined on Oct 2007
@ Vancouver, BC, Canada
|
#2
|
The Following User Says Thank You to qole For This Useful Post: | ||
|
2009-08-12
, 19:42
|
Posts: 2,802 |
Thanked: 4,491 times |
Joined on Nov 2007
|
#3
|
The Following User Says Thank You to lma For This Useful Post: | ||
|
2009-08-13
, 06:22
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#4
|
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
|
2009-08-13
, 07:08
|
Posts: 2,802 |
Thanked: 4,491 times |
Joined on Nov 2007
|
#5
|
some entries in its desktop file saying what protocols it supports, what method name it should call when opening the file etc.
The Following 5 Users Say Thank You to lma For This Useful Post: | ||
|
2009-08-13
, 07:10
|
Posts: 432 |
Thanked: 645 times |
Joined on Mar 2009
|
#6
|
I think you need to use libhildonmime (see /usr/share/applications/uri-action-defaults.list in particular) but it's undocumented (bug 3890)
|
2009-08-13
, 07:39
|
Posts: 654 |
Thanked: 664 times |
Joined on Feb 2009
@ Germany
|
#7
|
The Following User Says Thank You to conny For This Useful Post: | ||
|
2009-08-17
, 06:46
|
Posts: 654 |
Thanked: 664 times |
Joined on Feb 2009
@ Germany
|
#8
|
[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
gint dbus_handler(const gchar *interface, const gchar *method, GArray *arguments, gpointer data, osso_rpc_t *retval);
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"); }
The Following 9 Users Say Thank You to conny For This Useful Post: | ||
|
2009-08-25
, 12:19
|
Posts: 14 |
Thanked: 5 times |
Joined on Jan 2008
@ Finland
|
#9
|
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:
Now in code you need a callback and you need to register it. The callback needs a signature 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
Register the callback like this:Code:gint dbus_handler(const gchar *interface, const gchar *method, GArray *arguments, gpointer data, osso_rpc_t *retval);
Now lets assume in the browser we click on the following link: conboy://1234567Code: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"); }
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
|
2009-08-25
, 12:29
|
Posts: 654 |
Thanked: 664 times |
Joined on Feb 2009
@ Germany
|
#10
|
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?
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