extern int OrchestrationInit();
-extern ResponseService OrchestrationRequestService(char* p0, int p1, RequestServiceInfo* p2, int p3);
+extern ResponseService OrchestrationRequestService(char* p0, int p1, char* p2, RequestServiceInfo* p3, int p4);
extern int PrintLog(char* p0);
ORCH_ERROR_NONE = 0,
} _orchestration_state_e;
-typedef int (*request_service_cb)(char* app_name, bool self_select, RequestServiceInfo service_info[], int count);
+typedef int (*request_service_cb)(char* app_name, bool self_select, RequestServiceInfo service_info[], int count, int client_pid);
void set_default_dbus_interface(void);
int orchestration_server_initialize(request_service_cb cb);
#include <stdarg.h>
#include <stdlib.h>
#include <pthread.h>
+#include <string.h>
#include <orchestration_server.h>
-int request_cb(char* app_name, bool self_select, RequestServiceInfo service_info[], int count){
+int get_process_name_by_pid(char* process_name, int pid) {
+ char fname[1024] = {0, };
+ char line[1024] = {0, };
+ ssize_t fname_len = snprintf(NULL, 0, "/proc/%d/status", pid);
+
+ snprintf(fname, fname_len + 1, "/proc/%d/status", pid);
+ FILE *fp = fopen(fname, "r");
+ if (fp == NULL) {
+ DEBUG("%d Process not found!!!\n", pid);
+ return -1;
+ }
+ while (!feof(fp)) {
+ fgets(line, 1024, fp);
+ if (strstr(line, "Name:") != NULL) {
+ int index = 0;
+ char *ptr = strchr(line, ':');
+ while (1) {
+ ptr++;
+ if (*ptr == '\n' || *ptr == '\0')
+ break;
+ if (*ptr != ' ' && *ptr != '\t')
+ process_name[index++] = *ptr;
+ }
+ process_name[index] = '\0';
+ printf("process_name = %s\n", process_name);
+ fclose(fp);
+ return 0;
+ }
+ }
+ printf("%d Process status have no Process name!!\n", pid);
+ fclose(fp);
+ return -1;
+}
+
+int request_cb(char* app_name, bool self_select, RequestServiceInfo service_info[], int count, int client_pid){
int ret = ORCH_ERROR_NONE;
+ char process_name[128] = {0, };
ResponseService result;
+ if (get_process_name_by_pid(process_name, client_pid) != 0) {
+ DEBUG("could not get Process name");
+ strncpy(process_name, "Unknown", strlen("Unknown"));
+ }
+
DEBUG("[orchestration_server]\n")
DEBUG("\t app_name : %s\n", app_name);
DEBUG("\t self_select : %s\n", self_select ? "true" : "false");
DEBUG("\t count : %d\n", count);
+ DEBUG("\t client_pid : %d\n", client_pid);
+ DEBUG("\t process_name : %s\n", process_name);
for (int ix = 0; ix < count; ix++) {
DEBUG("\t service_info[%d].ExecutionType : %s\n", ix, service_info[ix].ExecutionType);
DEBUG("\t service_info[%d].ExeCmd : %s\n", ix, service_info[ix].ExeCmd);
}
- result = OrchestrationRequestService(app_name, self_select, service_info, count);
+ result = OrchestrationRequestService(app_name, self_select, process_name, service_info, count);
DEBUG("result = %s\n", result.Message);
/* TO DO : parsing API response */
" <arg type='i' name='self_select' direction='in'/>"
" <arg type='a(ss)' name='service_info' direction='in'/>"
" <arg type='i' name='count' direction='in'/>"
+ " <arg type='i' name='client_pid' direction='in'/>"
" <arg type='i' name='return_value' direction='out'/>"
" </method>"
" </interface>"
char *app_name;
int count;
bool self_select;
+ int client_pid;
GVariantIter *iter;
RequestServiceInfo service_info[MAX_SVC_INFO_NUM] = {NULL, };
return ORCH_ERROR_INVALID_PARAMETER;
}
- g_variant_get(parameters, "(sia(ss)i)", &app_name, &self_select, &iter, &count);
+ g_variant_get(parameters, "(sia(ss)ii)", &app_name, &self_select, &iter, &count, &client_pid);
DEBUG("[orchestration dbus_interface] _request_service\n");
DEBUG("\t app_name = %s\n", app_name);
DEBUG("\t self_select = %s\n", self_select ? "true" : "false");
DEBUG("\t count = %d\n", count);
+ DEBUG("\t client_pid = %d\n", client_pid);
for (int i = 0; i < count; i++) {
g_variant_iter_loop (iter, "(ss)", &service_info[i].ExecutionType, &service_info[i].ExeCmd);
if (g_strcmp0(app_name, "") == 0)
return ORCH_ERROR_INVALID_PARAMETER;
- result = _request_service_cb(app_name, self_select, service_info, count);
+ result = _request_service_cb(app_name, self_select, service_info, count, client_pid);
return result;
}
}
static const GDBusInterfaceVTable _interface_vtable =
- {
- _handle_method_call,
- NULL,
- NULL};
+{
+ _handle_method_call,
+ NULL,
+ NULL
+};
static int _get_sync(void)
{
} _orchestration_dbus_state_e;
int dbus_consumer_initailze();
-int request_service_execute(char* app_name, bool self_select, service_info_s service_info[], int count);
+int request_service_execute(char* app_name, bool self_select, service_info_s service_info[], int count, int client_pid);
#ifdef __cplusplus
}
return ORCH_DBUS_ERROR_NONE;
}
-int request_service_execute(char* app_name, bool self_select, service_info_s service_info[], int count)
+int request_service_execute(char* app_name, bool self_select, service_info_s service_info[], int count, int client_pid)
{
int idx;
GError *error = NULL;
printf("\t app_name = %s\n", app_name);
printf("\t self_select = %s\n", self_select ? "true" : "false");
printf("\t count = %d\n", count);
+ printf("\t client_pid = %d\n", client_pid);
for (idx = 0; idx < count; idx++) {
printf("\t service_info[%d].exec_type = %s\n", idx, service_info[idx].exec_type);
printf("\t service_info[%d].exec_parameter = %s\n", idx, service_info[idx].exec_parameter);
);
}
- services = g_variant_new ("(sia(ss)i)", app_name, self_select, builder, count);
+ services = g_variant_new ("(sia(ss)ii)", app_name, self_select, builder, count, client_pid);
g_variant_builder_unref (builder);
GVariant *result =
void *user_data)
{
int result = 0;
+ int client_pid = getpid();
if (strcmp(app_name, "") == 0)
{
}
printf("[orchestration_client]\n");
+ printf("\t client_pid : %d\n", client_pid);
printf("\t app_name : %s\n", app_name);
printf("\t self_select : %s\n", self_select ? "true" : "false");
printf("\t count : %d\n", service_info.count);
printf("\t service_info[%d]->exec_parameter : %s\n", i, service_info.services[i].exec_parameter);
}
- result = request_service_execute(app_name, self_select, service_info.services, service_info.count);
+ result = request_service_execute(app_name, self_select, service_info.services, service_info.count, client_pid);
if (result != ORCH_DBUS_ERROR_NONE)
{
printf("request_service_execute failed\n");