#endif
#include <libosso.h>
+#include <dbus/dbus-protocol.h>
#include <string.h>
+#include <dbus-1.0/dbus/dbus-protocol.h>
#include <stdio.h>
#include <stdlib.h>
#include <glib-2.0/glib.h>
-
-
-/** \brief Callback function definition
+/**\brief Callback function definition
*
*@param error - pointer to a GError structure. Currently not used
*@param words - GArray of osso_rpc_t structures containing sent data
function with ::ws_dbus_set_cb
*\sa ws_dbus_set_cb
*/
-typedef void (* ws_dbus_cb) (GError *error, GArray *words, gpointer user_data);
+typedef void (* ws_dbus_cb) (GError *error, gpointer data, gpointer user_data);
-/** \brief This structure contains data vital for DBUS communication.
+/**\brief This structure contains data vital for DBUS communication.
*
* These are for example both the local and remote addresses of the applications
which are supposed to communicate. In this case they are the <I>GUI</I> and the
function
*\sa ws_dbus_config
*/
+
+typedef enum
+{
+ WS_DBUS_TYPE_STRING = DBUS_TYPE_STRING,
+ WS_DBUS_TYPE_INT = DBUS_TYPE_INT32,
+ WS_DBUS_TYPE_UINT = DBUS_TYPE_UINT32,
+ WS_DBUS_TYPE_BOOLEAN = DBUS_TYPE_BOOLEAN,
+ WS_DBUS_TYPE_DOUBLE = DBUS_TYPE_DOUBLE,
+ WS_DBUS_TYPE_INVALID = DBUS_TYPE_INVALID,
+ WS_DBUS_TYPE_GARRAY = ((int) 'a'),
+ WS_DBUS_TYPE_SIGNAL = DBUS_TYPE_INT32
+} WSDBusDataType;
+
struct _WSDBusData
{
osso_context_t * context; ///<a pointer needed by osso_initiallize
gchar *name; ///<Program name
gchar *version; ///<Program version
- GArray *cb_data;
+ GArray *method_data;
+ GArray *remote_method_data;
};
/**
*/
WSDBusData * ws_dbus_create (gchar *name, gchar *version);
-/**\brief This function is used for setting dbus server/client parameters.
+/**\brief This function is used for setting dbus service/client parameters.
*
*These include the addresses of both remote and local apps communicating
*@param ws_dbus_data - pointer to a structure uniquely identifying
/**
*\brief Initialize D-BUS communication.
*
-*It should be called after <B>ws_dbus_create</B> and after setting all D-BUS
+*It should be the called after <B>ws_dbus_create</B> and after setting all D-BUS
parameters with the <B>ws_dbus_config</B> function.
*The structure it returns is necessary to call out every function implemented in
this wrapper library.
gchar * detailed_signal,
gpointer c_func,
gpointer user_data);
+
+WSDBusStatus ws_dbus_add_method (WSDBusData * ws_dbus_data, gchar *method, ...);
+
+
+WSDBusStatus ws_dbus_call_method (WSDBusData * ws_dbus_data, gchar *method,
+ ...);
-/**\brief Send signal to the remote application
-*
-*A purpose of this function is to send signals between both ends.
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for D-BUS
-*@param ws_dbus_info - the command or information to send to the other side.
-*\sa #WSDBusNotify
-*/
-
-WSDBusStatus ws_dbus_notify (WSDBusData * ws_dbus_data,
- WSDBusNotify ws_dbus_info);
-
-/**\brief Find a word in the dictionary
-*
-*This is run by <I>GUI</I>. This function is used for finding a word, the user
-is searching for. It should be
-*called after the user enters a word in the text field and presses the search
-button.
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param word - the word, user is looking for
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
-
-WSDBusStatus ws_dbus_client_find_word (WSDBusData * ws_dbus_data, gchar * word);
-
-/**\brief Find translation of a word
-*
-*This is run by <I>GUI</I>. When a user selects a word from the words list,
-this function is called in order
-*to find the translation of the selected word.
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param word - a word, for which the user wishes to find the translation
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
-
-WSDBusStatus ws_dbus_client_find_translation (WSDBusData * ws_dbus_data,
- gchar * word);
-
-/**\brief Return a list of words
-*
-*Transmits a list of words found by the parsing engine/engines
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param words - a GArray of words, the engine thread returned
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
-
-WSDBusStatus ws_dbus_server_return_words (WSDBusData * ws_dbus_data,
- GArray * words);
-
-/**
-*This function is used for returning the list of words the parsing thread has
-*found. It should be run after the last thread finishes the search, because it
-also
-*signalizes the GUI that the search has finished.
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param words - a GArray of words, the engine thread returned
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
-
-/**\brief Return a translation of a given word
-*
-*This is run by the <I>MANAGER</I>. It returns a translation of a
-previously sent word
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param translation - a string containing the word's translation
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
-
-WSDBusStatus ws_dbus_server_return_translations (WSDBusData * ws_dbus_data,
- gchar * translation);
+void ws_dbus_multipleargs_test (WSDBusData * ws_dbus_data, gchar *method, ...);
-/**\brief Returns the progress of an operation.
-*
-*It's used to inform a GUI progressbar about the progress
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param progress - a double containing the progress. It cannot exceed 1.
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
+#define ws_dbus_notify(structure,arg) ws_dbus_call_method(structure,"signal",WS_DBUS_TYPE_SIGNAL,arg,WS_DBUS_TYPE_INVALID)
-WSDBusStatus ws_dbus_server_update_progressbar (WSDBusData * ws_dbus_data,
- double progress);
+#define ws_dbus_client_find_word(structure,arg) ws_dbus_call_method(structure,"find_word",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
-/**\brief It's used to search for words, that have recently been searched for
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param word - a word.
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
+#define ws_dbus_client_find_translation(structure,arg) ws_dbus_call_method(structure,"find_translation",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
-WSDBusStatus ws_dbus_client_search_in_history (WSDBusData * ws_dbus_data,
- gchar * word);
+#define ws_dbus_client_add_bookmark(structure,arg1,arg2) ws_dbus_call_method(structure,"signal",WS_DBUS_TYPE_STRING,arg1,WS_DBUS_TYPE_STRING,arg2,WS_DBUS_TYPE_INVALID)
-/**\brief Bookmark a given word
-*
-*The given word is stored by the manager in a bookmark's database
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param word - a word to bookmark
-*@param word - a word's translation
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
+#define ws_dbus_client_remove_bookmark(structure,arg) ws_dbus_call_method(structure,"remove_bookmark",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
-WSDBusStatus ws_dbus_client_add_bookmark (WSDBusData * ws_dbus_data, gchar * word, gchar *translation);
+#define ws_dbus_client_extract_dictionary(structure,arg) ws_dbus_call_method(structure,"extract_dictionary",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
-/**\brief Remove a bookmark
-*
-*The given word is removed from the bookmark's database
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param word - a word to remove from bookmarks
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
-
-WSDBusStatus ws_dbus_client_remove_bookmark (WSDBusData * ws_dbus_data, gchar * word);
+#define ws_dbus_server_return_extracted_dict(structure,arg) ws_dbus_call_method(structure,"return_extracted_dict",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
-/**\brief Send a message for GUI to display it
-*
-*This is run by <I>MANAGER</I>. When a user selects a word from the words list,
-this function is called in order
-*to find the translation of the selected word.
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param word - a word, for which the user wishes to find the translation
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
-
-WSDBusStatus ws_dbus_server_send_message (WSDBusData* ws_dbus_data, gchar * word);
-
-
-/**\brief Tells the manager to extract a given file
-*
-*This is run by <I>GUI</I>. It allows for decompressing dictionaries
-*compressed with bzip2.
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param path - a path to the file to decompress
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
-WSDBusStatus ws_dbus_client_extract_dictionary(WSDBusData* ws_dbus_data,
- gchar* path);
+#define ws_dbus_server_return_words(structure,arg) ws_dbus_call_method(structure,"return_words",WS_DBUS_TYPE_GARRAY,arg,WS_DBUS_TYPE_INVALID)
-/**\brief Informs the GUI that the selected file has been extracted
-*
-*This is run by <I>MANAGER</I>.
-*
-*@param ws_dbus_data - pointer to a structure uniquely identifying the
-application for DBus
-*@param path - a path to the decompressed files
-*@return WS_STATUS_OK - on success \n
-*WS_STATUS_ERROR - on error
-*/
-WSDBusStatus ws_dbus_server_return_extracted_dict(WSDBusData* ws_dbus_data,
- gchar* path);
+#define ws_dbus_server_return_translations(structure,arg) ws_dbus_call_method(structure,"return_translations",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
-/* added by Gadomska Anna - HISA */
-WSDBusStatus ws_dbus_server_search_home_applet (WSDBusData * ws_dbus_data, gchar * word);
+#define ws_dbus_server_update_progressbar(structure,arg) ws_dbus_call_method(structure,"update_progressbar",WS_DBUS_TYPE_DOUBLE,arg,WS_DBUS_TYPE_INVALID)
#ifdef __cplusplus
}
#include <ws_dbus.h>
-struct _WSDBusCBData
+
+struct _WSDBusMethodData
{
GQuark id;
+ gchar *name;
gpointer handler;
gpointer user_data;
+ gchar* data_types;
};
-typedef struct _WSDBusCBData WSDBusCBData;
-
-
-static void ws_dbus_fill_message (DBusMessage *msg, void *data)
-{
- guint i;
- gchar *buffer;
- GArray *temp;
+typedef struct _WSDBusMethodData WSDBusMethodData;
- temp = (GArray *) data;
-
- for (i=0;((i<temp->len) && (i<250));++i)
- {
- buffer = g_array_index (temp, gchar *, i);
- dbus_message_append_args (msg,
- DBUS_TYPE_STRING, &buffer,
- DBUS_TYPE_INVALID);
- };
- g_debug ("DBUS: Added %d words\n", i);
-
-};
+/*static WSDBusStatus ws_dbus_send_method_data (WSDBusData *ws_dbus_data);*/
+static gchar* ws_dbus_get_ptr2method (GArray *methods, gchar* name );
+static void ws_dbus_libosso_errors (osso_return_t result);
+static void ws_dbus_fill_message (DBusMessage *msg, void *data);
-static gint ws_dbus_cb_handler (const gchar * interface,
- const gchar * method,
- GArray * arguments,
- gpointer data,
- osso_rpc_t * retval)
+static gchar* ws_dbus_get_ptr2method (GArray *methods, gchar* name)
{
- WSDBusCBData cb_data;
- GArray *dbus_cb_data;
- GQuark temp;
guint i;
- ws_dbus_cb cb;
- dbus_cb_data = (GArray *) data;
- gpointer tmp;
- retval = NULL;
+ gchar* temp;
- g_debug ("DBUS: Method: %s\n", method);
-
- temp = g_quark_try_string (method);
-
- if (temp != 0)
-
- {
-
- cb_data = g_array_index (dbus_cb_data, WSDBusCBData, temp-1);
-
- if (cb_data.id == temp)
- {
- cb = (ws_dbus_cb) cb_data.handler;
- tmp = cb_data.user_data;
- }
-
- else
-
- {
-
- for (i=0; i < dbus_cb_data->len; ++i)
- {
- cb_data = g_array_index (dbus_cb_data,
- WSDBusCBData,
- i);
- if (cb_data.id == temp)
- {
- cb = (ws_dbus_cb) cb_data.handler;
- tmp = cb_data.user_data;
- };
- };
- };
- }
-
- else
- {
- g_debug ("Error in function %s, couldn't find the signal %s\n",
- __FUNCTION__,
- method);
- return OSSO_ERROR;
- };
+ g_debug ("%d", methods->len);
+
+ return NULL;
+
+ for (i = 0; i < methods->len; i+=2)
+
+ {
+ temp = g_array_index (methods, gchar *,i);
+
+ if (strcmp (name, temp) == 0) {
+ temp = g_array_index (methods, gchar *,i+1);
+ g_debug ("\nData types: %s\n", temp);
+ return temp;
+ }
- if (cb != NULL)
- {
- g_debug ("\nDBUS: Running callback for %s\n", method);
- cb (NULL, arguments, tmp);
- retval = DBUS_TYPE_INVALID;
- return OSSO_OK;
- }
- else
- {
- g_debug ("DBUS: No callback defined for this function\n");
- return OSSO_ERROR;
};
-
+
+ return NULL;
};
-
static void ws_dbus_libosso_errors (osso_return_t result)
+
{
switch (result)
{
g_debug("The size of the given structure");
g_debug(" is different from the saved size\n");
break;
+ };
+};
+
+static WSDBusStatus ws_dbus_run_cb (WSDBusMethodData *method_data, gpointer data)
+
+{
+ g_debug ("%s: Running cb for method %s\n", __FUNCTION__,
+ method_data->name);
+
+ ws_dbus_cb cb;
+ osso_rpc_t osso_data;
+
+ GArray *args = (GArray *) data;
+
+ cb = (ws_dbus_cb) method_data->handler;
+ g_debug ("cb pointer address %p\n", cb);
+
+ if (cb != NULL)
+ {
+ if (args->len == 0)
+ {
+ osso_data.type = WS_DBUS_TYPE_STRING;
+ osso_data.value.s = NULL;
+ g_array_append_val (args, osso_data);
+ }
+
+ cb (NULL, data, method_data->user_data);
+ return OSSO_OK;
+ }
+
+ else
+ {
+ g_debug ("DBUS: No callback defined for this function\n");
+ return OSSO_ERROR;
};
};
-WSDBusData * ws_dbus_create (gchar *name, gchar *version)
+static gint ws_dbus_cb_handler (const gchar * interface,
+ const gchar * method,
+ GArray * arguments,
+ gpointer data,
+ osso_rpc_t * retval)
+
+{
+ WSDBusMethodData *method_data;
+ GArray *dbus_method_data;
+ GQuark temp;
+ guint i;
+ dbus_method_data = (GArray *) data;
+ retval = NULL;
+ g_debug ("DBUS: Method: %s\n", method);
+ temp = g_quark_try_string (method);
+
+ if (temp != 0)
+
+ {
+ for (i=0; i < dbus_method_data->len; ++i)
+
+ {
+ method_data = g_array_index (dbus_method_data,
+ WSDBusMethodData *, i);
+
+ if (method_data->id == temp)
+
+ {
+ g_debug ("DBUS: Running callback for %s\n",
+ method);
+ ws_dbus_run_cb (method_data, arguments);
+ };
+
+ };
+
+ }
+
+ else
+
+ {
+ g_debug ("Error in function %s, couldn't find the signal %s\n",
+ __FUNCTION__, method);
+ return OSSO_ERROR;
+ };
+
+ return OSSO_OK;
+};
+
+static void ws_dbus_fill_message (DBusMessage *msg, void *data)
{
- gchar *cb_table[] = {"find_word",
- "find_translation",
- "return_words",
- "return_translations",
- "signal",
- "update_progressbar",
- "search_in_history",
- "add_bookmark",
- "remove_bookmark",
- "send_message",
- "extract_dictionary",
- "return_extracted_dict",
- "search_home_applet",
- NULL};
-
- guint array_size = 0;
+
guint i;
+ osso_rpc_t *data_unit;
+ GArray *data_bundle;
+ gpointer buffer;
+
+ data_bundle = (GArray *) data;
+
+ g_debug ("%s, number of fields: %d", __FUNCTION__, data_bundle->len);
+
+ if (data_bundle->len > 255)
+ g_debug ("DBUS: Number of fields in message exceeds 255\n");
+
+ for (i=0;((i<data_bundle->len) && (i<255));++i)
+ {
+ data_unit = g_array_index (data_bundle, osso_rpc_t *, i);
+
+ g_debug ("%s, type: %c, value: ", __FUNCTION__, data_unit->type);
+
+ switch (data_unit->type)
+ {
+ case DBUS_TYPE_STRING:
+ buffer = &data_unit->value.s;
+ g_debug ("%s", data_unit->value.s);
+ break;
+
+ case DBUS_TYPE_INT32:
+ buffer = &data_unit->value.i;
+ g_debug ("%d", data_unit->value.i);
+ break;
+
+ case DBUS_TYPE_DOUBLE:
+ buffer = &data_unit->value.d;
+ g_debug ("%f", data_unit->value.d);
+ break;
+
+ case DBUS_TYPE_BOOLEAN:
+ buffer = &data_unit->value.b;
+ g_debug ("%d", data_unit->value.b);
+ break;
+ };
+
+ if (data_unit->value.s != NULL) {
+ g_debug ("Wiadomosc nie jest NULL");
+ dbus_message_append_args (msg,
+ data_unit->type, buffer,
+ DBUS_TYPE_INVALID);
+ }
+
+ else
+ if (data_bundle->len > 1)
+ g_debug ("One of the arguments is NULL, ommitting it");
+
+ };
+
+ g_debug ("DBUS: Added %d words\n", i);
+};
- while (cb_table[array_size] != NULL) array_size++;
+void ws_dbus_add_remote_methods (GError *error, gpointer data, gpointer user_data)
+{
+ WSDBusData *ws_dbus_data = (WSDBusData *) user_data;
+ GArray *methods_list = (GArray *) data;
+ guint i=0;
+
+ osso_rpc_t *temp;
+
+ for (i = 0; i < methods_list->len; ++i)
+ {
+ temp = g_array_index (methods_list, osso_rpc_t *, i);
+ g_array_append_val (ws_dbus_data->remote_method_data, temp->value);
+ };
+
+ return;
+};
+
+WSDBusData * ws_dbus_create (gchar *name, gchar *version)
+{
WSDBusData *temp;
- WSDBusCBData temp_cb_data;
- GQuark temp_quark;
temp = (gpointer) g_try_malloc (sizeof (WSDBusData));
temp->name = g_strconcat (name, NULL);
temp->version = g_strconcat (version, NULL);
- temp->cb_data = g_array_new (TRUE, TRUE, sizeof (WSDBusCBData));
+ temp->method_data = g_array_new (TRUE, TRUE, sizeof (WSDBusMethodData *));
+
+ //Adding callback for remote methods list
+ //ws_dbus_add_method (temp, "method_data", WS_DBUS_TYPE_STRING, WS_DBUS_TYPE_STRING);
+ //ws_dbus_set_cb (temp, "method_data", ws_dbus_add_remote_methods, NULL);
- for (i = 0; i < array_size; i++)
- {
- temp_quark = g_quark_try_string (cb_table[i]);
-
- if (temp_quark != 0)
- {
- g_debug(
- "DBUS: \"%s\" - signal has already been registered - %d\n",
- cb_table[i],
- g_quark_from_string(cb_table[i]));
- }
-
- else
- {
- temp_quark = g_quark_from_string (cb_table[i]);
- g_debug ("DBUS: Assigning signal \"%s\" an id %d\n",
- cb_table [i],
- temp_quark);
- temp_cb_data.id = temp_quark;
- temp_cb_data.handler = NULL;
- temp_cb_data.user_data = NULL;
- g_array_append_val (temp->cb_data, temp_cb_data);
- };
-
- };
-
- g_debug ("DBUS: Signals were successfully added\n");
-
return temp;
};
-/* added by Gadomska Anna - HISA */
-WSDBusStatus ws_dbus_server_search_home_applet (WSDBusData * ws_dbus_data, gchar * word)
-{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "search_home_applet",
- retval,
- DBUS_TYPE_STRING,
- word,
- DBUS_TYPE_INVALID);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
-
- ws_dbus_libosso_errors (result);
-
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
-};
-
WSDBusStatus ws_dbus_config (WSDBusData * ws_dbus_data,
WSDBusConfig field,
gchar *value)
ws_dbus_data->remote_iface = g_strconcat (value, NULL);
break;
};
-
+
return WS_DBUS_STATUS_OK;
};
ws_dbus_data->object,
ws_dbus_data->iface,
ws_dbus_cb_handler,
- ws_dbus_data->cb_data);
+ ws_dbus_data->method_data);
+
+ g_debug ("\nWysy³anie danych metod\n");
+ //sends methods list to remote receiver
+ //ws_dbus_send_method_data (ws_dbus_data);
+
if (result == OSSO_OK) return WS_DBUS_STATUS_OK;
else return WS_DBUS_STATUS_ERROR;
};
void ws_dbus_destroy (WSDBusData * ws_dbus_data)
{
+ guint i;
+
if (ws_dbus_data == NULL)
{
g_debug ("\nDBUS: Error in function %s - cannot free osso_context\n",
g_free (ws_dbus_data);
g_assert_not_reached();
};
-
+
g_debug ("\nDBUS deinitialization by %s:\n---------------------------\n",
ws_dbus_data->service);
osso_deinitialize (ws_dbus_data->context);
g_debug ("| Deinitializing osso context |\n");
- if (ws_dbus_data->cb_data != NULL)
- {
- g_array_free (ws_dbus_data->cb_data, TRUE);
+ if (ws_dbus_data->method_data != NULL)
+ {
+ for (i = 0; i < ws_dbus_data->method_data->len; ++i)
+ {
+ WSDBusMethodData *temp =
+ g_array_index(ws_dbus_data->method_data,
+ WSDBusMethodData *, i);
+ g_free (temp->data_types);
+ g_free (temp->name);
+
+ g_free (temp);
+ };
+
+ g_array_free (ws_dbus_data->method_data, TRUE);
g_debug ("| Freeing callback pointers list |\n");
};
g_free (ws_dbus_data->remote_service);
g_free (ws_dbus_data->remote_object);
g_free (ws_dbus_data->remote_iface);
+
+ if (ws_dbus_data->remote_method_data != NULL)
+ {
+ for (i = 0; i < ws_dbus_data->remote_method_data->len; ++i)
+ {
+ g_free (g_array_index(ws_dbus_data->remote_method_data,
+ gchar*, i));
+ };
+ g_array_free (ws_dbus_data->remote_method_data, TRUE);
+ };
g_free (ws_dbus_data);
g_debug ("| Freeing WSDBusData structure |\n----------------------\n");
WSDBusStatus ws_dbus_set_cb (WSDBusData * ws_dbus_data,
- gchar * detailed_signal,
+ gchar * method,
gpointer c_func,
gpointer user_data)
{
- WSDBusCBData cb_data;
+ WSDBusMethodData *method_data;
GQuark temp;
guint i;
- temp = g_quark_try_string (detailed_signal);
+ temp = g_quark_try_string (method);
if (temp == 0)
{
- g_debug ("DBUS:\"%s\"-signal not defined or invalid signal name\n",
- detailed_signal);
+ g_debug ("DBUS:\"%s\"- method not defined or invalid method name\n",
+ method);
return WS_DBUS_STATUS_ERROR;
}
else
{
- for (i = 0; i < ws_dbus_data->cb_data->len; ++i)
+
+ for (i = 0; i < ws_dbus_data->method_data->len; ++i)
{
- cb_data = g_array_index (ws_dbus_data->cb_data,
- WSDBusCBData,
+ method_data = g_array_index (ws_dbus_data->method_data,
+ WSDBusMethodData *,
i);
- if (cb_data.id == temp)
-
+
+ if (method_data->id == temp)
+
{
- cb_data.handler = c_func;
- cb_data.user_data = user_data;
- g_array_insert_val(ws_dbus_data->cb_data,
+ method_data->handler = c_func;
+ method_data->user_data = user_data;
+ g_array_insert_val(ws_dbus_data->method_data,
i,
- cb_data);
- g_array_remove_index (ws_dbus_data->cb_data,
+ method_data);
+ g_array_remove_index (ws_dbus_data->method_data,
i+1);
};
};
-
+
};
+
+// ws_dbus_send_method_data (ws_dbus_data);
return WS_DBUS_STATUS_OK;
};
-WSDBusStatus ws_dbus_notify (WSDBusData * ws_dbus_data,
- WSDBusNotify ws_dbus_info)
-{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s: ",__FUNCTION__);
- g_debug("Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "signal",
- retval,
- DBUS_TYPE_INT32,
- ws_dbus_info,
- DBUS_TYPE_INVALID);
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
- ws_dbus_libosso_errors (result);
-
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- if (/*strcmp */g_ascii_strcasecmp(retval->value.s,
- "No reply within specified time") != 0)
- {
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
-};
+WSDBusStatus ws_dbus_add_method (WSDBusData * ws_dbus_data, gchar *method, ...)
-WSDBusStatus ws_dbus_client_find_word (WSDBusData * ws_dbus_data, gchar * word)
{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "find_word",
- retval,
- DBUS_TYPE_STRING,
- word,
- DBUS_TYPE_INVALID);
+ WSDBusMethodData *method_data;
+ WSDBusDataType data_type;
+ GQuark temp;
+ gchar *buffer;
+ va_list arglist;
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
+ temp = g_quark_try_string (method);
- ws_dbus_libosso_errors (result);
+ if (temp == 0)
+ {
+ method_data = g_try_malloc (sizeof (WSDBusMethodData));
+
+ if (method_data != NULL)
+ {
+ va_start (arglist, method);
+
+ method_data->id = g_quark_from_string (method);
+ method_data->name = g_strdup (method);
+
+ data_type = va_arg (arglist, WSDBusDataType);
+
+ method_data->data_types = g_strdup("");
+
+ while (data_type != WS_DBUS_TYPE_INVALID)
+ {
+ buffer = method_data->data_types;
+
+ method_data->data_types = g_strdup_printf ("%s%c",
+ method_data->data_types,
+ (gchar) data_type );
+
+ g_free (buffer);
+
+ data_type = va_arg (arglist, WSDBusDataType);
+ };
+
+ g_debug ("%d, %s, %s\n", method_data->id, method_data->name, method_data->data_types);
+
+ va_end (arglist);
+
+ g_array_append_val (ws_dbus_data->method_data, method_data);
+ }
+
+ else g_debug ("DBUS: Failed to allocate memory for method data");
+
+ }
- if (result != OSSO_OK)
+ else
{
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
+ g_debug ("DBUS:\"%s\"- method has already been registered\n",
+ method);
+
return WS_DBUS_STATUS_ERROR;
};
- osso_rpc_free_val (retval);
- g_free (retval);
return WS_DBUS_STATUS_OK;
};
-WSDBusStatus ws_dbus_client_find_translation (WSDBusData * ws_dbus_data,
- gchar * word)
-{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s: ",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "find_translation",
- retval,
- DBUS_TYPE_STRING,
- word,
- DBUS_TYPE_INVALID);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
-
- ws_dbus_libosso_errors (result);
+WSDBusStatus ws_dbus_add_garray (GArray *data_bundle, GArray *strings)
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
-};
-
-WSDBusStatus ws_dbus_client_search_in_history (WSDBusData* ws_dbus_data,
- gchar* word)
{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "search_in_history",
- retval,
- DBUS_TYPE_STRING,
- word,
- DBUS_TYPE_INVALID);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
-
- ws_dbus_libosso_errors (result);
-
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
+ osso_rpc_t *temp;
+ guint i;
+
+ if (strings != NULL)
+ {
+
+ for (i = 0; i < strings->len; ++i)
+ {
+ temp = g_try_malloc (sizeof (osso_rpc_t));
+ temp->type = WS_DBUS_TYPE_STRING;
+ temp->value.s = g_array_index (strings, gchar *, i);
+ g_debug ("%d, %s", temp->type, temp->value.s);
+ g_array_append_val (data_bundle, temp);
+ };
+
+ return WS_DBUS_STATUS_OK;
+
+ }
+
+ else
+ {
+ printf ("\n%s - Error - GArray is NULL", __FUNCTION__);
+ return WS_DBUS_STATUS_ERROR;
+ };
+
};
-WSDBusStatus ws_dbus_server_return_words (WSDBusData * ws_dbus_data,
- GArray * words)
+WSDBusStatus ws_dbus_call_method (WSDBusData * ws_dbus_data, gchar *method, ...)
{
+ va_list arglist;
+ GArray *data_to_send;
+ osso_rpc_t *temp, *retval;
osso_return_t result;
- osso_rpc_t *retval;
-
+ GArray *temp_garray;
+
+ data_to_send = g_array_new (TRUE, TRUE, sizeof (osso_rpc_t *));
+
+ va_start (arglist, method);
+
+ while (1)
+ {
+ temp = g_try_malloc (sizeof (osso_rpc_t));
+
+ temp->type = va_arg (arglist, WSDBusDataType);
+
+ g_debug ("Type: %c ", temp->type);
+
+ if (temp->type == WS_DBUS_TYPE_INVALID) break;
+
+ switch (temp->type)
+ {
+ case WS_DBUS_TYPE_STRING:
+ temp->value.s = va_arg (arglist, gchar *);
+ g_debug ("Value: %s\n", temp->value.s);
+ break;
+ case WS_DBUS_TYPE_INT:
+ temp->value.i = va_arg (arglist, gint);
+ g_debug ("Value: %d\n", temp->value.i);
+ break;
+ case WS_DBUS_TYPE_UINT:
+ temp->value.u = va_arg (arglist, guint);
+ g_debug ("Value: %d\n", temp->value.u);
+ break;
+ case WS_DBUS_TYPE_DOUBLE:
+ temp->value.d = va_arg (arglist, gdouble);
+ g_debug ("Value: %f\n", temp->value.d);
+ break;
+ case WS_DBUS_TYPE_BOOLEAN:
+ temp->value.b = va_arg (arglist, gboolean);
+ g_debug ("Value: %d\n", temp->value.b);
+ break;
+ case WS_DBUS_TYPE_GARRAY:
+ temp_garray = va_arg (arglist, GArray *);
+ ws_dbus_add_garray (data_to_send,
+ temp_garray);
+ g_debug ("Value: GArray of strings");
+ break;
+ };
+ g_debug ("Type: %c %d", temp->type, temp->value.i);
+
+ if (temp->type != WS_DBUS_TYPE_GARRAY)
+ g_array_append_val (data_to_send, temp);
+ };
+
+ va_end (arglist);
+
+ g_debug ("%s, method %s, added %d arguments", __FUNCTION__,
+ method, data_to_send->len);
+
+
retval = g_try_malloc (sizeof (osso_rpc_t));
if (retval == NULL)
{
g_debug("DBUS: Error in function %s:",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
+ g_debug("Couldn't allocate memory for message's return value\n");
};
result = osso_rpc_run_with_argfill (ws_dbus_data->context,
ws_dbus_data->remote_service,
ws_dbus_data->remote_object,
ws_dbus_data->remote_iface,
- "return_words",
+ method,
retval,
ws_dbus_fill_message,
- words);
+ data_to_send);
+
g_debug ("\nDBUS: %s: ", __FUNCTION__);
ws_dbus_libosso_errors (result);
+
+ guint i;
+
+ for (i = 0; i < data_to_send->len; ++i)
+ {
+ g_free (g_array_index(data_to_send, osso_rpc_t*,i));
+ };
+
+ g_array_free (data_to_send, TRUE);
if (result != OSSO_OK)
{
g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
+ osso_rpc_free_val (retval);
g_free (retval);
return WS_DBUS_STATUS_ERROR;
};
osso_rpc_free_val (retval);
g_free (retval);
- return WS_DBUS_STATUS_OK;
+ return WS_DBUS_STATUS_OK;
};
-WSDBusStatus ws_dbus_server_return_words_last(WSDBusData * ws_dbus_data,
- GArray * words)
+WSDBusStatus ws_dbus_call_registered_method (WSDBusData * ws_dbus_data, gchar *method, ...)
{
+ va_list arglist;
+ guint i;
+ GArray *data_to_send;
+ osso_rpc_t *temp;
osso_return_t result;
osso_rpc_t *retval;
+
+ gchar* data_types = ws_dbus_get_ptr2method (
+ ws_dbus_data->remote_method_data,
+ method);
+
+ g_debug ("\n%s\n", data_types);
+
+ data_to_send = g_array_new (TRUE, TRUE, sizeof (osso_rpc_t *));
+
+ va_start (arglist, method);
+
+ for (i = 0; i < strlen (data_types); ++i)
+ {
+ temp = g_try_malloc (sizeof (osso_rpc_t));
+
+ switch ((char) data_types[i])
+ {
+ case WS_DBUS_TYPE_STRING:
+ temp->value.s = va_arg (arglist, gchar *);
+ break;
+ case WS_DBUS_TYPE_INT:
+ temp->value.i = va_arg (arglist, gint);
+ break;
+ case WS_DBUS_TYPE_UINT:
+ temp->value.u = va_arg (arglist, guint);
+ break;
+ case WS_DBUS_TYPE_DOUBLE:
+ temp->value.d = va_arg (arglist, gdouble);
+ break;
+ case WS_DBUS_TYPE_BOOLEAN:
+ temp->value.b = va_arg (arglist, gboolean);
+ break;
+ };
+
+ g_array_append_val (data_to_send, temp);
+ };
+
+ va_end (arglist);
retval = g_try_malloc (sizeof (osso_rpc_t));
if (retval == NULL)
{
g_debug("DBUS: Error in function %s:",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
+ g_debug("Couldn't allocate memory for message's return value\n");
};
result = osso_rpc_run_with_argfill (ws_dbus_data->context,
ws_dbus_data->remote_service,
ws_dbus_data->remote_object,
ws_dbus_data->remote_iface,
- "return_words",
+ method,
retval,
ws_dbus_fill_message,
- words);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
-
- ws_dbus_libosso_errors (result);
-
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
-};
-
-WSDBusStatus ws_dbus_server_return_translations(WSDBusData * ws_dbus_data,
- gchar * translation)
-
-{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:", __FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "return_translations",
- retval,
- DBUS_TYPE_STRING,
- translation,
- DBUS_TYPE_INVALID);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
-
- ws_dbus_libosso_errors (result);
-
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
-};
-
-WSDBusStatus ws_dbus_send_ptrtodata(WSDBusData * ws_dbus_data,
- gchar *method,
- gulong data_address)
-
-{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- method,
- retval,
- DBUS_TYPE_INT32,
- data_address,
- DBUS_TYPE_INVALID);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
-
- ws_dbus_libosso_errors (result);
-
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
-
-};
-
-
-WSDBusStatus ws_dbus_server_return_translations_last(WSDBusData * ws_dbus_data,
- gchar * translation)
-
-{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:", __FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run(ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "return_translations",
- retval,
- DBUS_TYPE_STRING,
- translation,
- DBUS_TYPE_INVALID);
-
+ data_to_send);
g_debug ("\nDBUS: %s: ", __FUNCTION__);
ws_dbus_libosso_errors (result);
if (result != OSSO_OK)
{
g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
-};
-
-gpointer ws_dbus_concat_data (GArray *garray)
-{
- guint i;
- gchar temp_len = 0;
- gulong total_len = 0;
- gpointer temp = NULL, start;
- gchar *array;
-
- for (i=0;i<garray->len;++i)
- {
- array = g_array_index (garray, gchar *, i);
- g_debug ("DBUS: %s: text added: %s\n", __FUNCTION__, array);
- temp = start;
- temp_len = strlen (array);
- g_debug ("length: %d\n", temp_len);
- start = g_malloc (total_len + temp_len + 1);
- memcpy (start, temp, total_len);
- if (i > 0) g_free (temp);
- temp = start + total_len;
- memcpy (temp, &temp_len, 1);
- memcpy (temp+1, array, temp_len);
- total_len = total_len + temp_len + 1;
- };
- return start;
-};
-
-GArray * ws_dbus_split_data (gpointer buffer)
-{
- gchar *temp;
- gchar *str;
- guint len;
- guint total_len = 0;
- guint buffer_len;
- guint i = 0;
- GArray *garray;
-
- temp = buffer;
-
- buffer_len = strlen (buffer);
-
- g_debug ("Buffer length %d\n", strlen (buffer));
- garray = g_array_new (TRUE, TRUE, sizeof(gchar *));
-
- while (temp[0] != 0)
- {
- len = temp[0];
- total_len = total_len + len;
- str = g_malloc (len + 1);
- memcpy (str, temp+1, len);
- str[len] = 0;
- temp = temp + len + 1;
- g_debug ("Received text: %s, %d\n", str, len);
- g_array_append_val (garray, str);
- ++i;
- };
-
- return garray;
-};
-
-WSDBusStatus ws_dbus_server_update_progressbar (WSDBusData * ws_dbus_data,
- double progress)
-
-{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:", __FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "update_progressbar",
- retval,
- DBUS_TYPE_DOUBLE,
- progress,
- DBUS_TYPE_INVALID);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
-
- ws_dbus_libosso_errors (result);
-
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
+ osso_rpc_free_val (retval);
g_free (retval);
return WS_DBUS_STATUS_ERROR;
};
osso_rpc_free_val (retval);
g_free (retval);
return WS_DBUS_STATUS_OK;
+
+ return WS_DBUS_STATUS_OK;
};
-WSDBusStatus ws_dbus_client_add_bookmark (WSDBusData * ws_dbus_data, gchar * word, gchar *translation)
+/*
+WSDBusStatus ws_dbus_run_method (WSDBusData * ws_dbus_data, gchar *method, ...)
{
+ va_list arglist;
+ guint i;
+ GArray *data_to_send;
+ osso_rpc_t *temp;
osso_return_t result;
osso_rpc_t *retval;
+
+ gchar* method_data = ws_dbus_get_ptr2method (
+ ws_dbus_data->method_data,
+ method);
+
+ data_to_send = g_array_new (TRUE, TRUE, sizeof (osso_rpc_t *));
+
+ va_start (arglist, method);
+
+ g_debug ("%p\n\n%p\n\n", method_data, method_data->data_types);
+
+ for (i = 0; i < strlen (method_data->data_types); ++i)
+ {
+ temp = g_try_malloc (sizeof (osso_rpc_t));
+ temp->type = method_data->data_types[i];
+
+ switch ((char) method_data->data_types[i])
+ {
+ case WS_DBUS_TYPE_STRING:
+ temp->value.s = va_arg (arglist, gchar *);
+ break;
+ case WS_DBUS_TYPE_INT:
+ temp->value.i = va_arg (arglist, gint);
+ break;
+ case WS_DBUS_TYPE_SIGNAL:
+ case WS_DBUS_TYPE_UINT:
+ temp->value.u = va_arg (arglist, guint);
+ break;
+ case WS_DBUS_TYPE_DOUBLE:
+ temp->value.d = va_arg (arglist, gdouble);
+ break;
+ case WS_DBUS_TYPE_BOOLEAN:
+ temp->value.b = va_arg (arglist, gboolean);
+ break;
+ };
+
+ g_array_append_val (data_to_send, temp);
+ };
+
+ va_end (arglist);
retval = g_try_malloc (sizeof (osso_rpc_t));
if (retval == NULL)
{
g_debug("DBUS: Error in function %s:",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
+ g_debug("Couldn't allocate memory for message's return value\n");
};
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "add_bookmark",
- retval,
- DBUS_TYPE_STRING,
- word,
- DBUS_TYPE_STRING,
- translation,
- DBUS_TYPE_INVALID);
-
+ result = osso_rpc_run_with_argfill (ws_dbus_data->context,
+ ws_dbus_data->remote_service,
+ ws_dbus_data->remote_object,
+ ws_dbus_data->remote_iface,
+ method,
+ retval,
+ ws_dbus_fill_message,
+ data_to_send);
g_debug ("\nDBUS: %s: ", __FUNCTION__);
ws_dbus_libosso_errors (result);
-
+registered_
if (result != OSSO_OK)
{
g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
+ osso_rpc_free_val (retval);
g_free (retval);
return WS_DBUS_STATUS_ERROR;
};
- osso_rpc_free_val (retval);
+ osso_rpc_free_val (retval);
g_free (retval);
return WS_DBUS_STATUS_OK;
+
+ return WS_DBUS_STATUS_OK;
};
+*/
-WSDBusStatus ws_dbus_client_remove_bookmark (WSDBusData * ws_dbus_data, gchar * word)
+/*static void ws_dbus_fill_method_data (DBusMessage *msg, void *data)
{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "remove_bookmark",
- retval,
- DBUS_TYPE_STRING,
- word,
- DBUS_TYPE_INVALID);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
-
- ws_dbus_libosso_errors (result);
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
-};
-
-WSDBusStatus ws_dbus_server_send_message (WSDBusData * ws_dbus_data, gchar * word)
-
-{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:",__FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run (ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "send_message",
- retval,
- DBUS_TYPE_STRING,
- word,
- DBUS_TYPE_INVALID);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
+ guint i;
+ WSDBusMethodData *buffer;
+ GArray *temp;
- ws_dbus_libosso_errors (result);
+ temp = (GArray *) data;
- if (result != OSSO_OK)
+ for (i=0;((i<temp->len) && (i<255));++i)
{
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
+ buffer = g_array_index (temp, WSDBusMethodData *, i);
+
+ g_debug ("name: %s\ntypes: %s", buffer->name, buffer->data_types);
+
+ return;
+
+ dbus_message_append_args (msg, DBUS_TYPE_STRING, buffer->name,
+ DBUS_TYPE_STRING, buffer->data_types,
+ DBUS_TYPE_INVALID);
};
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
+ g_debug ("DBUS: Added %d words\n", i);
};
-WSDBusStatus ws_dbus_client_extract_dictionary(WSDBusData * ws_dbus_data,
- gchar* path)
-
+WSDBusStatus ws_dbus_send_method_data (WSDBusData *ws_dbus_data)
{
osso_return_t result;
osso_rpc_t *retval;
g_debug("DBUS: Error in function %s:",__FUNCTION__);
g_debug(" Couldn't allocate memory for message's return value\n");
};
-
- result = osso_rpc_run(ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "extract_dictionary",
- retval,
- DBUS_TYPE_STRING,
- path,
- DBUS_TYPE_INVALID);
+
+ result = osso_rpc_run_with_argfill (ws_dbus_data->context,
+ ws_dbus_data->remote_service,
+ ws_dbus_data->remote_object,
+ ws_dbus_data->remote_iface,
+ "method_data",
+ retval,
+ ws_dbus_fill_method_data,
+ ws_dbus_data->method_data);
g_debug ("\nDBUS: %s: ", __FUNCTION__);
osso_rpc_free_val (retval);
g_free (retval);
return WS_DBUS_STATUS_OK;
-};
-
-WSDBusStatus ws_dbus_server_return_extracted_dict(WSDBusData* ws_dbus_data,
- gchar* path)
-{
- osso_return_t result;
- osso_rpc_t *retval;
-
- retval = g_try_malloc (sizeof (osso_rpc_t));
-
- if (retval == NULL)
- {
- g_debug("DBUS: Error in function %s:", __FUNCTION__);
- g_debug(" Couldn't allocate memory for message's return value\n");
- };
-
- result = osso_rpc_run(ws_dbus_data->context,
- ws_dbus_data->remote_service,
- ws_dbus_data->remote_object,
- ws_dbus_data->remote_iface,
- "return_extracted_dict",
- retval,
- DBUS_TYPE_STRING,
- path,
- DBUS_TYPE_INVALID);
-
- g_debug ("\nDBUS: %s: ", __FUNCTION__);
-
- ws_dbus_libosso_errors (result);
-
- if (result != OSSO_OK)
- {
- g_debug ("Error message: %s\n", retval->value.s);
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_ERROR;
- };
-
- osso_rpc_free_val (retval);
- g_free (retval);
- return WS_DBUS_STATUS_OK;
-};
+};*/