static void get_earlier_data_method_call(GVariant *parameters, GDBusMethodInvocation *invocation)
{
GVariant *param = NULL;
- int result = 0;
+ int result = ES_R_ERROR;
char *event_name = NULL;
bundle *b = NULL;
bundle_raw *raw = NULL;
earlier_item *item;
g_variant_get(parameters, "(&s)", &event_name);
-
- if (event_name && strlen(event_name) > 0) {
- _D("event_name(%s)", event_name);
- result = ES_R_OK;
- } else {
- _E("invalid event_name(%s)", event_name);
- result = ES_R_ERROR;
- }
+ _D("event_name(%s)", event_name);
item = (earlier_item *)g_hash_table_lookup(earlier_event_table, event_name);
if (item != NULL) {
if (item->earlier_data) {
b = bundle_dup(item->earlier_data);
bundle_add_str(b, "is_earlier_data", "true");
- bundle_encode(b, &raw, &len);
- bundle_free(b);
+ result = ES_R_OK;
}
}
+ if (result == ES_R_ERROR)
+ b = bundle_create();
+
+ bundle_encode(b, &raw, &len);
+ bundle_free(b);
+
param = g_variant_new("(iis)", result, len, raw);
_D("result(%d), len(%d)", result, len);