merge graph_dict_proxy into graph_proxy

This commit is contained in:
Nedko Arnaudov 2009-09-12 09:44:52 +03:00
parent 7a8931a94a
commit ff607c1e8e
6 changed files with 104 additions and 176 deletions

View File

@ -1,105 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains implementation of the graph dictionary D-Bus helpers
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "graph_dict_proxy.h"
#include "dbus/helpers.h"
#include "dbus_constants.h"
bool
lash_graph_dict_proxy_set(
const char * service,
const char * object,
uint32_t object_type,
uint64_t object_id,
const char * key,
const char * value)
{
if (!dbus_call(service, object, IFACE_GRAPH_DICT, "Set", "utss", &object_type, &object_id, &key, &value, ""))
{
lash_error(IFACE_GRAPH_DICT ".Set() failed.");
return false;
}
return true;
}
bool
lash_graph_dict_proxy_get(
const char * service,
const char * object,
uint32_t object_type,
uint64_t object_id,
const char * key,
char ** value_ptr_ptr)
{
DBusMessage * reply_ptr;
const char * reply_signature;
DBusMessageIter iter;
const char * cvalue_ptr;
char * value_ptr;
if (!dbus_call(service, object, IFACE_GRAPH_DICT, "Get", "uts", &object_type, &object_id, &key, NULL, &reply_ptr))
{
lash_error(IFACE_GRAPH_DICT ".Get() failed.");
return false;
}
reply_signature = dbus_message_get_signature(reply_ptr);
if (strcmp(reply_signature, "s") != 0)
{
lash_error("reply signature is '%s' but expected signature is 's'", reply_signature);
dbus_message_unref(reply_ptr);
return false;
}
dbus_message_iter_init(reply_ptr, &iter);
dbus_message_iter_get_basic(&iter, &cvalue_ptr);
value_ptr = strdup(cvalue_ptr);
dbus_message_unref(reply_ptr);
if (value_ptr == NULL)
{
lash_error("strdup() failed for dict value");
return false;
}
*value_ptr_ptr = value_ptr;
return true;
}
bool
lash_graph_dict_proxy_drop(
const char * service,
const char * object,
uint32_t object_type,
uint64_t object_id,
const char * key)
{
if (!dbus_call(service, object, IFACE_GRAPH_DICT, "Drop", "uts", &object_type, &object_id, &key, ""))
{
lash_error(IFACE_GRAPH_DICT ".Drop() failed.");
return false;
}
return true;
}

View File

@ -1,58 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains interface to graph dictionary D-Bus helpers
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef GRAPH_DICT_PROXY_H__83E681EB_798E_4A25_9653_F9A9DBEB4D82__INCLUDED
#define GRAPH_DICT_PROXY_H__83E681EB_798E_4A25_9653_F9A9DBEB4D82__INCLUDED
#include "common.h"
bool
lash_graph_dict_proxy_set(
const char * service,
const char * object,
uint32_t object_type,
uint64_t object_id,
const char * key,
const char * value);
bool
lash_graph_dict_proxy_get(
const char * service,
const char * object,
uint32_t object_type,
uint64_t object_id,
const char * key,
char ** value);
bool
lash_graph_dict_proxy_drop(
const char * service,
const char * object,
uint32_t object_type,
uint64_t object_id,
const char * key);
#endif /* #ifndef GRAPH_DICT_PROXY_H__83E681EB_798E_4A25_9653_F9A9DBEB4D82__INCLUDED */

View File

@ -770,3 +770,76 @@ message_hook(
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
bool
graph_proxy_dict_entry_set(
graph_proxy_handle graph,
uint32_t object_type,
uint64_t object_id,
const char * key,
const char * value)
{
if (!dbus_call(graph_ptr->service, graph_ptr->object, IFACE_GRAPH_DICT, "Set", "utss", &object_type, &object_id, &key, &value, ""))
{
lash_error(IFACE_GRAPH_DICT ".Set() failed.");
return false;
}
return true;
}
bool
graph_proxy_dict_entry_get(
graph_proxy_handle graph,
uint32_t object_type,
uint64_t object_id,
const char * key,
char ** value_ptr_ptr)
{
DBusMessage * reply_ptr;
const char * reply_signature;
DBusMessageIter iter;
const char * cvalue_ptr;
char * value_ptr;
if (!dbus_call(graph_ptr->service, graph_ptr->object, IFACE_GRAPH_DICT, "Get", "uts", &object_type, &object_id, &key, NULL, &reply_ptr))
{
lash_error(IFACE_GRAPH_DICT ".Get() failed.");
return false;
}
reply_signature = dbus_message_get_signature(reply_ptr);
if (strcmp(reply_signature, "s") != 0)
{
lash_error("reply signature is '%s' but expected signature is 's'", reply_signature);
dbus_message_unref(reply_ptr);
return false;
}
dbus_message_iter_init(reply_ptr, &iter);
dbus_message_iter_get_basic(&iter, &cvalue_ptr);
value_ptr = strdup(cvalue_ptr);
dbus_message_unref(reply_ptr);
if (value_ptr == NULL)
{
lash_error("strdup() failed for dict value");
return false;
}
*value_ptr_ptr = value_ptr;
return true;
}
bool
graph_proxy_dict_entry_drop(
graph_proxy_handle graph,
uint32_t object_type,
uint64_t object_id,
const char * key)
{
if (!dbus_call(graph_ptr->service, graph_ptr->object, IFACE_GRAPH_DICT, "Drop", "uts", &object_type, &object_id, &key, ""))
{
lash_error(IFACE_GRAPH_DICT ".Drop() failed.");
return false;
}
return true;
}

View File

@ -84,6 +84,29 @@ graph_proxy_disconnect_ports(
uint64_t port1_id,
uint64_t port2_id);
bool
graph_proxy_dict_entry_set(
graph_proxy_handle graph,
uint32_t object_type,
uint64_t object_id,
const char * key,
const char * value);
bool
graph_proxy_dict_entry_get(
graph_proxy_handle graph,
uint32_t object_type,
uint64_t object_id,
const char * key,
char ** value);
bool
graph_proxy_dict_entry_drop(
graph_proxy_handle graph,
uint32_t object_type,
uint64_t object_id,
const char * key);
#if 0
{ /* Adjust editor indent */
#endif

View File

@ -156,17 +156,15 @@ module_location_changed(
setlocale(LC_NUMERIC, locale);
free(locale);
lash_graph_dict_proxy_set(
graph_proxy_get_service(client_ptr->owner_ptr->graph),
graph_proxy_get_object(client_ptr->owner_ptr->graph),
graph_proxy_dict_entry_set(
client_ptr->owner_ptr->graph,
GRAPH_DICT_OBJECT_TYPE_CLIENT,
client_ptr->id,
URI_CANVAS_X,
x_str);
lash_graph_dict_proxy_set(
graph_proxy_get_service(client_ptr->owner_ptr->graph),
graph_proxy_get_object(client_ptr->owner_ptr->graph),
graph_proxy_dict_entry_set(
client_ptr->owner_ptr->graph,
GRAPH_DICT_OBJECT_TYPE_CLIENT,
client_ptr->id,
URI_CANVAS_Y,
@ -244,9 +242,8 @@ client_appeared(
x = 0;
y = 0;
if (!lash_graph_dict_proxy_get(
graph_proxy_get_service(graph_canvas_ptr->graph),
graph_proxy_get_object(graph_canvas_ptr->graph),
if (!graph_proxy_dict_entry_get(
client_ptr->owner_ptr->graph,
GRAPH_DICT_OBJECT_TYPE_CLIENT,
id,
URI_CANVAS_X,
@ -255,9 +252,8 @@ client_appeared(
x_str = NULL;
}
if (!lash_graph_dict_proxy_get(
graph_proxy_get_service(graph_canvas_ptr->graph),
graph_proxy_get_object(graph_canvas_ptr->graph),
if (!graph_proxy_dict_entry_get(
client_ptr->owner_ptr->graph,
GRAPH_DICT_OBJECT_TYPE_CLIENT,
id,
URI_CANVAS_Y,

View File

@ -262,7 +262,6 @@ def build(bld):
gladish.source = [
'jack_proxy.c',
'graph_proxy.c',
'graph_dict_proxy.c',
'studio_proxy.c',
'catdup.c',
]