int mc_db_disconnect(void *db_handle);
int mc_db_create_tables(void *handle);
int mc_db_create_server_table(void *handle, const char *server_name);
-int mc_db_delete_server_table(void *handle, const char* server_name);
-int mc_db_check_server_table_exist(void *handle, const char* server_name, bool *exist);
+int mc_db_delete_server_table(void *handle, const char *server_name);
+int mc_db_check_server_table_exist(void *handle, const char *server_name, bool *exist);
int mc_db_clear_table(void *db_handle, const char *table_name);
-int mc_db_update_playback_info(void *handle, const char* table_name, int playback_state, unsigned long long playback_position);
-int mc_db_update_whole_metadata(void *handle, const char* server_name,
- const char *title, const char *artist, const char *album, const char *author, const char *genre, const char *duration, const char *date,
- const char *copyright, const char *description, const char *track_num, const char *picture);
-int mc_db_update_metadata(void *handle, const char* table_name, char *name, char *value);
-int mc_db_update_shuffle_mode(void *handle, const char* table_name, int shuffle_mode);
-int mc_db_update_repeat_mode(void *handle, const char* table_name, int repeat_mode);
+int mc_db_update_playback_info(void *handle, const char *table_name, int playback_state, unsigned long long playback_position);
+int mc_db_update_whole_metadata(void *handle, const char *server_name,
+ const char *title, const char *artist, const char *album, const char *author, const char *genre, const char *duration, const char *date,
+ const char *copyright, const char *description, const char *track_num, const char *picture);
+int mc_db_update_metadata(void *handle, const char *table_name, char *name, char *value);
+int mc_db_update_shuffle_mode(void *handle, const char *table_name, int shuffle_mode);
+int mc_db_update_repeat_mode(void *handle, const char *table_name, int repeat_mode);
int mc_db_get_latest_server_name(void *handle, char **latest_server_name);
-int mc_db_get_server_state(void *handle, const char* server_name, mc_server_state_e *state);
-int mc_db_get_playback_info(void *handle, const char* server_name, mc_playback_h *playback);
-int mc_db_get_metadata_info(void *handle, const char* server_name, mc_metadata_h *metadata);
-int mc_db_get_shuffle_mode(void *handle, const char* server_name, mc_shuffle_mode_e *mode);
-int mc_db_get_repeat_mode(void *handle, const char* server_name, mc_repeat_mode_e *mode);
+int mc_db_get_server_state(void *handle, const char *server_name, mc_server_state_e *state);
+int mc_db_get_playback_info(void *handle, const char *server_name, mc_playback_h *playback);
+int mc_db_get_metadata_info(void *handle, const char *server_name, mc_metadata_h *metadata);
+int mc_db_get_shuffle_mode(void *handle, const char *server_name, mc_shuffle_mode_e *mode);
+int mc_db_get_repeat_mode(void *handle, const char *server_name, mc_repeat_mode_e *mode);
int mc_db_insert_server_address_into_table(void *db_handle, const char *table_name, char *address);
int mc_db_delete_server_address_from_table(void *db_handle, const char *table_name, char *address);
int mc_db_foreach_server_list(void *handle, mc_activated_server_cb callback, void *user_data);
-int mc_db_update_server_state(void *handle, const char* server_name, mc_server_state_e server_state);
-int mc_db_update_latest_server_table(void *handle, const char* server_name);
+int mc_db_update_server_state(void *handle, const char *server_name, mc_server_state_e server_state);
+int mc_db_update_latest_server_table(void *handle, const char *server_name);
#endif /*__MEDIA_CONTROL_DB_H__*/
#define FONT_COLOR_GRAY "\033[37m"
#define mc_debug(fmt, arg...) do { \
- LOGD(FONT_COLOR_RESET""fmt"", ##arg); \
- } while (0)
+ LOGD(FONT_COLOR_RESET""fmt"", ##arg); \
+ } while (0)
#define mc_info(fmt, arg...) do { \
- LOGI(FONT_COLOR_GREEN""fmt"", ##arg); \
- } while (0)
+ LOGI(FONT_COLOR_GREEN""fmt"", ##arg); \
+ } while (0)
#define mc_error(fmt, arg...) do { \
- LOGE(FONT_COLOR_RED""fmt"", ##arg); \
- } while (0)
+ LOGE(FONT_COLOR_RED""fmt"", ##arg); \
+ } while (0)
#define mc_debug_fenter() do { \
- LOGD(FONT_COLOR_RESET"<Enter>"); \
- } while (0)
+ LOGD(FONT_COLOR_RESET"<Enter>"); \
+ } while (0)
#define mc_debug_fleave() do { \
- LOGD(FONT_COLOR_RESET"<Leave>"); \
- } while (0)
+ LOGD(FONT_COLOR_RESET"<Leave>"); \
+ } while (0)
#define mc_retm_if(expr, fmt, arg...) do { \
if(expr) { \
#define ERR_BUF_LENGHT 256
#define mc_stderror(fmt) do { \
- char buf[ERR_BUF_LENGHT] = {0,}; \
+ char buf[ERR_BUF_LENGHT] = {0, }; \
strerror_r(errno, buf, ERR_BUF_LENGHT); \
LOGE(fmt" : standard error= [%s]", buf); \
} while (0)
#define MC_COMMAND_PLAYBACKSTATE "_playback_command_"
#define MC_COMMAND_CUSTOM "_custom_command_"
-typedef struct
-{
+typedef struct {
void *callback;
void *user_data;
}media_controller_reciever_s;
-typedef struct
-{
+typedef struct {
mc_playback_states_e state;
unsigned long long position;
}media_controller_playback_s;
-typedef struct
-{
+typedef struct {
char *title;
char *artist;
char *album;
char *picture;
}media_controller_metadata_s;
-typedef struct
-{
+typedef struct {
char *server_name;
void* db_handle;
media_controller_reciever_s custom_cmd_reciever;
}media_controller_server_s;
-typedef struct
-{
+typedef struct {
char *client_name;
void *db_handle;
media_controller_reciever_s reply_cb;
}media_controller_client_s;
-// formal callback to receive signal
-typedef void (*mc_signal_received_cb)(char* interface_name, char *signal_name, char *message, int size, void *user_data);
-typedef struct
-{
+/* formal callback to receive signal */
+typedef void(*mc_signal_received_cb)(char *interface_name, char *signal_name, char *message, int size, void *user_data);
+typedef struct {
GDBusConnection *dbus_conn;
char *interface_name;
char *signal_name;
} mc_ipc_listener_s;
-// util
+/* util */
int mc_util_get_own_name(char **name);
-char* mc_util_get_interface_name(const char *prefix, const char *type, const char *name);
+char *mc_util_get_interface_name(const char *prefix, const char *type, const char *name);
int mc_util_set_command_availabe(const char *name, const char *command_type, const char *command);
int mc_util_get_command_availabe(const char *name, const char *command_type, const char *command);
-// for d-bus IPC
+/* for d-bus IPC */
int mc_ipc_get_dbus_connection(GDBusConnection **conn, int *dref_count);
int mc_ipc_unref_dbus_connection(GDBusConnection *conn, int *dref_count);
int mc_ipc_register_listener(GList *manage_list, GDBusConnection *connection, const char *interface_name, const char *signal_name, mc_signal_received_cb callback, void *user_data);
* @brief Enumeration for the media controller error.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
MEDIA_CONTROLLER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
* @brief Enumeration for the media controller server state.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
MC_SERVER_STATE_NONE = 0, /**< None state*/
MC_SERVER_STATE_ACTIVATE, /**< Activate state*/
MC_SERVER_STATE_DEACTIVATE, /**< Deactivate state*/
* @brief Enumeration for the media meta info.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
MEDIA_TITLE = 0, /** < Title */
MEDIA_ARTIST, /** < Artist */
MEDIA_ALBUM, /** < Album */
* @brief Enumeration for the media playback state.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
MEDIA_PLAYBACK_STATE_NONE = 0, /** < None */
MEDIA_PLAYBACK_STATE_PLAYING, /** < Play */
MEDIA_PLAYBACK_STATE_PAUSED, /** < Pause */
* @brief Enumeration for the shuffle mode.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
SHUFFLE_MODE_ON = 0, /** < Shuffle mode on */
SHUFFLE_MODE_OFF, /** < Shuffle mode off */
} mc_shuffle_mode_e;
* @brief Enumeration for the repeat mode.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
REPEAT_MODE_ON = 0, /** < Repeat mode on */
REPEAT_MODE_OFF, /** < Repeat mode off */
} mc_repeat_mode_e;
Name: capi-media-controller
Summary: Multimedia Controller for player application
-Version: 0.0.1
+Version: 0.0.2
Release: 1
Group: System/Libraries
License: Apache-2.0
#include "media_controller_db.h"
-static void __client_server_cb(char* interface_name, char *signal_name, char *message, int size, void *user_data)
+static void __client_server_cb(char *interface_name, char *signal_name, char *message, int size, void *user_data)
{
gchar **params;
media_controller_reciever_s *reciever = (media_controller_reciever_s *)user_data;
g_strfreev(params);
}
-static void __client_playback_cb(char* interface_name, char *signal_name, char *message, int size, void *user_data)
+static void __client_playback_cb(char *interface_name, char *signal_name, char *message, int size, void *user_data)
{
gchar **params;
media_controller_reciever_s *reciever = (media_controller_reciever_s *)user_data;
mc_playback_updated_cb callback = (mc_playback_updated_cb)reciever->callback;
- media_controller_playback_s * playback = NULL;
+ media_controller_playback_s *playback = NULL;
mc_retm_if(reciever == NULL, "reciever is NULL");
mc_retm_if(reciever->callback == NULL, "playback_cb is NULL");
playback = (media_controller_playback_s *)g_malloc(sizeof(media_controller_playback_s));
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
- playback->state = atoi (params[1]);
+ playback->state = atoi(params[1]);
playback->position = atol(params[2]);
callback(params[0], (mc_playback_h) playback, reciever->user_data);
g_strfreev(params);
}
-static void __client_metadata_cb(char* interface_name, char* signal_name, char* message, int size, void* user_data)
+static void __client_metadata_cb(char *interface_name, char *signal_name, char *message, int size, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
mc_metadata_h metadata = NULL;
mc_debug("__client_metadata_cb(%s, %s, %s, %d, %p)", interface_name, signal_name, message, size, user_data);
ret = mc_db_get_metadata_info(mc_client->db_handle, message, &metadata);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- mc_error ("Fail to mc_db_get_metadata_info");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_db_get_metadata_info");
callback(message, metadata, mc_client->metadata_cb.user_data);
mc_client_destroy_metadata(metadata);
}
-static void __client_shuffle_cb(char* interface_name, char *signal_name, char *message, int size, void *user_data)
+static void __client_shuffle_cb(char *interface_name, char *signal_name, char *message, int size, void *user_data)
{
gchar **params;
media_controller_reciever_s *reciever = (media_controller_reciever_s *)user_data;
g_strfreev(params);
}
-static void __client_repeat_cb(char* interface_name, char *signal_name, char *message, int size, void *user_data)
+static void __client_repeat_cb(char *interface_name, char *signal_name, char *message, int size, void *user_data)
{
gchar **params;
media_controller_reciever_s *reciever = (media_controller_reciever_s *)user_data;
g_strfreev(params);
}
-static void __client_reply_cb(char* interface_name, char *signal_name, char *message, int size, void *user_data)
+static void __client_reply_cb(char *interface_name, char *signal_name, char *message, int size, void *user_data)
{
gchar **params = NULL;
int enc_size = 0;
mc_retm_if(params == NULL, "invalid custom data");
enc_size = atoi(params[2]);
- if(enc_size > 0)
+ if (enc_size > 0)
bundle_data = bundle_decode((bundle_raw *)params[3], enc_size);
callback(params[0], atoi(params[1]), bundle_data, reciever->user_data);
mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if(mc_client->dconn)
- {
+ if (mc_client->dconn) {
ret = mc_ipc_unref_dbus_connection(mc_client->dconn, &mc_client->dref_count);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("fail to mc_ipc_unref_dbus_connection");
}
- if(mc_client->db_handle)
- {
+ if (mc_client->db_handle) {
ret = mc_db_disconnect(mc_client->db_handle);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("fail to mc_db_disconnect");
}
mc_client = (media_controller_client_s *)calloc(1, sizeof(media_controller_client_s));
mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "Error allocation memory");
- mc_client->listeners = g_list_alloc ();
- if (mc_client->listeners == NULL)
- {
+ mc_client->listeners = g_list_alloc();
+ if (mc_client->listeners == NULL) {
ret = MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY;
- mc_error ("Error allocation list %d", ret);
+ mc_error("Error allocation list %d", ret);
__mc_client_destroy(mc_client);
return ret;
}
ret = mc_util_get_own_name(&(mc_client->client_name));
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
- mc_error ("Filed to get client name %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("Filed to get client name %d", ret);
__mc_client_destroy(mc_client);
return ret;
}
ret = mc_ipc_get_dbus_connection(&(mc_client->dconn), &(mc_client->dref_count));
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
- mc_error ("error in client init %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("error in client init %d", ret);
__mc_client_destroy(mc_client);
return ret;
}
ret = mc_db_connect(&mc_client->db_handle);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
- mc_error ("error in connecting to DB %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("error in connecting to DB %d", ret);
__mc_client_destroy(mc_client);
return ret;
}
ret = mc_db_create_tables(mc_client->db_handle);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
- mc_error ("mc_db_create_tables failed %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("mc_db_create_tables failed %d", ret);
__mc_client_destroy(mc_client);
return ret;
}
mc_client->server_state_cb.user_data = user_data;
ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_SERVER_STATE,
- __client_server_cb, (void*)&(mc_client->server_state_cb));
+ __client_server_cb, (void *)&(mc_client->server_state_cb));
return ret;
}
mc_client->playback_cb.user_data = user_data;
ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAY_BACK ,
- __client_playback_cb, (void*)&(mc_client->playback_cb));
+ __client_playback_cb, (void *)&(mc_client->playback_cb));
return ret;
}
mc_client->metadata_cb.user_data = user_data;
ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_METADATA,
- __client_metadata_cb, (void*)(mc_client));
+ __client_metadata_cb, (void *)(mc_client));
return ret;
}
mc_client->shuffle_cb.user_data = user_data;
ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_SHUFFLE,
- __client_shuffle_cb, (void*)&(mc_client->shuffle_cb));
+ __client_shuffle_cb, (void *)&(mc_client->shuffle_cb));
return ret;
}
mc_client->repeat_cb.user_data = user_data;
ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT,
- __client_repeat_cb, (void*)&(mc_client->repeat_cb));
+ __client_repeat_cb, (void *)&(mc_client->repeat_cb));
return ret;
}
int mc_client_get_metadata(mc_metadata_h metadata, mc_meta_e attribute, char **value)
{
char *meta_val = NULL;
- media_controller_metadata_s *mc_metadata = (media_controller_metadata_s*)metadata;
+ media_controller_metadata_s *mc_metadata = (media_controller_metadata_s *)metadata;
mc_retvm_if(mc_metadata == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(value == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "value is NULL");
mc_debug("attribute[%d]", attribute);
- switch(attribute)
- {
+ switch (attribute) {
case MEDIA_TITLE:
- if(mc_metadata->title != NULL)
+ if (mc_metadata->title != NULL)
meta_val = strdup(mc_metadata->title);
break;
case MEDIA_ARTIST:
- if(mc_metadata->artist != NULL)
+ if (mc_metadata->artist != NULL)
meta_val = strdup(mc_metadata->artist);
break;
case MEDIA_ALBUM:
- if(mc_metadata->album != NULL)
+ if (mc_metadata->album != NULL)
meta_val = strdup(mc_metadata->album);
break;
case MEDIA_AUTHOR:
- if(mc_metadata->author != NULL)
+ if (mc_metadata->author != NULL)
meta_val = strdup(mc_metadata->author);
break;
case MEDIA_GENRE:
- if(mc_metadata->genre != NULL)
+ if (mc_metadata->genre != NULL)
meta_val = strdup(mc_metadata->genre);
break;
case MEDIA_DURATION:
- if(mc_metadata->duration != NULL)
+ if (mc_metadata->duration != NULL)
meta_val = strdup(mc_metadata->duration);
break;
case MEDIA_DATE:
- if(mc_metadata->date != NULL)
+ if (mc_metadata->date != NULL)
meta_val = strdup(mc_metadata->date);
break;
case MEDIA_COPYRIGHT:
- if(mc_metadata->copyright != NULL)
+ if (mc_metadata->copyright != NULL)
meta_val = strdup(mc_metadata->copyright);
break;
case MEDIA_DESCRIPTION:
- if(mc_metadata->description != NULL)
+ if (mc_metadata->description != NULL)
meta_val = strdup(mc_metadata->description);
break;
case MEDIA_TRACK_NUM:
- if(mc_metadata->track_num != NULL)
+ if (mc_metadata->track_num != NULL)
meta_val = strdup(mc_metadata->track_num);
break;
case MEDIA_PICTURE:
- if(mc_metadata->picture != NULL)
+ if (mc_metadata->picture != NULL)
meta_val = strdup(mc_metadata->picture);
break;
default:
int mc_client_destroy_metadata(mc_metadata_h metadata)
{
- media_controller_metadata_s *mc_metadata = (media_controller_metadata_s*)metadata;
+ media_controller_metadata_s *mc_metadata = (media_controller_metadata_s *)metadata;
mc_retvm_if(mc_metadata == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
int mc_client_get_latest_server_info(mc_client_h client, char **server_name, mc_server_state_e *server_state)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- char * latest_server_name = NULL;
+ char *latest_server_name = NULL;
mc_server_state_e latest_server_state = MC_SERVER_STATE_NONE;
media_controller_client_s *mc_client = (media_controller_client_s *)client;
mc_retvm_if(server_state == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_state is NULL");
ret = mc_db_get_latest_server_name(mc_client->db_handle, &latest_server_name);
- mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail mc_db_get_latest_server_name [%d]",ret);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail mc_db_get_latest_server_name [%d]", ret);
- if(latest_server_name != NULL)
- {
+ if (latest_server_name != NULL) {
ret = mc_db_get_server_state(mc_client->db_handle, latest_server_name, &latest_server_state);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
- mc_error ("error in getting latest server state %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("error in getting latest server state %d", ret);
MC_SAFE_FREE(latest_server_name);
return ret;
}
*server_name = latest_server_name;
*server_state = latest_server_state;
- }
- else
- {
+ } else {
*server_name = NULL;
*server_state = MC_SERVER_STATE_NONE;
}
mc_retvm_if(playback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "playback Handle is NULL");
ret = mc_db_get_playback_info(mc_client->db_handle, server_name, playback);
- mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail mc_db_get_playback_info [%d]",ret);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail mc_db_get_playback_info [%d]", ret);
return ret;
}
mc_retvm_if(metadata == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "metadata Handle is NULL");
ret = mc_db_get_metadata_info(mc_client->db_handle, server_name, metadata);
- mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail mc_db_get_metadata_info [%d]",ret);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail mc_db_get_metadata_info [%d]", ret);
return ret;
}
mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
- mc_retvm_if(((state < MEDIA_PLAYBACK_STATE_PLAYING) ||( state > MEDIA_PLAYBACK_STATE_REWIND)) , MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "state is invalid");
+ mc_retvm_if(((state < MEDIA_PLAYBACK_STATE_PLAYING) || (state > MEDIA_PLAYBACK_STATE_REWIND)), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "state is invalid");
- message = g_strdup_printf ("%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, state);
- mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]",ret);
+ message = g_strdup_printf("%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, state);
+ mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]", ret);
ret = mc_util_set_command_availabe(mc_client->client_name, MC_COMMAND_PLAYBACKSTATE, NULL);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error mc_util_set_command_availabe [%d]", ret);
return ret;
}
ret = mc_ipc_send_message(mc_client->dconn, NULL, mc_util_get_interface_name(NULL, MC_SERVER, server_name), MC_DBUS_SIGNAL_NAME_PLAYBACK_STATE_CMD, message, 0);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error mc_ipc_send_message [%d]", ret);
}
char *message = NULL;
int size_r = 0;
bundle_raw *raw_data = NULL;
- media_controller_client_s *mc_client = (media_controller_client_s*)client;
+ media_controller_client_s *mc_client = (media_controller_client_s *)client;
mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
ret = mc_util_set_command_availabe(mc_client->client_name, MC_COMMAND_CUSTOM, command);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error mc_util_set_command_availabe [%d]", ret);
return ret;
}
- if(callback)
- {
+ if(callback) {
mc_client->reply_cb.callback = callback;
mc_client->reply_cb.user_data = user_data;
mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, mc_util_get_interface_name(NULL, MC_CLIENT, mc_client->client_name),
- MC_DBUS_SIGNAL_NAME_CMD_REPLY, __client_reply_cb, (void*)&(mc_client->reply_cb));
+ MC_DBUS_SIGNAL_NAME_CMD_REPLY, __client_reply_cb, (void *)&(mc_client->reply_cb));
}
- if(data)
- {
+ if (data) {
ret = bundle_encode(data, &raw_data, &size_r);
- mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail while encoding bundle [%d]",ret);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail while encoding bundle [%d]", ret);
}
if ((size_r == 0) || (raw_data == NULL)) {
- message = g_strdup_printf ("%s%s%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, command, MC_STRING_DELIMITER, size_r);
+ message = g_strdup_printf("%s%s%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, command, MC_STRING_DELIMITER, size_r);
} else {
- message = g_strdup_printf ("%s%s%s%s%d%s%s", mc_client->client_name, MC_STRING_DELIMITER, command, MC_STRING_DELIMITER, size_r, MC_STRING_DELIMITER, (unsigned char*)raw_data);
+ message = g_strdup_printf("%s%s%s%s%d%s%s", mc_client->client_name, MC_STRING_DELIMITER, command, MC_STRING_DELIMITER, size_r, MC_STRING_DELIMITER, (unsigned char *)raw_data);
}
- if(message == NULL)
- {
+ if (message == NULL) {
mc_error("Error when making message");
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
}
ret = mc_ipc_send_message(mc_client->dconn, NULL, mc_util_get_interface_name(NULL, MC_SERVER, server_name), MC_DBUS_SIGNAL_NAME_CUSTOM_CMD, message, 0);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("Error mc_ipc_send_message [%d]", ret);
MC_SAFE_FREE(message);
mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = mc_ipc_unregister_all_listener(mc_client->listeners, mc_client->dconn);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error mc_ipc_unregister_all_listener [%d]", ret);
}
int port = MC_DB_UPDATE_PORT;
int retry_count = 0;
- if(!MC_STRING_VALID(request_msg))
- {
+ if (!MC_STRING_VALID(request_msg)) {
mc_error("invalid query");
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
}
request_msg_size = strlen(request_msg);
- if(request_msg_size >= MAX_MSG_SIZE)
- {
+ if (request_msg_size >= MAX_MSG_SIZE) {
mc_error("Query is Too long. [%d] query size limit is [%d]", request_msg_size, MAX_MSG_SIZE);
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
}
send_msg.msg_type = msg_type;
send_msg.msg_size = request_msg_size;
- strncpy(send_msg.msg, request_msg, sizeof(send_msg.msg)-1);
+ strncpy(send_msg.msg, request_msg, sizeof(send_msg.msg) - 1);
/*Create Socket*/
ret = mc_ipc_create_client_socket(MC_TIMEOUT_SEC_10, &sock_info);
/*Set server Address*/
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sun_family = AF_UNIX;
- strncpy(serv_addr.sun_path, MC_IPC_PATH[port], sizeof(serv_addr.sun_path)-1);
+ strncpy(serv_addr.sun_path, MC_IPC_PATH[port], sizeof(serv_addr.sun_path) - 1);
/* Connecting to the media db server */
- if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
+ if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
mc_stderror("connect error");
mc_ipc_delete_client_socket(&sock_info);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
mc_error("recv failed : [%d]", sockfd);
mc_stderror("recv failed");
- if (errno == EINTR) {
+ if (errno == EINTR) {
mc_stderror("catch interrupt");
goto RETRY;
- }
+ }
if (errno == EWOULDBLOCK) {
- if(retry_count < MAX_RETRY_COUNT) {
+ if (retry_count < MAX_RETRY_COUNT) {
mc_error("TIME OUT[%d]", retry_count);
- retry_count ++;
+ retry_count++;
goto RETRY;
- }
+ }
mc_ipc_delete_client_socket(&sock_info);
mc_error("Timeout. Can't try any more");
sql_str = sqlite3_mprintf("CREATE TABLE IF NOT EXISTS %s (\
server_name TEXT PRIMARY KEY);",
- MC_DB_TABLE_SERVER_LIST);
+ MC_DB_TABLE_SERVER_LIST);
ret = __mc_db_update_db(handle, sql_str);
return ret;
}
-static int __mc_db_get_int_value_of_key(void *handle, const char* server_name, const char *key, int *value)
+static int __mc_db_get_int_value_of_key(void *handle, const char *server_name, const char *key, int *value)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
sql_str = sqlite3_mprintf(DB_SELECT_VALUE_OF_KEY, key, server_name);
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret)
- {
+ if (SQLITE_OK != ret) {
mc_error("prepare error [%s]\n", sqlite3_errmsg(db_handle));
SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
}
- while(SQLITE_ROW==ret)
- {
+ while (SQLITE_ROW == ret) {
*value = sqlite3_column_int(stmt, 0);
ret = sqlite3_step(stmt);
}
return MEDIA_CONTROLLER_ERROR_NONE;
}
-static int __mc_db_get_ulong_value_of_key(void *handle, const char* server_name, const char *key, unsigned long long *value)
+static int __mc_db_get_ulong_value_of_key(void *handle, const char *server_name, const char *key, unsigned long long *value)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
sql_str = sqlite3_mprintf(DB_SELECT_VALUE_OF_KEY, key, server_name);
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret)
- {
+ if (SQLITE_OK != ret) {
mc_error("prepare error [%s]\n", sqlite3_errmsg(db_handle));
SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
}
- while(SQLITE_ROW==ret)
- {
+ while (SQLITE_ROW == ret) {
*value = (unsigned long long)sqlite3_column_int64(stmt, 0);
ret = sqlite3_step(stmt);
}
/*Connect DB*/
ret = db_util_open(MC_DB_NAME, &db_handle, DB_UTIL_REGISTER_HOOK_METHOD);
- if (SQLITE_OK != ret)
- {
+ if (SQLITE_OK != ret) {
mc_error("error when db open");
*handle = NULL;
/*Register busy handler*/
ret = sqlite3_busy_handler(db_handle, __mc_db_busy_handler, NULL);
- if (SQLITE_OK != ret)
- {
+ if (SQLITE_OK != ret) {
if (db_handle) {
mc_error("error when register busy handler %s\n", sqlite3_errmsg(db_handle));
}
return ret;
}
-int mc_db_update_playback_info(void *handle, const char* server_name, int playback_state, unsigned long long playback_position)
+int mc_db_update_playback_info(void *handle, const char *server_name, int playback_state, unsigned long long playback_position)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
return ret;
}
-int mc_db_update_whole_metadata(void *handle, const char* server_name,
- const char *title, const char *artist, const char *album, const char *author, const char *genre, const char *duration, const char *date,
- const char *copyright, const char *description, const char *track_num, const char *picture)
+int mc_db_update_whole_metadata(void *handle, const char *server_name,
+ const char *title, const char *artist, const char *album, const char *author, const char *genre, const char *duration, const char *date,
+ const char *copyright, const char *description, const char *track_num, const char *picture)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
sql_str = sqlite3_mprintf(DB_UPDATE_METADATA_INFO_INFO_SERVER_TABLE, server_name,
- title, artist, album, author, genre, duration, date, copyright, description, track_num, picture);
+ title, artist, album, author, genre, duration, date, copyright, description, track_num, picture);
ret = __mc_db_update_db(handle, sql_str);
return ret;
}
-int mc_db_update_metadata(void *handle, const char* server_name, char *name, char *value)
+int mc_db_update_metadata(void *handle, const char *server_name, char *name, char *value)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
return ret;
}
-int mc_db_update_shuffle_mode(void *handle, const char* server_name, int shuffle_mode)
+int mc_db_update_shuffle_mode(void *handle, const char *server_name, int shuffle_mode)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
return ret;
}
-int mc_db_update_repeat_mode(void *handle, const char* server_name, int repeat_mode)
+int mc_db_update_repeat_mode(void *handle, const char *server_name, int repeat_mode)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
mc_error("end of row [%s]\n", sqlite3_errmsg(db_handle));
SQLITE3_FINALIZE(stmt);
SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_NONE; //There is no activated server yet.
+ return MEDIA_CONTROLLER_ERROR_NONE; /*There is no activated server yet. */
}
while (SQLITE_ROW == ret) {
MC_SAFE_FREE(server_name);
- server_name = strdup((char*)sqlite3_column_text(stmt, 0));
+ server_name = strdup((char *)sqlite3_column_text(stmt, 0));
ret = sqlite3_step(stmt);
}
- if(server_name)
+ if (server_name)
*latest_server_name = server_name;
SQLITE3_FINALIZE(stmt);
return MEDIA_CONTROLLER_ERROR_NONE;
}
-int mc_db_get_playback_info(void *handle, const char* server_name, mc_playback_h *playback)
+int mc_db_get_playback_info(void *handle, const char *server_name, mc_playback_h *playback)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
mc_playback_states_e playback_state = MEDIA_PLAYBACK_STATE_PLAYING;
ret = __mc_db_get_ulong_value_of_key(handle, server_name, "playback_position", &position);
mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "Fail to get position");
- _playback = (media_controller_playback_s*)calloc(1, sizeof(media_controller_playback_s));
+ _playback = (media_controller_playback_s *)calloc(1, sizeof(media_controller_playback_s));
mc_retvm_if(_playback == NULL, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
_playback->state = playback_state;
return MEDIA_CONTROLLER_ERROR_NONE;
}
-int mc_db_get_metadata_info(void *handle, const char* server_name, mc_metadata_h *metadata)
+int mc_db_get_metadata_info(void *handle, const char *server_name, mc_metadata_h *metadata)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
sql_str = sqlite3_mprintf(DB_SELECT_METADATA_FROM_DB, server_name);
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret)
- {
+ if (SQLITE_OK != ret) {
mc_error("prepare error [%s]\n", sqlite3_errmsg(db_handle));
SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
SQLITE3_FINALIZE(stmt);
SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
- }
-else
- {
- _metadata = (media_controller_metadata_s*)calloc(1, sizeof(media_controller_metadata_s));
+ } else {
+ _metadata = (media_controller_metadata_s *)calloc(1, sizeof(media_controller_metadata_s));
mc_retvm_if(_metadata == NULL, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TITLE)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TITLE)))
_metadata->title = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TITLE));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ARTIST)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ARTIST)))
_metadata->artist = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ARTIST));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ALBUM)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ALBUM)))
_metadata->album = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ALBUM));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_AUTHOR)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_AUTHOR)))
_metadata->author = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_AUTHOR));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_GENRE)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_GENRE)))
_metadata->genre = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_GENRE));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DURATION)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DURATION)))
_metadata->duration = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DURATION));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DATE)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DATE)))
_metadata->date = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DATE));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_COPYRIGHT)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_COPYRIGHT)))
_metadata->copyright = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_COPYRIGHT));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DESCRIPTION)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DESCRIPTION)))
_metadata->description = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DESCRIPTION));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TRACK_NUM)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TRACK_NUM)))
_metadata->track_num = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TRACK_NUM));
- if(MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_PICTURE)))
+ if (MC_STRING_VALID((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_PICTURE)))
_metadata->picture = strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_PICTURE));
}
return MEDIA_CONTROLLER_ERROR_NONE;
}
-int mc_db_get_server_state(void *handle, const char* server_name, mc_server_state_e *state)
+int mc_db_get_server_state(void *handle, const char *server_name, mc_server_state_e *state)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
return ret;
}
-int mc_db_get_shuffle_mode(void *handle, const char* server_name, mc_shuffle_mode_e *mode)
+int mc_db_get_shuffle_mode(void *handle, const char *server_name, mc_shuffle_mode_e *mode)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
return ret;
}
-int mc_db_get_repeat_mode(void *handle, const char* server_name, mc_repeat_mode_e *mode)
+int mc_db_get_repeat_mode(void *handle, const char *server_name, mc_repeat_mode_e *mode)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
mc_retvm_if(db_handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = db_util_close(db_handle);
- if (SQLITE_OK != ret)
- {
+ if (SQLITE_OK != ret) {
mc_error("error when db close");
mc_error("Error : %s", sqlite3_errmsg(db_handle));
db_handle = NULL;
mc_retvm_if(db_handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = __mc_db_create_latest_server_table(db_handle);
- mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "create latest_server table failed!err= [%d]",ret);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "create latest_server table failed!err= [%d]", ret);
ret = __mc_db_create_server_list_table(db_handle);
- mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "create server_list table failed!err= [%d]",ret);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "create server_list table failed!err= [%d]", ret);
return MEDIA_CONTROLLER_ERROR_NONE;
}
-int mc_db_create_server_table(void *handle, const char* server_name)
+int mc_db_create_server_table(void *handle, const char *server_name)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
shuffle_mode INTEGER DEFAULT 1, \
repeat_mode INTEGER DEFAULT 1 \
);",
- server_name);
+ server_name);
ret = __mc_db_update_db(handle, sql_str);
return ret;
}
-int mc_db_delete_server_table(void *handle, const char* server_name)
+int mc_db_delete_server_table(void *handle, const char *server_name)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
return ret;
}
-int mc_db_check_server_table_exist(void *handle, const char* server_name, bool *exist)
+int mc_db_check_server_table_exist(void *handle, const char *server_name, bool *exist)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
sqlite3_stmt *stmt = NULL;
- int count= 0;
+ int count = 0;
mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
mc_debug("table count [%d]", count);
- if(count > 0)
+ if (count > 0)
*exist = TRUE;
else
*exist = FALSE;
while (SQLITE_ROW == ret) {
char *server_name = NULL;
- server_name = strdup((char*)sqlite3_column_text(stmt, 0));
- if(callback(server_name, user_data) == false)
- {
+ server_name = strdup((char *)sqlite3_column_text(stmt, 0));
+ if (callback(server_name, user_data) == false) {
MC_SAFE_FREE(server_name);
break;
}
return MEDIA_CONTROLLER_ERROR_NONE;
}
-int mc_db_update_server_state(void *handle, const char* server_name, mc_server_state_e server_state)
+int mc_db_update_server_state(void *handle, const char *server_name, mc_server_state_e server_state)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
}
-int mc_db_update_latest_server_table(void *handle, const char* server_name)
+int mc_db_update_latest_server_table(void *handle, const char *server_name)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
#include "media_controller_private.h"
-static char* __make_key_for_map(const char* main_key, const char* sub_key)
+static char *__make_key_for_map(const char *main_key, const char *sub_key)
{
return g_strdup_printf("%s.%s", main_key, sub_key);
}
-static void __mc_ipc_signal_cb(GDBusConnection* connection,
- const gchar* sender_name,
- const gchar* object_path,
- const gchar* interface_name,
- const gchar* signal_name,
- GVariant* parameters,
- gpointer user_data)
- {
+static void __mc_ipc_signal_cb(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
char *key = __make_key_for_map(interface_name, signal_name);
- GList *listener_list = (GList*)user_data;
+ GList *listener_list = (GList *)user_data;
int i;
mc_debug("__mc_ipc_signal_cb Received : ");
- for(i=0;i<g_list_length(listener_list); i++)
- {
+ for (i = 0; i < g_list_length(listener_list); i++) {
mc_ipc_listener_s *listener = (mc_ipc_listener_s *)g_list_nth_data(listener_list, i);
- if(listener && !strcmp(listener->key, key))
- {
- gchar* message = NULL;
+ if (listener && !strcmp(listener->key, key)) {
+ gchar *message = NULL;
int internal_flags = 0;
g_variant_get(parameters, "(i&s)", &internal_flags, &message);
if (!message) {
static gboolean _mc_ipc_is_listener_duplicated(GList *listener_list, const char *key)
{
int i = 0;
- for (i=0; i<g_list_length(listener_list);i++)
- {
- mc_ipc_listener_s *listener = (mc_ipc_listener_s*)g_list_nth_data((listener_list), i);
+ for (i = 0; i < g_list_length(listener_list); i++) {
+ mc_ipc_listener_s *listener = (mc_ipc_listener_s *)g_list_nth_data((listener_list), i);
mc_retvm_if(listener && !strcmp(listener->key, key), TRUE, "listener[%s] is duplicated ", key);
}
return FALSE;
}
-static guint _mc_ipc_signal_subscribe(GDBusConnection* connection, const char* interface_name, const char* signal_name, void *user_data)
+static guint _mc_ipc_signal_subscribe(GDBusConnection *connection, const char *interface_name, const char *signal_name, void *user_data)
{
guint ret = g_dbus_connection_signal_subscribe(
- connection,
- NULL,
- interface_name,
- signal_name,
- MC_DBUS_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __mc_ipc_signal_cb,
- user_data,
- NULL);
+ connection,
+ NULL,
+ interface_name,
+ signal_name,
+ MC_DBUS_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __mc_ipc_signal_cb,
+ user_data,
+ NULL);
return ret;
}
-static void _mc_ipc_signal_unsubscribe(GDBusConnection* connection, guint handler)
+static void _mc_ipc_signal_unsubscribe(GDBusConnection *connection, guint handler)
{
g_dbus_connection_signal_unsubscribe(connection, handler);
}
_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (!_connection) {
- mc_error("g_bus_get_sync failed : %s", error?error->message:"none");
+ mc_error("g_bus_get_sync failed : %s", error ? error->message : "none");
g_object_unref(_connection);
if (error) g_error_free(error);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
mc_retvm_if(signal_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "signal_name is NULL");
key = __make_key_for_map(interface_name, signal_name);
- if(key == NULL)
- {
+ if (key == NULL) {
mc_error("fail to get key");
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
}
- for (i=g_list_length(listener_list); i > 0; i--)
- {
- mc_ipc_listener_s *listener = (mc_ipc_listener_s*)g_list_nth_data(listener_list, i);
- if (listener && !strcmp(listener->key, key))
- {
+ for (i = g_list_length(listener_list); i > 0; i--) {
+ mc_ipc_listener_s *listener = (mc_ipc_listener_s *)g_list_nth_data(listener_list, i);
+ if (listener && !strcmp(listener->key, key)) {
_mc_ipc_signal_unsubscribe(connection, listener->handler);
MC_SAFE_FREE(listener->interface_name);
MC_SAFE_FREE(listener->signal_name);
mc_retvm_if(connection == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "connection is NULL");
mc_retvm_if(listener_list == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "listener_list is NULL");
- for (i=g_list_length(listener_list); i > 0; i--)
- {
- mc_ipc_listener_s *listener = (mc_ipc_listener_s*)g_list_nth_data(listener_list, i);
- if (listener)
- {
+ for (i = g_list_length(listener_list); i > 0; i--) {
+ mc_ipc_listener_s *listener = (mc_ipc_listener_s *)g_list_nth_data(listener_list, i);
+ if (listener) {
_mc_ipc_signal_unsubscribe(connection, listener->handler);
MC_SAFE_FREE(listener->interface_name);
MC_SAFE_FREE(listener->signal_name);
return MEDIA_CONTROLLER_ERROR_NONE;
}
-int mc_ipc_send_message(GDBusConnection *connection, const char *dbus_name, const char *interface_name, const char* signal_name, const char* message, int flags)
+int mc_ipc_send_message(GDBusConnection *connection, const char *dbus_name, const char *interface_name, const char *signal_name, const char *message, int flags)
{
- GError* error = NULL;
+ GError *error = NULL;
mc_retvm_if(connection == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "connection is NULL");
mc_retvm_if(signal_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "signal_name is NULL");
mc_debug("emit signal - interface: %s, signal: %s", interface_name, signal_name);
gboolean emmiting = g_dbus_connection_emit_signal(
- connection,
- dbus_name,
- MC_DBUS_PATH,
- interface_name,
- signal_name,
- g_variant_new("(is)", 0, message),
- &error);
- if (!emmiting)
- {
- mc_error("g_dbus_connection_emit_signal failed : %s", error?error->message:"none");
- if (error)
- {
+ connection,
+ dbus_name,
+ MC_DBUS_PATH,
+ interface_name,
+ signal_name,
+ g_variant_new("(is)", 0, message),
+ &error);
+ if (!emmiting) {
+ mc_error("g_dbus_connection_emit_signal failed : %s", error ? error->message : "none");
+ if (error) {
mc_error("Error in g_dbus_connection_emit_signal");
g_error_free(error);
}
#include "media_controller_private.h"
#include "media_controller_db.h"
-static int __mc_server_create(media_controller_server_s** mc_server, const char* server_name)
+static int __mc_server_create(media_controller_server_s **mc_server, const char *server_name)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *_server = NULL;
mc_retvm_if(_server == NULL, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "Error allocation memory");
_server->server_name = strdup(server_name);
- if(_server->server_name == NULL)
- {
+ if (_server->server_name == NULL) {
mc_error("Error allocation memory");
ret = MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY;
goto ERROR;
}
_server->metadata = (media_controller_metadata_s *)calloc(1, sizeof(media_controller_metadata_s));
- if (_server->metadata==NULL)
- {
+ if (_server->metadata == NULL) {
mc_error("Error allocation memory");
ret = MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY;
goto ERROR;
}
ret = mc_ipc_get_dbus_connection(&(_server->dconn), &(_server->dref_count));
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error allocation memory");
goto ERROR;
}
ret = mc_db_connect(&(_server->db_handle));
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail mc_db_connect [%d]", ret);
goto ERROR;
}
return MEDIA_CONTROLLER_ERROR_NONE;
ERROR:
- if(_server->dconn)
+ if (_server->dconn)
mc_ipc_unref_dbus_connection(_server->dconn, &_server->dref_count);
- if(_server->db_handle)
+ if (_server->db_handle)
mc_db_disconnect(_server->db_handle);
MC_SAFE_FREE(_server->server_name);
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if(mc_server->dconn)
- {
+ if (mc_server->dconn) {
ret = mc_ipc_unref_dbus_connection(mc_server->dconn, &mc_server->dref_count);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("fail to mc_ipc_unref_dbus_connection");
}
- if(mc_server->db_handle)
- {
+ if (mc_server->db_handle) {
ret = mc_db_disconnect(mc_server->db_handle);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("fail to mc_db_disconnect");
}
MC_SAFE_FREE(mc_server->server_name);
- if (mc_server->metadata)
- {
+ if (mc_server->metadata) {
MC_SAFE_FREE(mc_server->metadata->title);
MC_SAFE_FREE(mc_server->metadata->artist);
MC_SAFE_FREE(mc_server->metadata->album);
return ret;
}
-static void __server_playback_state_command_cb(char* interface_name, char *signal_name, char *message, int size, void *user_data)
+static void __server_playback_state_command_cb(char *interface_name, char *signal_name, char *message, int size, void *user_data)
{
gchar **params;
media_controller_reciever_s *receiver = (media_controller_reciever_s *)user_data;
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid playback state command");
- if(mc_util_get_command_availabe(params[0], MC_COMMAND_PLAYBACKSTATE, NULL) != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (mc_util_get_command_availabe(params[0], MC_COMMAND_PLAYBACKSTATE, NULL) != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error permission denied");
return ;
}
g_strfreev(params);
}
-static void __server_custom_command_cb(char* interface_name, char *signal_name, char *message, int size, void *user_data)
+static void __server_custom_command_cb(char *interface_name, char *signal_name, char *message, int size, void *user_data)
{
gchar **params = NULL;
int enc_size = 0;
char *sender = NULL;
char *command = NULL;
- bundle * bundle_data = NULL;
+ bundle *bundle_data = NULL;
media_controller_reciever_s *receiver = (media_controller_reciever_s *)user_data;
mc_retm_if(receiver == NULL, "reciever is NULL");
mc_retm_if(params == NULL, "invalid custom data");
sender = strdup(params[0]);
- if(mc_util_get_command_availabe(sender, MC_COMMAND_CUSTOM, params[1]) != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (mc_util_get_command_availabe(sender, MC_COMMAND_CUSTOM, params[1]) != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error permission denied");
return ;
}
command = strdup(params[1]);
enc_size = atoi(params[2]);
- if(enc_size > 0)
+ if (enc_size > 0)
bundle_data = bundle_decode((bundle_raw *)params[3], enc_size);
callback(sender, command, bundle_data, receiver->user_data);
*is_latest = FALSE;
ret = mc_db_get_latest_server_name(mc_server->db_handle, &latest_server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail mc_db_get_latest_server_name [%d]", ret);
return ret;
}
- if((latest_server_name != NULL) && (mc_server->server_name != NULL))
- {
- if(!strcmp(latest_server_name, mc_server->server_name))
+ if ((latest_server_name != NULL) && (mc_server->server_name != NULL)) {
+ if (!strcmp(latest_server_name, mc_server->server_name))
*is_latest = TRUE;
}
mc_retvm_if(interface_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "interface_name is NULL");
mc_retvm_if(signal_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "signal_name is NULL");
- if(!strcmp(MC_DBUS_SIGNAL_NAME_PLAY_BACK, signal_name))
- {
+ if (!strcmp(MC_DBUS_SIGNAL_NAME_PLAY_BACK, signal_name)) {
message = g_strdup_printf("%s%s%d%s%llu", mc_server->server_name, MC_STRING_DELIMITER, param1, MC_STRING_DELIMITER, param2);
- }
- else if(!strcmp(MC_DBUS_SIGNAL_NAME_METADATA, signal_name))
- {
+ } else if (!strcmp(MC_DBUS_SIGNAL_NAME_METADATA, signal_name)) {
message = g_strdup_printf("%s", mc_server->server_name);
- }
- else
- {
+ } else {
message = g_strdup_printf("%s%s%d", mc_server->server_name, MC_STRING_DELIMITER, param1);
}
- if(message == NULL)
- {
+ if (message == NULL) {
mc_error("Error when making message");
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
}
ret = mc_ipc_send_message(mc_server->dconn, NULL, interface_name, signal_name, message, 0);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error mc_ipc_send_message [%d]", ret);
}
int mc_server_set_playback_state(mc_server_h server, mc_playback_states_e state)
{
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- mc_retvm_if(((state < MEDIA_PLAYBACK_STATE_PLAYING) ||( state > MEDIA_PLAYBACK_STATE_REWIND)) , MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "state is invalid");
+ mc_retvm_if(((state < MEDIA_PLAYBACK_STATE_PLAYING) || (state > MEDIA_PLAYBACK_STATE_REWIND)), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "state is invalid");
mc_debug("playback state update [%d]", state);
int mc_server_set_playback_position(mc_server_h server, unsigned long long position)
{
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
int mc_server_update_playback_info(mc_server_h server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_debug("playback info update: state [%d], position [%llu]", mc_server->playback.state, mc_server->playback.position);
ret = mc_db_update_playback_info(mc_server->db_handle, mc_server->server_name, (int)mc_server->playback.state, mc_server->playback.position);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail mc_db_update_playback_info [%d]", ret);
return ret;
}
ret = __mc_server_send_message(mc_server, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAY_BACK, mc_server->playback.state, mc_server->playback.position);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error __mc_server_send_message [%d]", ret);
}
- if(mc_server->playback.state == MEDIA_PLAYBACK_STATE_PLAYING)
- {
+ if (mc_server->playback.state == MEDIA_PLAYBACK_STATE_PLAYING) {
ret = mc_db_update_latest_server_table(mc_server->db_handle, mc_server->server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail mc_db_update_playback_info [%d]", ret);
return ret;
}
int mc_server_update_shuffle_mode(mc_server_h server, mc_shuffle_mode_e mode)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if((mode != SHUFFLE_MODE_ON) && (mode != SHUFFLE_MODE_OFF))
- {
+ if ((mode != SHUFFLE_MODE_ON) && (mode != SHUFFLE_MODE_OFF)) {
mc_error("Invalid shuffle mode [%d]", mode);
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
}
int mc_server_update_repeat_mode(mc_server_h server, mc_repeat_mode_e mode)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if((mode != REPEAT_MODE_ON) && (mode != REPEAT_MODE_OFF))
- {
+ if ((mode != REPEAT_MODE_ON) && (mode != REPEAT_MODE_OFF)) {
mc_error("Invalid repeat mode [%d]", mode);
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
}
int mc_server_set_metadata(mc_server_h server, mc_meta_e attribute, const char *value)
{
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_debug("meta data set attribute [%d] value [%s]", attribute, value);
- switch(attribute)
- {
+ switch (attribute) {
case MEDIA_TITLE:
MC_SAFE_FREE(mc_server->metadata->title);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->title = strdup(value);
break;
case MEDIA_ARTIST:
MC_SAFE_FREE(mc_server->metadata->artist);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->artist = strdup(value);
break;
case MEDIA_ALBUM:
MC_SAFE_FREE(mc_server->metadata->album);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->album = strdup(value);
break;
case MEDIA_AUTHOR:
MC_SAFE_FREE(mc_server->metadata->author);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->author = strdup(value);
break;
case MEDIA_GENRE:
MC_SAFE_FREE(mc_server->metadata->genre);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->genre = strdup(value);
break;
case MEDIA_DURATION:
MC_SAFE_FREE(mc_server->metadata->duration);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->duration = strdup(value);
break;
case MEDIA_DATE:
MC_SAFE_FREE(mc_server->metadata->date);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->date = strdup(value);
break;
case MEDIA_COPYRIGHT:
MC_SAFE_FREE(mc_server->metadata->copyright);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->copyright = strdup(value);
break;
case MEDIA_DESCRIPTION:
MC_SAFE_FREE(mc_server->metadata->description);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->description = strdup(value);
break;
case MEDIA_TRACK_NUM:
MC_SAFE_FREE(mc_server->metadata->track_num);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->track_num = strdup(value);
break;
case MEDIA_PICTURE:
MC_SAFE_FREE(mc_server->metadata->picture);
- if(value != NULL)
+ if (value != NULL)
mc_server->metadata->picture = strdup(value);
break;
default:
int mc_server_update_metadata(mc_server_h server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = mc_db_update_whole_metadata(mc_server->db_handle, mc_server->server_name,
- mc_server->metadata->title, mc_server->metadata->artist, mc_server->metadata->album, mc_server->metadata->author,
- mc_server->metadata->genre, mc_server->metadata->duration, mc_server->metadata->date, mc_server->metadata->copyright,
- mc_server->metadata->description, mc_server->metadata->track_num, mc_server->metadata->picture);
+ mc_server->metadata->title, mc_server->metadata->artist, mc_server->metadata->album, mc_server->metadata->author,
+ mc_server->metadata->genre, mc_server->metadata->duration, mc_server->metadata->date, mc_server->metadata->copyright,
+ mc_server->metadata->description, mc_server->metadata->track_num, mc_server->metadata->picture);
mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail to mc_db_update_whole_metadata");
ret = __mc_server_send_message(mc_server, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_METADATA, 0, 0);
int mc_server_set_playback_state_command_received_cb(mc_server_h server, mc_server_playback_state_command_received_cb callback, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "callback is NULL");
mc_server->playback_state_reciever.user_data = user_data;
ret = mc_ipc_register_listener(mc_server->listeners, mc_server->dconn, mc_util_get_interface_name(NULL, MC_SERVER, mc_server->server_name),
- MC_DBUS_SIGNAL_NAME_PLAYBACK_STATE_CMD, __server_playback_state_command_cb, (void*)&(mc_server->playback_state_reciever));
+ MC_DBUS_SIGNAL_NAME_PLAYBACK_STATE_CMD, __server_playback_state_command_cb, (void *)&(mc_server->playback_state_reciever));
return ret;
}
int mc_server_unset_playback_state_command_received_cb(mc_server_h server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = mc_ipc_unregister_listener(mc_server->listeners, mc_server->dconn, mc_util_get_interface_name(NULL, MC_SERVER, mc_server->server_name),
- MC_DBUS_SIGNAL_NAME_PLAYBACK_STATE_CMD);
+ MC_DBUS_SIGNAL_NAME_PLAYBACK_STATE_CMD);
mc_server->playback_state_reciever.callback = NULL;
mc_server->playback_state_reciever.user_data = NULL;
int mc_server_set_custom_command_received_cb(mc_server_h server, mc_server_custom_command_received_cb callback, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "callback is NULL");
mc_server->custom_cmd_reciever.user_data = user_data;
ret = mc_ipc_register_listener(mc_server->listeners, mc_server->dconn, mc_util_get_interface_name(NULL, MC_SERVER, mc_server->server_name),
- MC_DBUS_SIGNAL_NAME_CUSTOM_CMD, __server_custom_command_cb, (void*)&(mc_server->custom_cmd_reciever));
+ MC_DBUS_SIGNAL_NAME_CUSTOM_CMD, __server_custom_command_cb, (void *)&(mc_server->custom_cmd_reciever));
return ret;
}
int mc_server_unset_custom_command_received_cb(mc_server_h server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
char *message = NULL;
int size_r = 0;
bundle_raw *raw_data = NULL;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(client_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "client_name is NULL");
- if(data)
- {
+ if (data) {
ret = bundle_encode(data, &raw_data, &size_r);
- if (ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error while encoding bundle [%d]", ret);
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
}
}
- message = g_strdup_printf ("%s%s%d%s%d%s%s", mc_server->server_name, MC_STRING_DELIMITER, result_code, MC_STRING_DELIMITER, size_r, MC_STRING_DELIMITER, (unsigned char*)raw_data);
+ message = g_strdup_printf("%s%s%d%s%d%s%s", mc_server->server_name, MC_STRING_DELIMITER, result_code, MC_STRING_DELIMITER, size_r, MC_STRING_DELIMITER, (unsigned char *)raw_data);
ret = mc_ipc_send_message(mc_server->dconn, NULL, mc_util_get_interface_name(NULL, MC_CLIENT, client_name), MC_DBUS_SIGNAL_NAME_CMD_REPLY, message, 0);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("fail mc_ipc_send_message [%d]", ret);
MC_SAFE_FREE(message);
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "Error allocation memory");
ret = mc_util_get_own_name(&server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Failed to get server_name [%d]", ret);
return ret;
}
ret = __mc_server_create(&mc_server, server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail __mc_server_create [%d]", ret);
MC_SAFE_FREE(server_name);
__mc_server_destoy(mc_server);
MC_SAFE_FREE(server_name);
- mc_server->listeners = g_list_alloc ();
- if (mc_server->listeners == NULL)
- {
+ mc_server->listeners = g_list_alloc();
+ if (mc_server->listeners == NULL) {
ret = MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY;
- mc_error ("Error allocation list %d", ret);
+ mc_error("Error allocation list %d", ret);
__mc_server_destoy(mc_server);
return ret;
}
ret = mc_db_create_tables(mc_server->db_handle);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
- mc_error ("mc_db_create_tables failed [%d]", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("mc_db_create_tables failed [%d]", ret);
}
ret = mc_db_check_server_table_exist(mc_server->db_handle, mc_server->server_name, &table_exist);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
- mc_error ("mc_db_check_server_table_exist failed [%d]", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("mc_db_check_server_table_exist failed [%d]", ret);
__mc_server_destoy(mc_server);
return ret;
}
- if(table_exist)
- {
+ if (table_exist) {
ret = mc_db_delete_server_table(mc_server->db_handle, mc_server->server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
- mc_error ("mc_db_delete_server_table failed [%d]", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("mc_db_delete_server_table failed [%d]", ret);
__mc_server_destoy(mc_server);
return ret;
}
ret = mc_db_delete_server_address_from_table(mc_server->db_handle, MC_DB_TABLE_SERVER_LIST, mc_server->server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
- mc_error ("mc_db_delete_server_table failed [%d]", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("mc_db_delete_server_table failed [%d]", ret);
__mc_server_destoy(mc_server);
return ret;
}
}
ret = mc_db_create_server_table(mc_server->db_handle, mc_server->server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail mc_db_clear_table [%d]", ret);
__mc_server_destoy(mc_server);
return ret;
}
ret = mc_db_insert_server_address_into_table(mc_server->db_handle, mc_server->server_name, mc_server->server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail mc_db_insert_server_address_into_table [%d]", ret);
__mc_server_destoy(mc_server);
return ret;
}
ret = mc_db_insert_server_address_into_table(mc_server->db_handle, MC_DB_TABLE_SERVER_LIST, mc_server->server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail mc_db_insert_server_address_into_table [%d]", ret);
__mc_server_destoy(mc_server);
return ret;
}
ret = __mc_server_send_message(mc_server, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_SERVER_STATE, MC_SERVER_STATE_ACTIVATE, 0);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error __mc_server_send_message [%d]", ret);
}
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
bool is_latest = FALSE;
- media_controller_server_s *mc_server = (media_controller_server_s*)server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = mc_ipc_unregister_all_listener(mc_server->listeners, mc_server->dconn);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail mc_ipc_unregister_all_listener [%d]", ret);
}
g_list_free(mc_server->listeners);
ret = mc_db_delete_server_address_from_table(mc_server->db_handle, MC_DB_TABLE_SERVER_LIST, mc_server->server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("fail mc_db_delete_server_address_from_table [%d]", ret);
ret = __mc_server_current_is_latest(mc_server, &is_latest);
- if(is_latest)
- {
+ if (is_latest) {
ret = mc_db_update_server_state(mc_server->db_handle, mc_server->server_name, MC_SERVER_STATE_DEACTIVATE);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("fail mc_db_delete_server_table [%d]", ret);
- }
- else
- {
+ } else {
ret = mc_db_delete_server_table(mc_server->db_handle, mc_server->server_name);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("fail mc_db_delete_server_table [%d]", ret);
}
ret = __mc_server_send_message(mc_server, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_SERVER_STATE, MC_SERVER_STATE_DEACTIVATE, 0);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Error __mc_server_send_message [%d]", ret);
}
ret = __mc_server_destoy(mc_server);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("fail __mc_server_destoy [%d]", ret);
return ret;
char new_word[MAX_NAME_LENGTH];
int i = 0;
- mc_retm_if (name == NULL, "Invalid parameter.");
+ mc_retm_if(name == NULL, "Invalid parameter.");
memset(old_word, 0, MAX_NAME_LENGTH);
memset(new_word, 0, MAX_NAME_LENGTH);
memcpy(old_word, name, strlen(name));
}
- // only 0~9, a~z, A~Z, '.', '_' will be used
- for(i=0; i<strlen(old_word); i++)
- {
+ /* only 0~9, a~z, A~Z, '.', '_' will be used */
+ for (i = 0; i < strlen(old_word); i++) {
if ((old_word[i] >= '0' && old_word[i] <= '9') ||
- (old_word[i] >= 'a' && old_word[i] <= 'z') ||
- (old_word[i] >= 'A' && old_word[i] <= 'Z') ||
- (old_word[i] == '.' && i != 0)) {
+ (old_word[i] >= 'a' && old_word[i] <= 'z') ||
+ (old_word[i] >= 'A' && old_word[i] <= 'Z') ||
+ (old_word[i] == '.' && i != 0)) {
new_word[i] = old_word[i];
} else {
- if (i-1 > 1 && new_word[i-1] != '.')
+ if (i - 1 > 1 && new_word[i - 1] != '.')
new_word[i] = '_';
else
new_word[i] = 'x';
}
(*new_name) = strdup(new_word);
- mc_retm_if ((*new_name) == NULL, "Error allocation memory.");
+ mc_retm_if((*new_name) == NULL, "Error allocation memory.");
}
int mc_util_get_own_name(char **name)
return MEDIA_CONTROLLER_ERROR_NONE;
}
-char* mc_util_get_interface_name(const char *prefix, const char *type, const char *name)
+char *mc_util_get_interface_name(const char *prefix, const char *type, const char *name)
{
char *temp = NULL;
char *interface_name = NULL;
int retry_count = 0;
char *message = NULL;
- if(!MC_STRING_VALID(name) ||!MC_STRING_VALID(command_type))
- {
+ if (!MC_STRING_VALID(name) || !MC_STRING_VALID(command_type)) {
mc_error("invalid query");
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
}
- if(command == NULL)
- message = g_strdup_printf ("%s%s", name, command_type);
+ if (command == NULL)
+ message = g_strdup_printf("%s%s", name, command_type);
else
- message = g_strdup_printf ("%s%s%s", name, command_type, command);
+ message = g_strdup_printf("%s%s%s", name, command_type, command);
request_msg_size = strlen(message);
- if(request_msg_size >= MAX_MSG_SIZE)
- {
+ if (request_msg_size >= MAX_MSG_SIZE) {
mc_error("Query is Too long. [%d] query size limit is [%d]", request_msg_size, MAX_MSG_SIZE);
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
}
send_msg.msg_type = MC_MSG_CLIENT_SET;
send_msg.msg_size = request_msg_size;
- strncpy(send_msg.msg, message, sizeof(send_msg.msg)-1);
+ strncpy(send_msg.msg, message, sizeof(send_msg.msg) - 1);
/*Create Socket*/
ret = mc_ipc_create_client_socket(MC_TIMEOUT_SEC_10, &sock_info);
/*Set server Address*/
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sun_family = AF_UNIX;
- strncpy(serv_addr.sun_path, MC_IPC_PATH[port], sizeof(serv_addr.sun_path)-1);
+ strncpy(serv_addr.sun_path, MC_IPC_PATH[port], sizeof(serv_addr.sun_path) - 1);
/* Connecting to the media db server */
- if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
+ if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
mc_stderror("connect error");
mc_ipc_delete_client_socket(&sock_info);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
mc_error("recv failed : [%d]", sockfd);
mc_stderror("recv failed");
- if (errno == EINTR) {
+ if (errno == EINTR) {
mc_stderror("catch interrupt");
goto RETRY;
}
if (errno == EWOULDBLOCK) {
- if(retry_count < MAX_RETRY_COUNT) {
+ if (retry_count < MAX_RETRY_COUNT) {
mc_error("TIME OUT[%d]", retry_count);
- retry_count ++;
+ retry_count++;
goto RETRY;
}
int retry_count = 0;
char *message = NULL;
- if(!MC_STRING_VALID(name) ||!MC_STRING_VALID(command_type))
- {
+ if (!MC_STRING_VALID(name) || !MC_STRING_VALID(command_type)) {
mc_error("invalid query");
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
}
- if(command == NULL)
- message = g_strdup_printf ("%s%s", name, command_type);
+ if (command == NULL)
+ message = g_strdup_printf("%s%s", name, command_type);
else
- message = g_strdup_printf ("%s%s%s", name, command_type, command);
+ message = g_strdup_printf("%s%s%s", name, command_type, command);
request_msg_size = strlen(message);
- if(request_msg_size >= MAX_MSG_SIZE)
- {
+ if (request_msg_size >= MAX_MSG_SIZE) {
mc_error("Query is Too long. [%d] query size limit is [%d]", request_msg_size, MAX_MSG_SIZE);
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
}
send_msg.msg_type = MC_MSG_CLIENT_GET;
send_msg.msg_size = request_msg_size;
- strncpy(send_msg.msg, message, sizeof(send_msg.msg)-1);
+ strncpy(send_msg.msg, message, sizeof(send_msg.msg) - 1);
/*Create Socket*/
ret = mc_ipc_create_client_socket(MC_TIMEOUT_SEC_10, &sock_info);
/*Set server Address*/
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sun_family = AF_UNIX;
- strncpy(serv_addr.sun_path, MC_IPC_PATH[port], sizeof(serv_addr.sun_path)-1);
+ strncpy(serv_addr.sun_path, MC_IPC_PATH[port], sizeof(serv_addr.sun_path) - 1);
/* Connecting to the media db server */
- if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
+ if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
mc_stderror("connect error");
mc_ipc_delete_client_socket(&sock_info);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
mc_error("recv failed : [%d]", sockfd);
mc_stderror("recv failed");
- if (errno == EINTR) {
+ if (errno == EINTR) {
mc_stderror("catch interrupt");
goto RETRY;
}
if (errno == EWOULDBLOCK) {
- if(retry_count < MAX_RETRY_COUNT) {
+ if (retry_count < MAX_RETRY_COUNT) {
mc_error("TIME OUT[%d]", retry_count);
- retry_count ++;
+ retry_count++;
goto RETRY;
}
/*Connect DB*/
ret = db_util_open(MC_DB_NAME, &db_handle, DB_UTIL_REGISTER_HOOK_METHOD);
- if (SQLITE_OK != ret)
- {
+ if (SQLITE_OK != ret) {
mc_error("error when db open");
*handle = NULL;
/*Register busy handler*/
ret = sqlite3_busy_handler(db_handle, __mc_db_util_busy_handler, NULL);
- if (SQLITE_OK != ret)
- {
+ if (SQLITE_OK != ret) {
if (db_handle) {
mc_error("error when register busy handler %s\n", sqlite3_errmsg(db_handle));
}
mc_retvm_if(db_handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = db_util_close(db_handle);
- if (SQLITE_OK != ret)
- {
+ if (SQLITE_OK != ret) {
mc_error("error when db close");
mc_error("Error : %s", sqlite3_errmsg(db_handle));
db_handle = NULL;
return ret;
}
-int mc_ipc_create_client_socket(int timeout_sec, mc_sock_info_s* sock_info) {
+int mc_ipc_create_client_socket(int timeout_sec, mc_sock_info_s *sock_info)
+{
int sock = -1;
struct timeval tv_timeout = { timeout_sec, 0 };
return MEDIA_CONTROLLER_ERROR_NONE;
}
-int mc_ipc_delete_client_socket(mc_sock_info_s* sock_info)
+int mc_ipc_delete_client_socket(mc_sock_info_s *sock_info)
{
int ret = 0;
mc_debug("sockfd %d close", sock_info->sock_fd);
if (sock_info->sock_path != NULL) {
ret = unlink(sock_info->sock_path);
- if (ret< 0) {
+ if (ret < 0) {
mc_stderror("unlink failed");
}
free(sock_info->sock_path);
return ret;
}
-int mc_ipc_create_server_socket(mc_msg_port_type_e port, int *sock_fd) {
+int mc_ipc_create_server_socket(mc_msg_port_type_e port, int *sock_fd)
+{
int i;
bool bind_success = false;
int sock = -1;
serv_addr.sun_family = AF_UNIX;
unlink(MC_IPC_PATH[serv_port]);
- strncpy(serv_addr.sun_path, MC_IPC_PATH[serv_port], sizeof(serv_addr.sun_path)-1);
+ strncpy(serv_addr.sun_path, MC_IPC_PATH[serv_port], sizeof(serv_addr.sun_path) - 1);
/* Bind to the local address */
- for (i = 0; i < 20; i ++) {
+ for (i = 0; i < 20; i++) {
if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == 0) {
bind_success = true;
break;
}
- mc_debug("%d",i);
+ mc_debug("%d", i);
usleep(250000);
}
}
-int mc_ipc_send_msg_to_client_tcp(int sockfd, mc_comm_msg_s *send_msg, struct sockaddr_un *client_addr) {
+int mc_ipc_send_msg_to_client_tcp(int sockfd, mc_comm_msg_s *send_msg, struct sockaddr_un *client_addr)
+{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
if (write(sockfd, send_msg, sizeof(*(send_msg))) != sizeof(*(send_msg))) {
return ret;
}
-int mc_ipc_receive_message_tcp(int client_sock, mc_comm_msg_s *recv_msg) {
+int mc_ipc_receive_message_tcp(int client_sock, mc_comm_msg_s *recv_msg)
+{
int recv_msg_size = 0;
if ((recv_msg_size = read(client_sock, recv_msg, sizeof(mc_comm_msg_s))) < 0) {
return MEDIA_CONTROLLER_ERROR_NONE;
}
-int mc_ipc_accept_client_tcp(int serv_sock, int* client_sock) {
+int mc_ipc_accept_client_tcp(int serv_sock, int *client_sock)
+{
int sockfd = -1;
struct sockaddr_un client_addr;
socklen_t client_addr_len;
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
client_addr_len = sizeof(client_addr);
- if ((sockfd = accept(serv_sock, (struct sockaddr*)&client_addr, &client_addr_len)) < 0) {
+ if ((sockfd = accept(serv_sock, (struct sockaddr *)&client_addr, &client_addr_len)) < 0) {
mc_stderror("accept failed");
*client_sock = -1;
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
return MEDIA_CONTROLLER_ERROR_NONE;
}
-gboolean mc_read_db_update_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer data) {
+gboolean mc_read_db_update_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer data)
+{
int sock = -1;
int client_sock = -1;
- char * sql_query = NULL;
+ char *sql_query = NULL;
mc_comm_msg_s recv_msg;
int ret = MEDIA_CONTROLLER_ERROR_NONE;
void *db_handle = (void *)data;
int send_msg = MEDIA_CONTROLLER_ERROR_NONE;
-// gboolean privilege = TRUE;
+ /* gboolean privilege = TRUE; */
mc_debug("[GD] mc_read_db_update_tcp_socket is called!!!!!");
}
/* check privileage, it is removed for smack rule */
-/* if(__mc_privilege_check(recv_msg.msg, &privilege) != MEDIA_CONTROLLER_ERROR_NONE) {
- mc_error("invalid query. size[%d]", recv_msg.msg_size);
- send_msg = MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED;
- goto ERROR;
- }
-
- if (privilege == TRUE) {
- ret = __mc_privilege_ask(client_sock, "mediacontroller::db", "w");
- if (ret == MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED) {
+ /* if(__mc_privilege_check(recv_msg.msg, &privilege) != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("invalid query. size[%d]", recv_msg.msg_size);
send_msg = MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED;
goto ERROR;
}
- }*/
+
+ if (privilege == TRUE) {
+ ret = __mc_privilege_ask(client_sock, "mediacontroller::db", "w");
+ if (ret == MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED) {
+ send_msg = MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED;
+ goto ERROR;
+ }
+ }*/
sql_query = strndup(recv_msg.msg, recv_msg.msg_size);
if (sql_query != NULL) {
mc_debug("Sent successfully");
}
- if (close(client_sock) <0) {
+ if (close(client_sock) < 0) {
mc_stderror("close failed");
}
return TRUE;
}
-gboolean mc_read_client_set_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer data) {
+gboolean mc_read_client_set_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer data)
+{
int sock = -1;
int client_sock = -1;
mc_comm_msg_s recv_msg;
int ret = MEDIA_CONTROLLER_ERROR_NONE;
int send_msg = MEDIA_CONTROLLER_ERROR_NONE;
int i = 0;
- GList *mc_svc_list = (GList*)data;
+ GList *mc_svc_list = (GList *)data;
bool is_duplicated = FALSE;
sock = g_io_channel_unix_get_fd(src);
if (mc_svc_list != NULL && g_list_length(mc_svc_list) == 0) {
for (i = 0; i < g_list_length(mc_svc_list); i++) {
- char *data = (char*)g_list_nth_data(mc_svc_list, i);
+ char *data = (char *)g_list_nth_data(mc_svc_list, i);
if (strcmp(data, recv_msg.msg) == 0) {
is_duplicated = TRUE;
}
mc_debug("Sent successfully");
}
- if (close(client_sock) <0) {
+ if (close(client_sock) < 0) {
mc_stderror("close failed");
}
return TRUE;
}
-gboolean mc_read_client_get_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer data) {
+gboolean mc_read_client_get_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer data)
+{
int sock = -1;
int client_sock = -1;
mc_comm_msg_s recv_msg;
int ret = MEDIA_CONTROLLER_ERROR_NONE;
int send_msg = MEDIA_CONTROLLER_ERROR_NONE;
int i = 0;
- GList *mc_svc_list = (GList*)data;
+ GList *mc_svc_list = (GList *)data;
sock = g_io_channel_unix_get_fd(src);
if (sock < 0) {
for (i = 0; i < g_list_length(mc_svc_list); i++) {
send_msg = MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED;
- char *data = (char*)g_list_nth_data(mc_svc_list, i);
+ char *data = (char *)g_list_nth_data(mc_svc_list, i);
if (strcmp(data, recv_msg.msg) == 0) {
mc_svc_list = g_list_remove(mc_svc_list, data);
send_msg = MEDIA_CONTROLLER_ERROR_NONE;
mc_debug("Sent successfully");
}
- if (close(client_sock) <0) {
+ if (close(client_sock) < 0) {
mc_stderror("close failed");
}
MC_MSG_MAX,
} mc_msg_type_e;
-typedef struct
-{
+typedef struct {
int sock_fd;
char *sock_path;
}mc_sock_info_s;
-typedef struct
-{
+typedef struct {
mc_msg_type_e msg_type;
int pid;
int result;
/* Create TCP Socket*/
ret = mc_ipc_create_server_socket(MC_DB_UPDATE_PORT, &sockfd);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
/* Disconnect DB*/
mc_error("Failed to create socket");
return FALSE;
/* Create TCP Socket for set client*/
ret = mc_ipc_create_server_socket(MC_DB_SET_PORT, &sockfd_set);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
/* Disconnect DB*/
close(sockfd);
mc_error("Failed to create socket");
/* Create TCP Socket for get client*/
ret = mc_ipc_create_server_socket(MC_DB_GET_PORT, &sockfd_get);
- if(ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
/* Disconnect DB*/
close(sockfd);
close(sockfd_set);
}
/* Connect Media DB*/
- if(mc_db_util_connect(&db_handle) != MEDIA_CONTROLLER_ERROR_NONE) {
+ if (mc_db_util_connect(&db_handle) != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Failed to connect DB");
close(sockfd);
close(sockfd_set);
close(sockfd_get);
return FALSE;
}
- g_mc_svc_list = g_list_alloc ();
+ g_mc_svc_list = g_list_alloc();
context = g_main_context_new();
if (context == NULL) {
---------------------------------------------------------------------------*/
static mc_client_h g_mc_client;
-static char* g_server_name;
+static char *g_server_name;
static mc_playback_states_e g_playback_state;
void _mc_server_state_updated_cb(const char *server_name, mc_server_state_e state, void *user_data)
{
- media_controller_client_s* _client = (media_controller_client_s*)g_mc_client;
+ media_controller_client_s *_client = (media_controller_client_s *)g_mc_client;
mc_debug("[Client:%s] Server state(%d) updated from server[%s]", _client->client_name, state, server_name);
}
void _mc_playback_updated_cb(const char *server_name, mc_playback_h playback, void *user_data)
{
- media_controller_client_s* _client = (media_controller_client_s*)g_mc_client;
+ media_controller_client_s *_client = (media_controller_client_s *)g_mc_client;
unsigned long long position = 0;
mc_playback_states_e playback_state = MEDIA_PLAYBACK_STATE_NONE;
int ret = MEDIA_CONTROLLER_ERROR_NONE;
int idx = 0;
char *str_val = NULL;
- media_controller_client_s* _client = (media_controller_client_s*)g_mc_client;
+ media_controller_client_s *_client = (media_controller_client_s *)g_mc_client;
mc_debug("[Client:%s] Metadata updated from server[%s] ", _client->client_name, server_name);
- for(idx = 0; idx <= MEDIA_PICTURE; idx++)
- {
+ for (idx = 0; idx <= MEDIA_PICTURE; idx++) {
ret = mc_client_get_metadata(metadata, idx, &str_val);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- mc_error ("Fail to mc_client_get_metadata");
- mc_debug ("metadata [%d] val [%s]\n", idx, str_val);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_client_get_metadata");
+ mc_debug("metadata [%d] val [%s]\n", idx, str_val);
- if(str_val)
+ if (str_val)
g_free(str_val);
}
}
void _mc_shuffle_mode_updated_cb(const char *server_name, mc_shuffle_mode_e mode, void *user_data)
{
- media_controller_client_s* _client = (media_controller_client_s*)g_mc_client;
+ media_controller_client_s *_client = (media_controller_client_s *)g_mc_client;
mc_debug("[Client:%s] Shuffle mode(%d) updated from server[%s]", _client->client_name, mode, server_name);
}
void _mc_repeat_mode_updated_cb(const char *server_name, mc_repeat_mode_e mode, void *user_data)
{
- media_controller_client_s* _client = (media_controller_client_s*)g_mc_client;
+ media_controller_client_s *_client = (media_controller_client_s *)g_mc_client;
mc_debug("[Client:%s] Repeat mode(%d) updated from server[%s]", _client->client_name, mode, server_name);
}
bool _mc_activated_server_cb(const char *server_name, void *user_data)
{
- media_controller_client_s* _client = (media_controller_client_s*)g_mc_client;
+ media_controller_client_s *_client = (media_controller_client_s *)g_mc_client;
mc_debug("[Client:%s] Activated server_name: %s", _client->client_name, server_name);
return TRUE;
}
-void _mc_command_reply_received_cb (const char *server_name, int result_code, bundle *data, void *user_data)
+void _mc_command_reply_received_cb(const char *server_name, int result_code, bundle *data, void *user_data)
{
- char* value = NULL;
- media_controller_client_s* _client = (media_controller_client_s*)g_mc_client;
+ char *value = NULL;
+ media_controller_client_s *_client = (media_controller_client_s *)g_mc_client;
- if(data)
+ if (data)
bundle_get_str(data, "key1", &value);
mc_debug("[Client:%s] Command Reply (key1: %s)received from server[%s] result code[%d]", _client->client_name, value, server_name, result_code);
}
-static gboolean _create ()
+static gboolean _create()
{
g_print("== create \n");
int ret;
ret = mc_client_create(&g_mc_client);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to create media contoller client");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to create media contoller client");
return FALSE;
}
- g_print ("== success create \n");
+ g_print("== success create \n");
return TRUE;
}
-static gboolean _foreach ()
+static gboolean _foreach()
{
g_print("== create \n");
int ret;
ret = mc_client_foreach_server(g_mc_client, _mc_activated_server_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to foreach media contoller client");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to foreach media contoller client");
return FALSE;
}
- g_print ("== success create \n");
+ g_print("== success create \n");
return TRUE;
}
-static gboolean _set ()
+static gboolean _set()
{
- g_print ("== set default callback \n");
+ g_print("== set default callback \n");
int ret = TRUE;
ret = mc_client_set_server_update_cb(g_mc_client, _mc_server_state_updated_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to set param and initialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to set param and initialize %d", ret);
return FALSE;
}
ret = mc_client_set_playback_update_cb(g_mc_client, _mc_playback_updated_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to set param and initialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to set param and initialize %d", ret);
return FALSE;
}
ret = mc_client_set_metadata_update_cb(g_mc_client, _mc_metadata_updated_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to set param and initialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to set param and initialize %d", ret);
return FALSE;
}
ret = mc_client_set_shuffle_mode_update_cb(g_mc_client, _mc_shuffle_mode_updated_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to set param and initialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to set param and initialize %d", ret);
return FALSE;
}
ret = mc_client_set_repeat_mode_update_cb(g_mc_client, _mc_repeat_mode_updated_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to set param and initialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to set param and initialize %d", ret);
return FALSE;
}
static gboolean _unset()
{
- g_print ("== unset callback \n");
+ g_print("== unset callback \n");
int ret;
ret = mc_client_unset_server_update_cb(g_mc_client);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to deinitialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to deinitialize %d", ret);
return FALSE;
}
ret = mc_client_unset_playback_update_cb(g_mc_client);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to deinitialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to deinitialize %d", ret);
return FALSE;
}
ret = mc_client_unset_metadata_update_cb(g_mc_client);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to deinitialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to deinitialize %d", ret);
return FALSE;
}
ret = mc_client_unset_shuffle_mode_update_cb(g_mc_client);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to deinitialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to deinitialize %d", ret);
return FALSE;
}
ret = mc_client_unset_repeat_mode_update_cb(g_mc_client);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to deinitialize %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to deinitialize %d", ret);
return FALSE;
}
- g_print ("== success destroy \n");
+ g_print("== success destroy \n");
return TRUE;
}
static gboolean _get_info(int type)
{
- g_print ("== get information \n");
+ g_print("== get information \n");
int ret;
mc_server_state_e server_state;
mc_playback_h playback;
mc_playback_states_e playback_state;
unsigned long long playback_position;
mc_metadata_h metadata;
- char* metadata_value;
+ char *metadata_value;
mc_shuffle_mode_e shuffle_mode;
mc_repeat_mode_e repeate_mode;
- switch(type)
- {
+ switch (type) {
case 1:
ret = mc_client_get_latest_server_info(g_mc_client, &g_server_name, &server_state);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to get latest server info");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to get latest server info");
return FALSE;
}
- g_print ("get server name: %s, state: %d", g_server_name, server_state);
+ g_print("get server name: %s, state: %d", g_server_name, server_state);
break;
case 2:
ret = mc_client_get_server_playback_info(g_mc_client, g_server_name, &playback);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to get playback info");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to get playback info");
return FALSE;
}
ret = mc_client_get_playback_state(playback, &playback_state);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to get playback state");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to get playback state");
}
ret = mc_client_get_playback_position(playback, &playback_position);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to get playback position");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to get playback position");
}
- g_print ("playback state: %d, position: %lld", playback_state, playback_position);
+ g_print("playback state: %d, position: %lld", playback_state, playback_position);
ret = mc_client_destroy_playback(playback);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to destroy playback");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to destroy playback");
return FALSE;
}
break;
case 3:
ret = mc_client_get_server_metadata(g_mc_client, g_server_name, &metadata);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to get metadata");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to get metadata");
return FALSE;
}
ret = mc_client_get_metadata(metadata, MEDIA_TITLE, &metadata_value);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to get infot");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to get infot");
}
- g_print ("metadata title: %s", metadata_value);
+ g_print("metadata title: %s", metadata_value);
ret = mc_client_destroy_metadata(metadata);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to destroy metadata");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to destroy metadata");
return FALSE;
}
free(metadata_value);
break;
case 4:
ret = mc_client_get_server_shuffle_mode(g_mc_client, g_server_name, &shuffle_mode);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to get infot");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to get infot");
return FALSE;
}
- g_print ("shuffle mode: %d", shuffle_mode);
+ g_print("shuffle mode: %d", shuffle_mode);
break;
case 5:
ret = mc_client_get_server_repeat_mode(g_mc_client, g_server_name, &repeate_mode);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to get infot");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to get infot");
return FALSE;
}
- g_print ("repeate mode: %d", repeate_mode);
+ g_print("repeate mode: %d", repeate_mode);
break;
default:
- g_print ("== unknown type!\n");
+ g_print("== unknown type!\n");
return TRUE;
}
- g_print ("== success get information \n");
+ g_print("== success get information \n");
return TRUE;
}
static gboolean _send()
{
- g_print ("== send command to latest server \n");
+ g_print("== send command to latest server \n");
int ret;
if (g_playback_state == MEDIA_PLAYBACK_STATE_PLAYING)
else
g_playback_state = MEDIA_PLAYBACK_STATE_PLAYING;
ret = mc_client_send_playback_state_command(g_mc_client, g_server_name, g_playback_state);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to send playback state command %d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to send playback state command %d", ret);
return FALSE;
}
usleep(500000);
- bundle * bundle_data = bundle_create();
+ bundle *bundle_data = bundle_create();
bundle_add_str(bundle_data, "key1", "val1");
bundle_add_str(bundle_data, "key2", "val2");
bundle_add_str(bundle_data, "key3", "val3");
bundle_add_str(bundle_data, "key4", "val4");
ret = mc_client_send_custom_command(g_mc_client, g_server_name, "Custom Command", bundle_data, _mc_command_reply_received_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
bundle_free(bundle_data);
- mc_error ("Fail to send custom command %d", ret);
+ mc_error("Fail to send custom command %d", ret);
return FALSE;
}
bundle_free(bundle_data);
- g_print ("== success send command \n");
+ g_print("== success send command \n");
return TRUE;
}
static gboolean _destroy()
{
- g_print ("== destroy \n");
+ g_print("== destroy \n");
int ret;
ret = mc_client_destroy(g_mc_client);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to destroy media contoller client");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to destroy media contoller client");
return FALSE;
}
- g_print ("== success destroy \n");
+ g_print("== success destroy \n");
g_mc_client = NULL;
return TRUE;
}
/***************************************************************/
/** Testsuite */
/***************************************************************/
-void quit (void)
+void quit(void)
{
if (g_mc_client != NULL)
_destroy();
return;
}
-static void display_information_menu (void)
+static void display_information_menu(void)
{
g_print("\n");
g_print("====================================================\n");
}
-static void display_main_menu (void)
+static void display_main_menu(void)
{
g_print("\n");
g_print("====================================================\n");
}
-static void display_menu (void)
+static void display_menu(void)
{
if (g_menu_state == CURRENT_STATE_MAIN_MENU) {
- display_main_menu ();
+ display_main_menu();
} else if (g_menu_state == CURRENT_STATE_INFORMATION_GET_MENU) {
display_information_menu();
} else {
}
}
-void _interpret_information_menu (char *cmd)
+void _interpret_information_menu(char *cmd)
{
int len = strlen(cmd);
if (len == 1) {
- if ( !strncmp(cmd, "1", len)) {
+ if (!strncmp(cmd, "1", len)) {
_get_info(1);
- } else if ( !strncmp(cmd, "2", len)) {
+ } else if (!strncmp(cmd, "2", len)) {
_get_info(2);
- } else if ( !strncmp(cmd, "3", len)) {
+ } else if (!strncmp(cmd, "3", len)) {
_get_info(3);
- } else if ( !strncmp(cmd, "4", len)) {
+ } else if (!strncmp(cmd, "4", len)) {
_get_info(4);
- } else if ( !strncmp(cmd, "5", len)) {
+ } else if (!strncmp(cmd, "5", len)) {
_get_info(5);
- } else if ( !strncmp(cmd, "0", len)) {
+ } else if (!strncmp(cmd, "0", len)) {
reset_current_menu_state();
}
} else {
}
}
-void _interpret_main_menu (char *cmd)
+void _interpret_main_menu(char *cmd)
{
int len = strlen(cmd);
if (len == 1) {
- if ( !strncmp(cmd, "1", len)) {
+ if (!strncmp(cmd, "1", len)) {
_create();
- } else if ( !strncmp(cmd, "2", len)) {
+ } else if (!strncmp(cmd, "2", len)) {
_foreach();
- } else if ( !strncmp(cmd, "3", len)) {
+ } else if (!strncmp(cmd, "3", len)) {
_set();
- } else if ( !strncmp(cmd, "4", len)) {
+ } else if (!strncmp(cmd, "4", len)) {
_unset();
- } else if ( !strncmp(cmd, "5", len)) {
+ } else if (!strncmp(cmd, "5", len)) {
g_menu_state = CURRENT_STATE_INFORMATION_GET_MENU;
- } else if ( !strncmp(cmd, "6", len)) {
+ } else if (!strncmp(cmd, "6", len)) {
_send();
- } else if ( !strncmp(cmd, "9", len)) {
+ } else if (!strncmp(cmd, "9", len)) {
_destroy();
- } else if ( !strncmp(cmd, "0", len)) {
+ } else if (!strncmp(cmd, "0", len)) {
quit();
}
} else {
}
}
-static void interpret_cmd (char *cmd)
+static void interpret_cmd(char *cmd)
{
switch (g_menu_state) {
case CURRENT_STATE_MAIN_MENU:
}
}
-gboolean input (GIOChannel *channel)
+gboolean input(GIOChannel *channel)
{
gchar buf[MAX_STRING_LEN];
gsize read;
buf[read] = '\0';
g_strstrip(buf);
- interpret_cmd (buf);
+ interpret_cmd(buf);
return TRUE;
-
+
}
int client_sequential_test(void)
/*Create Client*/
ret = mc_client_create(&g_mc_client);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_client_create");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_client_create");
return ret;
}
/*Get Latest Server Info*/
ret = mc_client_get_latest_server_info(g_mc_client, &server_name, &server_state);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_client_create");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_client_create");
return ret;
}
- g_print ("latest server name[%s] server_state[%d]\n", server_name, server_state);
+ g_print("latest server name[%s] server_state[%d]\n", server_name, server_state);
- if(server_name == NULL)
+ if (server_name == NULL)
return MEDIA_CONTROLLER_ERROR_NONE;
/*Get Foreach server*/
ret = mc_client_foreach_server(g_mc_client, _mc_activated_server_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_foreach_server\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_foreach_server\n");
/*Get Playback Info*/
ret = mc_client_get_server_playback_info(g_mc_client, server_name, &playback);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_get_server_playback_info\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_get_server_playback_info\n");
ret = mc_client_get_playback_state(playback, &playback_state);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_get_playback_state\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_get_playback_state\n");
ret = mc_client_get_playback_position(playback, &playback_position);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_get_server_playback_info\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_get_server_playback_info\n");
- g_print ("playback_state[%d] playback_position[%lld]\n", playback_state, playback_position);
+ g_print("playback_state[%d] playback_position[%lld]\n", playback_state, playback_position);
ret = mc_client_destroy_playback(playback);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_destroy_playback\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_destroy_playback\n");
/*Get Metadata*/
ret = mc_client_get_server_metadata(g_mc_client, server_name, &metadata);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_get_server_metadata\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_get_server_metadata\n");
- for(idx = 0; idx <= MEDIA_PICTURE; idx++)
- {
+ for (idx = 0; idx <= MEDIA_PICTURE; idx++) {
ret = mc_client_get_metadata(metadata, idx, &str_val);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_get_metadata\n");
- g_print ("metadata [%d] val [%s]\n", idx, str_val);
- if(str_val)
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_get_metadata\n");
+ g_print("metadata [%d] val [%s]\n", idx, str_val);
+ if (str_val)
g_free(str_val);
}
ret = mc_client_destroy_metadata(metadata);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_destroy_metadata\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_destroy_metadata\n");
/*Get Shuffle / Repeat mode*/
ret = mc_client_get_server_shuffle_mode(g_mc_client, server_name, &shuffle_mode);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_get_server_shuffle_mode\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_get_server_shuffle_mode\n");
ret = mc_client_get_server_repeat_mode(g_mc_client, server_name, &repeat_mode);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print ("Fail to mc_client_get_server_repeat_mode\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_client_get_server_repeat_mode\n");
- g_print ("shuffle_mode[%d] repeat_mode[%d]\n", shuffle_mode, repeat_mode);
+ g_print("shuffle_mode[%d] repeat_mode[%d]\n", shuffle_mode, repeat_mode);
g_free(server_name);
ret = mc_client_destroy(g_mc_client);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_client_create\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_client_create\n");
return ret;
}
GIOChannel *stdin_channel = NULL;
stdin_channel = g_io_channel_unix_new(0);
g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
- g_io_add_watch (stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
+ g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
g_playback_state = MEDIA_PLAYBACK_STATE_PLAYING;
static gboolean __func1(void *mc_server)
{
- int i =MEDIA_TITLE;
+ int i = MEDIA_TITLE;
mc_server_set_playback_state(mc_server, MEDIA_PLAYBACK_STATE_PLAYING);
mc_server_set_playback_position(mc_server, duration);
mc_server_update_playback_info(mc_server);
- for (; i <= MEDIA_PICTURE; ++i)
- {
- mc_server_set_metadata(mc_server, (mc_meta_e)i, "META_VALUE");
+ for (; i <= MEDIA_PICTURE; ++i) {
+ mc_server_set_metadata(mc_server, (mc_meta_e)i, "META_VALUE");
}
mc_server_update_metadata(mc_server);
mc_server_update_shuffle_mode(mc_server, SHUFFLE_MODE_OFF);
int error = MEDIA_CONTROLLER_ERROR_NONE;
error = mc_server_create(&mc_server);
- if (MEDIA_CONTROLLER_ERROR_NONE == error && mc_server != NULL)
- {
- g_timeout_add_seconds(5, __func1, (void*)mc_server);
+ if (MEDIA_CONTROLLER_ERROR_NONE == error && mc_server != NULL) {
+ g_timeout_add_seconds(5, __func1, (void *)mc_server);
- g_loop = g_main_loop_new(NULL, FALSE);
- g_main_loop_run(g_loop);
- quit_program(mc_server);
- }
- else
- {
- dlog_print (DLOG_INFO, PACKAGE,"mc_server_create: error %d ",error);
+ g_loop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(g_loop);
+ quit_program(mc_server);
+ } else {
+ dlog_print(DLOG_INFO, PACKAGE, "mc_server_create: error %d ", error);
}
return error;
/*---------------------------------------------------------------------------
| LOCAL CONSTANT DEFINITIONS: |
---------------------------------------------------------------------------*/
-//#define DEFAULT_SERVICE "com.samsung.mcontroller_service"
+/*#define DEFAULT_SERVICE "com.samsung.mcontroller_service" */
enum {
CURRENT_STATE_MAIN_MENU,
| LOCAL FUNCTION PROTOTYPES: |
---------------------------------------------------------------------------*/
-void __playback_state_command_received_cb(const char* client_name, mc_playback_states_e state, void *user_data)
+void __playback_state_command_received_cb(const char *client_name, mc_playback_states_e state, void *user_data)
{
- media_controller_server_s *mc_server = (media_controller_server_s*)g_mc_server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)g_mc_server;
mc_debug("[%s] recieved playback state:[%d] from [%s]", mc_server->server_name, state, client_name);
}
-void __custom_command_received_cb(const char* client_name, const char *command, bundle *data, void *user_data)
+void __custom_command_received_cb(const char *client_name, const char *command, bundle *data, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- media_controller_server_s *mc_server = (media_controller_server_s*)g_mc_server;
+ media_controller_server_s *mc_server = (media_controller_server_s *)g_mc_server;
- char * bundle_data = NULL;
- char * get_value1 = NULL;
- char * get_value2 = NULL;
- char * get_value3 = NULL;
- char * get_value4 = NULL;
+ char *bundle_data = NULL;
+ char *get_value1 = NULL;
+ char *get_value2 = NULL;
+ char *get_value3 = NULL;
+ char *get_value4 = NULL;
- if(data)
- {
+ if (data) {
bundle_get_str(data, "key1", &get_value1);
bundle_get_str(data, "key2", &get_value2);
bundle_get_str(data, "key3", &get_value3);
mc_debug("[%s] recieved command:[%s] from [%s]", mc_server->server_name, command, client_name);
mc_debug("[%s] recieved bundle:[%s] from [%s]", mc_server->server_name, bundle_data, client_name);
- bundle * bundle_reply = bundle_create();
+ bundle *bundle_reply = bundle_create();
bundle_add_str(bundle_reply, "key1", "result1");
bundle_add_str(bundle_reply, "key2", "result2");
bundle_add_str(bundle_reply, "key3", "result3");
bundle_add_str(bundle_reply, "key4", "result4");
ret = mc_server_send_command_reply(g_mc_server, client_name, 0, bundle_reply);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE)
- mc_error ("Fail to mc_server_send_command_reply");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_server_send_command_reply");
bundle_free(bundle_reply);
}
-static gboolean _create ()
+static gboolean _create()
{
g_print("== create \n");
int ret;
ret = mc_server_create(&g_mc_server);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to create media contoller server");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to create media contoller server");
return FALSE;
}
- g_print ("== success create \n");
+ g_print("== success create \n");
return TRUE;
}
static gboolean _set_cb()
{
- g_print ("== set default callback for commands \n");
+ g_print("== set default callback for commands \n");
int ret;
ret = mc_server_set_playback_state_command_received_cb(g_mc_server, __playback_state_command_received_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to create media contoller server");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to create media contoller server");
return FALSE;
}
ret = mc_server_set_custom_command_received_cb(g_mc_server, __custom_command_received_cb, NULL);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to create media contoller server");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to create media contoller server");
return FALSE;
}
- g_print ("== success set default callback \n");
+ g_print("== success set default callback \n");
return TRUE;
}
static gboolean _set_info(int type, char *cmd)
{
- g_print ("== get information \n");
+ g_print("== get information \n");
int ret;
int playback_state = 0;
unsigned long long playback_position;
char *metadata;
- switch(type)
- {
+ switch (type) {
case CURRENT_STATE_SET_PLAYBACK_STATE:
playback_state = atoi(cmd);
ret = mc_server_set_playback_state(g_mc_server, playback_state);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to set playback state");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to set playback state");
return FALSE;
}
- g_print ("set state: %d", playback_state);
+ g_print("set state: %d", playback_state);
break;
case CURRENT_STATE_SET_PLAYBACK_POSITION:
playback_position = atoi(cmd);
ret = mc_server_set_playback_position(g_mc_server, playback_position);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to set playback position");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to set playback position");
return FALSE;
}
- g_print ("set position: %lld", playback_position);
+ g_print("set position: %lld", playback_position);
break;
case CURRENT_STATE_SET_METADATA_NAME:
g_metadata_type = atoi(cmd);
- g_print ("set metadata name: %d", g_metadata_type);
+ g_print("set metadata name: %d", g_metadata_type);
break;
case CURRENT_STATE_SET_METADATA_VALUE:
metadata = strdup(cmd);
ret = mc_server_set_metadata(g_mc_server, g_metadata_type, metadata);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to set metadata");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to set metadata");
return FALSE;
}
- g_print ("set metadata value: %s", metadata);
+ g_print("set metadata value: %s", metadata);
free(metadata);
break;
default:
- g_print (" == unknown type!\n");
+ g_print(" == unknown type!\n");
return TRUE;
}
- g_print (" == success get information \n");
+ g_print(" == success get information \n");
return TRUE;
}
static gboolean _update_info(int type)
{
- g_print (" == update information \n");
+ g_print(" == update information \n");
int ret;
- switch(type)
- {
+ switch (type) {
case 1:
ret = mc_server_update_playback_info(g_mc_server);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to update playback info err=%d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to update playback info err=%d", ret);
return FALSE;
}
break;
case 2:
ret = mc_server_update_metadata(g_mc_server);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to update metadata err=%d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to update metadata err=%d", ret);
return FALSE;
}
break;
else
g_shuffle_mode = SHUFFLE_MODE_OFF;
ret = mc_server_update_shuffle_mode(g_mc_server, g_shuffle_mode);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to update shuffle mode err=%d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to update shuffle mode err=%d", ret);
return FALSE;
}
break;
else
g_repeat_mode = REPEAT_MODE_OFF;
ret = mc_server_update_repeat_mode(g_mc_server, g_repeat_mode);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to update repeat mode err=%d", ret);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to update repeat mode err=%d", ret);
return FALSE;
}
break;
default:
- g_print (" == unknown type!\n");
+ g_print(" == unknown type!\n");
return TRUE;
}
- g_print (" == success update information \n");
+ g_print(" == success update information \n");
return TRUE;
}
static gboolean _destroy()
{
- g_print ("== destroy \n");
+ g_print("== destroy \n");
int ret;
ret = mc_server_destroy(g_mc_server);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to destroy media contoller server");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to destroy media contoller server");
return FALSE;
}
- g_print ("== success destroy \n");
+ g_print("== success destroy \n");
g_mc_server = NULL;
return TRUE;
}
/***************************************************************/
/** Testsuite */
/***************************************************************/
-void quit (void)
+void quit(void)
{
if (g_mc_server != NULL)
_destroy();
return;
}
-static void display_update_info_menu (void)
+static void display_update_info_menu(void)
{
g_print("\n");
g_print("====================================================\n");
}
-static void display_set_info_menu (void)
+static void display_set_info_menu(void)
{
g_print("\n");
g_print("====================================================\n");
}
-static void display_main_menu (void)
+static void display_main_menu(void)
{
g_print("\n");
g_print("====================================================\n");
}
-static void display_menu (void)
+static void display_menu(void)
{
if (g_menu_state == CURRENT_STATE_MAIN_MENU) {
- display_main_menu ();
+ display_main_menu();
} else if (g_menu_state == CURRENT_STATE_INFORMATION_SET_MENU) {
display_set_info_menu();
} else if (g_menu_state == CURRENT_STATE_INFORMATION_UPDATE_MENU) {
}
}
-void _interpret_update_info_menu (char *cmd)
+void _interpret_update_info_menu(char *cmd)
{
int len = strlen(cmd);
if (len == 1) {
- if ( !strncmp(cmd, "1", len)) {
+ if (!strncmp(cmd, "1", len)) {
_update_info(1);
- } else if ( !strncmp(cmd, "2", len)) {
+ } else if (!strncmp(cmd, "2", len)) {
_update_info(2);
- } else if ( !strncmp(cmd, "3", len)) {
+ } else if (!strncmp(cmd, "3", len)) {
_update_info(3);
- } else if ( !strncmp(cmd, "4", len)) {
+ } else if (!strncmp(cmd, "4", len)) {
_update_info(4);
- } else if ( !strncmp(cmd, "0", len)) {
+ } else if (!strncmp(cmd, "0", len)) {
reset_current_menu_state();
}
} else {
}
}
-void _interpret_set_info_menu (char *cmd)
+void _interpret_set_info_menu(char *cmd)
{
int len = strlen(cmd);
if (len == 1) {
- if ( !strncmp(cmd, "1", len)) {
+ if (!strncmp(cmd, "1", len)) {
g_menu_set_state = CURRENT_STATE_SET_PLAYBACK_STATE;
- } else if ( !strncmp(cmd, "2", len)) {
+ } else if (!strncmp(cmd, "2", len)) {
g_menu_set_state = CURRENT_STATE_SET_PLAYBACK_POSITION;
- } else if ( !strncmp(cmd, "3", len)) {
+ } else if (!strncmp(cmd, "3", len)) {
g_menu_set_state = CURRENT_STATE_SET_METADATA_NAME;
- } else if ( !strncmp(cmd, "4", len)) {
+ } else if (!strncmp(cmd, "4", len)) {
g_menu_set_state = CURRENT_STATE_SET_METADATA_VALUE;
- } else if ( !strncmp(cmd, "0", len)) {
+ } else if (!strncmp(cmd, "0", len)) {
reset_current_menu_state();
display_menu();
}
}
}
-void _interpret_main_menu (char *cmd)
+void _interpret_main_menu(char *cmd)
{
int len = strlen(cmd);
if (len == 1) {
- if ( !strncmp(cmd, "1", len)) {
+ if (!strncmp(cmd, "1", len)) {
_create();
- } else if ( !strncmp(cmd, "2", len)) {
+ } else if (!strncmp(cmd, "2", len)) {
_set_cb();
- } else if ( !strncmp(cmd, "3", len)) {
+ } else if (!strncmp(cmd, "3", len)) {
g_menu_state = CURRENT_STATE_INFORMATION_SET_MENU;
- } else if ( !strncmp(cmd, "4", len)) {
+ } else if (!strncmp(cmd, "4", len)) {
g_menu_state = CURRENT_STATE_INFORMATION_UPDATE_MENU;
- } else if ( !strncmp(cmd, "9", len)) {
+ } else if (!strncmp(cmd, "9", len)) {
_destroy();
- } else if ( !strncmp(cmd, "0", len)) {
+ } else if (!strncmp(cmd, "0", len)) {
quit();
}
} else {
}
}
-static void interpret_cmd (char *cmd)
+static void interpret_cmd(char *cmd)
{
switch (g_menu_state) {
case CURRENT_STATE_MAIN_MENU:
display_menu();
break;
case CURRENT_STATE_INFORMATION_SET_MENU:
- switch(g_menu_set_state) {
+ switch (g_menu_set_state) {
case CURRENT_STATE_SET_MODE_NONE:
_interpret_set_info_menu(cmd);
break;
}
}
-gboolean input (GIOChannel *channel)
+gboolean input(GIOChannel *channel)
{
gchar buf[MAX_STRING_LEN];
gsize read;
buf[read] = '\0';
g_strstrip(buf);
- interpret_cmd (buf);
+ interpret_cmd(buf);
return TRUE;
-
+
}
int server_sequential_test(void)
int ret = MEDIA_CONTROLLER_ERROR_NONE;
ret = mc_server_create(&g_mc_server);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_server_create\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_server_create\n");
return ret;
}
ret = mc_server_set_playback_state(g_mc_server, MEDIA_PLAYBACK_STATE_PLAYING);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_server_set_playback_state\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_server_set_playback_state\n");
return ret;
}
ret = mc_server_set_playback_position(g_mc_server, 10000);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_server_set_playback_state\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_server_set_playback_state\n");
return ret;
}
ret = mc_server_update_playback_info(g_mc_server);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_server_update_playback_info\n");
- //return ret;
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_server_update_playback_info\n");
+ /*return ret; */
}
ret = mc_server_set_metadata(g_mc_server, MEDIA_TITLE, "media_title");
ret = mc_server_set_metadata(g_mc_server, MEDIA_TRACK_NUM, "media_track_num 3/10");
ret = mc_server_set_metadata(g_mc_server, MEDIA_PICTURE, "media_picture_path");
ret = mc_server_update_metadata(g_mc_server);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_server_update_metadata\n");
- //return ret;
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_server_update_metadata\n");
+ /*return ret; */
}
ret = mc_server_update_shuffle_mode(g_mc_server, SHUFFLE_MODE_ON);
ret = mc_server_update_repeat_mode(g_mc_server, REPEAT_MODE_ON);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_server_update_repeat_mode\n");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_server_update_repeat_mode\n");
return ret;
}
ret = mc_server_destroy(g_mc_server);
- if ( ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print ("Fail to mc_server_destroy");
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to mc_server_destroy");
return ret;
}
GIOChannel *stdin_channel;
stdin_channel = g_io_channel_unix_new(0);
g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
- g_io_add_watch (stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
+ g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
g_shuffle_mode = SHUFFLE_MODE_OFF;
g_repeat_mode = REPEAT_MODE_OFF;
mainloop = g_main_loop_new(NULL, FALSE);
display_menu();
-
+
g_main_loop_run(mainloop);
g_main_loop_unref(mainloop);