Editing URL Handler

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
 +
= URL Handler =
The main purpose of the wiki page is to describe the way to register an application as URL handler. The idea is, that an application test would be launched by using the url: test://foo Therefore it provides:
The main purpose of the wiki page is to describe the way to register an application as URL handler. The idea is, that an application test would be launched by using the url: test://foo Therefore it provides:
-
* Description of the Hildon URI API
+
* Descrition of the Hildon URI API
* Step-by-step example based on the implementation of Cornelius Hald
* Step-by-step example based on the implementation of Cornelius Hald
== Hildon URI API ==
== Hildon URI API ==
-
 
The most updated revision of the API is revision 2, but it bases on the first revision. So please take both documents into account. The API descriptions, with some examples you will find here:
The most updated revision of the API is revision 2, but it bases on the first revision. So please take both documents into account. The API descriptions, with some examples you will find here:
Up to date revision:
Up to date revision:
-
: '''[[/API_rev2|Hildon URI API, revision 2]]'''
+
: '''[[{{PAGENAME}}/API_rev2|Hildon URI API, revision 2]]'''
Revision 2 is based on:
Revision 2 is based on:
-
: '''[[/API_rev1|Hildon URI API, revision 1]]'''
+
:'''[[{{PAGENAME}}/API_rev1|Hildon URI API, revision 1]]'''
This information might be needed to understand the following example.
This information might be needed to understand the following example.
== Example ==
== Example ==
-
 
The example is based on a discussion in [http://talk.maemo.org/showthread.php?t=30772 talk.maemo.org] and gives an overview of the result of the discussion. Conboy is used as an example application, with the goal to create an URL handler for "conboy://". The following steps has to be taken:
The example is based on a discussion in [http://talk.maemo.org/showthread.php?t=30772 talk.maemo.org] and gives an overview of the result of the discussion. Conboy is used as an example application, with the goal to create an URL handler for "conboy://". The following steps has to be taken:
* '''Modification of the .desktop file'''
* '''Modification of the .desktop file'''
:Add a X-Osso-URI-Actions line to the Desktop Entry group and add a X-Osso-URI-Action Handler group. For example:
:Add a X-Osso-URI-Actions line to the Desktop Entry group and add a X-Osso-URI-Action Handler group. For example:
-
<pre>
 
-
[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]
+
[Desktop Entry]
-
Method=load_url
+
Encoding=UTF-8
-
Name=some_name
+
Version=1.0
-
TranslationDomain=conboy
+
Type=Application
-
</pre>
+
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
 +
 
:'''Important:''' 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'.
:'''Important:''' 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'.
Line 46: Line 45:
* '''Implement a callback in your code:'''
* '''Implement a callback in your code:'''
-
<source lang="c">
+
 
-
gint dbus_handler(const gchar *interface,
+
gint dbus_handler(const gchar *interface,
-
                        const gchar *method,
+
                        const gchar *method,
-
                        GArray *arguments,
+
                        GArray *arguments,
-
                        gpointer data,
+
                        gpointer data,
-
                        osso_rpc_t *retval);
+
                        osso_rpc_t *retval);
-
</source>
+
 
* '''Register the callback:'''
* '''Register the callback:'''
-
<source lang="c">
+
-
if (osso_rpc_set_cb_f(osso_context,
+
if (osso_rpc_set_cb_f(osso_context,
-
      "de.zwong.conboy",
+
        "de.zwong.conboy",
-
      "/de/zwong/conboy",
+
        "/de/zwong/conboy",
-
      "de.zwong.conboy",
+
        "de.zwong.conboy",
-
      dbus_handler,
+
        dbus_handler,
-
      NULL) != OSSO_OK) {
+
        NULL) != OSSO_OK) {
-
  g_printerr("Failed to set callback\n");
+
    g_printerr("Failed to set callback\n");
-
}
+
}
-
</source>
+
* '''Call it from the browser:'''
* '''Call it from the browser:'''
:Now lets assume in the browser we click on the following link:   
:Now lets assume in the browser we click on the following link:   
Line 73: Line 72:
  method = "load_url"
  method = "load_url"
  first element of arguments = "conboy://1234567"
  first element of arguments = "conboy://1234567"
-
 
-
[[Category:Development]]
 

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)