## Include common directory ##
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include")
-INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/client")
-INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/provider")
-INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/consumer")
+INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/client/inc")
## Dependent packages ##
INCLUDE(FindPkgConfig)
## API ##
ADD_SUBDIRECTORY(include)
+## Sticker client ##
+ADD_SUBDIRECTORY(client)
+
## Sticker server ##
ADD_SUBDIRECTORY(server)
-## Sticker provider library ##
-ADD_SUBDIRECTORY(provider)
-
-## Sticker consumer library ##
-ADD_SUBDIRECTORY(consumer)
-
## Sticker parser ##
ADD_SUBDIRECTORY(sticker-parser)
--- /dev/null
+SET(CONSUMER_SRCS
+ src/sticker_consumer.c
+ src/sticker_data.c
+ src/sticker_dbus.c
+)
+
+SET(PROVIDER_SRCS
+ src/sticker_provider.c
+ src/sticker_data.c
+ src/sticker_dbus.c
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/client/inc)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+
+## Add definitions ##
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+
+## sticker consumer library ##
+ADD_LIBRARY(${PROJECT_NAME}-consumer SHARED ${CONSUMER_SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}-consumer ${pkgs_LDFLAGS})
+
+## sticker provider library ##
+ADD_LIBRARY(${PROJECT_NAME}-provider SHARED ${PROVIDER_SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}-provider ${pkgs_LDFLAGS})
+
+## Install library files ##
+INSTALL(TARGETS ${PROJECT_NAME}-consumer DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
+INSTALL(TARGETS ${PROJECT_NAME}-provider DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
\ No newline at end of file
static cynara *p_cynara = NULL;
-static void _free_sticker_data(sticker_data_h sticker_data)
-{
- if (sticker_data->app_id) {
- free(sticker_data->app_id);
- sticker_data->app_id = NULL;
- }
-
- if (sticker_data->uri) {
- free(sticker_data->uri);
- sticker_data->uri = NULL;
- }
-
- if (sticker_data->thumbnail) {
- free(sticker_data->thumbnail);
- sticker_data->thumbnail = NULL;
- }
-
- if (sticker_data->keyword) {
- g_list_free_full(sticker_data->keyword, free);
- sticker_data->keyword = NULL;
- }
-
- if (sticker_data->group) {
- free(sticker_data->group);
- sticker_data->group = NULL;
- }
-
- if (sticker_data->description) {
- free(sticker_data->description);
- sticker_data->description = NULL;
- }
-
- if (sticker_data->date) {
- free(sticker_data->date);
- sticker_data->date = NULL;
- }
-
- free(sticker_data);
- sticker_data = NULL;
-}
-
static int _cynara_initialize()
{
int ret = cynara_initialize(&p_cynara, NULL);
return ret;
}
+static int _call_sticker_data_foreach_cb(sticker_consumer_h consumer_handle, GVariantIter *id_iter, sticker_consumer_data_foreach_cb callback, void *user_data)
+{
+ int ret;
+ int info_id;
+ int count = 0;
+
+ if (!id_iter) return count;
+
+ while (g_variant_iter_loop (id_iter, "(i)", &info_id)) {
+ sticker_data_h sticker_data = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
+ if (!sticker_data)
+ continue;
+
+ ret = sticker_dbus_get_sticker_info_by_record_id(consumer_handle->gdbus_connection, sticker_data, info_id);
+ if (ret == STICKER_ERROR_NONE) {
+ count++;
+ callback(sticker_data, user_data);
+ }
+ sticker_data_destroy(sticker_data);
+ }
+
+ return count;
+}
+
EXPORT_API int sticker_consumer_create(sticker_consumer_h *consumer_handle)
{
CHECK_STICKER_FEATURE();
CHECK_STICKER_FEATURE();
int ret;
- int info_id;
int sticker_count = 0;
GVariantIter *id_iter = NULL;
goto cleanup;
}
- if (id_iter) {
- while (g_variant_iter_loop (id_iter, "(i)", &info_id)) {
- sticker_data_h sticker_data = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
- if (!sticker_data) {
- ret = STICKER_ERROR_OUT_OF_MEMORY;
- goto cleanup;
- }
-
- ret = sticker_dbus_get_sticker_info_by_record_id(consumer_handle->gdbus_connection, sticker_data, info_id);
- if (ret == STICKER_ERROR_NONE) {
- sticker_count++;
- callback(sticker_data, user_data);
- _free_sticker_data(sticker_data);
- } else {
- _free_sticker_data(sticker_data);
- goto cleanup;
- }
- }
- }
+ if (id_iter)
+ sticker_count = _call_sticker_data_foreach_cb(consumer_handle, id_iter, callback, user_data);
*result = sticker_count;
CHECK_STICKER_FEATURE();
int ret;
- int info_id;
int sticker_count = 0;
GVariantIter *id_iter = NULL;
goto cleanup;
}
- if (id_iter) {
- while (g_variant_iter_loop (id_iter, "(i)", &info_id)) {
- sticker_data_h sticker_data = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
- if (!sticker_data) {
- ret = STICKER_ERROR_OUT_OF_MEMORY;
- goto cleanup;
- }
-
- ret = sticker_dbus_get_sticker_info_by_record_id(consumer_handle->gdbus_connection, sticker_data, info_id);
- if (ret == STICKER_ERROR_NONE) {
- sticker_count++;
- callback(sticker_data, user_data);
- _free_sticker_data(sticker_data);
- } else {
- _free_sticker_data(sticker_data);
- goto cleanup;
- }
- }
- }
+ if (id_iter)
+ sticker_count = _call_sticker_data_foreach_cb(consumer_handle, id_iter, callback, user_data);
*result = sticker_count;
CHECK_STICKER_FEATURE();
int ret;
- int info_id;
int sticker_count = 0;
GVariantIter *id_iter = NULL;
goto cleanup;
}
- if (id_iter) {
- while (g_variant_iter_loop (id_iter, "(i)", &info_id)) {
- sticker_data_h sticker_data = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
- if (!sticker_data) {
- ret = STICKER_ERROR_OUT_OF_MEMORY;
- goto cleanup;
- }
-
- ret = sticker_dbus_get_sticker_info_by_record_id(consumer_handle->gdbus_connection, sticker_data, info_id);
- if (ret == STICKER_ERROR_NONE) {
- sticker_count++;
- callback(sticker_data, user_data);
- _free_sticker_data(sticker_data);
- } else {
- _free_sticker_data(sticker_data);
- goto cleanup;
- }
- }
- }
+ if (id_iter)
+ sticker_count = _call_sticker_data_foreach_cb(consumer_handle, id_iter, callback, user_data);
*result = sticker_count;
CHECK_STICKER_FEATURE();
int ret;
- int info_id;
int sticker_count = 0;
GVariantIter *id_iter = NULL;
goto cleanup;
}
- if (id_iter) {
- while (g_variant_iter_loop (id_iter, "(i)", &info_id)) {
- sticker_data_h sticker_data = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
- if (!sticker_data) {
- ret = STICKER_ERROR_OUT_OF_MEMORY;
- goto cleanup;
- }
-
- ret = sticker_dbus_get_sticker_info_by_record_id(consumer_handle->gdbus_connection, sticker_data, info_id);
- if (ret == STICKER_ERROR_NONE) {
- sticker_count++;
- callback(sticker_data, user_data);
- _free_sticker_data(sticker_data);
- } else {
- _free_sticker_data(sticker_data);
- goto cleanup;
- }
- }
- }
+ if (id_iter)
+ sticker_count = _call_sticker_data_foreach_cb(consumer_handle, id_iter, callback, user_data);
*result = sticker_count;
CHECK_STICKER_FEATURE();
int ret;
- int info_id;
int sticker_count = 0;
GVariantIter *id_iter = NULL;
goto cleanup;
}
- if (id_iter) {
- while (g_variant_iter_loop (id_iter, "(i)", &info_id)) {
- sticker_data_h sticker_data = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
- if (!sticker_data) {
- ret = STICKER_ERROR_OUT_OF_MEMORY;
- goto cleanup;
- }
-
- ret = sticker_dbus_get_sticker_info_by_record_id(consumer_handle->gdbus_connection, sticker_data, info_id);
- if (ret == STICKER_ERROR_NONE) {
- sticker_count++;
- callback(sticker_data, user_data);
- _free_sticker_data(sticker_data);
- } else {
- _free_sticker_data(sticker_data);
- goto cleanup;
- }
- }
- }
+ if (id_iter)
+ sticker_count = _call_sticker_data_foreach_cb(consumer_handle, id_iter, callback, user_data);
*result = sticker_count;
CHECK_STICKER_FEATURE();
int ret;
- int info_id;
int sticker_count = 0;
GVariantIter *id_iter = NULL;
goto cleanup;
}
- if (id_iter) {
- while (g_variant_iter_loop (id_iter, "(i)", &info_id)) {
- sticker_data_h sticker_data = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
- if (!sticker_data) {
- ret = STICKER_ERROR_OUT_OF_MEMORY;
- goto cleanup;
- }
-
- ret = sticker_dbus_get_sticker_info_by_record_id(consumer_handle->gdbus_connection, sticker_data, info_id);
- if (ret == STICKER_ERROR_NONE) {
- sticker_count++;
- callback(sticker_data, user_data);
- _free_sticker_data(sticker_data);
- } else {
- _free_sticker_data(sticker_data);
- goto cleanup;
- }
- }
- }
+ if (id_iter)
+ sticker_count = _call_sticker_data_foreach_cb(consumer_handle, id_iter, callback, user_data);
*result = sticker_count;
return NULL;
}
-static void _free_sticker_data(sticker_data_h sticker_data)
-{
- if (!sticker_data)
- return;
-
- if (sticker_data->app_id) {
- free(sticker_data->app_id);
- sticker_data->app_id = NULL;
- }
-
- if (sticker_data->uri) {
- free(sticker_data->uri);
- sticker_data->uri = NULL;
- }
-
- if (sticker_data->thumbnail) {
- free(sticker_data->thumbnail);
- sticker_data->thumbnail = NULL;
- }
-
- if (sticker_data->keyword) {
- g_list_free_full(sticker_data->keyword, free);
- sticker_data->keyword = NULL;
- }
-
- if (sticker_data->group) {
- free(sticker_data->group);
- sticker_data->group = NULL;
- }
-
- if (sticker_data->description) {
- free(sticker_data->description);
- sticker_data->description = NULL;
- }
-
- if (sticker_data->date) {
- free(sticker_data->date);
- sticker_data->date = NULL;
- }
-
- free(sticker_data);
- sticker_data = NULL;
-}
-
EXPORT_API int sticker_data_create(sticker_data_h *data_handle)
{
CHECK_STICKER_FEATURE();
cleanup:
if (handle)
- _free_sticker_data(handle);
+ sticker_data_destroy(handle);
if (gdbus_connection) {
int ret_err = sticker_dbus_shutdown(gdbus_connection, &server_watcher_id, &server_monitor_id, &monitor_id, STICKER_CLIENT_LIB_PROVIDER);
g_variant_iter_free(keyword_iter);
}
-static void _free_sticker_data(sticker_data_h sticker_data)
-{
- if (sticker_data->app_id) {
- free(sticker_data->app_id);
- sticker_data->app_id = NULL;
- }
-
- if (sticker_data->uri) {
- free(sticker_data->uri);
- sticker_data->uri = NULL;
- }
-
- if (sticker_data->thumbnail) {
- free(sticker_data->thumbnail);
- sticker_data->thumbnail = NULL;
- }
-
- if (sticker_data->keyword) {
- g_list_free_full(sticker_data->keyword, free);
- sticker_data->keyword = NULL;
- }
-
- if (sticker_data->group) {
- free(sticker_data->group);
- sticker_data->group = NULL;
- }
-
- if (sticker_data->description) {
- free(sticker_data->description);
- sticker_data->description = NULL;
- }
-
- if (sticker_data->date) {
- free(sticker_data->date);
- sticker_data->date = NULL;
- }
-
- free(sticker_data);
- sticker_data = NULL;
-}
-
static void _call_insert_finished_cb(sticker_provider_h provider_handle, GVariant *body)
{
int ret;
gpointer user_data)
{
LOGD("own_name : %s, signal_name : %s", g_dbus_connection_get_unique_name(connection), signal_name);
+
sticker_consumer_h consumer_handle = (sticker_consumer_h)user_data;
if (consumer_handle == NULL) {
if (keyword_iter)
g_variant_iter_free(keyword_iter);
- _free_sticker_data(sticker_data);
+ sticker_data_destroy(sticker_data);
}
}
}
ret = _send_sync_message(gdbus_connection, g_variant_new("(i)", sticker_data->sticker_info_id), &reply, "send_update_event");
cleanup:
- _free_sticker_data(origin_data);
+ sticker_data_destroy(origin_data);
if (reply_body)
g_variant_unref(reply_body);
#endif
#define LOG_TAG "STICKER_PROVIDER"
-static void _free_sticker_data(sticker_data_h sticker_data)
-{
- if (sticker_data->app_id) {
- free(sticker_data->app_id);
- sticker_data->app_id = NULL;
- }
-
- if (sticker_data->uri) {
- free(sticker_data->uri);
- sticker_data->uri = NULL;
- }
-
- if (sticker_data->thumbnail) {
- free(sticker_data->thumbnail);
- sticker_data->thumbnail = NULL;
- }
-
- if (sticker_data->keyword) {
- g_list_free_full(sticker_data->keyword, free);
- sticker_data->keyword = NULL;
- }
-
- if (sticker_data->group) {
- free(sticker_data->group);
- sticker_data->group = NULL;
- }
-
- if (sticker_data->description) {
- free(sticker_data->description);
- sticker_data->description = NULL;
- }
-
- if (sticker_data->date) {
- free(sticker_data->date);
- sticker_data->date = NULL;
- }
-
- free(sticker_data);
- sticker_data = NULL;
-}
-
EXPORT_API int sticker_provider_create(sticker_provider_h *provider_handle)
{
CHECK_STICKER_FEATURE();
if (ret == STICKER_ERROR_NONE) {
sticker_count++;
callback(sticker_data, user_data);
- _free_sticker_data(sticker_data);
+ sticker_data_destroy(sticker_data);
} else {
- _free_sticker_data(sticker_data);
+ sticker_data_destroy(sticker_data);
goto cleanup;
}
}
+++ /dev/null
-SET(SRCS
- sticker_consumer.c
- ../client/sticker_data.c
- ../client/sticker_dbus.c
-)
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
-
-## Add definitions ##
-ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
-
-## sticker consumer library ##
-ADD_LIBRARY(${PROJECT_NAME}-consumer SHARED ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME}-consumer ${pkgs_LDFLAGS})
-
-## Install library files ##
-INSTALL(TARGETS ${PROJECT_NAME}-consumer DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
+++ /dev/null
-SET(SRCS
- sticker_provider.c
- ../client/sticker_data.c
- ../client/sticker_dbus.c
-)
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
-
-## Add definitions ##
-ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
-
-## sticker provider library ##
-ADD_LIBRARY(${PROJECT_NAME}-provider SHARED ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME}-provider ${pkgs_LDFLAGS})
-
-## Install library files ##
-INSTALL(TARGETS ${PROJECT_NAME}-provider DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
AUX_SOURCE_DIRECTORY(src SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../common STICKER_COMMON_SOURCES)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../client STICKER_CLIENT_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../client/src STICKER_CLIENT_SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../consumer STICKER_CONSUMER_SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../provider STICKER_PROVIDER_SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mock MOCK_SRCS)