gpointer user_data,
GDestroyNotify user_data_free_func,
GError **error);
-typedef void (*_g_dbus_error_register_error_domain)(const gchar *error_domain_quark_name,
- volatile gsize *quark_volatile,
- const GDBusErrorEntry *entries,
- guint num_entries);
-typedef GError *(*_g_error_new)(GQuark domain,
- gint code,
- const gchar *format,
- ...);
typedef void (*_g_error_free)(GError *error);
typedef void (*_g_dbus_method_invocation_return_value)(GDBusMethodInvocation *invocation,
GVariant *parameters);
-typedef void (*_g_dbus_method_invocation_return_gerror)(GDBusMethodInvocation *invocation,
- const GError *error);
/* ---------------------------------------------------------------------------------------------------- */
typedef struct
_g_dbus_node_info_new_for_xml node_info_new_for_xml;
_g_dbus_node_info_unref node_info_unref;
_g_dbus_connection_register_object connection_register_object;
- _g_dbus_error_register_error_domain register_error_domain;
- _g_error_new error_new;
_g_error_free error_free;
_g_dbus_method_invocation_return_value invocation_return_value;
- _g_dbus_method_invocation_return_gerror invocation_return_gerror;
} _gdbus_interface;
#ifdef __cplusplus
#define DEBUG(format, ...) printLog("[%s:%d] "format, __FILE__, __LINE__, ##__VA_ARGS__);
typedef enum {
+ /* Errors of Orchestration*/
+ ORCH_ERROR_NOT_READY = -1,
+ ORCH_ERROR_WIFI_UNREACHABLE = -2,
+
+ /* Errors of DBus*/
+ ORCH_ERROR_FAULT = -100,
+ ORCH_ERROR_INVALID_PARAMETER = -101,
+ ORCH_ERROR_DBUS_FAILURE = -102,
+
+ /*Success Error Code*/
ORCH_ERROR_NONE = 0,
- ORCH_ERROR_INVALID_PARAMETER,
- ORCH_ERROR_DBUS_FAILURE,
- ORCH_ERROR_FAULT,
} _orchestration_state_e;
-typedef void (*request_service_cb)(char* app_name, char* service_info);
+typedef int (*request_service_cb)(char* app_name, char* service_info);
void set_default_dbus_interface(void);
int orchestration_server_initialize(request_service_cb cb);
#include <orchestration_server.h>
#include <orchestration.h>
-void request_cb(char* app_name, char* service_info){
+int request_cb(char* app_name, char* service_info){
int result = ORCH_ERROR_FAULT;
DEBUG("app_name : %s\n", app_name);
DEBUG("service_info : %s\n", service_info);
result = OrchestrationRequestService(app_name, service_info);
- if (result != ORCH_ERROR_NONE) {
- DEBUG("OrchestrationRequestService failed\n");
- }
+
+ return result;
}
void* thread_orchestration() {
#define _ORCHESTRATION_BUS_NAME "org.tizen.orchestration"
#define _ORCHESTRATION_OBJECT_PATH "/org/tizen/orchestration"
-#define _ORCHESTRATION_SVC_ERROR_DOMAIN "orchestration"
-
-GDBusErrorEntry _orchestration_svc_errors[] = {
- {ORCH_ERROR_NONE, "NoError"},
- {ORCH_ERROR_INVALID_PARAMETER, "Invalid parameter"},
- {ORCH_ERROR_DBUS_FAILURE, "dbus failure"},
- {ORCH_ERROR_FAULT, "Orchestration Failed"},
-};
/* Introspection data for the service we are exporting */
static gchar introspection_xml[] =
" <method name='request_service'>"
" <arg type='s' name='app_name' direction='in'/>"
" <arg type='s' name='service_info' direction='in'/>"
+ " <arg type='i' name='return_value' direction='out'/>"
" </method>"
" </interface>"
" </node>";
_gdbus.node_info_new_for_xml = g_dbus_node_info_new_for_xml;
_gdbus.node_info_unref = g_dbus_node_info_unref;
_gdbus.connection_register_object = g_dbus_connection_register_object;
- _gdbus.register_error_domain = g_dbus_error_register_error_domain;
- _gdbus.error_new = g_error_new;
_gdbus.error_free = g_error_free;
_gdbus.invocation_return_value = g_dbus_method_invocation_return_value;
- _gdbus.invocation_return_gerror = g_dbus_method_invocation_return_gerror;
}
-static GQuark _ORCHESTRATION_ERROR_quark(void)
+static int _request_service(GVariant *parameters)
{
- static volatile gsize quark_volatile = 0;
- _gdbus.register_error_domain(_ORCHESTRATION_SVC_ERROR_DOMAIN,
- &quark_volatile,
- _orchestration_svc_errors,
- G_N_ELEMENTS(_orchestration_svc_errors));
- return (GQuark)quark_volatile;
-}
+ int result = ORCH_ERROR_NONE;
-static int _request_service(GVariant *parameters, GVariant **reply_body)
-{
char *app_name, *service_info;
if (!parameters)
{
return ORCH_ERROR_INVALID_PARAMETER;
}
+
g_variant_get(parameters, "(&ss)", &app_name, &service_info);
- if (app_name == NULL)
+ if (g_strcmp0(app_name, "") == 0)
return ORCH_ERROR_INVALID_PARAMETER;
- _request_service_cb(app_name, service_info);
+ result = _request_service_cb(app_name, service_info);
- *reply_body = g_variant_new("()");
- if (*reply_body == NULL)
- {
- printf("Failed to make reply_body\n");
- return ORCH_ERROR_FAULT;
- }
-
- return ORCH_ERROR_NONE;
+ return result;
}
static void _handle_method_call(
gpointer user_data)
{
int ret = ORCH_ERROR_NONE;
- GVariant *reply_body = NULL;
if (g_strcmp0(method_name, "request_service") == 0)
{
- ret = _request_service(parameters, &reply_body);
+ ret = _request_service(parameters);
}
if (ret == ORCH_ERROR_NONE)
{
printf("Orchestration service Success, method name : %s\n", method_name);
- g_dbus_method_invocation_return_value(invocation, reply_body);
}
else
{
printf("Orchestration service fail, method name : %s\n", method_name);
-
- GError *error = _gdbus.error_new(_ORCHESTRATION_ERROR_quark(), ret, "orchestration failed");
- _gdbus.invocation_return_gerror(invocation, error);
- _gdbus.error_free(error);
}
+ _gdbus.invocation_return_value(invocation, g_variant_new("(i)", ret));
}
static const GDBusInterfaceVTable _interface_vtable =
GDBusInterfaceInfo *valid_GDBusinterface;
gboolean requestCbResult;
-void fake_request_cb(char *app_name, char *service_info)
+int fake_request_cb(char *app_name, char *service_info)
{
if (app_name == APP_NAME && service_info == SERVICE_INFO)
{
- requestCbResult = true;
+ return 1;
}
else
{
- requestCbResult = false;
+ return -1;
}
}
{
}
-void fake_invocation_return_gerror(GDBusMethodInvocation *invocation,
- const GError *error)
-{
-}
-
-GError *fake_error_new(GQuark domain,
- gint code,
- const gchar *format,
- ...)
-{
- return NULL;
-}
-
void fake_error_free(GError *error)
{
}
-void fake_error_register_error_domain(const gchar *error_domain_quark_name,
- volatile gsize *quark_volatile,
- const GDBusErrorEntry *entries,
- guint num_entries)
-{
-}
-
class OrchestrationServerTests : public testing::Test
{
protected:
_gdbus.node_info_new_for_xml = fake_node_info_new_for_xml_success;
_gdbus.connection_register_object = fake_connection_register_object_success;
_gdbus.invocation_return_value = fake_invocation_return_value;
- _gdbus.invocation_return_gerror = fake_invocation_return_gerror;
- _gdbus.register_error_domain = fake_error_register_error_domain;
- _gdbus.error_new = fake_error_new;
_gdbus.error_free = fake_error_free;
_handle_method_call(NULL,
NULL,