Commit 001629b7 authored by Keith Preston's avatar Keith Preston

Added Find API

parent f5cb1ecf
/* Geoclue - A DBus api and wrapper for geography information
* Copyright (C) 2006 Garmin
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2 as published by the Free Software Foundation;
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <dbus/dbus.h>
#include <find.h>
#include <find_client_glue.h>
#include <stdio.h>
#include <find_signal_marshal.h>
#include <geoclue_master_client_glue.h>
#define GEOCLUE_FIND_DBUS_INTERFACE "org.foinse_project.geoclue.find"
#define GEOCLUE_MASTER_DBUS_SERVICE "org.foinse_project.geoclue.master"
#define GEOCLUE_MASTER_DBUS_PATH "/org/foinse_project/geoclue/master"
#define GEOCLUE_MASTER_DBUS_INTERFACE "org.foinse_project.geoclue.master"
static DBusGConnection* geoclue_find_connection = NULL;
static DBusGProxy* geoclue_find_proxy = NULL;
static GEOCLUE_FIND_CALLBACK callbackfunction = NULL;
static void* userdatastore = NULL;
static int current_search_id = NULL;
//void geoclue_find_results_found(void* userdata, gdouble lat, gdouble lon)
void geoclue_find_results_found(void* userdata, gint search_id, char** name, char** description, GArray* latitude, GArray* longitude , char** address, char** city , char** state, char** zip)
{
printf("Results Found\n");
if(callbackfunction != NULL)
callbackfunction( name, description, latitude, longitude , address, city , state, zip, userdatastore);
}
GEOCLUE_FIND_RETURNCODE geoclue_find_version(int* major, int* minor, int* micro)
{
if(geoclue_find_connection == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
if(geoclue_find_proxy == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
GError* error = NULL;
org_foinse_project_geoclue_find_version ( geoclue_find_proxy, major, minor, micro, &error );
if( error != NULL )
{
g_printerr ("Error getting geoclue_find version: %s\n", error->message);
g_error_free (error);
return GEOCLUE_FIND_DBUS_ERROR;
}
return GEOCLUE_FIND_SUCCESS;
}
GEOCLUE_FIND_RETURNCODE geoclue_find_service_provider(char** name)
{
if(geoclue_find_connection == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
if(geoclue_find_proxy == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
GError* error = NULL;
org_foinse_project_geoclue_find_service_provider ( geoclue_find_proxy, name, &error );
if( error != NULL )
{
g_printerr ("Error getting geoclue_find service provider: %s\n", error->message);
g_error_free (error);
return GEOCLUE_FIND_DBUS_ERROR;
}
return GEOCLUE_FIND_SUCCESS;
}
GEOCLUE_FIND_RETURNCODE geoclue_find_init_specific(char* service, char* path)
{
GError* error = NULL;
geoclue_find_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (geoclue_find_connection == NULL)
{
g_printerr ("Geomap failed to open connection to bus: %s\n", error->message);
g_error_free (error);
return GEOCLUE_FIND_DBUS_ERROR;
}
geoclue_find_proxy = dbus_g_proxy_new_for_name (geoclue_find_connection,
service,
path,
GEOCLUE_FIND_DBUS_INTERFACE);
dbus_g_object_register_marshaller ( _geoclue_find_VOID__INT_BOXED_BOXED_BOXED_BOXED_BOXED_BOXED_BOXED_BOXED,
G_TYPE_NONE,
G_TYPE_INT, G_TYPE_STRV, G_TYPE_STRV, DBUS_TYPE_G_UINT64_ARRAY, DBUS_TYPE_G_UINT64_ARRAY,G_TYPE_STRV, G_TYPE_STRV,G_TYPE_STRV,G_TYPE_STRV, G_TYPE_INVALID);
dbus_g_proxy_add_signal (geoclue_find_proxy,
"results_found",
G_TYPE_INT, G_TYPE_STRV, G_TYPE_STRV, DBUS_TYPE_G_UINT64_ARRAY , DBUS_TYPE_G_UINT64_ARRAY, G_TYPE_STRV,G_TYPE_STRV,G_TYPE_STRV,G_TYPE_STRV, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (geoclue_find_proxy,
"results_found",
(GCallback) geoclue_find_results_found,
(gpointer)NULL,
(GClosureNotify) NULL);
callbackfunction = NULL;
userdatastore = NULL;
current_search_id = 0;
return GEOCLUE_FIND_SUCCESS;
}
GEOCLUE_FIND_RETURNCODE geoclue_find_init()
{
GError* error = NULL;
geoclue_find_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (geoclue_find_connection == NULL)
{
g_printerr ("Geomap failed to open connection to bus: %s\n", error->message);
g_error_free (error);
return GEOCLUE_FIND_DBUS_ERROR;
}
printf(" master %s and %s\n", GEOCLUE_MASTER_DBUS_SERVICE, GEOCLUE_MASTER_DBUS_PATH);
DBusGProxy* master = dbus_g_proxy_new_for_name (geoclue_find_connection,
GEOCLUE_MASTER_DBUS_SERVICE,
GEOCLUE_MASTER_DBUS_PATH,
GEOCLUE_MASTER_DBUS_INTERFACE);
char* service;
char* path;
char* desc;
org_foinse_project_geoclue_master_get_default_find_provider (master, &service, &path, &desc, &error);
if( error != NULL )
{
g_printerr ("Error getting default find provider: %s\n", error->message);
g_error_free (error);
return GEOCLUE_FIND_DBUS_ERROR;
}
printf(" Hooking up to %s and %s\n", service, path);
geoclue_find_proxy = dbus_g_proxy_new_for_name (geoclue_find_connection,
service,
path,
GEOCLUE_FIND_DBUS_INTERFACE);
free(service);
free(path);
free(desc);
dbus_g_object_register_marshaller ( _geoclue_find_VOID__INT_BOXED_BOXED_BOXED_BOXED_BOXED_BOXED_BOXED_BOXED,
G_TYPE_NONE,
G_TYPE_INT, G_TYPE_STRV, G_TYPE_STRV, DBUS_TYPE_G_UINT64_ARRAY, DBUS_TYPE_G_UINT64_ARRAY,G_TYPE_STRV, G_TYPE_STRV,G_TYPE_STRV,G_TYPE_STRV, G_TYPE_INVALID);
dbus_g_proxy_add_signal (geoclue_find_proxy,
"results_found",
G_TYPE_INT, G_TYPE_STRV, G_TYPE_STRV, DBUS_TYPE_G_UINT64_ARRAY , DBUS_TYPE_G_UINT64_ARRAY, G_TYPE_STRV,G_TYPE_STRV,G_TYPE_STRV,G_TYPE_STRV, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (geoclue_find_proxy,
"results_found",
(GCallback) geoclue_find_results_found,
(gpointer)NULL,
(GClosureNotify) NULL);
printf("signal hooked up\n");
callbackfunction = NULL;
userdatastore = NULL;
return GEOCLUE_FIND_SUCCESS;
}
GEOCLUE_FIND_RETURNCODE geoclue_find_close()
{
g_object_unref (geoclue_find_proxy);
geoclue_find_proxy = NULL;
geoclue_find_connection = NULL;
callbackfunction = NULL;
userdatastore = NULL;
return GEOCLUE_FIND_SUCCESS;
}
GEOCLUE_FIND_RETURNCODE geoclue_find_get_all_providers(char*** OUT_service, char*** OUT_path, char*** OUT_desc)
{
GError* error = NULL;
if (geoclue_find_connection == NULL)
{
geoclue_find_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
}
DBusGProxy* master = dbus_g_proxy_new_for_name (geoclue_find_connection,
GEOCLUE_MASTER_DBUS_SERVICE,
GEOCLUE_MASTER_DBUS_PATH,
GEOCLUE_MASTER_DBUS_INTERFACE);
org_foinse_project_geoclue_master_get_all_find_providers (master, OUT_service, OUT_path, OUT_desc, &error);
if( error != NULL )
{
g_printerr ("Error getting all find provider: %s\n", error->message);
g_error_free (error);
return GEOCLUE_FIND_DBUS_ERROR;
}
return GEOCLUE_FIND_SUCCESS;
}
GEOCLUE_FIND_RETURNCODE geoclue_find_top_level_categories (char *** OUT_names)
{
if(geoclue_find_connection == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
if(geoclue_find_proxy == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
GError* error = NULL;
org_foinse_project_geoclue_find_top_level_categories ( geoclue_find_proxy, OUT_names, &error );
if( error != NULL )
{
g_printerr ("Error getting geoclue_find top level categories : %s\n", error->message);
g_error_free (error);
return GEOCLUE_FIND_DBUS_ERROR;
}
return GEOCLUE_FIND_SUCCESS;
}
GEOCLUE_FIND_RETURNCODE geoclue_find_subcategories (const char * IN_category_name, char *** OUT_subcategory_names)
{
if(geoclue_find_connection == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
if(geoclue_find_proxy == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
GError* error = NULL;
org_foinse_project_geoclue_find_subcategories ( geoclue_find_proxy, IN_category_name, OUT_subcategory_names, &error );
if( error != NULL )
{
g_printerr ("Error getting geoclue_find subcategories : %s\n", error->message);
g_error_free (error);
return GEOCLUE_FIND_DBUS_ERROR;
}
return GEOCLUE_FIND_SUCCESS;
}
GEOCLUE_FIND_RETURNCODE geoclue_find_find_near (const gdouble IN_latitude, const gdouble IN_longitude, const char * IN_category_name, const char *IN_name, GEOCLUE_FIND_CALLBACK callback, void* userdata)
{
if(geoclue_find_connection == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
if(geoclue_find_proxy == NULL)
return GEOCLUE_FIND_NOT_INITIALIZED;
callbackfunction = callback;
userdatastore = userdata;
GError* error = NULL;
org_foinse_project_geoclue_find_find_near ( geoclue_find_proxy, IN_latitude, IN_longitude, IN_category_name, IN_name ,&current_search_id, &error );
if( error != NULL )
{
g_printerr ("Error getting geoclue_find find near : %s\n", error->message);
g_error_free (error);
return GEOCLUE_FIND_DBUS_ERROR;
}
return GEOCLUE_FIND_SUCCESS;
}
/* Geoclue - A DBus api and wrapper for geography information
* Copyright (C) 2006 Garmin
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2 as published by the Free Software Foundation;
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ORG_FOINSE_PROJECT_GEOCLUE_FIND_GEOCLUE_FIND_H__
#define __ORG_FOINSE_PROJECT_GEOCLUE_FIND_GEOCLUE_FIND_H__
#include <dbus/dbus-glib.h>
G_BEGIN_DECLS
typedef enum _geoclue_find_returncode
{
GEOCLUE_FIND_SUCCESS = 0,
GEOCLUE_FIND_NOT_INITIALIZED = -1,
GEOCLUE_FIND_DBUS_ERROR = -2,
GEOCLUE_FIND_SERVICE_NOT_AVAILABLE = -3,
GEOCLUE_FIND_METHOD_NOT_IMPLEMENTED = -4,
GEOCLUE_FIND_NO_SATELLITE_FIX = -5,
GEOCLUE_FIND_SATELLITE_NOT_IN_VIEW = -6
} GEOCLUE_FIND_RETURNCODE;
typedef enum _geoclue_find_fix
{
GEOCLUE_FIND_NO_FIX = -1,
GEOCLUE_FIND_TWO_DIMENSION = 1,
GEOCLUE_FIND_THREE_DIMENSION = 2,
GEOCLUE_FIND_TWO_DIMENSION_DIFFERENTIAL = 3,
GEOCLUE_FIND_THREE_DIMENSION_DIFFERENTIAL = 4
} GEOCLUE_FIND_FIX;
typedef void (*GEOCLUE_FIND_CALLBACK)(char** name, char** description, GArray* latitude, GArray* longitude , char** address, char** city , char** state, char** zip, void* userdata );
/*!
* \brief texttospeech version
* \param major placeholder for version return
* \param minor
* \param micro
* \return TRUE Version returned sucessfully
* FALSE Error
*/
GEOCLUE_FIND_RETURNCODE geoclue_find_version(int* major, int* minor, int* micro);
/*!
* \brief texttospeech init, must be called first. Uses default provider
* \return TRUE Version returned sucessfully
* FALSE Error
*/
GEOCLUE_FIND_RETURNCODE geoclue_find_init();
/*!
* \brief texttospeech init, must be called first.
* \param service DBUS service path
* \param path DBUS path to object
* \return TRUE Version returned sucessfully
* FALSE Error
*/
GEOCLUE_FIND_RETURNCODE geoclue_find_init_specific(char* service, char* path);
/*!
* \brief query master for all providers of find
* \param service DBUS service path array
* \param path DBUS path to object array
* \param desc Text Description array
* \return TRUE Version returned sucessfully
* FALSE Error
*/
GEOCLUE_FIND_RETURNCODE geoclue_find_get_all_providers(char*** OUT_service, char*** OUT_path, char*** OUT_desc);
/*!
* \brief Clean up and free memory
* \return TRUE Version returned sucessfully
* FALSE Error
*/
GEOCLUE_FIND_RETURNCODE geoclue_find_close();
/*!
* \brief Text description of current provider
* \param name name of provider
* \return TRUE Version returned sucessfully
* FALSE Error
*/
GEOCLUE_FIND_RETURNCODE geoclue_find_service_provider(char** name);
GEOCLUE_FIND_RETURNCODE geoclue_find_top_level_categories (char *** OUT_names);
GEOCLUE_FIND_RETURNCODE geoclue_find_subcategories (const char * IN_category_name, char *** OUT_subcategory_names);
GEOCLUE_FIND_RETURNCODE geoclue_find_find_near (const gdouble IN_latitude, const gdouble IN_longitude, const char * IN_category_name, const char *IN_name, GEOCLUE_FIND_CALLBACK callback, void* userdata);
G_END_DECLS
#endif // __ORG_FOINSE_PROJECT_GEOCLUE_FIND_GEOCLUE_FIND_H__
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Geoclue - A DBus api and wrapper for geography information
* Copyright (C) 2006 Garmin
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2 as published by the Free Software Foundation;
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
-->
<node name="/org/foinse_project/geoclue/find">
<interface name="org.foinse_project.geoclue.find">
<method name="version">
<arg type="i" name="major" direction="out" />
<arg type="i" name="minor" direction="out" />
<arg type="i" name="micro" direction="out" />
</method>
<method name="service_provider">
<arg type="s" name="name" direction="out" />
</method>
<method name="top_level_categories">
<arg type="as" name="names" direction="out" />
</method>
<method name="subcategories">
<arg type="s" name="category_name" direction="in" />
<arg type="as" name="subcategory_names" direction="out" />
</method>
<method name="find_near">
<arg type="d" name="latitude" direction="in" />
<arg type="d" name="longitude" direction="in" />
<arg type="s" name="category_name" direction="in" />
<arg type="s" name="name" direction="in" />
<arg type="i" name="search_id" direction="out" />
</method>
<signal name="results_found">
<arg type="i" name="search_id" direction="out" />
<arg type="as" name="name" direction="out" />
<arg type="as" name="description" direction="out" />
<arg type="ad" name="latitude" direction="out" />
<arg type="ad" name="longitude" direction="out" />
<arg type="as" name="address" direction="out" />
<arg type="as" name="city" direction="out" />
<arg type="as" name="state" direction="out" />
<arg type="as" name="zip" direction="out" />
</signal>
<method name="service_available">
<arg type="b" name="available" direction="out" />
<arg type="s" name="reason" direction="out" />
</method>
<method name="shutdown">
</method>
</interface>
</node>
VOID:INT,BOXED,BOXED,BOXED,BOXED,BOXED,BOXED,BOXED,BOXED
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment