SET(submodule "controller")
# for package file
-SET(dependents "capi-base-common glib-2.0 gio-2.0 dlog sqlite3 db-util aul bundle libtzplatform-config cynara-client cynara-session cynara-creds-socket")
+SET(dependents "capi-base-common glib-2.0 gio-2.0 dlog sqlite3 db-util aul bundle libtzplatform-config cynara-client cynara-session cynara-creds-socket uuid")
SET(fw_name "${project_prefix}-${service}-${submodule}")
PROJECT(${fw_name})
typedef bool (*mc_activated_server_cb)(const char *server_name, void *user_data);
/**
+ * @deprecated Deprecated since 4.0. Use mc_cmd_reply_received_cb() instead.
* @brief Called when receiving the command processing result from the server.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*
- * @remarks The callback is called in the dbus event loop. @a data should be released using @c bundle_free().
+ * @remarks The callback is called in the dbus event loop. @a data should be released using bundle_free().
*
* @param[in] server_name The app_id of the media controller server which sent the reply, It can be used only in the callback. To use outside, make a copy.
* @param[in] result_code The result code of custom command
*
* @see mc_client_send_custom_command()
*/
-typedef void (*mc_command_reply_received_cb)(const char *server_name, int result_code, bundle *data, void *user_data);
+typedef void (*mc_command_reply_received_cb)(const char *server_name, int result_code, bundle *data, void *user_data) TIZEN_DEPRECATED_API;
+
+/**
+ * @brief Called when the result of the command from the server is received.
+ * @since_tizen 4.0
+ *
+ * @remarks The callback is called in the dbus event loop. @a data should be released using bundle_free().
+ *
+ * @param[in] server_name The app_id of the media controller server which sent the reply, It can be used only in the callback. To use outside, make a copy.
+ * @param[in] request_id The id of the command request
+ * @param[in] result_code The result code of the action
+ * @param[in] data The extra data
+ * @param[in] user_data The user data passed from the mc_client_send_custom_command() function
+ *
+ * @pre mc_client_send_custom_cmd()
+ * @pre mc_client_set_cmd_reply_cb()
+ *
+ * @see mc_client_send_custom_cmd()
+ */
+typedef void (*mc_cmd_reply_received_cb)(const char *server_name, const char *request_id, int result_code, bundle *data, void *user_data);
/**
* @brief Called when requesting the list of subscribed servers.
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.client
*
- * @remarks The @a client should be released using @c mc_client_destroy(). And you can create only one client handle for each process.
+ * @remarks The @a client should be released using @c mc_client_destroy(). You can create only one client handle for each process.
*
* @param[out] client The handle to the media controller client
* @return @c 0 on success,
int mc_client_unset_playlist_update_cb(mc_client_h client);
/**
+ * @brief Sets the callback for receiving the result of the command from the media controller server.
+ * @details The media controller client which calls this function will receives the result of the command from all media controller servers.
+ * @since_tizen 4.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/mediacontroller.client
+ *
+ * @param[in] client The handle to the media controller client
+ * @param[in] callback The callback to be invoked when the reply is received
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
+ * @pre Create a media controller client handle by calling mc_client_create().
+ * @see mc_client_create()
+ * @see mc_client_unset_cmd_reply_received_cb()
+ * @see mc_client_destroy()
+ */
+int mc_client_set_cmd_reply_received_cb(mc_client_h client, mc_cmd_reply_received_cb callback, void *user_data);
+
+/**
+ * @brief Unsets the callback for receiving common reply of the media controller server.
+ * @since_tizen 4.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/mediacontroller.client
+ *
+ * @param[in] client The handle to the media controller client
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
+ * @pre Create a media controller client handle by calling mc_client_create().
+ * @see mc_client_create()
+ * @see mc_client_set_cmd_reply_received_cb()
+ * @see mc_client_destroy()
+ */
+int mc_client_unset_cmd_reply_received_cb(mc_client_h client);
+
+/**
* @brief Subscribes media controller server for monitoring status.
* @details If media controller client subscribe media controller server, \n
* the media controller client receive callback from subscribed media controller server. \n
int mc_client_foreach_server(mc_client_h client, mc_activated_server_cb callback, void *user_data);
/**
- * @deprecated Deprecated since 5.0. Use mc_client_send_playback_action() instead.
+ * @deprecated Deprecated since 4.0. Use mc_client_send_playback_action_cmd() instead.
* @brief Sends the playback state command to server.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*
/**
* @brief Sends the playback action command to server.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.client
*
+ * @remarks The @a request_id should be released using free().\n
+ * If the @a request_id is null, the server will not send the reply of the command.
+ *
* @param[in] client The handle to the media controller client
* @param[in] server_name The app_id of the media controller server
* @param[in] action The playback action command to send to the media controller server
+ * @param[out] request_id The id of the command request, it will be passed to the mc_cmd_reply_received_cb() function
* @return @c 0 on success,
* otherwise a negative error value
* @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
* @pre Create a media controller client handle by calling mc_client_create().
* @see mc_client_create()
* @see mc_client_get_server_playback_info()
+ * @see mc_client_set_cmd_reply_received_cb()
*/
-int mc_client_send_playback_action(mc_client_h client, const char *server_name, mc_playback_action_e action);
+int mc_client_send_playback_action_cmd(mc_client_h client, const char *server_name, mc_playback_action_e action, char **request_id);
/**
* @brief Sends the playback position command to server.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.client
*
+ * @remarks The @a request_id should be released using free().\n
+ * If the @a request_id is null, the server will not send the reply of the command.
+ *
* @param[in] client The handle to the media controller client
* @param[in] server_name The app_id of the media controller server
* @param[in] position The position of the playback in milliseconds to send to media controller server.
+ * @param[out] request_id The id of the command request, it will be passed to the mc_cmd_reply_received_cb() function
* @return @c 0 on success,
* otherwise a negative error value
* @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
* @pre Create a media controller client handle by calling mc_client_create().
* @see mc_client_create()
* @see mc_client_get_server_playback_info()
+ * @see mc_client_set_cmd_reply_received_cb()
*/
-int mc_client_send_playback_position_command(mc_client_h client, const char *server_name, unsigned long long position);
+int mc_client_send_playback_position_cmd(mc_client_h client, const char *server_name, unsigned long long position, char **request_id);
/**
* @brief Sends the shuffle mode command to server.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.client
*
+ * @remarks The @a request_id should be released using free().\n
+ * If the @a request_id is null, the server will not send the reply of the command.
+ *
* @param[in] client The handle to the media controller client
* @param[in] server_name The app_id of the media controller server
* @param[in] shuffle_mode The shuffle mode to send to media controller server
+ * @param[out] request_id The id of the command request, it will be passed to the mc_cmd_reply_received_cb() function
* @return @c 0 on success,
* otherwise a negative error value
* @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
* @pre Create a media controller client handle by calling mc_client_create().
* @see mc_client_create()
* @see mc_client_get_server_playback_info()
+ * @see mc_client_set_cmd_reply_received_cb()
*/
-int mc_client_send_shuffle_mode_command(mc_client_h client, const char *server_name, mc_shuffle_mode_e shuffle_mode);
+int mc_client_send_shuffle_mode_cmd(mc_client_h client, const char *server_name, mc_shuffle_mode_e shuffle_mode, char **request_id);
/**
* @brief Sends the repeat mode command to server.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.client
*
+ * @remarks The @a request_id should be released using free().\n
+ * If the @a request_id is null, the server will not send the reply of the command.
+ *
* @param[in] client The handle to the media controller client
* @param[in] server_name The app_id of the media controller server
* @param[in] repeat_mode The repeat mode to send to media controller server
+ * @param[out] request_id The id of the command request, it will be passed to the mc_cmd_reply_received_cb() function
* @return @c 0 on success,
* otherwise a negative error value
* @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
* @pre Create a media controller client handle by calling mc_client_create().
* @see mc_client_create()
* @see mc_client_get_server_playback_info()
+ * @see mc_client_set_cmd_reply_received_cb()
*/
-int mc_client_send_repeat_mode_command(mc_client_h client, const char *server_name, mc_repeat_mode_e repeat_mode);
+int mc_client_send_repeat_mode_cmd(mc_client_h client, const char *server_name, mc_repeat_mode_e repeat_mode, char **request_id);
/**
* @brief Sends the custom command to server.
* @pre Create a media controller client handle by calling mc_client_create().
* @see mc_client_create()
*/
-int mc_client_send_custom_command(mc_client_h client, const char *server_name, const char *command, bundle *data, mc_command_reply_received_cb callback, void *user_data);
+int mc_client_send_custom_command(mc_client_h client, const char *server_name, const char *command, bundle *data, mc_command_reply_received_cb callback, void *user_data) TIZEN_DEPRECATED_API;
/**
* @brief Sends the playlist command to server.
* @details The media controller client can send "index" of the playlist to the media controller server with playback action and position.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.client
*
+ * @remarks The @a request_id should be released using free().\n
+ * If the @a request_id is null, the server will not send the reply of the command.
+ *
* @param[in] client The handle to the media controller client
* @param[in] server_name The app_id of the media controller server
* @param[in] playlist_name The playlist name of the server
* @param[in] index The index of the media in playlist to send to the media controller server
* @param[in] action The playback action command to send to the media controller server
* @param[in] position The position of the playback in milliseconds to send to media controller server
+ * @param[out] request_id The id of the command request, it will be passed to the mc_cmd_reply_received_cb() function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
+ * @pre Create a media controller client handle by calling mc_client_create().
+ * @see mc_client_create()
+ * @see mc_client_set_cmd_reply_received_cb()
+ */
+int mc_client_send_playlist_cmd(mc_client_h client, const char *server_name, const char *playlist_name, const char *index, mc_playback_action_e action, unsigned long long position, char **request_id);
+
+/**
+ * @brief Sends the custom command to server.
+ * @details If the server sends the result of the command, the media controller client will get the result of the custom command by mc_cmd_reply_received_cb() callback.
+ * @since_tizen 4.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/mediacontroller.client
+ *
+ * @remarks The @a request_id should be released using free().\n
+ * If the @a request_id is null, the server will not send the reply of the command.
+ *
+ * @param[in] client The handle to the media controller client
+ * @param[in] server_name The app_id of the media controller server
+ * @param[in] command The command to be sent
+ * @param[in] data The extra data
+ * @param[out] request_id The id of the command request, it will be passed to the mc_cmd_reply_received_cb() function
* @return @c 0 on success,
* otherwise a negative error value
* @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
* @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
* @pre Create a media controller client handle by calling mc_client_create().
* @see mc_client_create()
+ * @see mc_client_set_cmd_reply_received_cb()
*/
-int mc_client_send_playlist_command(mc_client_h client, const char *server_name, const char *playlist_name, const char *index, mc_playback_action_e action, unsigned long long position);
+int mc_client_send_custom_cmd(mc_client_h client, const char *server_name, const char *command, bundle *data, char **request_id);
/**
* @brief Destroys client.
#define MC_DBUS_SIGNAL_NAME_SHUFFLE_CMD "shuffle_cmd"
#define MC_DBUS_SIGNAL_NAME_REPEAT_CMD "repeat_cmd"
#define MC_DBUS_SIGNAL_NAME_CUSTOM_CMD "custom_cmd"
-#define MC_DBUS_SIGNAL_NAME_CMD_REPLY "custom_cmd_reply"
-#define MC_DBUS_SIGNAL_NAME_PLAYLIST "playlist"
+#define MC_DBUS_SIGNAL_NAME_CMD_REPLY "cmd_reply"
+#define MC_DBUS_SIGNAL_NAME_PLAYLIST "playlist"
#define MC_DBUS_SIGNAL_NAME_PLAYBACK_PLAYLIST "pb_playlist"
+#define MC_DBUS_SIGNAL_NAME_CUSTOM_COMMAND "custom_command"
+#define MC_DBUS_SIGNAL_NAME_CUSTOM_COMMAND_REPLY "custom_command_reply"
#define MC_COMMAND_PLAYBACKSTATE "_pb_state_cmd_"
#define MC_COMMAND_REPEAT "_repeat_cmd_"
#define MC_COMMAND_CUSTOM "_custom_cmd_"
#define MC_COMMAND_PLAY_PLAYLIST "_playlist_cmd_"
-
+#define MC_COMMAND_CUSTOMACTION "_custom_action_"
+#define MC_COMMAND_CMDREPLY "_cmd_reply_"
#define MC_DB_CMD_CREATE_SERVER "DB_CMD_CREATE_SERVER" /* Create New Server Table*/
#define MC_DB_CMD_UPDATE_SERVER_LIST "DB_CMD_UPDATE_SERVER_LIST" /* Update Server Name*/
media_controller_receiver_s repeat_mode_reciever;
media_controller_receiver_s custom_cmd_reciever;
media_controller_receiver_s play_playlist_reciever;
+ media_controller_receiver_s custom_command_reciever;
} media_controller_server_s;
typedef struct {
media_controller_receiver_s repeat_cb;
media_controller_receiver_s reply_cb;
media_controller_receiver_s playlist_cb;
+ media_controller_receiver_s cmd_reply_cb;
} media_controller_client_s;
/* formal callback to receive signal */
-typedef void(*mc_signal_received_cb)(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data);
+typedef void(*mc_signal_received_cb)(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data);
typedef struct {
GDBusConnection *dbus_conn;
char *interface_name;
int mc_util_make_filter_interface_name(const char *prefix, const char *filter, char **interface_name);
int mc_util_set_command_available(mc_priv_type_e priv_type, const char *name, const char *command_type, const char *command);
int mc_util_get_command_available(mc_priv_type_e priv_type, const char *name, const char *command_type, const char *command);
-int mc_util_get_request_id(unsigned int *req_id);
+char *mc_util_generate_uuid(void);
int mc_util_bundle_to_string(bundle *bundle_data, char **str_data);
int mc_safe_strtoi(const char *buffer, int *value);
int mc_safe_strtoull(const char *buffer, unsigned long long *value);
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);
int mc_ipc_unregister_listener(GList **manage_list, GDBusConnection *connection, const char *interface_name, const char *signal_name);
int mc_ipc_unregister_all_listener(GList **manage_list, GDBusConnection *connection);
-int mc_ipc_send_message(GDBusConnection *connection, const char *dbus_name, const char *interface_name, const char* signal_name, const char* message, unsigned int *request_id);
+int mc_ipc_send_message(GDBusConnection *connection, const char *dbus_name, const char *interface_name, const char* signal_name, const char* message, char **request_id);
+int mc_ipc_send_reply(GDBusConnection *connection, const char *dbus_name, const char *interface_name, const char *signal_name, const char *message, const char *request_id);
int mc_ipc_send_message_to_server(mc_msg_type_e msg_type, mc_priv_type_e priv_type, const char *request_msg);
int mc_ipc_service_connect(mc_priv_type_e type);
*/
/**
- * @deprecated Deprecated since 5.0.
+ * @deprecated Deprecated since 4.0. Use mc_server_playback_action_cmd_received_cb() instead.
* @brief Called when the server receives the playback state from the client.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*
/**
* @brief Called when the server receives the playback action command from the client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
- * @remarks The callback is called in the dbus event loop.
+ * @remarks The callback is called in the dbus event loop.\n
+ * If @a request_id is not null, the server should send the reply to the client with the @a request_id.
*
* @param[in] client_name The app_id of the media controller client. It can be used only in the callback. To use outside, make a copy.
+ * @param[in] request_id The request_id of the media controller client.
* @param[in] action The received playback action
- * @param[in] user_data The user data passed from the mc_server_set_playback_action_received_cb() function
+ * @param[in] user_data The user data passed from the mc_server_set_playback_action_cmd_received_cb() function
*
- * @pre mc_server_set_playback_action_received_cb()
+ * @pre mc_server_set_playback_action_cmd_received_cb()
*
- * @see mc_server_set_playback_action_received_cb()
+ * @see mc_server_set_playback_action_cmd_received_cb()
+ * @see mc_server_send_cmd_reply()
*/
-typedef void (*mc_server_playback_action_received_cb)(const char* client_name, mc_playback_action_e action, void *user_data);
+typedef void (*mc_server_playback_action_cmd_received_cb)(const char* client_name, const char *request_id, mc_playback_action_e action, void *user_data);
/**
* @brief Called when the server receives the playback position from the client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
- * @remarks The callback is called in the dbus event loop.
+ * @remarks The callback is called in the dbus event loop.\n
+ * If @a request_id is not null, the server should send the reply to the client with the @a request_id.
*
* @param[in] client_name The app_id of the media controller client. It can be used only in the callback. To use outside, make a copy.
+ * @param[in] request_id The request_id of the media controller client.
* @param[in] position The received playback position (milliseconds)
- * @param[in] user_data The user data passed from the mc_server_set_playback_position_command_received_cb() function
+ * @param[in] user_data The user data passed from the mc_server_set_playback_position_cmd_received_cb() function
*
- * @pre mc_server_set_playback_position_command_received_cb()
+ * @pre mc_server_set_playback_position_cmd_received_cb()
*
- * @see mc_server_set_playback_position_command_received_cb()
+ * @see mc_server_set_playback_position_cmd_received_cb()
+ * @see mc_server_send_cmd_reply()
*/
-typedef void (*mc_server_playback_position_command_received_cb)(const char* client_name, unsigned long long position, void *user_data);
+typedef void (*mc_server_playback_position_cmd_received_cb)(const char* client_name, const char *request_id, unsigned long long position, void *user_data);
/**
* @brief Called when the server receives the shuffle mode from the client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
- * @remarks The callback is called in the dbus event loop.
+ * @remarks The callback is called in the dbus event loop.\n
+ * If @a request_id is not null, the server should send the reply to the client with the @a request_id.
*
* @param[in] client_name The app_id of the media controller client. It can be used only in the callback. To use outside, make a copy.
+ * @param[in] request_id The request_id of the media controller client.
* @param[in] shuffle_mode The received shuffle_mode
- * @param[in] user_data The user data passed from the mc_server_set_shuffle_mode_command_received_cb() function
+ * @param[in] user_data The user data passed from the mc_server_set_shuffle_mode_cmd_received_cb() function
*
- * @pre mc_server_set_shuffle_mode_command_received_cb()
+ * @pre mc_server_set_shuffle_mode_cmd_received_cb()
*
- * @see mc_server_set_shuffle_mode_command_received_cb()
+ * @see mc_server_set_shuffle_mode_cmd_received_cb()
+ * @see mc_server_send_cmd_reply()
*/
-typedef void (*mc_server_shuffle_mode_command_received_cb)(const char* client_name, mc_shuffle_mode_e shuffle_mode, void *user_data);
+typedef void (*mc_server_shuffle_mode_cmd_received_cb)(const char* client_name, const char *request_id, mc_shuffle_mode_e shuffle_mode, void *user_data);
/**
* @brief Called when the server receives the repeat mode from the client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
- * @remarks The callback is called in the dbus event loop.
+ * @remarks The callback is called in the dbus event loop.\n
+ * If @a request_id is not null, the server should send the reply to the client with the @a request_id.
*
* @param[in] client_name The app_id of the media controller client. It can be used only in the callback. To use outside, make a copy.
+ * @param[in] request_id The request_id of the media controller client.
* @param[in] repeat_mode The received repeat mode
- * @param[in] user_data The user data passed from the mc_server_set_repeat_mode_command_received_cb() function
+ * @param[in] user_data The user data passed from the mc_server_set_repeat_mode_cmd_received_cb() function
*
- * @pre mc_server_set_repeat_mode_command_received_cb()
+ * @pre mc_server_set_repeat_mode_cmd_received_cb()
*
- * @see mc_server_set_repeat_mode_command_received_cb()
+ * @see mc_server_set_repeat_mode_cmd_received_cb()
+ * @see mc_server_send_cmd_reply()
*/
-typedef void (*mc_server_repeat_mode_command_received_cb)(const char* client_name, mc_repeat_mode_e repeat_mode, void *user_data);
+typedef void (*mc_server_repeat_mode_cmd_received_cb)(const char* client_name, const char *request_id, mc_repeat_mode_e repeat_mode, void *user_data);
/**
+ * @deprecated Deprecated since 4.0. Use mc_server_custom_cmd_received_cb() instead.
* @brief Called when the Server receives custom command from the client.
* @details This callback is called when server receives custom command from client.
* If there is reply for command, call mc_server_send_command_reply() function.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*
- * @remarks The callback is called in the dbus event loop. @a data should be released using bundle_free().
+ * @remarks The callback is called in the dbus event loop. @a data should be released using bundle_free().\n
+ * If @a request_id is not null, the server should send the reply to the client with the @a request_id.
*
* @param[in] client_name The app_id of the media controller client. It can be used only in the callback. To use outside, make a copy.
* @param[in] command The received command. It can be used only in the callback. To use outside, make a copy.
*
* @see mc_server_set_custom_command_received_cb()
*/
-typedef void (*mc_server_custom_command_received_cb)(const char* client_name, const char *command, bundle *data, void *user_data);
+typedef void (*mc_server_custom_command_received_cb)(const char* client_name, const char *command, bundle *data, void *user_data) TIZEN_DEPRECATED_API;
/**
* @brief Called when the Server receives playlist command from the client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
- * @remarks The callback is called in the dbus event loop.
+ * @remarks The callback is called in the dbus event loop. \n
+ * If @a request_id is not null, the server should send the reply to the client with the @a request_id.
*
* @param[in] client_name The app_id of the media controller client. It can be used only in the callback. To use outside, make a copy.
+ * @param[in] request_id The request_id of the media controller client.
* @param[in] playlist_name The name of the server playlist. It can be used only in the callback. To use outside, make a copy.
* @param[in] index The index of the media in playlist. It can be used only in the callback. To use outside, make a copy.
* @param[in] action The received playback action
* @param[in] position The received playback position (milliseconds)
- * @param[in] user_data The user data passed from the mc_server_set_playlist_command_received_cb() function
+ * @param[in] user_data The user data passed from the mc_server_set_playlist_cmd_received_cb() function
+ *
+ * @pre mc_server_set_playlist_cmd_received_cb()
+ *
+ * @see mc_server_set_playlist_cmd_received_cb()
+ * @see mc_server_send_cmd_reply()
+ */
+typedef void (*mc_server_playlist_cmd_received_cb)(const char* client_name, const char *request_id, const char *playlist_name, const char *index, mc_playback_action_e action, unsigned long long position, void *user_data);
+
+/**
+ * @brief Called when the Server receives custom command from the client.
+ * @details This callback is called when server receives custom command from client.
+ * If you want to reply to the command, call mc_server_send_cmd_reply() function.
+ * @since_tizen 4.0
+ *
+ * @remarks The callback is called in the dbus event loop. @a data should be released using bundle_free().\n
+ * If @a request_id is not null, the server should send the reply to the client with the @a request_id.
+ *
+ * @param[in] client_name The app_id of the media controller client. It can be used only in the callback. To use outside, make a copy.
+ * @param[in] request_id The id of the command request
+ * @param[in] command The received command. It can be used only in the callback. To use outside, make a copy.
+ * @param[in] data The extra data
+ * @param[in] user_data The user data passed from the mc_server_set_custom_cmd_received_cb() function
*
- * @pre mc_server_set_playlist_command_received_cb()
+ * @pre mc_server_set_custom_cmd_received_cb()
*
- * @see mc_server_set_playlist_command_received_cb()
+ * @see mc_server_set_custom_cmd_received_cb()
+ * @see mc_server_unset_custom_cmd_received_cb()
+ * @see mc_server_send_cmd_reply()
*/
-typedef void (*mc_server_playlist_command_received_cb)(const char* client_name, const char *playlist_name, const char *index, mc_playback_action_e action, unsigned long long position, void *user_data);
+typedef void (*mc_server_custom_cmd_received_cb)(const char* client_name, const char *request_id, const char *command, bundle *data, void *user_data);
/**
* @brief Creates a media controller server.
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
*
- * @remarks The @a server should be released using mc_server_destroy(). And you can create only one server handle for each process.
+ * @remarks The @a server should be released using mc_server_destroy(). You can create only one server handle for each process.
*
* @param[out] server The handle to media controller server
* @return @c 0 on success,
int mc_server_set_playback_state_command_received_cb(mc_server_h server, mc_server_playback_state_command_received_cb callback, void *user_data) TIZEN_DEPRECATED_API;
/**
- * @deprecated Deprecated since 5.0. Use mc_server_unset_playback_action_received_cb() instead.
+ * @deprecated Deprecated since 4.0. Use mc_server_unset_playback_action_cmd_received_cb() instead.
* @brief Unsets the callback for receiving playback state command from client.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*
/**
* @brief Sets the callback for receiving playback action command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_set_playback_action_received_cb(mc_server_h server, mc_server_playback_action_received_cb callback, void *user_data);
+int mc_server_set_playback_action_cmd_received_cb(mc_server_h server, mc_server_playback_action_cmd_received_cb callback, void *user_data);
/**
* @brief Unsets the callback for receiving playback action command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_unset_playback_action_received_cb(mc_server_h server);
+int mc_server_unset_playback_action_cmd_received_cb(mc_server_h server);
/**
* @brief Sets the callback for receiving playback position command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_set_playback_position_command_received_cb(mc_server_h server, mc_server_playback_position_command_received_cb callback, void *user_data);
+int mc_server_set_playback_position_cmd_received_cb(mc_server_h server, mc_server_playback_position_cmd_received_cb callback, void *user_data);
/**
* @brief Unsets the callback for receiving playback position command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_unset_playback_position_command_received_cb(mc_server_h server);
+int mc_server_unset_playback_position_cmd_received_cb(mc_server_h server);
/**
* @brief Sets the callback for receiving shuffle mode command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_set_shuffle_mode_command_received_cb(mc_server_h server, mc_server_shuffle_mode_command_received_cb callback, void *user_data);
+int mc_server_set_shuffle_mode_cmd_received_cb(mc_server_h server, mc_server_shuffle_mode_cmd_received_cb callback, void *user_data);
/**
* @brief Unsets the callback for receiving shuffle mode command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_unset_shuffle_mode_command_received_cb(mc_server_h server);
+int mc_server_unset_shuffle_mode_cmd_received_cb(mc_server_h server);
/**
* @brief Sets the callback for receiving repeat mode command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_set_repeat_mode_command_received_cb(mc_server_h server, mc_server_repeat_mode_command_received_cb callback, void *user_data);
+int mc_server_set_repeat_mode_cmd_received_cb(mc_server_h server, mc_server_repeat_mode_cmd_received_cb callback, void *user_data);
/**
* @brief Unsets the callback for receiving repeat mode command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_unset_repeat_mode_command_received_cb(mc_server_h server);
+int mc_server_unset_repeat_mode_cmd_received_cb(mc_server_h server);
/**
+ * @deprecated Deprecated since 4.0. Use mc_server_set_custom_cmd_received_cb() instead.
* @brief Sets the callback for receiving custom command from client.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_set_custom_command_received_cb(mc_server_h server, mc_server_custom_command_received_cb callback, void *user_data);
+int mc_server_set_custom_command_received_cb(mc_server_h server, mc_server_custom_command_received_cb callback, void *user_data) TIZEN_DEPRECATED_API;
/**
+ * @deprecated Deprecated since 4.0. Use mc_server_unset_custom_cmd_received_cb() instead.
* @brief Unsets the callback for receiving custom command from client.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_unset_custom_command_received_cb(mc_server_h server);
+int mc_server_unset_custom_command_received_cb(mc_server_h server) TIZEN_DEPRECATED_API;
/**
+ * @deprecated Deprecated since 4.0. Use mc_server_send_cmd_reply() instead.
* @brief Sends a reply for the requested command to the client.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_send_command_reply(mc_server_h server, const char *client_name, int result_code, bundle *data);
+int mc_server_send_command_reply(mc_server_h server, const char *client_name, int result_code, bundle *data) TIZEN_DEPRECATED_API;
/**
* @brief Sets the callback for receiving playlist command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
* @see mc_server_create()
* @see mc_server_destroy()
*/
-int mc_server_set_playlist_command_received_cb(mc_server_h server, mc_server_playlist_command_received_cb callback, void *user_data);
+int mc_server_set_playlist_cmd_received_cb(mc_server_h server, mc_server_playlist_cmd_received_cb callback, void *user_data);
/**
* @brief Unsets the callback for receiving playlist command from client.
- * @since_tizen 5.0
+ * @since_tizen 4.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/mediacontroller.server
+ *
+ * @param[in] server The handle to media controller server
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
+ * @pre Create a media controller server handle by calling mc_server_create().
+ * @see mc_server_create()
+ * @see mc_server_destroy()
+ */
+int mc_server_unset_playlist_cmd_received_cb(mc_server_h server);
+
+/**
+ * @brief Sets the callback for receiving custom command from client.
+ * @since_tizen 4.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/mediacontroller.server
+ *
+ * @param[in] server The handle to media controller server
+ * @param[in] callback The callback to be invoked when media controller server receives custom command from client.
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
+ * @pre Create a media controller server handle by calling mc_server_create().
+ * @see mc_server_create()
+ * @see mc_server_destroy()
+ */
+int mc_server_set_custom_cmd_received_cb(mc_server_h server, mc_server_custom_cmd_received_cb callback, void *user_data);
+
+/**
+ * @brief Unsets the callback for receiving custom command from client.
+ * @since_tizen 4.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/mediacontroller.server
+ *
+ * @param[in] server The handle to media controller server
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
+ * @pre Create a media controller server handle by calling mc_server_create().
+ * @see mc_server_create()
+ * @see mc_server_destroy()
+ */
+int mc_server_unset_custom_cmd_received_cb(mc_server_h server);
+
+/**
+ * @brief Replys the result of the requested command to the client.
+ * @since_tizen 4.0
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.server
*
+ * @remarks When the server receives a command, this function can be called by mc_server_playback_action_cmd_received_cb(), mc_server_playback_position_cmd_received_cb(), mc_server_shuffle_mode_cmd_received_cb(), mc_server_repeat_mode_cmd_received_cb(), mc_server_playlist_cmd_received_cb() and mc_server_custom_cmd_received_cb().\n
+ * If @a request_id is null, this function will return #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER.
+ *
* @param[in] server The handle to media controller server
+ * @param[in] client_name The app_id of the media controller client
+ * @param[in] request_id The id of the command request, received in the mc_server_custom_cmd_received_cb() function.
+ * @param[in] result_code The result code of custom command
+ * @param[in] data The extra data
* @return @c 0 on success,
* otherwise a negative error value
* @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
* @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
* @pre Create a media controller server handle by calling mc_server_create().
* @see mc_server_create()
+ * @see mc_server_playback_action_cmd_received_cb()
+ * @see mc_server_playback_position_cmd_received_cb()
+ * @see mc_server_shuffle_mode_cmd_received_cb()
+ * @see mc_server_repeat_mode_cmd_received_cb()
+ * @see mc_server_playlist_cmd_received_cb()
+ * @see mc_server_custom_cmd_received_cb()
* @see mc_server_destroy()
*/
-int mc_server_unset_playlist_command_received_cb(mc_server_h server);
+int mc_server_send_cmd_reply(mc_server_h server, const char *client_name, const char *request_id, int result_code, bundle *data);
/**
* @brief Destroys media controller server.
MC_PLAYBACK_STATE_PLAYING, /**< Playing */
MC_PLAYBACK_STATE_PAUSED, /**< Paused */
MC_PLAYBACK_STATE_STOPPED, /**< Stopped */
- MC_PLAYBACK_STATE_NEXT_FILE, /**< Next file (Deprecated since 5.0)*/
- MC_PLAYBACK_STATE_PREV_FILE, /**< Previous file (Deprecated since 5.0)*/
- MC_PLAYBACK_STATE_FAST_FORWARD, /**< Fast forward (Deprecated since 5.0)*/
- MC_PLAYBACK_STATE_REWIND, /**< Rewind (Deprecated since 5.0)*/
- MC_PLAYBACK_STATE_MOVING_TO_NEXT, /**< Moving to the next item (Since 5.0)*/
- MC_PLAYBACK_STATE_MOVING_TO_PREVIOUS, /**< Moving to the previous item (Since 5.0)*/
- MC_PLAYBACK_STATE_FAST_FORWARDING, /**< Fast forwarding (Since 5.0)*/
- MC_PLAYBACK_STATE_REWINDING, /**< Rewinding (Since 5.0)*/
+ MC_PLAYBACK_STATE_NEXT_FILE, /**< Next file (Deprecated since 4.0)*/
+ MC_PLAYBACK_STATE_PREV_FILE, /**< Previous file (Deprecated since 4.0)*/
+ MC_PLAYBACK_STATE_FAST_FORWARD, /**< Fast forward (Deprecated since 4.0)*/
+ MC_PLAYBACK_STATE_REWIND, /**< Rewind (Deprecated since 4.0)*/
+ MC_PLAYBACK_STATE_MOVING_TO_NEXT, /**< Moving to the next item (Since 4.0)*/
+ MC_PLAYBACK_STATE_MOVING_TO_PREVIOUS, /**< Moving to the previous item (Since 4.0)*/
+ MC_PLAYBACK_STATE_FAST_FORWARDING, /**< Fast forwarding (Since 4.0)*/
+ MC_PLAYBACK_STATE_REWINDING, /**< Rewinding (Since 4.0)*/
} mc_playback_states_e;
/**
* @brief Enumeration for the media playback action.
- * @since_tizen 5.0
+ * @since_tizen 4.0
*/
typedef enum {
MC_PLAYBACK_ACTION_PLAY, /**< Play */
typedef enum {
MC_REPEAT_MODE_ON = 0, /**< Repeat mode on for all media*/
MC_REPEAT_MODE_OFF, /**< Repeat mode off */
- MC_REPEAT_MODE_ONE_MEDIA, /**< Repeat mode on for one media (Since 5.0)*/
+ MC_REPEAT_MODE_ONE_MEDIA, /**< Repeat mode on for one media (Since 4.0)*/
} mc_repeat_mode_e;
/**
Name: capi-media-controller
Summary: A media controller library in Tizen Native API
-Version: 0.1.61
+Version: 0.1.62
Release: 1
Group: Multimedia/API
License: Apache-2.0
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(cynara-client)
BuildRequires: pkgconfig(cynara-session)
+BuildRequires: pkgconfig(uuid)
BuildRequires: pkgconfig(capi-appfw-app-control)
%define upgrade_script_path /usr/share/upgrade/scripts
#include "media_controller_db.h"
#include <bundle_internal.h>
-static void __client_server_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __client_server_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *reciever = (media_controller_receiver_s *)user_data;
mc_retm_if(reciever->callback == NULL, "server_state_cb is NULL");
mc_retm_if(message == NULL, "message is NULL");
- mc_debug("__client_server_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__client_server_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid server data");
g_strfreev(params);
}
-static void __client_playback_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __client_playback_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *reciever = (media_controller_receiver_s *)user_data;
mc_retm_if(reciever->callback == NULL, "playback_cb is NULL");
mc_retm_if(message == NULL, "message is NULL");
- mc_debug("__client_playback_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__client_playback_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
playback = (media_controller_playback_s *)calloc(1, sizeof(media_controller_playback_s));
mc_retm_if(playback == NULL, "Error allocation memory");
g_strfreev(params);
}
-static void __client_metadata_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __client_metadata_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
mc_metadata_h metadata = NULL;
mc_retm_if(mc_client->metadata_cb.callback == NULL, "metadata_cb is NULL");
mc_retm_if(message == NULL, "message is NULL");
- mc_debug("__client_metadata_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__client_metadata_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
ret = mc_db_get_metadata_info(mc_client->db_handle, message, &metadata);
if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_client_destroy_metadata(metadata);
}
-static void __client_shuffle_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __client_shuffle_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *reciever = (media_controller_receiver_s *)user_data;
mc_retm_if(reciever->callback == NULL, "shuffle_cb is NULL");
- mc_debug("__client_shuffle_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__client_shuffle_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid shuffle mode data");
g_strfreev(params);
}
-static void __client_repeat_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __client_repeat_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *reciever = (media_controller_receiver_s *)user_data;
mc_retm_if(reciever->callback == NULL, "repeat_cb is NULL");
- mc_debug("__client_repeat_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__client_repeat_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid repeat mode data");
g_strfreev(params);
}
-static void __client_reply_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __client_reply_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
int enc_size = 0;
mc_command_reply_received_cb callback = (mc_command_reply_received_cb)reciever->callback;
mc_retm_if(reciever->callback == NULL, "reply_cb is NULL");
- mc_debug("__client_reply_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__client_reply_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid custom data");
g_strfreev(params);
}
-static void __client_playlist_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __client_cmd_reply_received_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
+{
+ gchar **params = NULL;
+ int result_code = 0;
+ int enc_size = 0;
+ bundle *bundle_data = NULL;
+
+ media_controller_receiver_s *reciever = (media_controller_receiver_s *)user_data;
+ mc_retm_if(reciever == NULL, "reciever is NULL");
+
+ mc_cmd_reply_received_cb callback = (mc_cmd_reply_received_cb)reciever->callback;
+ mc_retm_if(reciever->callback == NULL, "reply_cb is NULL");
+
+ mc_debug("__client_cmd_reply_received_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
+
+ params = g_strsplit(message, MC_STRING_DELIMITER, 0);
+ mc_retm_if(params == NULL, "invalid custom data");
+
+ if (params[1] != NULL)
+ mc_retm_if(MEDIA_CONTROLLER_ERROR_NONE != mc_safe_strtoi(params[1], &result_code), "getting result_code is failed");
+
+ if (params[2] != NULL)
+ mc_retm_if(MEDIA_CONTROLLER_ERROR_NONE != mc_safe_strtoi(params[2], &enc_size), "getting message is failed");
+
+ if (enc_size > 0)
+ bundle_data = bundle_decode((bundle_raw *)params[3], enc_size);
+
+ callback(params[0], request_id, result_code, bundle_data, reciever->user_data);
+
+ g_strfreev(params);
+}
+
+static void __client_playlist_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
gchar **params = NULL;
mc_retm_if(mc_client->playlist_cb.callback == NULL, "playlist_cb is NULL");
mc_retm_if(message == NULL, "message is NULL");
- mc_debug("__client_playlist_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__client_playlist_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid custom data");
return MEDIA_CONTROLLER_ERROR_NONE;
}
-static int __mc_client_send_command(mc_client_h client, const char *server_name, const char *command_type, const char *command, const char *signal_name, const char *message, unsigned int *request_id)
+static int __mc_client_send_command(mc_client_h client, const char *server_name, const char *command_type, const char *command, const char *signal_name, const char *message, char **request_id)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_client_s *mc_client = (media_controller_client_s *)client;
return ret;
}
+int mc_client_set_cmd_reply_received_cb(mc_client_h client, mc_cmd_reply_received_cb callback, void *user_data)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ 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(callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "callback is NULL");
+ mc_retvm_if(mc_client->cmd_reply_cb.callback != NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "callback is already set");
+
+ mc_client->cmd_reply_cb.callback = callback;
+ mc_client->cmd_reply_cb.user_data = user_data;
+
+ char *interface_name = mc_util_get_interface_name(MC_CLIENT, mc_client->client_name);
+ ret = mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CMD_REPLY,
+ __client_cmd_reply_received_cb, (void *)&(mc_client->cmd_reply_cb));
+
+ MC_SAFE_FREE(interface_name);
+
+ return ret;
+}
+
+int mc_client_unset_cmd_reply_received_cb(mc_client_h client)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ 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");
+
+ char *interface_name = mc_util_get_interface_name(MC_CLIENT, mc_client->client_name);
+ ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CMD_REPLY);
+
+ mc_client->cmd_reply_cb.callback = NULL;
+ mc_client->cmd_reply_cb.user_data = NULL;
+ mc_client->cmd_reply_cb.filter_list = NULL;
+
+ MC_SAFE_FREE(interface_name);
+
+ return ret;
+}
+
int mc_client_subscribe(mc_client_h client, const mc_subscription_type_e subscription_type, const char *server_name)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *message = NULL;
media_controller_client_s *mc_client = (media_controller_client_s *)client;
- mc_warning("DEPRECATION WARNING: mc_client_send_playback_state_command() is deprecated and will be removed from next release. Use mc_client_send_playback_action() instead.");
+ mc_warning("DEPRECATION WARNING: mc_client_send_playback_state_command() is deprecated and will be removed from next release. Use mc_client_send_playback_action_cmd() instead.");
mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(!MC_STRING_VALID(server_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid server_name");
mc_retvm_if(((state < MC_PLAYBACK_STATE_PLAYING) || (state > MC_PLAYBACK_STATE_REWIND)), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "state is invalid");
return ret;
}
-int mc_client_send_playback_action(mc_client_h client, const char *server_name, mc_playback_action_e action)
+int mc_client_send_playback_action_cmd(mc_client_h client, const char *server_name, mc_playback_action_e action, char **request_id)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *message = NULL;
message = g_strdup_printf("%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, action);
mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]", ret);
- ret = __mc_client_send_command(client, server_name, MC_COMMAND_PLAYBACKACTION, NULL, MC_DBUS_SIGNAL_NAME_PLAYBACK_ACTION, message, NULL);
+ ret = __mc_client_send_command(client, server_name, MC_COMMAND_PLAYBACKACTION, NULL, MC_DBUS_SIGNAL_NAME_PLAYBACK_ACTION, message, request_id);
MC_SAFE_G_FREE(message);
return ret;
}
-int mc_client_send_playback_position_command(mc_client_h client, const char *server_name, unsigned long long position)
+int mc_client_send_playback_position_cmd(mc_client_h client, const char *server_name, unsigned long long position, char **request_id)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *message = NULL;
message = g_strdup_printf("%s%s%llu", mc_client->client_name, MC_STRING_DELIMITER, position);
mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]", ret);
- ret = __mc_client_send_command(client, server_name, MC_COMMAND_PLAYBACKPOSITION, NULL, MC_DBUS_SIGNAL_NAME_PLAYBACK_POS_CMD, message, NULL);
+ ret = __mc_client_send_command(client, server_name, MC_COMMAND_PLAYBACKPOSITION, NULL, MC_DBUS_SIGNAL_NAME_PLAYBACK_POS_CMD, message, request_id);
MC_SAFE_G_FREE(message);
return ret;
}
-int mc_client_send_shuffle_mode_command(mc_client_h client, const char *server_name, mc_shuffle_mode_e shuffle_mode)
+int mc_client_send_shuffle_mode_cmd(mc_client_h client, const char *server_name, mc_shuffle_mode_e shuffle_mode, char **request_id)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *message = NULL;
message = g_strdup_printf("%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, shuffle_mode);
mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]", ret);
- ret = __mc_client_send_command(client, server_name, MC_COMMAND_SHUFFLE, NULL, MC_DBUS_SIGNAL_NAME_SHUFFLE_CMD, message, NULL);
+ ret = __mc_client_send_command(client, server_name, MC_COMMAND_SHUFFLE, NULL, MC_DBUS_SIGNAL_NAME_SHUFFLE_CMD, message, request_id);
MC_SAFE_G_FREE(message);
return ret;
}
-int mc_client_send_repeat_mode_command(mc_client_h client, const char *server_name, mc_repeat_mode_e repeat_mode)
+int mc_client_send_repeat_mode_cmd(mc_client_h client, const char *server_name, mc_repeat_mode_e repeat_mode, char **request_id)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *message = NULL;
message = g_strdup_printf("%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, repeat_mode);
mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]", ret);
- ret = __mc_client_send_command(client, server_name, MC_COMMAND_REPEAT, NULL, MC_DBUS_SIGNAL_NAME_REPEAT_CMD, message, NULL);
+ ret = __mc_client_send_command(client, server_name, MC_COMMAND_REPEAT, NULL, MC_DBUS_SIGNAL_NAME_REPEAT_CMD, message, request_id);
MC_SAFE_G_FREE(message);
char *bundle_str = NULL;
media_controller_client_s *mc_client = (media_controller_client_s *)client;
+ mc_warning("DEPRECATION WARNING: mc_client_send_custom_command() is deprecated and will be removed from next release. Use mc_client_send_custom_cmd() instead.");
+
mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(!MC_STRING_VALID(server_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid server_name");
char *interface_name_for_reply = mc_util_get_interface_name(MC_CLIENT, mc_client->client_name);
mc_client->reply_cb.callback = callback;
mc_client->reply_cb.user_data = user_data;
- mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, interface_name_for_reply, MC_DBUS_SIGNAL_NAME_CMD_REPLY, __client_reply_cb, (void *)&(mc_client->reply_cb));
+ mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, interface_name_for_reply, MC_DBUS_SIGNAL_NAME_CUSTOM_COMMAND_REPLY, __client_reply_cb, (void *)&(mc_client->reply_cb));
MC_SAFE_FREE(interface_name_for_reply);
}
MC_SAFE_G_FREE(bundle_str);
mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "Error when making message");
- ret = __mc_client_send_command(client, server_name, MC_COMMAND_CUSTOM, command, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD, message, NULL);
+ ret = __mc_client_send_command(client, server_name, MC_COMMAND_CUSTOM, command, MC_DBUS_SIGNAL_NAME_CUSTOM_COMMAND, message, NULL);
MC_SAFE_G_FREE(message);
return ret;
}
-int mc_client_send_playlist_command(mc_client_h client, const char *server_name, const char *playlist_name, const char *index, mc_playback_action_e action, unsigned long long position)
+int mc_client_send_playlist_cmd(mc_client_h client, const char *server_name, const char *playlist_name, const char *index, mc_playback_action_e action, unsigned long long position, char **request_id)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *message = NULL;
message = g_strdup_printf("%s%s%s%s%s%s%d%s%llu", mc_client->client_name, MC_STRING_DELIMITER, playlist_name, MC_STRING_DELIMITER, index, MC_STRING_DELIMITER, action, MC_STRING_DELIMITER, position);
mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]", ret);
- ret = __mc_client_send_command(client, server_name, MC_COMMAND_PLAY_PLAYLIST, NULL, MC_DBUS_SIGNAL_NAME_PLAYBACK_PLAYLIST, message, NULL);
+ ret = __mc_client_send_command(client, server_name, MC_COMMAND_PLAY_PLAYLIST, NULL, MC_DBUS_SIGNAL_NAME_PLAYBACK_PLAYLIST, message, request_id);
+
+ MC_SAFE_G_FREE(message);
+
+ return ret;
+}
+
+int mc_client_send_custom_cmd(mc_client_h client, const char *server_name, const char *command, bundle *data, char **request_id)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ char *message = NULL;
+ char *bundle_str = NULL;
+ 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(!MC_STRING_VALID(server_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid server_name");
+
+ ret = mc_util_bundle_to_string(data, &bundle_str);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "Error when make string from bundle");
+
+ message = g_strdup_printf("%s%s%s%s%s", mc_client->client_name, MC_STRING_DELIMITER, command, MC_STRING_DELIMITER, bundle_str);
+ MC_SAFE_G_FREE(bundle_str);
+ mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "Error when making message");
+
+ ret = __mc_client_send_command(client, server_name, MC_COMMAND_CUSTOMACTION, command, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD, message, request_id);
MC_SAFE_G_FREE(message);
#define MAX_RETRY_COUNT 3
#define MAX_WAIT_COUNT 100
-#define MC_SVC_NAME "mediacontroller"
+#define DEFAULT_REQ_ID "DEF_REQ_ID"
/* This checks if service daemon is running */
static int __is_service_activated(mc_priv_type_e priv_type)
mc_debug("__mc_ipc_signal_cb Received :");
gchar *message = NULL;
- unsigned int request_id = 0;
+ gchar * request_id = NULL;
- g_variant_get(parameters, "(u&s)", &request_id, &message);
+ g_variant_get(parameters, "(s&s)", &request_id, &message);
if (!message) {
mc_error("g_variant_get() fail");
return;
}
+ if ((request_id != NULL) && (!g_strcmp0(request_id, DEFAULT_REQ_ID))) {
+ request_id = NULL;
+ }
+
char *key = __make_key_for_map(interface_name, signal_name);
if (key == NULL) {
mc_error("fail to get key");
for (i = 0; i < listener_cnt; i++) {
listener = (mc_ipc_listener_s *)g_list_nth_data(*listener_list, i);
if (listener && !g_strcmp0(listener->key, key)) {
- mc_debug("Received : [%s] (req_id = %ld) from %s.%s", message, request_id, listener->interface_name, listener->signal_name);
+ mc_debug("Received : [%s] (req_id = %s) from %s.%s", message, request_id, listener->interface_name, listener->signal_name);
listener->callback(listener->interface_name, listener->signal_name, message, request_id, listener->user_data);
break;
}
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, unsigned int *request_id)
+int mc_ipc_send_message(GDBusConnection *connection, const char *dbus_name, const char *interface_name, const char *signal_name, const char *message, char **request_id)
{
GError *error = NULL;
- unsigned int req_id = 0;
+ char *req_id = (char*)"DEF_REQ_ID";
mc_retvm_if(connection == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "connection is NULL");
mc_retvm_if(!MC_STRING_VALID(signal_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid signal_name");
mc_debug("emit signal - interface_name [%s], signal_name [%s]", interface_name, signal_name);
- if (request_id != NULL)
- mc_util_get_request_id(&req_id);
+ if (request_id != NULL) {
+ req_id = mc_util_generate_uuid();
+ *request_id = g_strdup(req_id);
+
+ mc_secure_debug("req_id[%s]", req_id);
+ }
+
+ gboolean emmiting = g_dbus_connection_emit_signal(
+ connection,
+ dbus_name,
+ MC_DBUS_PATH,
+ interface_name,
+ signal_name,
+ g_variant_new("(ss)", req_id, 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);
+ }
+ return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
+ }
+
+ return MEDIA_CONTROLLER_ERROR_NONE;
+}
+
+int mc_ipc_send_reply(GDBusConnection *connection, const char *dbus_name, const char *interface_name, const char *signal_name, const char *message, const char *request_id)
+{
+ GError *error = NULL;
+
+ mc_retvm_if(connection == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "connection is NULL");
+ mc_retvm_if(!MC_STRING_VALID(signal_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid signal_name");
+ mc_retvm_if(!MC_STRING_VALID(message), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid message");
+
+ mc_debug("emit signal - interface_name [%s], signal_name [%s]", interface_name, signal_name);
gboolean emmiting = g_dbus_connection_emit_signal(
connection,
MC_DBUS_PATH,
interface_name,
signal_name,
- g_variant_new("(us)", req_id, message),
+ g_variant_new("(ss)", request_id, message),
&error);
if (!emmiting) {
mc_error("g_dbus_connection_emit_signal failed : %s", error ? error->message : "none");
return ret;
}
-static void __server_playback_state_command_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __server_playback_state_command_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *receiver = (media_controller_receiver_s *)user_data;
mc_server_playback_state_command_received_cb callback = receiver->callback;
mc_retm_if(receiver->callback == NULL, "playback_state_command_received_cb is NULL");
- mc_debug("__server_playback_state_command_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__server_playback_state_command_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid playback state command");
g_strfreev(params);
}
-static void __server_playback_action_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __server_playback_action_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *receiver = (media_controller_receiver_s *)user_data;
mc_retm_if(receiver == NULL, "reciever is NULL");
mc_retm_if(message == NULL, "message is NULL");
- mc_server_playback_action_received_cb callback = receiver->callback;
+ mc_server_playback_action_cmd_received_cb callback = receiver->callback;
mc_retm_if(receiver->callback == NULL, "playback_action_command_received_cb is NULL");
- mc_debug("__server_playback_action_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__server_playback_action_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid playback_action command");
return;
}
- callback(params[0], (mc_playback_action_e)value, receiver->user_data);
+ callback(params[0], request_id, (mc_playback_action_e)value, receiver->user_data);
g_strfreev(params);
}
-static void __server_playback_position_command_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __server_playback_position_cmd_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *receiver = (media_controller_receiver_s *)user_data;
mc_retm_if(receiver == NULL, "reciever is NULL");
mc_retm_if(message == NULL, "message is NULL");
- mc_server_playback_position_command_received_cb callback = receiver->callback;
- mc_retm_if(receiver->callback == NULL, "playback_position_command_received_cb is NULL");
+ mc_server_playback_position_cmd_received_cb callback = receiver->callback;
+ mc_retm_if(receiver->callback == NULL, "playback_position_cmd_received_cb is NULL");
- mc_debug("__server_playback_position_command_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__server_playback_position_cmd_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid playback_position command");
return;
}
- callback(params[0], value, receiver->user_data);
+ callback(params[0], request_id, value, receiver->user_data);
g_strfreev(params);
}
-static void __server_shuffle_mode_command_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __server_shuffle_mode_cmd_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *receiver = (media_controller_receiver_s *)user_data;
mc_retm_if(receiver == NULL, "reciever is NULL");
mc_retm_if(message == NULL, "message is NULL");
- mc_server_shuffle_mode_command_received_cb callback = receiver->callback;
- mc_retm_if(receiver->callback == NULL, "shuffle_mode_command_received_cb is NULL");
+ mc_server_shuffle_mode_cmd_received_cb callback = receiver->callback;
+ mc_retm_if(receiver->callback == NULL, "shuffle_mode_cmd_received_cb is NULL");
- mc_debug("__server_shuffle_mode_command_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__server_shuffle_mode_cmd_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid shuffle_mode command");
return;
}
- callback(params[0], (mc_shuffle_mode_e)value, receiver->user_data);
+ callback(params[0], request_id, (mc_shuffle_mode_e)value, receiver->user_data);
g_strfreev(params);
}
-static void __server_repeat_mode_command_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __server_repeat_mode_cmd_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *receiver = (media_controller_receiver_s *)user_data;
mc_retm_if(receiver == NULL, "reciever is NULL");
mc_retm_if(message == NULL, "message is NULL");
- mc_server_repeat_mode_command_received_cb callback = receiver->callback;
- mc_retm_if(receiver->callback == NULL, "repeat_mode_command_received_cb is NULL");
+ mc_server_repeat_mode_cmd_received_cb callback = receiver->callback;
+ mc_retm_if(receiver->callback == NULL, "repeat_mode_cmd_received_cb is NULL");
- mc_debug("__server_repeat_mode_command_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__server_repeat_mode_cmd_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid repeat_mode command");
return;
}
- callback(params[0], (mc_repeat_mode_e)value, receiver->user_data);
+ callback(params[0], request_id, (mc_repeat_mode_e)value, receiver->user_data);
g_strfreev(params);
}
-static void __server_custom_command_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __server_custom_command_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
int enc_size = 0;
mc_server_custom_command_received_cb callback = receiver->callback;
mc_retm_if(receiver->callback == NULL, "custom_command_received_cb is NULL");
- mc_debug("__server_custom_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__server_custom_cb(%s, %s, %s, %s, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid custom data");
g_strfreev(params);
}
-static void __server_play_playlist_command_cb(const char *interface_name, const char *signal_name, const char *message, const unsigned int request_id, void *user_data)
+static void __server_play_playlist_cmd_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
{
gchar **params = NULL;
media_controller_receiver_s *receiver = (media_controller_receiver_s *)user_data;
mc_retm_if(receiver == NULL, "reciever is NULL");
mc_retm_if(message == NULL, "message is NULL");
- mc_server_playlist_command_received_cb callback = receiver->callback;
- mc_retm_if(receiver->callback == NULL, "mc_server_playlist_command_received_cb is NULL");
+ mc_server_playlist_cmd_received_cb callback = receiver->callback;
+ mc_retm_if(receiver->callback == NULL, "mc_server_playlist_cmd_received_cb is NULL");
- mc_debug("__server_play_playlist_command_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
+ mc_debug("__server_play_playlist_cmd_cb(%s, %s, %s, %ld, %p)", interface_name, signal_name, message, request_id, user_data);
params = g_strsplit(message, MC_STRING_DELIMITER, 0);
mc_retm_if(params == NULL, "invalid play_playlist command");
return;
}
- callback(params[0], params[1], params[2], (mc_playback_action_e)action, position, receiver->user_data);
+ callback(params[0], request_id, params[1], params[2], (mc_playback_action_e)action, position, receiver->user_data);
+
+ g_strfreev(params);
+}
+
+static void __server_custom_cmd_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data)
+{
+ gchar **params = NULL;
+ int enc_size = 0;
+ char *sender = NULL;
+ char *command = NULL;
+ bundle *bundle_data = NULL;
+
+ media_controller_receiver_s *receiver = (media_controller_receiver_s *)user_data;
+ mc_retm_if(receiver == NULL, "reciever is NULL");
+
+ mc_server_custom_cmd_received_cb callback = receiver->callback;
+ mc_retm_if(receiver->callback == NULL, "custom_command_received_cb is NULL");
+
+ mc_debug("__server_custom_cb(%s, %s, %s, %llu, %p)", interface_name, signal_name, message, request_id, user_data);
+
+ params = g_strsplit(message, MC_STRING_DELIMITER, 0);
+ mc_retm_if(params == NULL, "invalid custom data");
+
+ if (params[0])
+ sender = strdup(params[0]);
+
+ if (mc_util_get_command_available(MC_PRIV_TYPE_SERVER, sender, MC_COMMAND_CUSTOMACTION, params[1]) != MEDIA_CONTROLLER_ERROR_NONE) {
+ mc_error("Error permission denied");
+ MC_SAFE_FREE(sender);
+ g_strfreev(params);
+ return;
+ }
+
+ command = strdup(params[1]);
+ enc_size = atoi(params[2]);
+ if (enc_size > 0)
+ bundle_data = bundle_decode((bundle_raw *)params[3], enc_size);
+
+ callback(sender, request_id, command, bundle_data, receiver->user_data);
+
+ MC_SAFE_FREE(sender);
+ MC_SAFE_FREE(command);
g_strfreev(params);
}
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
- mc_warning("DEPRECATION WARNING: mc_server_set_playback_state_command_received_cb() is deprecated and will be removed from next release. Use mc_server_set_playback_action_received_cb() instead.");
+ mc_warning("DEPRECATION WARNING: mc_server_set_playback_state_command_received_cb() is deprecated and will be removed from next release. Use mc_server_set_playback_action_cmd_received_cb() instead.");
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");
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
- mc_warning("DEPRECATION WARNING: mc_server_set_playback_state_command_received_cb() is deprecated and will be removed from next release. Use mc_server_unset_playback_action_received_cb() instead.");
+ mc_warning("DEPRECATION WARNING: mc_server_set_playback_state_command_received_cb() is deprecated and will be removed from next release. Use mc_server_unset_playback_action_cmd_received_cb() instead.");
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
return ret;
}
-int mc_server_set_playback_action_received_cb(mc_server_h server, mc_server_playback_action_received_cb callback, void *user_data)
+int mc_server_set_playback_action_cmd_received_cb(mc_server_h server, mc_server_playback_action_cmd_received_cb callback, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
return ret;
}
-int mc_server_unset_playback_action_received_cb(mc_server_h server)
+int mc_server_unset_playback_action_cmd_received_cb(mc_server_h server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
return ret;
}
-int mc_server_set_playback_position_command_received_cb(mc_server_h server, mc_server_playback_position_command_received_cb callback, void *user_data)
+int mc_server_set_playback_position_cmd_received_cb(mc_server_h server, mc_server_playback_position_cmd_received_cb callback, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_server->playback_position_reciever.user_data = user_data;
char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name);
- ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_POS_CMD, __server_playback_position_command_cb, (void *)&(mc_server->playback_position_reciever));
+ ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_POS_CMD, __server_playback_position_cmd_cb, (void *)&(mc_server->playback_position_reciever));
MC_SAFE_FREE(interface_name);
return ret;
}
-int mc_server_unset_playback_position_command_received_cb(mc_server_h server)
+int mc_server_unset_playback_position_cmd_received_cb(mc_server_h server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
return ret;
}
-int mc_server_set_shuffle_mode_command_received_cb(mc_server_h server, mc_server_shuffle_mode_command_received_cb callback, void *user_data)
+int mc_server_set_shuffle_mode_cmd_received_cb(mc_server_h server, mc_server_shuffle_mode_cmd_received_cb callback, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_server->shuffle_mode_reciever.user_data = user_data;
char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name);
- ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_SHUFFLE_CMD, __server_shuffle_mode_command_cb, (void *)&(mc_server->shuffle_mode_reciever));
+ ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_SHUFFLE_CMD, __server_shuffle_mode_cmd_cb, (void *)&(mc_server->shuffle_mode_reciever));
MC_SAFE_FREE(interface_name);
return ret;
}
-int mc_server_unset_shuffle_mode_command_received_cb(mc_server_h server)
+int mc_server_unset_shuffle_mode_cmd_received_cb(mc_server_h server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
return ret;
}
-int mc_server_set_repeat_mode_command_received_cb(mc_server_h server, mc_server_repeat_mode_command_received_cb callback, void *user_data)
+int mc_server_set_repeat_mode_cmd_received_cb(mc_server_h server, mc_server_repeat_mode_cmd_received_cb callback, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_server->repeat_mode_reciever.user_data = user_data;
char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name);
- ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_REPEAT_CMD, __server_repeat_mode_command_cb, (void *)&(mc_server->repeat_mode_reciever));
+ ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_REPEAT_CMD, __server_repeat_mode_cmd_cb, (void *)&(mc_server->repeat_mode_reciever));
MC_SAFE_FREE(interface_name);
return ret;
}
-int mc_server_unset_repeat_mode_command_received_cb(mc_server_h server)
+int mc_server_unset_repeat_mode_cmd_received_cb(mc_server_h server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
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.callback = callback;
- mc_server->custom_cmd_reciever.user_data = user_data;
+ mc_server->custom_command_reciever.callback = callback;
+ mc_server->custom_command_reciever.user_data = user_data;
char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name);
- ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD, __server_custom_command_cb, (void *)&(mc_server->custom_cmd_reciever));
+ ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_COMMAND, __server_custom_command_cb, (void *)&(mc_server->custom_command_reciever));
MC_SAFE_FREE(interface_name);
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name);
- ret = mc_ipc_unregister_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD);
+ ret = mc_ipc_unregister_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_COMMAND);
- mc_server->custom_cmd_reciever.callback = NULL;
- mc_server->custom_cmd_reciever.user_data = NULL;
+ mc_server->custom_command_reciever.callback = NULL;
+ mc_server->custom_command_reciever.user_data = NULL;
MC_SAFE_FREE(interface_name);
mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "Error when make string from bundle");
message = g_strdup_printf("%s%s%d%s%s", mc_server->server_name, MC_STRING_DELIMITER, result_code, MC_STRING_DELIMITER, bundle_str);
- MC_SAFE_FREE(bundle_str);
+ MC_SAFE_G_FREE(bundle_str);
mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "Error when making message");
char *interface_name = mc_util_get_interface_name(MC_CLIENT, client_name);
- ret = mc_ipc_send_message(mc_server->dconn, NULL, interface_name, MC_DBUS_SIGNAL_NAME_CMD_REPLY, message, NULL);
+ ret = mc_ipc_send_message(mc_server->dconn, NULL, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_COMMAND_REPLY, message, NULL);
if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("Error mc_ipc_send_message [%d]", ret);
return ret;
}
-int mc_server_set_playlist_command_received_cb(mc_server_h server, mc_server_playlist_command_received_cb callback, void *user_data)
+int mc_server_set_playlist_cmd_received_cb(mc_server_h server, mc_server_playlist_cmd_received_cb callback, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
mc_server->play_playlist_reciever.user_data = user_data;
char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name);
- ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_PLAYLIST, __server_play_playlist_command_cb, (void *)&(mc_server->play_playlist_reciever));
+ ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_PLAYLIST, __server_play_playlist_cmd_cb, (void *)&(mc_server->play_playlist_reciever));
MC_SAFE_FREE(interface_name);
return ret;
}
-int mc_server_unset_playlist_command_received_cb(mc_server_h server)
+int mc_server_unset_playlist_cmd_received_cb(mc_server_h server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_server_s *mc_server = (media_controller_server_s *)server;
return ret;
}
+int mc_server_set_custom_cmd_received_cb(mc_server_h server, mc_server_custom_cmd_received_cb callback, void *user_data)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ 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.callback = callback;
+ mc_server->custom_cmd_reciever.user_data = user_data;
+
+ char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name);
+ ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD, __server_custom_cmd_cb, (void *)&(mc_server->custom_cmd_reciever));
+
+ MC_SAFE_FREE(interface_name);
+
+ return ret;
+}
+
+int mc_server_unset_custom_cmd_received_cb(mc_server_h server)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ 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 *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name);
+ ret = mc_ipc_unregister_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD);
+
+ mc_server->custom_cmd_reciever.callback = NULL;
+ mc_server->custom_cmd_reciever.user_data = NULL;
+
+ MC_SAFE_FREE(interface_name);
+
+ return ret;
+}
+
+int mc_server_send_cmd_reply(mc_server_h server, const char *client_name, const char *request_id, int result_code, bundle *data)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ char *message = NULL;
+ char *bundle_str = NULL;
+ 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(!MC_STRING_VALID(client_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "client_name is NULL");
+ mc_retvm_if(!MC_STRING_VALID(request_id), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "request_id is NULL");
+
+ ret = mc_util_bundle_to_string(data, &bundle_str);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "Error when make string from bundle");
+
+ message = g_strdup_printf("%s%s%d%s%s", mc_server->server_name, MC_STRING_DELIMITER, result_code, MC_STRING_DELIMITER, bundle_str);
+ MC_SAFE_G_FREE(bundle_str);
+ mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "Error when making message");
+
+ char *interface_name = mc_util_get_interface_name(MC_CLIENT, client_name);
+ ret = mc_ipc_send_reply(mc_server->dconn, NULL, interface_name, MC_DBUS_SIGNAL_NAME_CMD_REPLY, message, request_id);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Error mc_ipc_send_message [%d]", ret);
+
+ MC_SAFE_G_FREE(message);
+ MC_SAFE_G_FREE(interface_name);
+
+ return ret;
+}
+
int mc_server_create(mc_server_h *server)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
+#include <uuid/uuid.h>
#include "media_controller_private.h"
//#define UNIT_TEST /* for testsuite */
#define MAX_NAME_LENGTH 255
-static GMutex mutex_req_id;
-
static void _mc_util_check_valid_name(const char *name, char **valid_name)
{
char old_word[MAX_NAME_LENGTH] = {0, };
return ret;
}
-int mc_util_get_request_id(unsigned int *req_id)
+char *mc_util_generate_uuid(void)
{
- int ret = MEDIA_CONTROLLER_ERROR_NONE;
- static unsigned int request_id = 0;
-
- mc_retvm_if(req_id == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid parameter");
+ uuid_t uuid_value;
+ static char uuid_unparsed[37];
- g_mutex_lock(&mutex_req_id);
+RETRY_GEN:
+ uuid_generate(uuid_value);
+ uuid_unparse(uuid_value, uuid_unparsed);
- if (request_id + 1 == UINT_MAX) {
- request_id = 0;
+ if (strlen(uuid_unparsed) < 36) {
+ mc_debug("INVALID UUID : %s. RETRY GENERATE.", uuid_unparsed);
+ goto RETRY_GEN;
}
- request_id++;
- *req_id = request_id;
- g_mutex_unlock(&mutex_req_id);
-
- return ret;
+ return uuid_unparsed;
}
int mc_util_bundle_to_string(bundle *bundle_data, char **str_data)
static mc_shuffle_mode_e g_shuffle_mode;
static mc_repeat_mode_e g_repeat_mode;
+typedef enum {
+ TEST_REQ_PB_ACT_CMD,
+ TEST_REQ_PB_POS_CMD,
+ TEST_REQ_SHUFFLE_CMD,
+ TEST_REQ_REPEAT_CMD,
+ TEST_REQ_PLAYLIST_CMD,
+ TEST_REQ_CUSTOM_CMD,
+ TEST_REQ_MAX,
+} test_req_e;
+static char *g_request_id[TEST_REQ_MAX];
+
GMainLoop *mainloop = NULL;
#define MAX_STRING_LEN 2048
mc_debug("[Client:%s] Command Reply (key1: %s)received from server[%s] result code[%d]", _client->client_name, value, server_name, result_code);
}
+void _mc_cmd_reply_received_cb(const char *server_name, const char *request_id, int result_code, bundle *data, void *user_data)
+{
+ char *value = NULL;
+ media_controller_client_s *_client = (media_controller_client_s *)g_mc_client;
+
+ mc_error("[No-Errror][Id:%s]", request_id);
+
+ unsigned int i = 0;
+ unsigned int found = 0;
+ for (i = 0; i < TEST_REQ_MAX; i++) {
+ if (strcmp(request_id, g_request_id[i]) == 0) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ mc_error("[Client:%s] Wrong request_id", _client->client_name, request_id);
+ }
+ if (strcmp(request_id, g_request_id[TEST_REQ_CUSTOM_CMD]) == 0) {
+ if (data)
+ bundle_get_str(data, "key1", &value);
+
+ mc_debug("[Client:%s] Custom Command Reply (key1: %s)received from server[%s] result code[%d]", _client->client_name, request_id, value, server_name, result_code);
+ } else {
+ mc_error("[Client:%s] Reply result code[%d] from server[%s]", _client->client_name, request_id, result_code, server_name);
+ }
+}
+
static gboolean _create()
{
g_print("== create \n");
ret = mc_client_set_playlist_update_cb(g_mc_client, _mc_playlist_update_cb, NULL);
mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, FALSE, "Fail to mc_client_set_playlist_update_cb [%d]", ret);
+ ret = mc_client_set_cmd_reply_received_cb(g_mc_client, _mc_cmd_reply_received_cb, NULL);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, FALSE, "Fail to mc_client_set_reply_received_cb [%d]", ret);
+
mc_debug_fleave();
return ret;
ret = mc_client_unset_playlist_update_cb(g_mc_client);
mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, FALSE, "Fail to mc_client_unset_playlist_update_cb [%d]", ret);
+ ret = mc_client_unset_cmd_reply_received_cb(g_mc_client);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, FALSE, "Fail to mc_client_unset_reply_received_cb [%d]", ret);
+
mc_debug_fleave();
return TRUE;
return FALSE;
}
- ret = mc_client_send_playback_action(g_mc_client, g_server_name, action);
+ ret = mc_client_send_playback_action_cmd(g_mc_client, g_server_name, action, &g_request_id[TEST_REQ_PB_ACT_CMD]);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
g_print("Fail to send playback action command [%d]", ret);
return FALSE;
}
g_playback_position += 1000;
- ret = mc_client_send_playback_position_command(g_mc_client, g_server_name, g_playback_position);
+ ret = mc_client_send_playback_position_cmd(g_mc_client, g_server_name, g_playback_position, &g_request_id[TEST_REQ_PB_POS_CMD]);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
g_print("Fail to send playback position command [%d]", ret);
return FALSE;
g_shuffle_mode = MC_SHUFFLE_MODE_ON;
else
g_shuffle_mode = MC_SHUFFLE_MODE_OFF;
- ret = mc_client_send_shuffle_mode_command(g_mc_client, g_server_name, g_shuffle_mode);
+ ret = mc_client_send_shuffle_mode_cmd(g_mc_client, g_server_name, g_shuffle_mode, &g_request_id[TEST_REQ_SHUFFLE_CMD]);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
g_print("Fail to send shuffle mode command [%d]", ret);
return FALSE;
g_repeat_mode = MC_REPEAT_MODE_ON;
else
g_repeat_mode = MC_REPEAT_MODE_OFF;
- ret = mc_client_send_repeat_mode_command(g_mc_client, g_server_name, g_repeat_mode);
+
+ ret = mc_client_send_repeat_mode_cmd(g_mc_client, g_server_name, g_repeat_mode, &g_request_id[TEST_REQ_REPEAT_CMD]);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
g_print("Fail to send shuffle mode command [%d]", ret);
return FALSE;
}
- ret = mc_client_send_playlist_command(g_mc_client, g_server_name, g_playlist_name, "1", MC_PLAYBACK_ACTION_PLAY, 300);
+ ret = mc_client_send_playlist_cmd(g_mc_client, g_server_name, g_playlist_name, "1", MC_PLAYBACK_ACTION_PLAY, 300, &g_request_id[TEST_REQ_PLAYLIST_CMD]);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
g_print("Fail to send play playlist item [%d]", ret);
return FALSE;
}
bundle_free(bundle_data);
+ bundle_data = bundle_create();
+ bundle_add_str(bundle_data, "key1", "val1_2");
+ bundle_add_str(bundle_data, "key2", "val2_2");
+ bundle_add_str(bundle_data, "key3", "val3_2");
+ bundle_add_str(bundle_data, "key4", "val4_2");
+
+ ret = mc_client_send_custom_cmd(g_mc_client, g_server_name, "Custom Command2", bundle_data, &g_request_id[TEST_REQ_CUSTOM_CMD]);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ bundle_free(bundle_data);
+ mc_error("Fail to send custom command %d", ret);
+ return FALSE;
+ }
+ bundle_free(bundle_data);
+
+ unsigned int i = 0;
+ for (i = 0; i < TEST_REQ_MAX; i++)
+ mc_error("[No-Errror][%02u][Id:%s]", i, g_request_id[i]);
+
g_print("== success send command \n");
return TRUE;
void __playback_state_command_received_cb(const char *client_name, mc_playback_states_e state, void *user_data)
{
- mc_debug("[%s] recieved playback state:[%d] from [%s]", client_name, state, client_name);
+ g_print("[%s] recieved playback state:[%d] from [%s]\n", client_name, state, client_name);
}
-void __playback_action_received_cb(const char *client_name, mc_playback_action_e action, void *user_data)
+void __playback_action_received_cb(const char *client_name, const char *request_id, mc_playback_action_e action, void *user_data)
{
- mc_debug("[%s] recieved playback action:[%d] from [%s]", client_name, action, client_name);
+ int ret = 0;
+ g_print("[%s][%s] recieved playback action:[%d] from [%s]\n", client_name, request_id, action, client_name);
+
+ ret = mc_server_send_cmd_reply(g_mc_server, client_name, request_id, 0, NULL);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_server_send_command_reply\n");
}
-void __playback_position_command_received_cb(const char *client_name, unsigned long long position, void *user_data)
+void __playback_position_cmd_received_cb(const char *client_name, const char *request_id, unsigned long long position, void *user_data)
{
- mc_debug("[%s] recieved playback position:[%llu] from [%s]", client_name, position, client_name);
+ int ret = 0;
+ g_print("[%s][%s] recieved playback position:[%llu] from [%s]\n", client_name, request_id, position, client_name);
+
+ ret = mc_server_send_cmd_reply(g_mc_server, client_name, request_id, 0, NULL);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_server_send_command_reply\n");
}
-void __shuffle_mode_command_received_cb(const char *client_name, mc_shuffle_mode_e shuffle_mode, void *user_data)
+void __shuffle_mode_cmd_received_cb(const char *client_name, const char *request_id, mc_shuffle_mode_e shuffle_mode, void *user_data)
{
- mc_debug("[%s] recieved shuffle mode:[%d] from [%s]", client_name, shuffle_mode, client_name);
+ int ret = 0;
+ g_print("[%s][%s] recieved shuffle mode:[%d] from [%s]\n", client_name, request_id, shuffle_mode, client_name);
+
+ ret = mc_server_send_cmd_reply(g_mc_server, client_name, request_id, 0, NULL);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_server_send_command_reply\n");
}
-void __repeat_mode_command_received_cb(const char *client_name, mc_repeat_mode_e repeat_mode, void *user_data)
+void __repeat_mode_cmd_received_cb(const char *client_name, const char *request_id, mc_repeat_mode_e repeat_mode, void *user_data)
{
- mc_debug("[%s] recieved repeat mode:[%d] from [%s]", client_name, repeat_mode, client_name);
+ int ret = 0;
+
+ g_print("[%s][%s] recieved repeat mode:[%d] from [%s]\n", client_name, request_id, repeat_mode, client_name);
+ ret = mc_server_send_cmd_reply(g_mc_server, client_name, request_id, 0, NULL);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_server_send_command_reply\n");
}
void __playlist_play_received_cb(const char* client_name, const char *playlist_name, const char *index, mc_playback_action_e action, unsigned long long position, void *user_data)
bundle_data = g_strdup_printf("%s, %s, %s, %s", get_value1, get_value2, get_value3, get_value4);
}
- mc_debug("[%s] recieved command:[%s] from [%s]", client_name, command, client_name);
- mc_debug("[%s] recieved bundle:[%s] from [%s]", client_name, bundle_data, client_name);
+ g_print("[%s] recieved command:[%s] from [%s]\n", client_name, command, client_name);
+ g_print("[%s] recieved bundle:[%s] from [%s]\n", client_name, bundle_data, client_name);
bundle *bundle_reply = bundle_create();
bundle_add_str(bundle_reply, "key1", "result1");
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");
+ g_print("Fail to mc_server_send_command_reply\n");
+
+ bundle_free(bundle_reply);
+ if (bundle_data != NULL)
+ g_free(bundle_data);
+}
+
+void __custom_cmd_received_cb(const char *client_name, const char *request_id, const char *command, bundle *data, void *user_data)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+
+ char *bundle_data = NULL;
+ char *get_value1 = NULL;
+ char *get_value2 = NULL;
+ char *get_value3 = NULL;
+ char *get_value4 = NULL;
+
+ if (data) {
+ bundle_get_str(data, "key1", &get_value1);
+ bundle_get_str(data, "key2", &get_value2);
+ bundle_get_str(data, "key3", &get_value3);
+ bundle_get_str(data, "key4", &get_value4);
+
+ bundle_data = g_strdup_printf("%s, %s, %s, %s", get_value1, get_value2, get_value3, get_value4);
+ }
+
+ g_print("[%s] recieved request_id:[%s] command:[%s] from [%s]\n", client_name, request_id, command, client_name);
+ g_print("[%s] recieved bundle:[%s] from [%s]\n", client_name, bundle_data, client_name);
+
+ bundle *bundle_reply = bundle_create();
+ bundle_add_str(bundle_reply, "key1", "result1_2");
+ bundle_add_str(bundle_reply, "key2", "result2_2");
+ bundle_add_str(bundle_reply, "key3", "result3_2");
+ bundle_add_str(bundle_reply, "key4", "result4_2");
+
+ ret = mc_server_send_cmd_reply(g_mc_server, client_name, request_id, 0, bundle_reply);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to mc_server_send_command_reply\n");
bundle_free(bundle_reply);
if (bundle_data != NULL)
return FALSE;
}
- ret = mc_server_set_playback_action_received_cb(g_mc_server, __playback_action_received_cb, NULL);
+ ret = mc_server_set_playback_action_cmd_received_cb(g_mc_server, __playback_action_received_cb, NULL);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print("Fail to set mc_server_set_playback_action_received_cb");
+ g_print("Fail to set mc_server_set_playback_action_cmd_received_cb");
return FALSE;
}
- ret = mc_server_set_playback_position_command_received_cb(g_mc_server, __playback_position_command_received_cb, NULL);
+ ret = mc_server_set_playback_position_cmd_received_cb(g_mc_server, __playback_position_cmd_received_cb, NULL);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print("Fail to set mc_server_set_playback_position_command_received_cb");
+ g_print("Fail to set mc_server_set_playback_position_cmd_received_cb");
return FALSE;
}
- ret = mc_server_set_shuffle_mode_command_received_cb(g_mc_server, __shuffle_mode_command_received_cb, NULL);
+ ret = mc_server_set_shuffle_mode_cmd_received_cb(g_mc_server, __shuffle_mode_cmd_received_cb, NULL);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print("Fail to set mc_server_set_shuffle_mode_command_received_cb");
+ g_print("Fail to set mc_server_set_shuffle_mode_cmd_received_cb");
return FALSE;
}
- ret = mc_server_set_repeat_mode_command_received_cb(g_mc_server, __repeat_mode_command_received_cb, NULL);
+ ret = mc_server_set_repeat_mode_cmd_received_cb(g_mc_server, __repeat_mode_cmd_received_cb, NULL);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print("Fail to set mc_server_set_repeat_mode_command_received_cb");
+ g_print("Fail to set mc_server_set_repeat_mode_cmd_received_cb");
return FALSE;
}
return FALSE;
}
- ret = mc_server_set_playlist_command_received_cb(g_mc_server, __playlist_play_received_cb, NULL);
+ ret = mc_server_set_custom_cmd_received_cb(g_mc_server, __custom_cmd_received_cb, NULL);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print("Fail to set mc_server_set_playlist_command_received_cb");
+ g_print("Fail to set mc_server_set_custom_cmd_received_cb");
return FALSE;
}