}
if (strncmp("COMP_REQ_CREATE_GROUP", cmd, strlen(cmd)) == 0) {
- msgp("[CMD] Request Create Group [%s(0x%X)]", mdg_error_to_string(ret),
- ret);
+ msgp("[CMD] Request Create Group [%s(0x%X)]", mdg_error_to_string(ret), ret);
if (ret == MDG_ERROR_NONE && arg != NULL) {
msgb("Created Group name is %s", arg);
run_group_find(NULL, NULL);
if (ret == MDG_ERROR_NONE && arg != NULL)
msgb("Ejected Device ID is %s", arg);
} else if (strncmp("COMP_REQ_DELETE_GROUP", cmd, strlen(cmd)) == 0) {
- msgp("[CMD] Request Delete Group [%s(0x%X)]", mdg_error_to_string(ret),
- ret);
+ msgp("[CMD] Request Delete Group [%s(0x%X)]", mdg_error_to_string(ret), ret);
if (ret == MDG_ERROR_NONE && arg != NULL)
msgb("Deleted Group name is %s", arg);
} else if (strncmp("COMP_REQ_SEND_DATA", cmd, strlen(cmd)) == 0) {
static int run_device_eject(MManager *mm, struct menu_data *menu)
{
int ret;
- int idx;
+ int idx = 1;
mdg_group_h group = NULL;
mdg_device_h device = NULL;
found_invited_device_list = g_list_append(found_invited_device_list, device);
+ g_free(device_id);
+
return true;
}
static int run_group_foreach_device(MManager *mm, struct menu_data *menu)
{
int ret;
- int idx;
+ int idx = 1;
mdg_group_h group = NULL;
msg("Foreach Device");
static int run_device_invite(MManager *mm, struct menu_data *menu)
{
int ret;
- int idx;
+ int idx = 1;
mdg_group_h group = NULL;
mdg_device_h device = NULL;
static int run_group_delete(MManager *mm, struct menu_data *menu)
{
int ret;
- int idx;
- mdg_group_h group;
+ int idx = 1;
+ mdg_group_h group = NULL;
msg("Delete Group");
bool _device_found_cb(mdg_device_h device, void *user_data)
{
- char *addr = NULL;
char *device_id = NULL;
char *model_name = NULL;
mdg_device_type_e device_type;
if (device_id)
free(device_id);
- if (addr)
- free(addr);
return TRUE;
}
static int run_devices_find(MManager *mm, struct menu_data *menu)
{
int ret;
- int duration;
+ int duration = 0;
msg("Find Devices");
if (strlen(timeout))
mdg_group_info_get_name(group, &name);
msgb("device is invited by [%s], Group Name [%s]", device_id, name);
+
+ g_free(device_id);
+ g_free(name);
}
void __ejected_event_cb(mdg_group_h group, void *user_data)
mdg_group_info_get_name(group, &name);
msgb("device is ejected by [%s], Group Name [%s]", device_id, name);
+
+ g_free(device_id);
+ g_free(name);
}
void __receive_file_cb(int result, char *device_id, const char *file_path, void *user_data)
msgb("[Is Invited] %d", is_invited);
msgb("[Type] %s\n", __device_type_to_string(type));
+ if (model_name)
+ free(model_name);
if (device_id)
free(device_id);
if (device_name)
static int run_group_find(MManager *mm, struct menu_data *menu)
{
int ret;
- int duration;
+ int duration = 0;
msg("Find Group");
if (strlen(timeout))
{
int ret = 0;
char *deviceid = NULL;
- char *address = NULL;
mdg_device_h device = NULL;
channel_t *channel = NULL;
}
}
+ if (NULL == device) {
+ msgr("device is NULL");
+ return RET_FAILURE;
+ }
+
+ if (NULL == channel) {
+ msgr("channel is NULL");
+ return RET_FAILURE;
+ }
+
mdg_device_info_get_device_id(device, &deviceid);
msgp("Sent to [ID] %s [CHANNEL ID] %s", deviceid, channel->channel_id);
if (deviceid) {
free(deviceid);
deviceid = NULL;
}
- if (address) {
- free(address);
- address = NULL;
- }
int msg_id;
ret = mdg_device_send_data(handle, device, channel->channel_id, (unsigned char *)message,
- strlen(message), _send_data_finish_cb, NULL, &msg_id);
+ strlen(message), _send_data_finish_cb, NULL, &msg_id);
if (MDG_ERROR_NONE != ret)
- msgr("Failed to Send Data: [ID] %s [IP] %s", deviceid, address);
+ msgr("Failed to Send Data: [ID] %s", deviceid);
msgp("The message ID is %d", msg_id);
mdg_device_info_get_device_id(device, &device_id);
msgp("Send file to %s Finished [%s]", device_id, mdg_error_to_string(result));
+
+ g_free(device_id);
}
static int __send_file(int devidx)
{
int ret = 0;
char *deviceid = NULL;
- char *address = NULL;
mdg_device_h device = NULL;
if (found_invited_device_list) {
free(deviceid);
deviceid = NULL;
}
- if (address) {
- free(address);
- address = NULL;
- }
ret = mdg_device_send_file(handle, device, file_path,
__send_file_progress_cb, __send_file_finish_cb, NULL);
if (MDG_ERROR_NONE != ret)
- msgr("Failed to Send Data: [ID] %s [IP] %s", deviceid, address);
+ msgr("Failed to Send Data: [ID] %s", deviceid);
return ret;
}
static int run_devices_find_invited_device(MManager *mm, struct menu_data *menu)
{
int ret;
- int duration;
+ int duration = 0;
msg("Find My Owned Devices");
if (strlen(timeout))
return RET_SUCCESS;
}
- int dev_idx;
+ int dev_idx = 1;
if (device_idx != NULL && strlen(device_idx)) {
dev_idx = (unsigned short)strtol(device_idx, NULL, 10);
if (0 >= dev_idx) {
return RET_SUCCESS;
}
- int grp_idx;
+ int grp_idx = 1;
if (group_idx != NULL && strlen(group_idx)) {
grp_idx = (unsigned short)strtol(group_idx, NULL, 10);
if (0 >= grp_idx) {
}
}
- int dev_idx;
+ int dev_idx = 1;
if (device_idx != NULL && strlen(device_idx)) {
dev_idx = (unsigned short)strtol(device_idx, NULL, 10);
if (0 >= dev_idx) {
return RET_SUCCESS;
}
- int grp_idx;
+ int grp_idx = 1;
if (group_idx != NULL && strlen(group_idx)) {
grp_idx = (unsigned short)strtol(group_idx, NULL, 10);
if (0 >= grp_idx) {
}
}
- int dev_idx;
+ int dev_idx = 1;
if (device_idx != NULL && strlen(device_idx)) {
dev_idx = (unsigned short)strtol(device_idx, NULL, 10);
if (0 >= dev_idx) {
return RET_SUCCESS;
}
- int dev_idx;
+ int dev_idx = 1;
if (device_idx != NULL && strlen(device_idx)) {
dev_idx = (unsigned short)strtol(device_idx, NULL, 10);
if (0 >= dev_idx) {