Applications


Typedefs

typedef void() osso_application_top_cb_f (const gchar *arguments, gpointer data)

Functions

osso_return_t osso_application_top (osso_context_t *osso, const gchar *application, const gchar *arguments)
osso_return_t osso_application_set_top_cb (osso_context_t *osso, osso_application_top_cb_f *cb, gpointer data)
osso_return_t osso_application_unset_top_cb (osso_context_t *osso, osso_application_top_cb_f *cb, gpointer data)

Typedef Documentation

typedef void() osso_application_top_cb_f(const gchar *arguments, gpointer data)
 

This is the type for the top callback function.

Deprecated:
{This feature will be removed from Libosso soon, use osso_rpc functions instead}
Parameters:
arguments This string lists some extra parameters for the application. It can be used to give the names of the files to open, etc.
data The data that was set with the osso_application_set_top_cb function.


Function Documentation

osso_return_t osso_application_set_top_cb osso_context_t osso,
osso_application_top_cb_f cb,
gpointer  data
 

This function registers a top event callback function.

Deprecated:
{This feature will be removed from Libosso soon, use osso_rpc functions instead}
Parameters:
osso The library context as returned by osso_initialize.
cb The callback function.
data Arbitrary application specific pointer that will be passed to the callback and ignored by Libosso.
Returns:
OSSO_OK if all goes well, OSSO_ERROR if an error occurred, or OSSO_INVALID if some parameter is invalid.

osso_return_t osso_application_top osso_context_t osso,
const gchar *  application,
const gchar *  arguments
 

This function tops an application (i.e. brings it to the foreground). If the application is not already running, D-BUS will launch it via the auto-activation mechanism. By using this function, only one instance of the application will be running at any given time. If the application is already running, this function will only bring it to the foreground.

Parameters:
osso The library context as returned by osso_initialize.
application The name of the application to top.
arguments This string lists some parameters for the application. It can be used to give the names of the files to open, etc. If no arguments are to be passed, this can be NULL.
Returns:
OSSO_OK if the application launch request was successfully sent to the D-BUS daemon, OSSO_ERROR if not.

Example

This is an example on how to parse the argument from a top message. The format is the same as a commandline with long options, i.e. --param=value... So that the same arguments can be easily implemented as commandline arguments.

#include <unistd.h>
#define _GNU_SOURCE
#include <getopt.h>

void top_handler(const gchar *arguments, gpointer data);
{
  gchar **argv;
  gint argc;
  GError *err

  // this will split the arguments string into something similar to
  // what one would get in main.
  g_shell_parse_argv(arguments, &argc, &argv, &err);

  // This forces getopt to start from the first argument every time
  optind=0;
  optarg=argv;

  // call the generic commandline parser
  parse_commandline(argc, argv);

  // Free memory allocated previously.
  g_strfreev(argv);
}

void parse_commandline(int argc, char *argv[])
{
  static struct option long_options[] = {
    {"to", 1, 0, 't'}, // "to" requires an argument
    {"files", 1, 0, 'f'},
    {"url", 1, 0, 'u'},
    {0, 0, 0, 0}
  };
  gint index = 0, r;

  while(1) {
    // This function will parse and return the next argument,
    // see getopt(3) for more info.
    r = getopt_long(argc, argv, "t:f:u:", long_options, &index);

    // No more arguments
    if (r == -1) break;

    switch(r) {
      case 't':
        // do something with the argument, optarg is a global, external
        // variable that will point to the parameter value
        handle_to(optarg);
        break;
      // And so on
    }
  }
}

osso_return_t osso_application_unset_top_cb osso_context_t osso,
osso_application_top_cb_f cb,
gpointer  data
 

This function unregisters a top event callback function.

Deprecated:
{This feature will be removed from Libosso soon, use osso_rpc functions instead}
Parameters:
osso The library context as returned by osso_initialize.
cb The callback function.
data The same pointer that was used with the call to osso_application_set_top_cb
Returns:
OSSO_OK if all goes well, OSSO_ERROR if an error occurred, or OSSO_INVALID if some parameter is invalid.


Generated on Thu Jul 6 13:33:57 2006 for LibOSSO by  doxygen 1.4.6