4
Fork 0

Updated to support actual D-BUS interface

This commit is contained in:
R3ABM Artem 2016-04-04 23:22:28 +03:00
parent 660133c812
commit 9c4c356a3d
9 changed files with 103 additions and 34 deletions

View file

@ -24,19 +24,21 @@ int main(int argc, const char* argv[])
{ "expression", required_argument, NULL, 'e' },
{ "connection", required_argument, NULL, 'c' },
{ "identity", required_argument, NULL, 'i' },
{ "network", required_argument, NULL, 'n' },
{ "link", required_argument, NULL, 'l' },
{ NULL, 0, NULL, 0 }
};
pcre* expression = NULL;
const char* file = NULL;
uint32_t number = 10;
uint32_t network = 0;
uint32_t link = 10;
int position = 0;
const char* error = NULL;
int selection = 0;
while ((selection = getopt_long(argc, const_cast<char* const*>(argv), "e:c:l:", options, NULL)) != EOF)
while ((selection = getopt_long(argc, const_cast<char* const*>(argv), "e:c:n:l:", options, NULL)) != EOF)
switch (selection)
{
case 'e':
@ -51,8 +53,12 @@ int main(int argc, const char* argv[])
openlog(optarg, 0, LOG_USER);
break;
case 'n':
network = atoi(optarg);
break;
case 'l':
number = atoi(optarg);
link = atoi(optarg);
break;
}
@ -64,12 +70,14 @@ int main(int argc, const char* argv[])
}
if ((expression == NULL) ||
(network == 0) ||
(file == NULL))
{
printf(
"Usage: %s"
" --expression <regular expression>"
" --connection <path to configuration file>"
" --network <network number>"
" --link <link number>"
" [--identity <identity>]"
"\n",
@ -80,7 +88,7 @@ int main(int argc, const char* argv[])
// Main
UserDataStore store(file);
PatchCordProxy proxy(number);
PatchCordProxy proxy(network, link);
char* line = NULL;
size_t length = 0;

View file

@ -18,17 +18,19 @@
#define VALUE_CORD_OUTGOING_SOURCE_ID 1
#define VALUE_CORD_INCOMING_SOURCE_ID 4
PatchCordProxy::PatchCordProxy(uint32_t number) :
number(number),
banner(NULL)
PatchCordProxy::PatchCordProxy(uint32_t network, uint32_t link)
{
banner = NULL;
number = link;
asprintf(&path, OBJECT_PATH "/%d", network);
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
}
PatchCordProxy::~PatchCordProxy()
{
free(banner);
dbus_connection_unref(connection);
free(banner);
free(path);
}
void PatchCordProxy::setTalkerID(uint32_t value)
@ -46,7 +48,7 @@ uint32_t PatchCordProxy::getTalkerID()
void PatchCordProxy::getContextBanner()
{
DBusMessage* message = dbus_message_new_method_call(
SERVICE_NAME, OBJECT_PATH,
SERVICE_NAME, path,
INTERFACE_NAME, "getContextList");
const char* name = AUTOPATCH_LINK_NAME;
@ -82,7 +84,7 @@ void PatchCordProxy::getContextBanner()
void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value)
{
DBusMessage* message = dbus_message_new_method_call(
SERVICE_NAME, OBJECT_PATH,
SERVICE_NAME, path,
INTERFACE_NAME, "setVendorSpecificValue");
dbus_message_append_args(message,
@ -109,7 +111,7 @@ void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value)
uint32_t PatchCordProxy::getVendorSpecificValue(uint32_t key)
{
DBusMessage* message = dbus_message_new_method_call(
SERVICE_NAME, OBJECT_PATH,
SERVICE_NAME, path,
INTERFACE_NAME, "getContextData");
dbus_message_append_args(message,

View file

@ -10,7 +10,7 @@ class PatchCordProxy
{
public:
PatchCordProxy(uint32_t number);
PatchCordProxy(uint32_t network, uint32_t link);
~PatchCordProxy();
void setTalkerID(uint32_t value);
@ -19,6 +19,8 @@ class PatchCordProxy
private:
DBusConnection* connection;
char* path;
uint32_t number;
char* banner;