...
This commit is contained in:
parent
143fb78682
commit
c937c9b2d6
4 changed files with 62 additions and 28 deletions
|
@ -48,22 +48,13 @@ uint32_t PatchCordProxy::getTalkerID()
|
||||||
|
|
||||||
void PatchCordProxy::setTalkerAlias(const char* value)
|
void PatchCordProxy::setTalkerAlias(const char* value)
|
||||||
{
|
{
|
||||||
size_t length = strlen(value);
|
char* buffer;
|
||||||
const uint32_t* data = (const uint32_t*)value;
|
asprintf(&buffer, "set alias %s", value);
|
||||||
|
|
||||||
size_t index = VALUE_CORD_TALKER_ALIAS;
|
|
||||||
size_t count =
|
|
||||||
(length / sizeof(uint32_t)) +
|
|
||||||
((length % sizeof(uint32_t)) > 0);
|
|
||||||
|
|
||||||
getContextBanner();
|
getContextBanner();
|
||||||
while (count > 0)
|
invokeCommand(buffer);
|
||||||
{
|
|
||||||
setSpecificValue(index, *data);
|
free(buffer);
|
||||||
count --;
|
|
||||||
index ++;
|
|
||||||
data ++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchCordProxy::getContextBanner()
|
void PatchCordProxy::getContextBanner()
|
||||||
|
@ -101,6 +92,31 @@ void PatchCordProxy::getContextBanner()
|
||||||
dbus_message_unref(message);
|
dbus_message_unref(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PatchCordProxy::invokeCommand(const char* command)
|
||||||
|
{
|
||||||
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
|
name, OBJECT_PATH, INTERFACE_NAME, "invokeCommand");
|
||||||
|
|
||||||
|
dbus_message_append_args(message,
|
||||||
|
DBUS_TYPE_STRING, &banner,
|
||||||
|
DBUS_TYPE_STRING, &command,
|
||||||
|
DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
|
DBusPendingCall* pending;
|
||||||
|
if (dbus_connection_send_with_reply(connection, message, &pending, -1))
|
||||||
|
{
|
||||||
|
dbus_connection_flush(connection);
|
||||||
|
dbus_message_unref(message);
|
||||||
|
dbus_pending_call_block(pending);
|
||||||
|
message = dbus_pending_call_steal_reply(pending);
|
||||||
|
dbus_pending_call_unref(pending);
|
||||||
|
}
|
||||||
|
dbus_message_unref(message);
|
||||||
|
|
||||||
|
// Each call of dbus_message_unref removes banner from the heap
|
||||||
|
banner = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void PatchCordProxy::setSpecificValue(uint32_t key, uint32_t value)
|
void PatchCordProxy::setSpecificValue(uint32_t key, uint32_t value)
|
||||||
{
|
{
|
||||||
DBusMessage* message = dbus_message_new_method_call(
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
|
|
|
@ -26,6 +26,7 @@ class PatchCordProxy
|
||||||
char* banner;
|
char* banner;
|
||||||
|
|
||||||
void getContextBanner();
|
void getContextBanner();
|
||||||
|
void invokeCommand(const char* command);
|
||||||
void setSpecificValue(uint32_t key, uint32_t value);
|
void setSpecificValue(uint32_t key, uint32_t value);
|
||||||
uint32_t getSpecificValue(uint32_t key);
|
uint32_t getSpecificValue(uint32_t key);
|
||||||
|
|
||||||
|
|
|
@ -48,22 +48,13 @@ uint32_t PatchCordProxy::getTalkerID()
|
||||||
|
|
||||||
void PatchCordProxy::setTalkerAlias(const char* value)
|
void PatchCordProxy::setTalkerAlias(const char* value)
|
||||||
{
|
{
|
||||||
size_t length = strlen(value);
|
char* buffer;
|
||||||
const uint32_t* data = (const uint32_t*)value;
|
asprintf(&buffer, "set alias %s", value);
|
||||||
|
|
||||||
size_t index = VALUE_CORD_TALKER_ALIAS;
|
|
||||||
size_t count =
|
|
||||||
(length / sizeof(uint32_t)) +
|
|
||||||
((length % sizeof(uint32_t)) > 0);
|
|
||||||
|
|
||||||
getContextBanner();
|
getContextBanner();
|
||||||
while (count > 0)
|
invokeCommand(buffer);
|
||||||
{
|
|
||||||
setSpecificValue(index, *data);
|
free(buffer);
|
||||||
count --;
|
|
||||||
index ++;
|
|
||||||
data ++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchCordProxy::getContextBanner()
|
void PatchCordProxy::getContextBanner()
|
||||||
|
@ -101,6 +92,31 @@ void PatchCordProxy::getContextBanner()
|
||||||
dbus_message_unref(message);
|
dbus_message_unref(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PatchCordProxy::invokeCommand(const char* command)
|
||||||
|
{
|
||||||
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
|
name, OBJECT_PATH, INTERFACE_NAME, "invokeCommand");
|
||||||
|
|
||||||
|
dbus_message_append_args(message,
|
||||||
|
DBUS_TYPE_STRING, &banner,
|
||||||
|
DBUS_TYPE_STRING, &command,
|
||||||
|
DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
|
DBusPendingCall* pending;
|
||||||
|
if (dbus_connection_send_with_reply(connection, message, &pending, -1))
|
||||||
|
{
|
||||||
|
dbus_connection_flush(connection);
|
||||||
|
dbus_message_unref(message);
|
||||||
|
dbus_pending_call_block(pending);
|
||||||
|
message = dbus_pending_call_steal_reply(pending);
|
||||||
|
dbus_pending_call_unref(pending);
|
||||||
|
}
|
||||||
|
dbus_message_unref(message);
|
||||||
|
|
||||||
|
// Each call of dbus_message_unref removes banner from the heap
|
||||||
|
banner = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void PatchCordProxy::setSpecificValue(uint32_t key, uint32_t value)
|
void PatchCordProxy::setSpecificValue(uint32_t key, uint32_t value)
|
||||||
{
|
{
|
||||||
DBusMessage* message = dbus_message_new_method_call(
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
|
|
|
@ -26,6 +26,7 @@ class PatchCordProxy
|
||||||
char* banner;
|
char* banner;
|
||||||
|
|
||||||
void getContextBanner();
|
void getContextBanner();
|
||||||
|
void invokeCommand(const char* command);
|
||||||
void setSpecificValue(uint32_t key, uint32_t value);
|
void setSpecificValue(uint32_t key, uint32_t value);
|
||||||
uint32_t getSpecificValue(uint32_t key);
|
uint32_t getSpecificValue(uint32_t key);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue