Remove "Subgroup" terms. (Now, The Device doesn't have subgroup structure)
authorJihoon Jung <jh8801.jung@samsung.com>
Thu, 25 Jan 2018 08:27:12 +0000 (17:27 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:47 +0000 (19:38 +0900)
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
13 files changed:
capi/demo/comp-manager.c
capi/include/companion.h
capi/src/companion.c
capi/src/companion_gdbus.xml
src/companion-manager/include/comp_gdbus_group.h
src/companion-manager/include/comp_group.h
src/companion-manager/include/comp_mot_agent.h
src/companion-manager/src/comp_gdbus.c
src/companion-manager/src/comp_gdbus_group.c
src/companion-manager/src/comp_group.c
src/companion-manager/src/comp_iot.c
src/companion-manager/src/comp_mot_agent.c
src/companion-manager/src/companion_gdbus.xml

index 68a9766b719acccbad9a8287d17a45fb8785d0bd..c21a2c8acf702252492dfa3ec90c0ac282940260 100644 (file)
 GList *found_group_list;
 GList *found_device_list;
 GList *my_devices_list;
-GList *found_subgroup_list;
 
 static char groupid[MENU_DATA_SIZE + 1] = "mygroup";
-static char timeout[MENU_DATA_SIZE + 1] = "5";
+static char request_groupid[MENU_DATA_SIZE + 1] = "subgroup";
+static char timeout[MENU_DATA_SIZE + 1] = "7";
 static char group_idx[MENU_DATA_SIZE + 1] = "1";
 static char group_idx_a[MENU_DATA_SIZE + 1] = "1";
 static char group_idx_b[MENU_DATA_SIZE + 1] = "2";
 static char device_idx[MENU_DATA_SIZE + 1] = "1";
 static char pin[MENU_DATA_SIZE + 1] = "12341234";
 static char message[MENU_DATA_SIZE + 1] = "Hello World!!";
-static char subgroupid[MENU_DATA_SIZE + 1] = "subgroup";
-static char subgroup_idx[MENU_DATA_SIZE + 1] = "1";
 
 int run_get_my_id(MManager *mm, struct menu_data *menu)
 {
@@ -64,7 +62,8 @@ int run_get_my_id(MManager *mm, struct menu_data *menu)
 
 void _device_eject_result_cb(int result, void *user_data)
 {
-       msgp("Eject Device Complete [%s]", comp_error_to_string(result) );
+       msg("");
+       msgb("Eject Device Complete [%s]", comp_error_to_string(result) );
 }
 
 static int run_device_eject(MManager *mm, struct menu_data *menu)
@@ -123,7 +122,8 @@ static int run_device_eject(MManager *mm, struct menu_data *menu)
 
 void _device_invite_result_cb(int result, void *user_data)
 {
-       msgp("Invite Device Finished [%s]", comp_error_to_string(result) );
+       msg("");
+       msgb("Invite Device Finished [%s]", comp_error_to_string(result) );
 }
 
 static int run_device_invite(MManager *mm, struct menu_data *menu)
@@ -170,9 +170,9 @@ static int run_device_invite(MManager *mm, struct menu_data *menu)
                return RET_FAILURE;
        }
 
-       ret = companion_device_invite(group, device, pin,_device_invite_result_cb, NULL );
+       ret = companion_device_invite(group, device, pin, _device_invite_result_cb, NULL);
        if (COMP_ERROR_NONE != ret) {
-               msgr("Failed to Delete Group: [%s(0x%X)]", comp_error_to_string(ret), ret);
+               msgr("Failed to device invite: [%s(0x%X)]", comp_error_to_string(ret), ret);
                return RET_FAILURE;
        }
        msg(" - companion_device_invite() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
@@ -202,7 +202,7 @@ static int run_devices_show(MManager *mm, struct menu_data *menu)
                companion_device_information_get_device_id(device, &deviceid);
                companion_device_information_get_ip(device, &ip);
                companion_device_information_get_device_type(device, &devicetype);
-               msgb("[%d] deviceid: %s, IP: %s type: %s", i+1, deviceid, ip, devicetype);
+               msgp("[%d] deviceid: %s, IP: %s type: %s", i+1, deviceid, ip, devicetype);
 
                if (deviceid) {
                        free(deviceid);
@@ -267,7 +267,7 @@ static int run_group_get_members(MManager *mm, struct menu_data *menu)
                companion_device_information_get_ip(devices[i], &ip);
                companion_device_information_get_device_type(devices[i], &device_type);
 
-               msgb("device_id : %s, name : %s, type : %s", device_id, ip, device_type);
+               msgp("device_id : %s, name : %s, type : %s", device_id, ip, device_type);
 
                if (device_id)
                        free(device_id);
@@ -374,12 +374,12 @@ int run_device_show_found(MManager *mm, struct menu_data *menu)
 
        msg("");
 
-       ret = companion_device_get_found_mowned_devices(&devices, &count);
+       ret = companion_device_get_found_devices(&devices, &count);
        if (COMP_ERROR_NONE != ret) {
                msgr("Failed to Get Found Devices: [%s(0x%X)]", comp_error_to_string(ret), ret);
                return RET_FAILURE;
        }
-       msg(" - companion_device_get_found_mowned_devices() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+       msg(" - companion_device_get_found_devices() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
 
        for (int i = 0; i < count; i++) {
                char *device_id = NULL;
@@ -390,7 +390,7 @@ int run_device_show_found(MManager *mm, struct menu_data *menu)
                companion_device_information_get_ip(devices[i], &ip);
                companion_device_information_get_device_type(devices[i], &device_type);
 
-               msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
+               msgp("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
 
                if (device_id)
                        free(device_id);
@@ -403,9 +403,9 @@ int run_device_show_found(MManager *mm, struct menu_data *menu)
        return RET_SUCCESS;
 }
 
-void _device_finish_cb(int num_of_devs, void *user_data)
+void _device_finish_cb(int result, void *user_data)
 {
-       msgp("%d Device(s) Found", num_of_devs);
+       msgb("Find Device Finished ret: [0x%X] [%s]", result, comp_error_to_string(result));
 }
 
 bool _device_found_cb(companion_device_h device, void *user_data)
@@ -418,7 +418,7 @@ bool _device_found_cb(companion_device_h device, void *user_data)
        companion_device_information_get_ip(device, &ip);
        companion_device_information_get_device_type(device, &device_type);
 
-       msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
+       msgp("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type);
 
        if (device_id)
                free(device_id);
@@ -582,7 +582,7 @@ static int run_group_show(MManager *mm, struct menu_data *menu)
                companion_group_information_get_type(group, &type);
                companion_group_information_get_uri_path(group, &uri);
                companion_group_information_get_resource_type(group, &rt);
-               msgb("[%d] type: %s, URI: %s RT: %s", i+1, comp_group_type_to_string(type), uri, rt);
+               msgp("[%d] type: %s, URI: %s RT: %s", i+1, comp_group_type_to_string(type), uri, rt);
                if (uri) {
                        free(uri);
                        uri = NULL;
@@ -599,37 +599,6 @@ static int run_group_show(MManager *mm, struct menu_data *menu)
        return RET_SUCCESS;
 }
 
-static int run_subgroup_show(MManager *mm, struct menu_data *menu)
-{
-       char *name;
-       companion_group_h subgroup;
-
-       int i;
-       GList *iter = NULL;
-
-       /* Get a first item */
-       i = 0;
-       iter = g_list_first(found_subgroup_list);
-       while (NULL != iter) {
-               subgroup = iter->data;
-               if (!subgroup) {
-                       msgr("subgroup is null");
-                       break;
-               }
-               companion_group_information_get_name(subgroup, &name);
-               msgb("[%d] subgroup name: %s", i+1, name);
-               if (name) {
-                       free(name);
-                       name = NULL;
-               }
-               /* Next item */
-               iter = g_list_next(iter);
-               i++;
-       }
-
-       return RET_SUCCESS;
-}
-
 static void _group_join_finish_cb(int result, void *user_data)
 {
        msgp("join operation finished");
@@ -674,13 +643,13 @@ static void _destroy_comp_group_info(gpointer data)
        companion_group_information_destroy((companion_group_h)data);
 }
 
-static int run_group_get_found(MManager *mm, struct menu_data *menu)
+static int run_group_show_found(MManager *mm, struct menu_data *menu)
 {
        int ret;
        int count;
        companion_group_h *groups;
 
-       msg("Get Found Groups");
+       msg("Show Found Group(s)");
 
        ret = companion_group_get_found_groups(&groups, &count);
        if (COMP_ERROR_NONE != ret) {
@@ -698,20 +667,20 @@ static int run_group_get_found(MManager *mm, struct menu_data *menu)
                companion_group_type_e type;
                char *uri_path;
                char *group_name;
-               char *host_addr;
+
                companion_group_information_get_type(groups[i], &type);
                companion_group_information_get_uri_path(groups[i], &uri_path);
                companion_group_information_get_name(groups[i], &group_name);
-               companion_group_information_get_host_addr(groups[i], &host_addr);
 
-               msgb("%d. type : %d, name : %s host address : %s uri path : %s", i+1,
-                        type, group_name, host_addr, uri_path);
+               if (type == COMPANION_GROUP_TYPE_MINE)
+                       msgb("%d. type : MINE, name : %s, uri : %s", i+1, group_name, uri_path);
+               else
+                       msgb("%d. type : REMOTE, name : %s, uri : %s", i+1, group_name, uri_path);
 
                found_group_list = g_list_prepend(found_group_list, groups[i]);
 
                g_free(uri_path);
                g_free(group_name);
-               g_free(host_addr);
        }
 
        return RET_SUCCESS;
@@ -719,12 +688,17 @@ static int run_group_get_found(MManager *mm, struct menu_data *menu)
 
 bool _group_found_cb(companion_group_type_e type, companion_group_h group, void *user_data)
 {
-       char *uri_path;
+       char *group_name;
 
-       companion_group_information_get_uri_path(group, &uri_path);
+       companion_group_information_get_name(group, &group_name);
 
        msg("");
-       msgp("found group type : %d, uri : %s", type, uri_path);
+
+
+       if (type == COMPANION_GROUP_TYPE_MINE)
+               msgp("found group type : MINE, name : %s", group_name);
+       else
+               msgp("found group type : REMOTE, name : %s", group_name);
 
        found_group_list = g_list_prepend(found_group_list, group);
 
@@ -733,7 +707,7 @@ bool _group_found_cb(companion_group_type_e type, companion_group_h group, void
 
 void _group_finish_cb(int result, void *user_data)
 {
-       msgb("Find Group Finished = %d", result);
+       msgb("Find Group Finished ret: [0x%X] [%s]", result, comp_error_to_string(result));
 }
 
 static int run_group_find(MManager *mm, struct menu_data *menu)
@@ -771,6 +745,7 @@ static int run_group_create(MManager *mm, struct menu_data *menu)
                return RET_FAILURE;
        }
        msg(" - companion_group_create() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+       msgb("Create Group Successfully");
 
        return RET_SUCCESS;
 }
@@ -882,12 +857,12 @@ int run_device_show_mowned_device(MManager *mm, struct menu_data *menu)
 
        msg("");
 
-       ret = companion_device_get_found_devices(&devices, &count);
+       ret = companion_device_get_found_mowned_devices(&devices, &count);
        if (COMP_ERROR_NONE != ret) {
-               msgr("Failed to Get Found Devices: [%s(0x%X)]", comp_error_to_string(ret), ret);
+               msgr("Failed to Get Found Mowned Devices: [%s(0x%X)]", comp_error_to_string(ret), ret);
                return RET_FAILURE;
        }
-       msg(" - companion_device_get_found_devices() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+       msg(" - companion_device_get_found_mowned_devices() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
 
        for (int i = 0; i < count; i++) {
                char *device_id = NULL;
@@ -910,41 +885,21 @@ int run_device_show_mowned_device(MManager *mm, struct menu_data *menu)
 
        return RET_SUCCESS;
 }
-static int run_create_subgroup(MManager *mm, struct menu_data *menu)
+static int run_request_create_group(MManager *mm, struct menu_data *menu)
 {
        int ret = 0;
-       int grp_count = 0;
        int dev_count = 0;
        companion_device_h device = NULL;
-       companion_group_h group = NULL;
 
-       msg("Create subgroup");
+       msg("Request create group");
 
-       grp_count = g_list_length(found_group_list);
        dev_count = g_list_length(found_device_list);
 
-       if (0 >= dev_count || 0 >= grp_count) {
+       if (0 >= dev_count) {
                msgr("No Device");
                return RET_SUCCESS;
        }
 
-       int grp_idx;
-       if (group_idx != NULL && strlen(group_idx)) {
-               grp_idx = (unsigned short)strtol(group_idx, NULL, 10);
-               if (0 >= grp_idx) {
-                       msgp("Invalid index. set to 1");
-                       grp_idx = 1;
-               }
-       }
-
-       if (found_group_list) {
-               group = g_list_nth_data(found_group_list, grp_idx - 1);
-               if (NULL == group) {
-                       msgr("Failed to g_hash_table_find");
-                       return RET_FAILURE;
-               }
-       }
-
        int dev_idx;
        if (device_idx != NULL && strlen(device_idx)) {
                dev_idx = (unsigned short)strtol(device_idx, NULL, 10);
@@ -962,29 +917,29 @@ static int run_create_subgroup(MManager *mm, struct menu_data *menu)
                }
        }
 
-       ret = companion_create_subgroup(group, device, subgroupid);
+       ret = companion_request_create_group(device, request_groupid);
        if (COMP_ERROR_NONE != ret) {
-               msgr("Failed to Create Subgroup: [%s(0x%X)]", comp_error_to_string(ret), ret);
+               msgr("Failed to Request Create Group: [%s(0x%X)]", comp_error_to_string(ret), ret);
                return RET_FAILURE;
        }
 
-       msg(" - companion_create_subgroup() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+       msg(" - companion_request_create_group() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
 
        return RET_SUCCESS;
 }
 
-static int run_get_subgroup(MManager *mm, struct menu_data *menu)
+static int run_request_invite(MManager *mm, struct menu_data *menu)
 {
-       int ret;
-       int count;
+       int ret = 0;
+       int grp_count = 0;
+       int dev_count = 0;
+       companion_device_h device = NULL;
        companion_group_h group = NULL;
-       companion_group_h *subgroups;
 
-       msg("Get Subgroups");
-
-       count = g_list_length(found_group_list);
+       dev_count = g_list_length(found_device_list);
+       grp_count = g_list_length(found_group_list);
 
-       if (0 >= count) {
+       if (0 >= dev_count || 0 >= grp_count) {
                msgr("No Device");
                return RET_SUCCESS;
        }
@@ -1006,51 +961,62 @@ static int run_get_subgroup(MManager *mm, struct menu_data *menu)
                }
        }
 
-       ret = companion_get_subgroups(group, &subgroups, &count);
+       int dev_idx;
+       if (device_idx != NULL && strlen(device_idx)) {
+               dev_idx = (unsigned short)strtol(device_idx, NULL, 10);
+               if (0 >= dev_idx) {
+                       msgp("Invalid index. set to 1");
+                       dev_idx = 1;
+               }
+       }
+
+       if (found_device_list) {
+               device = g_list_nth_data(found_device_list, dev_idx - 1);
+               if (NULL == device) {
+                       msgr("Failed to g_hash_table_find");
+                       return RET_FAILURE;
+               }
+       }
+
+       ret = companion_request_invite(group, device, pin);
        if (COMP_ERROR_NONE != ret) {
-               msgr("Failed to Get Found Groups: [%s(0x%X)]", comp_error_to_string(ret), ret);
+               msgr("Failed to Request Invite: [%s(0x%X)]", comp_error_to_string(ret), ret);
                return RET_FAILURE;
        }
-       msg(" - companion_get_subgroups() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
 
-       for (int i = 0; i < count; i++) {
-               char *name;
-               companion_group_information_get_name(subgroups[i], &name);
-               msgb("%d. name : %s", i+1, name);
-               found_subgroup_list = g_list_prepend(found_subgroup_list, subgroups[i]);
-       }
+       msg(" - companion_request_invite() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
 
        return RET_SUCCESS;
 }
 
-static int run_add_device_to_subgroup(MManager *mm, struct menu_data *menu)
+static int run_request_eject(MManager *mm, struct menu_data *menu)
 {
        int ret = 0;
-       int subgrp_count = 0;
+       int grp_count = 0;
        int dev_count = 0;
        companion_device_h device = NULL;
-       companion_group_h subgroup = NULL;
+       companion_group_h group = NULL;
 
        dev_count = g_list_length(found_device_list);
-       subgrp_count = g_list_length(found_subgroup_list);
+       grp_count = g_list_length(found_group_list);
 
-       if (0 >= dev_count || 0 >= subgrp_count) {
+       if (0 >= dev_count || 0 >= grp_count) {
                msgr("No Device");
                return RET_SUCCESS;
        }
 
-       int subgrp_idx;
-       if (subgroup_idx != NULL && strlen(subgroup_idx)) {
-               subgrp_idx = (unsigned short)strtol(subgroup_idx, NULL, 10);
-               if (0 >= subgrp_idx) {
+       int grp_idx;
+       if (group_idx != NULL && strlen(group_idx)) {
+               grp_idx = (unsigned short)strtol(group_idx, NULL, 10);
+               if (0 >= grp_idx) {
                        msgp("Invalid index. set to 1");
-                       subgrp_idx = 1;
+                       grp_idx = 1;
                }
        }
 
-       if (found_subgroup_list) {
-               subgroup = g_list_nth_data(found_subgroup_list, subgrp_idx - 1);
-               if (NULL == subgroup) {
+       if (found_group_list) {
+               group = g_list_nth_data(found_group_list, grp_idx - 1);
+               if (NULL == group) {
                        msgr("Failed to g_hash_table_find");
                        return RET_FAILURE;
                }
@@ -1073,45 +1039,54 @@ static int run_add_device_to_subgroup(MManager *mm, struct menu_data *menu)
                }
        }
 
-       ret = companion_add_device_to_subgroup(subgroup, device);
+       ret = companion_request_eject(group, device);
        if (COMP_ERROR_NONE != ret) {
-               msgr("Failed to Create Subgroup: [%s(0x%X)]", comp_error_to_string(ret), ret);
+               msgr("Failed to Request Eject: [%s(0x%X)]", comp_error_to_string(ret), ret);
                return RET_FAILURE;
        }
 
-       msg(" - companion_create_subgroup() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+       msg(" - companion_request_eject() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
 
        return RET_SUCCESS;
 }
 
-static int run_delete_subgroup(MManager *mm, struct menu_data *menu)
+static int run_request_delete_group(MManager *mm, struct menu_data *menu)
 {
        int ret = 0;
        int grp_count = 0;
-       int dev_count = 0;
-       companion_device_h device = NULL;
        companion_group_h group = NULL;
 
-       dev_count = g_list_length(found_device_list);
        grp_count = g_list_length(found_group_list);
 
-       if (0 >= dev_count || 0 >= grp_count) {
+       if (0 >= grp_count) {
                msgr("No Device");
                return RET_SUCCESS;
        }
 
-       group = (companion_group_h)(found_group_list[atoi(group_idx - 1)].data);
-       device = (companion_device_h)(found_device_list[atoi(device_idx - 1)].data);
+       int grp_idx;
+       if (group_idx != NULL && strlen(group_idx)) {
+               grp_idx = (unsigned short)strtol(group_idx, NULL, 10);
+               if (0 >= grp_idx) {
+                       msgp("Invalid index. set to 1");
+                       grp_idx = 1;
+               }
+       }
 
-       msgr("Device selected");
+       if (found_group_list) {
+               group = g_list_nth_data(found_group_list, grp_idx - 1);
+               if (NULL == group) {
+                       msgr("Failed to g_hash_table_find");
+                       return RET_FAILURE;
+               }
+       }
 
-       ret = companion_create_subgroup(group, device, subgroupid);
+       ret = companion_request_delete_group(group);
        if (COMP_ERROR_NONE != ret) {
-               msgr("Failed to Create Subgroup: [%s(0x%X)]", comp_error_to_string(ret), ret);
+               msgr("Failed to Request Delete Group: [%s(0x%X)]", comp_error_to_string(ret), ret);
                return RET_FAILURE;
        }
 
-       msg(" - companion_create_subgroup() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+       msg(" - companion_request_delete_group() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
 
        return RET_SUCCESS;
 }
@@ -1158,13 +1133,6 @@ static struct menu_data menu_group_merge[] = {
        { NULL, NULL, },
 };
 
-static struct menu_data menu_group_get_members[] = {
-       { "0", "Show Found Group(s)", NULL, run_group_show, NULL },
-       { "1", "Index", NULL, NULL, group_idx },
-       { "2", "Run", NULL, run_group_get_members, NULL },
-       { NULL, NULL, },
-};
-
 static struct menu_data menu_devices_find[] = {
        { "0", "Timeout", NULL, NULL, timeout },
        { "1", "Run", NULL, run_devices_find, NULL },
@@ -1202,62 +1170,58 @@ static struct menu_data menu_devices_find_mownd_device[] = {
        { NULL, NULL, },
 };
 
-static struct menu_data menu_create_subgroup[] = {
+static struct menu_data menu_request_create_group[] = {
+       { "0", "Show Found Device(s)", NULL, run_devices_show, NULL },
+       { "1", "Device Index", NULL, NULL, device_idx },
+       { "2", "Request Group Name", NULL, NULL, request_groupid },
+       { "3", "Run", NULL, run_request_create_group, NULL },
+       { NULL, NULL, },
+};
+
+static struct menu_data menu_request_invite[] = {
        { "0", "Show Found Group(s)", NULL, run_group_show, NULL },
        { "1", "Show Found Device(s)", NULL, run_devices_show, NULL },
        { "2", "Group Index", NULL, NULL, group_idx },
        { "3", "Device Index", NULL, NULL, device_idx },
-       { "4", "Subgroup Name", NULL, NULL, subgroupid },
-       { "5", "Run", NULL, run_create_subgroup, NULL },
+       { "4", "PIN", NULL, NULL, pin },
+       { "5", "Run", NULL, run_request_invite, NULL },
        { NULL, NULL, },
 };
 
-static struct menu_data menu_get_subgroups[] = {
+static struct menu_data menu_request_eject[] = {
        { "0", "Show Found Group(s)", NULL, run_group_show, NULL },
-       { "1", "Group Index", NULL, NULL, group_idx },
-       { "2", "Run", NULL, run_get_subgroup, NULL },
-       { NULL, NULL, },
-};
-
-static struct menu_data menu_add_device_to_subgroup[] = {
-       { "0", "Show Subgroup(s)", NULL, run_subgroup_show, NULL },
        { "1", "Show Found Device(s)", NULL, run_devices_show, NULL },
-       { "2", "Subgroup Index", NULL, NULL, subgroup_idx },
+       { "2", "Group Index", NULL, NULL, group_idx },
        { "3", "Device Index", NULL, NULL, device_idx },
-       { "4", "Run", NULL, run_add_device_to_subgroup, NULL },
+       { "4", "Run", NULL, run_request_eject, NULL },
        { NULL, NULL, },
 };
 
-static struct menu_data menu_delete_subgroup[] = {
+static struct menu_data menu_request_delete_group[] = {
        { "0", "Show Found Group(s)", NULL, run_group_show, NULL },
-       { "1", "Show Found Device(s)", NULL, run_devices_show, NULL },
-       { "2", "Group Index", NULL, NULL, group_idx },
-       { "3", "Device Index", NULL, NULL, device_idx },
-       { "4", "Subgroup Name", NULL, NULL, subgroupid },
-       { "5", "Run", NULL, run_delete_subgroup, NULL },
+       { "1", "Group Index", NULL, NULL, group_idx },
+       { "2", "Run", NULL, run_request_delete_group, NULL },
        { NULL, NULL, },
 };
 struct menu_data menu_comp_manager[] = {
-       { "0", "Get My Device ID", NULL, run_get_my_id, NULL },
-       { "1", "Group Create", menu_group_create, NULL, NULL },
-       { "2", "Find Groups", menu_group_find, NULL, NULL },
-       { "3", "Get Found Groups", NULL, run_group_get_found , NULL },
-       { "4", "Join Group", menu_group_join, NULL, NULL },
-       { "5", "Leave Group", menu_group_leave, NULL, NULL },
-       { "6", "Delete Group", menu_group_delete, NULL, NULL },
-       { "7", "Merge Group B to A", menu_group_merge, NULL, NULL },
-       { "8", "Get Group Member Devices", menu_group_get_members, NULL, NULL },
-       { "9", "Show My Local Device", NULL, run_device_show_my_device, NULL },
-       { "10", "Find Device(s)", menu_devices_find, NULL, NULL },
-       { "11", "Show Found Device(s)", NULL, run_device_show_found, NULL },
-       { "12", "Invite Device", menu_group_invite_device, NULL, NULL },
-       { "13", "Eject Device", menu_group_eject_device, NULL, NULL },
-       { "14", "Find My Onwed Device(s)", menu_devices_find_mownd_device, NULL, NULL },
-       { "15", "Show My Onwed Device(s)", NULL, run_device_show_mowned_device, NULL},
-       { "16", "Send Message", menu_send_data, NULL, NULL },
-       { "17", "Create Subgroup", menu_create_subgroup, NULL, NULL },
-       { "18", "Get Subgroups", menu_get_subgroups, NULL, NULL },
-       { "19", "Add device to Subgroup", menu_add_device_to_subgroup, NULL, NULL },
-       { "20", "Delete Subgroup", menu_delete_subgroup, NULL, NULL },
+       { "0", "Show My Device ID", NULL, run_get_my_id, NULL },
+       { "1", "Create Group", menu_group_create, NULL, NULL },
+       { "2", "Find Group(s)", menu_group_find, NULL, NULL },
+       { "3", "Show Found Group(s)", NULL, run_group_show_found , NULL },
+       { "4", "Join Group (Not yet developed)", menu_group_join, NULL, NULL },
+       { "5", "Leave Group (Not yet developed)", menu_group_leave, NULL, NULL },
+       { "6", "Delete Group (Not yet developed)", menu_group_delete, NULL, NULL },
+       { "7", "Merge Group B to A (Not yet developed)", menu_group_merge, NULL, NULL },
+       { "8", "Find Device(s)", menu_devices_find, NULL, NULL },
+       { "9", "Show Found Device(s)", NULL, run_device_show_found, NULL },
+       { "10", "Invite Device", menu_group_invite_device, NULL, NULL },
+       { "11", "Eject Device", menu_group_eject_device, NULL, NULL },
+       { "12", "Find My Owned Device(s)", menu_devices_find_mownd_device, NULL, NULL },
+       { "13", "Show My Owned Device(s)", NULL, run_device_show_mowned_device, NULL},
+       { "14", "Send Message", menu_send_data, NULL, NULL },
+       { "15", "Request Create Group", menu_request_create_group, NULL, NULL },
+       { "16", "Request Invite", menu_request_invite, NULL, NULL },
+       { "17", "Request Eject", menu_request_eject, NULL, NULL },
+       { "18", "Request Delete Group (Not yet developed)", menu_request_delete_group, NULL, NULL },
        { NULL, NULL, },
 };
index 210bda32b721f2d5138f1637273309ba0ec431ca..718bf3138466bb68251e3fadbc3c5041398ab731 100644 (file)
@@ -112,10 +112,11 @@ int companion_device_information_get_device_type(companion_device_h device, char
 
 int companion_send_data(companion_device_h device, char *data, int len,
        companion_send_data_finish_cb finish_cb, void *user_data);
-int companion_create_subgroup(companion_group_h group, companion_device_h device, char *subgroup_name);
-int companion_get_subgroups(companion_group_h group, companion_group_h **subgroups, int *count);
-int companion_add_device_to_subgroup(companion_group_h subgroup, companion_device_h device);
-int companion_delete_subgroup(companion_group_h subgroup);
+
+int companion_request_create_group(companion_device_h device, char *group_name);
+int companion_request_invite(companion_group_h group, companion_device_h device, char *PIN);
+int companion_request_eject(companion_group_h group, companion_device_h device);
+int companion_request_delete_group(companion_group_h group);
 
 
 #ifdef __cplusplus
index 06abeabeceac4608870591b3b610e0ad0a77b487..4e0f928c10e547f3b6bd520f4e905c39aee37c30 100644 (file)
@@ -159,7 +159,7 @@ static void __group_found_cb(Group *object,
 static void _group_find_finish_cb(Group *object,
         gint ret, gpointer user_data)
 {
-       if (device_find_finish_cb.finish_cb)
+       if (group_find_finish_cb.finish_cb)
                group_find_finish_cb.finish_cb(ret, group_find_finish_cb.user_data);
 }
 
@@ -458,7 +458,7 @@ int companion_device_find(int timeout, companion_device_found_cb found_cb,
 
        device_found_cb.found_cb = found_cb;
        device_found_cb.user_data = user_data;
-       device_find_finish_cb.finish_cb= finish_cb;
+       device_find_finish_cb.finish_cb = finish_cb;
        device_find_finish_cb.user_data = user_data;
 
        /* get groups from daemon using gdbus */
@@ -914,97 +914,52 @@ int companion_device_information_get_device_type(companion_device_h device, char
        return 0;
 }
 
-int companion_create_subgroup(companion_group_h group, companion_device_h device, char *subgroup_name)
+int companion_request_create_group(companion_device_h device, char *group_name)
 {
        int ret;
        GError *error = NULL;
        companion_device_t *dev = (companion_device_t *)device;
-       companion_group_t *grp = (companion_group_t *)group;
+
        _ERR("Device id : %s", dev->device_id);
 
-       group_call_create_subgroup_sync(group_proxy, grp->group_name, dev->device_id, subgroup_name, &ret, NULL, &error);
+       group_call_request_create_group_sync(group_proxy, dev->device_id, group_name, &ret, NULL, &error);
 
        return ret;
 }
 
-int companion_get_subgroups(companion_group_h group, companion_group_h **subgroups, int *count)
+int companion_request_invite(companion_group_h group, companion_device_h device, char *PIN)
 {
        int ret = 0;
-       GVariant *va = NULL;
        GError *error = NULL;
        companion_group_t *grp = (companion_group_t *)group;
+       companion_device_t *dev = (companion_device_t *)device;
 
+       _ERR("%s", grp->device_id);
        _ERR("%s", grp->group_name);
+       _ERR("%s", dev->device_id);
 
-       /* get groups from daemon using gdbus */
-       group_call_get_subgroups_sync(group_proxy, grp->group_name, &va, &ret, NULL, &error);
-       *count = g_variant_n_children(va);
-
-       _ERR("get subgroups : %d", *count);
-
-       if (*count > 0) {
-               GVariantIter *iter = NULL, *iter_row = NULL;
-               GVariant *key_value;
-               const gchar *key;
-               guint i = 0;
-
-               *subgroups = g_new0(companion_group_h, *count);
-
-               g_variant_get(va, "aa{sv}", &iter);
-               while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
-                       companion_group_t *subgroup = NULL;
-                       companion_group_type_e type;
-                       char *uri_path;
-                       char *device_id;
-                       char *group_name;
-                       char *host_addr;
-                       char *resource_type;
-
-                       while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) {
-                               if (g_strcmp0(key, "URI") == 0) {
-                                       uri_path = (char *)g_variant_get_string(key_value, NULL);
-                               } else if (g_strcmp0(key, "DeviceID") == 0) {
-                                       device_id = (char *)g_variant_get_string(key_value, NULL);
-                               } else if (g_strcmp0(key, "GroupName") == 0) {
-                                       group_name = (char *)g_variant_get_string(key_value, NULL);
-                               } else if (g_strcmp0(key, "HostAddress") == 0) {
-                                       host_addr = (char *)g_variant_get_string(key_value, NULL);
-                               } else if (g_strcmp0(key, "GroupDeviceType") == 0) {
-                                       resource_type = (char *)g_variant_get_string(key_value, NULL);
-                               } else if (g_strcmp0(key, "GroupType") == 0) {
-                                       type = g_variant_get_int32(key_value);
-                               }
-                       }
-                       g_variant_iter_free(iter_row);
-
-                       subgroup = _create_group_handle(uri_path,
-                               device_id, group_name, host_addr, resource_type, type);
-
-                       (*subgroups)[i++] = (companion_group_h)subgroup;
-               }
-               g_variant_iter_free(iter);
-       }
-       g_variant_unref(va);
+       group_call_request_invite(group_proxy, grp->device_id, grp->group_name, dev->device_id, PIN, &ret, NULL, &error);
 
        return ret;
 }
 
-int companion_add_device_to_subgroup(companion_group_h subgroup, companion_device_h device)
+int companion_request_eject(companion_group_h group, companion_device_h device)
 {
        int ret = 0;
        GError *error = NULL;
-       companion_group_t *subgrp = (companion_group_t *)subgroup;
+       companion_group_t *grp = (companion_group_t *)group;
        companion_device_t *dev = (companion_device_t *)device;
 
-       _ERR("%s", subgrp->group_name);
+       _ERR("%s", grp->device_id);
+       _ERR("%s", grp->group_name);
        _ERR("%s", dev->device_id);
 
-       group_call_add_device_to_subgroup(group_proxy, subgrp->group_name, dev->device_id, &ret, NULL, &error);
+       group_call_request_eject(group_proxy, grp->device_id, grp->group_name, dev->device_id, &ret, NULL, &error);
 
        return ret;
 }
 
-int companion_delete_subgroup(companion_group_h subgroup)
+int companion_request_delete_group(companion_group_h group)
 {
 
 }
index 97c0b9f8272b9bbfb440856b1cab3e780178bba9..c6e9c854dee7aac045ea8728f8e5996bb2c3a41f 100644 (file)
                <method name="GetMyUuid">
                        <arg type="s" name="uuid" direction="out" />
                </method>
-               <method name="CreateSubgroup">
-                       <arg type="s" name="group_name" direction="in" />
+               <method name="RequestCreateGroup">
                        <arg type="s" name="uuid" direction="in" />
-                       <arg type="s" name="subgroup_name" direction="in" />
+                       <arg type="s" name="group_name" direction="in" />
                        <arg type="i" name="result" direction="out" />
                </method>
-               <method name="GetSubgroups">
+               <method name="RequestInvite">
+                       <arg type="s" name="uuid" direction="in" />
                        <arg type="s" name="group_name" direction="in" />
-                       <arg type="aa{sv}" name="groups" direction="out" />
+                       <arg type="s" name="target_uuid" direction="in" />
+                       <arg type="s" name="pin" direction="in" />
                        <arg type="i" name="result" direction="out" />
                </method>
-               <method name="AddDeviceToSubgroup">
-                       <arg type="s" name="subgroup_name" direction="in" />
+               <method name="RequestEject">
                        <arg type="s" name="uuid" direction="in" />
+                       <arg type="s" name="group_name" direction="in" />
+                       <arg type="s" name="target_uuid" direction="in" />
                        <arg type="i" name="result" direction="out" />
                </method>
-               <method name="DeleteSubgroup">
-                       <arg type="s" name="subgroup_name" direction="in" />
+               <method name="RequestDeleteGroup">
+                       <arg type="s" name="uuid" direction="in" />
+                       <arg type="s" name="group_name" direction="in" />
                        <arg type="i" name="result" direction="out" />
                </method>
                <!-- Signal (D-Bus) definitions -->
index 735641c44df67f787182c6f7154d88d5c50b476b..83da7b1f47213612563cfd4e472ab74a6d63adb8 100644 (file)
@@ -23,7 +23,7 @@ gboolean group_leave(Group *group, GDBusMethodInvocation *invocation,
 gboolean group_delete(Group *group, GDBusMethodInvocation *invocation,
        gpointer user_data);
 
-gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation,
+gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation, gint timeout,
        gpointer user_data);
 
 gboolean group_device_invite(Group *group, GDBusMethodInvocation *invocation,
@@ -67,21 +67,22 @@ gboolean group_get_my_mowned_device(Group *group,
 gboolean group_get_my_uuid(Group *group,
        GDBusMethodInvocation *invocation, gpointer user_data);
 
-gboolean group_create_subgroup(Group *group, GDBusMethodInvocation *invocation,
gchar *group_name, gchar *uuid, gchar *subgroup_name, gpointer user_data);
+gboolean group_request_create_group(Group *group, GDBusMethodInvocation *invocation,
      gchar *uuid, gchar *group_name, gpointer user_data);
 
-gboolean group_get_subgroups(Group *group, GDBusMethodInvocation *invocation,
- gchar *group_name, gpointer user_data);
+gboolean group_request_invite(Group *group, GDBusMethodInvocation *invocation, gchar *uuid,
+ gchar *group_name, gchar *target_uuid, gchar *PIN, gpointer user_data);
 
-gboolean group_add_device_to_subgroup(Group *group, GDBusMethodInvocation *invocation,
- gchar *subgroup_name, gchar *uuid, gpointer user_data);
+gboolean group_request_eject(Group *group, GDBusMethodInvocation *invocation, gchar *uuid,
+ gchar *group_name, gchar *target_uuid, gpointer user_data);
 
-gboolean group_delete_subgroup(Group *group, GDBusMethodInvocation *invocation,
      gchar *subgroup_name, gpointer user_data);
+gboolean group_request_delete_group(Group *group, GDBusMethodInvocation *invocation,
gchar *uuid, gchar *group_name, gpointer user_data);
 
 void notify_group_found(GVariant *group_data);
 void notify_group_find_finish(int ret);
 void notify_device_found(int device_count, GVariant *device_data);
+void notify_device_find_finish(int ret);
 void notify_group_device_invite_result(int ret);
 void notify_group_device_eject_result(int ret);
 void notify_mowned_device_found(int device_count, GVariant *device_data);
index 6b3199aee82b95b759faafd2e40afdd8322e2062..4b0b15e1e26c8813cd64f306c8d4b580c9ac38a8 100644 (file)
@@ -61,7 +61,7 @@ int comp_group_get_remote_devices(/* callback */); //Get all of device in networ
 
 void comp_group_add_new_mot_device(comp_mot_device_t *device);
 void comp_group_notify_mot_enable_device_done(int device_count);
-int comp_group_find_mot_enabled_devices();
+int comp_group_find_mot_enabled_devices(int timeout);
 
 char *comp_group_invite_get_uuid();
 char *comp_group_invite_get_pin();
@@ -108,11 +108,10 @@ int comp_group_get_group_device_id(comp_group_t *handle);
 /* notify */
 int comp_group_event_handler(/*callback*/); // event hadnler
 int comp_group_add_device_in_group(char *group_name, char *uuid);
-int comp_group_add_subgroup_in_group(char *group_name, char *uuid, char *subgroup_name);
 
-int comp_group_create_subgroup(char *group_name, char *uuid, char *subgroup_name);
-GVariant *comp_group_get_subgroups(char *group_name);
-int comp_group_add_device_to_subgroup(char *subgroup_name, char *uuid);
-int comp_group_delete_subgroup(char *subgroup_name);
+int comp_group_request_create_group(char *uuid, char *group_name);
+int comp_group_request_invite(char *uuid, char *group_name, char *target_uuid, char *PIN);
+int comp_group_request_eject(char *uuid, char *group_name, char *target_uuid);
+int comp_group_request_delete_group(char *uuid, char *group_name);
 
 #endif
index b01816f4169c955821b33d180b264945d27427e8..c5df6d3eb0456939c6d43659c048b54beca89a20 100755 (executable)
@@ -30,7 +30,7 @@ int agent_dbus_stop();
 int agent_enable();
 int agent_disable();
 int agent_get_ownerid(char* deviceid);
-int agent_find_mot_enable_devices();
+int agent_find_mot_enable_devices(int timeout);
 int agent_find_mowned_devices();
 int agent_mot(char* uuid_str, char *pin);
 int agent_pairwise(char* target1, char *subject1, char *uri1,
index c81c9b9894d4c648a9ab14b254e080d7f863f673..48cf7730193ca2e0de19ec455f948b8538c14e7f 100644 (file)
@@ -115,23 +115,23 @@ static bool __group_init(GDBusConnection *connection)
                NULL);
 
        g_signal_connect(group_skeleton,
-               "handle-create-subgroup",
-               G_CALLBACK(group_create_subgroup),
+               "handle-request-create-group",
+               G_CALLBACK(group_request_create_group),
                NULL);
 
        g_signal_connect(group_skeleton,
-               "handle-get-subgroups",
-               G_CALLBACK(group_get_subgroups),
+               "handle-request-invite",
+               G_CALLBACK(group_request_invite),
                NULL);
 
        g_signal_connect(group_skeleton,
-               "handle-add-device-to-subgroup",
-               G_CALLBACK(group_add_device_to_subgroup),
+               "handle-request-eject",
+               G_CALLBACK(group_request_eject),
                NULL);
 
        g_signal_connect(group_skeleton,
-               "handle-delete-subgroup",
-               G_CALLBACK(group_delete_subgroup),
+               "handle-request-delete-group",
+               G_CALLBACK(group_request_delete_group),
                NULL);
 
        group = g_dbus_object_manager_server_new(COMP_DBUS_GROUP_PATH);
index daf76d75605ad21bdf3fc9f6c1400b50c2b2243a..f8e9be39732660c157531be9f44200b84b769a76 100644 (file)
@@ -74,14 +74,14 @@ gboolean group_delete(Group *group, GDBusMethodInvocation *invocation,
        return TRUE;
 }
 
-gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation,
+gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation, gint timeout,
        gpointer user_data)
 {
-       int ret;
+       int result = 0;
 
-       ret = comp_group_find_mot_enabled_devices();
+       result = comp_group_find_mot_enabled_devices(timeout);
 
-       group_complete_device_find(group, invocation, ret);
+       group_complete_device_find(group, invocation, result);
 
        return TRUE;
 }
@@ -279,59 +279,58 @@ gboolean group_get_my_uuid(Group *group,
        return TRUE;
 }
 
-gboolean group_create_subgroup(Group *group, GDBusMethodInvocation *invocation,
gchar *group_name, gchar *uuid, gchar *subgroup_name, gpointer user_data)
+gboolean group_request_create_group(Group *group, GDBusMethodInvocation *invocation,
      gchar *uuid, gchar *group_name, gpointer user_data)
 {
        int ret = 0;
 
-       LOG_DEBUG("create subgroup called using dbus successful");
+       LOG_DEBUG("Request Create Group called using dbus successful");
 
-       ret = comp_group_create_subgroup(group_name, uuid, subgroup_name);
+       ret = comp_group_request_create_group(uuid, group_name);
 
-       group_complete_create_subgroup(group, invocation, ret);
+       group_complete_request_create_group(group, invocation, ret);
 
        return TRUE;
 }
 
-gboolean group_get_subgroups(Group *group, GDBusMethodInvocation *invocation,
gchar *group_name, gpointer user_data)
+gboolean group_request_invite(Group *group, GDBusMethodInvocation *invocation, gchar *uuid,
      gchar *group_name, gchar *target_uuid, gchar *PIN, gpointer user_data)
 {
        int ret = 0;
-       GVariant *group_data;
 
-       LOG_DEBUG("get subgroups called using dbus successful : %s", group_name);
+       LOG_DEBUG("Request Invite called using dbus successful");
 
-       group_data = comp_group_get_subgroups(group_name);
+       ret = comp_group_request_invite(uuid, group_name, target_uuid, PIN);
 
-       group_complete_get_subgroups(group, invocation, group_data, ret);
+       group_complete_request_invite(group, invocation, ret);
 
        return TRUE;
 }
 
-gboolean group_add_device_to_subgroup(Group *group, GDBusMethodInvocation *invocation,
gchar *subgroup_name, gchar *uuid, gpointer user_data)
+gboolean group_request_eject(Group *group, GDBusMethodInvocation *invocation, gchar *uuid,
      gchar *group_name, gchar *target_uuid, gpointer user_data)
 {
        int ret = 0;
 
-       LOG_DEBUG("Add device to subgroup called using dbus successful");
+       LOG_DEBUG("Request Eject called using dbus successful");
 
-       ret = comp_group_add_device_to_subgroup(subgroup_name, uuid);
+       ret = comp_group_request_eject(uuid, group_name, target_uuid);
 
-       group_complete_add_device_to_subgroup(group, invocation, ret);
+       group_complete_request_eject(group, invocation, ret);
 
        return TRUE;
 }
 
-gboolean group_delete_subgroup(Group *group, GDBusMethodInvocation *invocation,
-       gchar *subgroup_name, gpointer user_data)
+gboolean group_request_delete_group(Group *group, GDBusMethodInvocation *invocation,
+       gchar *uuid, gchar *group_name, gpointer user_data)
 {
        int ret = 0;
 
-       LOG_DEBUG("Delete subgroup called using dbus successful");
+       LOG_DEBUG("Request Delete Group called using dbus successful");
 
-       ret = comp_group_delete_subgroup(subgroup_name);
+       ret = comp_group_request_delete_group(uuid, group_name);
 
-       group_complete_delete_subgroup(group, invocation, ret);
+       group_complete_request_delete_group(group, invocation, ret);
 
        return TRUE;
 }
@@ -351,6 +350,11 @@ void notify_device_found(int device_count, GVariant *device_data)
        group_emit_device_found(group_dbus_get_object(), device_count, device_data);
 }
 
+void notify_device_find_finish(int ret)
+{
+       group_emit_device_find_finish(group_dbus_get_object(), ret);
+}
+
 void notify_group_device_invite_result(int ret)
 {
        group_emit_device_invite_result(group_dbus_get_object(), ret);
index 271efdb6fba0ff4c38cedf9dc99dfb0b9edde5d5..5971d20e68309e9456537b530b389d00ee60ceef 100644 (file)
@@ -16,23 +16,11 @@ int comp_group_initialize()
        return COMP_ERROR_NONE;
 }
 
-typedef struct {
-       char *uuid; //remote device uuid
-       char *name; //subgroup name
-} comp_subgrp_t;
-
 typedef struct {
        char *name; //group name
        GList *device_list; //remote device UUIDs. char* type
-       GList *subgroup_list; //comp sub group t type
 } comp_grp_t;
 
-void __print_foreach_subgroup(gpointer data, gpointer user_data)
-{
-       comp_subgrp_t *sub_grp = (comp_subgrp_t *)data;
-       LOG_DEBUG("        - Group name : %s, uuid : %s", sub_grp->name, sub_grp->uuid);
-}
-
 void __print_foreach_device(gpointer data, gpointer user_data)
 {
        char *uuid = (char *)data;
@@ -45,8 +33,6 @@ void __print_foreach_grp(gpointer data, gpointer user_data)
        LOG_DEBUG("Group name : %s", grp->name);
        LOG_DEBUG("    <Device>");
        g_list_foreach(grp->device_list, __print_foreach_device, NULL);
-       LOG_DEBUG("    <Sub Group>");
-       g_list_foreach(grp->subgroup_list, __print_foreach_subgroup, NULL);
        LOG_DEBUG("");
 }
 
@@ -324,7 +310,7 @@ void comp_group_notify_mot_enable_device_done(int device_count)
        LOG_END();
 }
 
-int comp_group_find_mot_enabled_devices()
+int comp_group_find_mot_enabled_devices(int timeout)
 {
        int ret;
 
@@ -334,7 +320,7 @@ int comp_group_find_mot_enabled_devices()
        g_list_free_full (mot_enb_dev_list, _mot_enb_dev_list_free_func);
        mot_enb_dev_list = NULL;
 
-       ret = agent_find_mot_enable_devices();
+       ret = agent_find_mot_enable_devices(timeout);
        if (ret != COMP_ERROR_NONE) {
                LOG_ERR("Failed to find mot enable devices : %s",
                                 comp_log_get_error_string(ret));
@@ -411,7 +397,6 @@ int comp_group_add_device_in_group(char *group_name, char *uuid)
 
                if (strcmp(group_name, group->name) == 0) {
                        GList *device_iter = group->device_list;
-                       GList *subgroup_iter = group->subgroup_list;
                        while (device_iter != NULL) {
                                char *device_uuid = (char *)device_iter->data;
                                if (strcmp(device_uuid, uuid) == 0)
@@ -420,14 +405,6 @@ int comp_group_add_device_in_group(char *group_name, char *uuid)
                                device_iter = g_list_next(device_iter);
                        }
 
-                       while (subgroup_iter != NULL) {
-                               comp_subgrp_t *subgroup = (comp_subgrp_t *)subgroup_iter->data;
-                               if (strcmp(subgroup->uuid, uuid) == 0)
-                                       return -1;
-
-                               subgroup_iter = g_list_next(subgroup_iter);
-                       }
-
                        group->device_list = g_list_prepend(group->device_list, strdup(uuid));
                        __print_groups_information();
                        return 0;
@@ -439,43 +416,6 @@ int comp_group_add_device_in_group(char *group_name, char *uuid)
        return -1;
 }
 
-int comp_group_add_subgroup_in_group(char *group_name, char *uuid, char *subgroup_name)
-{
-       comp_context_t *comp_ctx = comp_context_get_context();
-
-       GList *iter = NULL;
-
-       iter = comp_ctx->grp_list;
-       while (iter != NULL) {
-               comp_grp_t *group = (comp_grp_t *)iter->data;
-
-               if (strcmp(group_name, group->name) == 0) {
-                       GList *subgroup_iter = group->subgroup_list;
-
-                       while (subgroup_iter != NULL) {
-                               comp_subgrp_t *subgroup = (comp_subgrp_t *)subgroup_iter->data;
-                               if (strcmp(subgroup->uuid, uuid) == 0)
-                                       return -1;
-
-                               subgroup_iter = g_list_next(subgroup_iter);
-                       }
-
-                       comp_subgrp_t *subgroup;
-                       subgroup = g_try_malloc0(sizeof(comp_subgrp_t));
-                       subgroup->name = g_strdup(subgroup_name);
-                       subgroup->uuid = g_strdup(uuid);
-
-                       group->subgroup_list = g_list_prepend(group->subgroup_list, subgroup);
-                       __print_groups_information();
-                       return 0;
-               }
-
-               iter = g_list_next(iter);
-       }
-
-       return -1;
-}
-
 //Join to device in group (async)
 int comp_group_invite(char *group_name, char *uuid, char *pin)
 {
@@ -605,7 +545,7 @@ int comp_group_send_data(gchar *uuid_dev, gchar *addr, int port, gchar *data,
                percent[0] = '\0';
 
        comp_command_t *cmd = g_new0(comp_command_t, 1);
-       cmd->command = g_strdup("3");
+       cmd->command = g_strdup("0");
        cmd->uuid = g_strdup(uuid_dev);
 
        if (strchr(ip, ':')) /* IPv6 Adress */
@@ -838,17 +778,17 @@ int comp_group_get_group_device_id(comp_group_t *handle)
        return ret;
 }
 
-int comp_group_create_subgroup(char *group_name, char *uuid, char *subgroup_name)
+int comp_group_request_create_group(char *uuid, char *group_name)
 {
        int ret = COMP_ERROR_NONE;
 
+       LOG_ERR("[Request Create Group] %s", group_name);
+       LOG_ERR("[Request Create Group] to %s", uuid);
+
        comp_command_t *cmd = g_new0(comp_command_t, 1);
        cmd->command = g_strdup("1");
        cmd->uuid = g_strdup(uuid);
        cmd->arg1 = g_strdup(group_name);
-       cmd->arg2 = g_strdup(subgroup_name);
-
-       comp_group_add_subgroup_in_group(group_name, uuid, subgroup_name);
 
        ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_DATA, 5, cmd);
        if (ret != COMP_ERROR_NONE) {
@@ -859,95 +799,65 @@ int comp_group_create_subgroup(char *group_name, char *uuid, char *subgroup_name
        return ret;
 }
 
-GVariant *comp_group_get_subgroups(char *group_name)
+int comp_group_request_invite(char *uuid, char *group_name, char *target_uuid, char *PIN)
 {
-       GVariantBuilder builder;
-
-       GVariant *group_data;
-       GList *iter = NULL;
-
-       comp_context_t *comp_ctx = comp_context_get_context();
-
-       g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
-
-       iter = comp_ctx->grp_list;
-       while(iter != NULL) {
-               comp_grp_t *group = (comp_grp_t *)iter->data;
+       int ret = COMP_ERROR_NONE;
 
-               LOG_ERR("group->name : %s, group_name : %s", group->name, group_name);
-
-               if (strcmp(group->name, group_name) == 0) {
-                       GList *sub_iter = group->subgroup_list;
-                       LOG_ERR("sub iter");
-
-                       while(sub_iter != NULL) {
-                               LOG_ERR("sub iter");
-                               comp_subgrp_t *subgroup = (comp_subgrp_t *)sub_iter->data;
-                               g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
-                               g_variant_builder_add(&builder, "{sv}", "DeviceID",
-                                                                         g_variant_new_string(subgroup->uuid));
-                               g_variant_builder_add(&builder, "{sv}", "GroupName",
-                                                                         g_variant_new_string(subgroup->name));
-                               g_variant_builder_close(&builder);
-                               sub_iter = g_list_next(sub_iter);
-                       }
-               }
+       LOG_ERR("[Request Invite] %s, %s, %s", group_name, target_uuid, PIN);
+       LOG_ERR("[Request Invite] to %s", uuid);
 
-               iter = g_list_next(iter);
+       comp_command_t *cmd = g_new0(comp_command_t, 1);
+       cmd->command = g_strdup("2");
+       cmd->uuid = g_strdup(uuid);
+       cmd->arg1 = g_strdup(group_name);
+       cmd->arg2 = g_strdup(target_uuid);
+       cmd->arg3 = g_strdup(PIN);
 
+       ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_DATA, 5, cmd);
+       if (ret != COMP_ERROR_NONE) {
+               LOG_ERR("Failed to discover resource : %s",
+                                comp_log_get_error_string(ret));
        }
 
-       group_data = g_variant_builder_end(&builder);
-
-       return group_data;
+       return ret;
 }
-char *__get_uuid_by_subgroup(char *subgroup_name)
-{
-       comp_context_t *comp_ctx = comp_context_get_context();
 
-       GList *iter = NULL;
 
-       iter = comp_ctx->grp_list;
-       while (iter != NULL) {
-               comp_grp_t *group = (comp_grp_t *)iter->data;
-               GList *subgroup_iter = group->subgroup_list;
+int comp_group_request_eject(char *uuid, char *group_name, char *target_uuid)
+{
+       int ret = COMP_ERROR_NONE;
 
-               while (subgroup_iter != NULL) {
-                       comp_subgrp_t *subgroup = (comp_subgrp_t *)subgroup_iter->data;
-                       if (strcmp(subgroup->name, subgroup_name) == 0) {
-                               return subgroup->uuid;
-                       }
+       LOG_ERR("[Request Eject] %s, %s", group_name, target_uuid);
+       LOG_ERR("[Request Eject] to %s", uuid);
 
-                       subgroup_iter = g_list_next(subgroup_iter);
-               }
+       comp_command_t *cmd = g_new0(comp_command_t, 1);
+       cmd->command = g_strdup("3");
+       cmd->uuid = g_strdup(uuid);
+       cmd->arg1 = g_strdup(group_name);
+       cmd->arg2 = g_strdup(target_uuid);
 
-               iter = g_list_next(iter);
+       ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_DATA, 5, cmd);
+       if (ret != COMP_ERROR_NONE) {
+               LOG_ERR("Failed to discover resource : %s",
+                                comp_log_get_error_string(ret));
        }
 
-       return NULL;
+       return ret;
+
 }
 
-int comp_group_add_device_to_subgroup(char *subgroup_name, char *uuid)
+
+int comp_group_request_delete_group(char *uuid, char *group_name)
 {
-       //get uuid from subgroup_name.
-       //create CMD : add_device_to_subgroup
-       //arg1 : target UUID by subgroupname.
-       //arg2 : uuid
        int ret = COMP_ERROR_NONE;
-       char *subgroup_uuid;
-       comp_command_t *cmd = NULL;
-
-       subgroup_uuid = __get_uuid_by_subgroup(subgroup_name);
-       LOG_ERR("send remote data : %s, %s, %s", subgroup_name, subgroup_uuid, uuid);
-       if (subgroup_uuid != NULL) {
-               cmd = g_new0(comp_command_t, 1);
-               cmd->command = g_strdup("2");
-               cmd->uuid = g_strdup(subgroup_uuid);
-               cmd->arg1 = g_strdup(subgroup_name);
-               cmd->arg2 = g_strdup(uuid);
-       } else {
-               LOG_ERR("the uuid is NULL");
-       }
+
+       LOG_ERR("[Request Delete Group] %s", group_name);
+       LOG_ERR("[Request Delete Group] to %s", uuid);
+
+       comp_command_t *cmd = g_new0(comp_command_t, 1);
+       cmd->command = g_strdup("4");
+       cmd->uuid = g_strdup(uuid);
+       cmd->arg1 = g_strdup(group_name);
 
        ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_DATA, 5, cmd);
        if (ret != COMP_ERROR_NONE) {
@@ -959,9 +869,3 @@ int comp_group_add_device_to_subgroup(char *subgroup_name, char *uuid)
 }
 
 
-int comp_group_delete_subgroup(char *subgroup_name)
-{
-       return COMP_ERROR_NONE;
-}
-
-
index c1648313fcf76ecc60022f8c14d6ac7ac7b001f9..1ce209831dfc4377dd43b60d9049f3b73e63aafa 100644 (file)
@@ -71,18 +71,6 @@ int comp_iot_initialize()
        return COMP_ERROR_NONE;
 }
 
-static bool _query_foreach(const char *key, const char *value, void *user_data)
-{
-       char *group_name = (char *)user_data;
-
-       if (strncmp(key, "UUID", 4) == 0) {
-               LOG_DEBUG("Insert in %s, UUID : %s", group_name, value);
-               comp_group_add_device_in_group(group_name, (char *)value);
-       }
-
-       return IOTCON_FUNC_CONTINUE;
-}
-
 static void _request_handler(iotcon_resource_h resource, iotcon_request_h request,
        void *user_data)
 {
@@ -114,23 +102,37 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques
                        iotcon_query_lookup(query, "CMD", &command);
 
                        if (strcmp(command, "1") == 0) {
-                               LOG_DEBUG("Another device request create sub group");
+                               LOG_DEBUG("Request create group");
                                char *group_name;
-                               iotcon_query_lookup(query, "group_name", &group_name);
+                               iotcon_query_lookup(query, "name", &group_name);
 
+                               comp_group_find_mot_enabled_devices(7);
                                comp_group_create(group_name);
-                               comp_group_find_mot_enabled_devices();
                        } else if (strcmp(command, "2") == 0) {
-                               LOG_DEBUG("Another device request add device to sub group");
+                               LOG_DEBUG("Request invite");
                                char *group_name;
                                char *uuid;
 
                                iotcon_query_lookup(query, "name", &group_name);
                                iotcon_query_lookup(query, "id", &uuid);
 
-                               LOG_DEBUG("group_name : %s, UUID : %s", group_name, uuid);
+                               LOG_DEBUG("group_name : %s, UUID : %s");
 
                                comp_group_invite(group_name, uuid, "12341234");
+                       } else if (strcmp(command, "3") == 0) {
+                               LOG_DEBUG("Request eject");
+                               char *group_name;
+                               char *uuid;
+
+                               iotcon_query_lookup(query, "name", &group_name);
+                               iotcon_query_lookup(query, "id", &uuid);
+
+                               LOG_DEBUG("group_name : %s, UUID : %s", group_name, uuid);
+
+                               comp_group_dismiss(group_name, uuid);
+                       } else if (strcmp(command, "4") == 0) {
+                               LOG_DEBUG("Request delete group");
+
                        }
                }
 
@@ -224,7 +226,7 @@ static bool _get_res_type_cb(const char *string, void *user_data)
        return IOTCON_FUNC_CONTINUE;
 }
 
-int found_device_count = 0;
+int found_group_count = 0;
 
 static void _on_get(iotcon_remote_resource_h resource, iotcon_error_e err,
         iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
@@ -309,7 +311,7 @@ static bool _found_resource(iotcon_remote_resource_h resource,
                LOG_DEBUG("group name is %s", ptr);
                comp_group_add_new(resource_uri_path, resource_device_id,
                                                 ptr, resource_host, resource_type, group_type);
-               found_device_count++;
+               found_group_count++;
 
                g_free(resource_type);
 
@@ -318,7 +320,7 @@ static bool _found_resource(iotcon_remote_resource_h resource,
                comp_command_t *cmd = (comp_command_t *)user_data;
 
                if (cmd != NULL && strcmp(cmd->uuid, resource_device_id) == 0) {
-                       LOG_DEBUG("Send data is ready. Create Subgroup Start");
+                       LOG_DEBUG("Request to Remote Device");
 
                        iotcon_remote_resource_h resource_clone = NULL;
                        iotcon_query_h query = NULL;
@@ -331,19 +333,19 @@ static bool _found_resource(iotcon_remote_resource_h resource,
                        if (IOTCON_ERROR_NONE != ret)
                                return IOTCON_FUNC_CONTINUE;
 
-                       if (strcmp(cmd->command, "1") == 0) {
-                               LOG_DEBUG("CMD : %s, group_name : %s", cmd->command, cmd->arg2);
-                               iotcon_query_add(query, "CMD", cmd->command);
-                               iotcon_query_add(query, "group_name", cmd->arg2);
-                       } else if (strcmp(cmd->command, "2") == 0) {
-                               LOG_DEBUG("CMD : %s, group_name : %s, UUID : %s", cmd->command, cmd->arg1, cmd->arg2);
-                               iotcon_query_add(query, "CMD", cmd->command);
+                       iotcon_query_add(query, "CMD", cmd->command);
+
+                       if (strcmp(cmd->command, "1") == 0) { //request create group
+                               iotcon_query_add(query, "name", cmd->arg1);
+                       } else if (strcmp(cmd->command, "2") == 0) { //request invite
                                iotcon_query_add(query, "name", cmd->arg1);
                                iotcon_query_add(query, "id", cmd->arg2);
-                       } else if (strcmp(cmd->command, "3") == 0) {
-                               LOG_DEBUG("CMD : %s, UUID : %s", cmd->command, cmd->uuid);
-                               iotcon_query_add(query, "CMD", cmd->command);
-                               iotcon_query_add(query, "data", cmd->arg1);
+                               iotcon_query_add(query, "PIN", cmd->arg3);
+                       } else if (strcmp(cmd->command, "3") == 0) { //request eject
+                               iotcon_query_add(query, "name", cmd->arg1);
+                               iotcon_query_add(query, "id", cmd->arg2);
+                       } else if (strcmp(cmd->command, "4") == 0) { //request delete group
+                               iotcon_query_add(query, "name", cmd->arg1);
                        }
 
                        ret = iotcon_remote_resource_get(resource_clone, query, _on_get, NULL);
@@ -365,7 +367,7 @@ static gboolean _timeout_cb(gpointer data)
        comp_resource_type_e resource_type = (comp_resource_type_e)data;
 
        if (resource_type == COMP_RESOURCE_TYPE_GROUP) {
-               if (found_device_count > 0)
+               if (found_group_count > 0)
                        ret = 0;
 
                notify_group_find_finish(ret);
@@ -382,7 +384,7 @@ int comp_iot_discovery_resource(comp_resource_type_e resource_type, int timeout,
        iotcon_query_h query;
        comp_command_t *cmd = user_data;
 
-       found_device_count = 0;
+       found_group_count = 0;
 
        ret = iotcon_set_timeout(timeout);
        if (IOTCON_ERROR_NONE != ret) {
@@ -405,7 +407,7 @@ int comp_iot_discovery_resource(comp_resource_type_e resource_type, int timeout,
 
        LOG_DEBUG("Set Resource Type : %s", get_error_message(ret));
 
-       if (cmd && (g_strcmp0(cmd->command, "3") == 0))
+       if (cmd && (g_strcmp0(cmd->command, "0") == 0))
                ret = iotcon_find_resource(cmd->host,
                        IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP,
                        query, _found_resource, user_data);
index 28b04522205bcae6f9e95508067a68b44f2d78fd..10a504c2195b961ad0514a8992d7551ae42c7d81 100644 (file)
@@ -54,6 +54,8 @@ static char *device_uuid1 = NULL;
 static char *device_uuid2 = NULL;
 #endif
 
+int found_device_count;
+
 int agent_get_ownerid(char* deviceid)
 {
        GVariant *variant = NULL;
@@ -79,7 +81,19 @@ int agent_get_ownerid(char* deviceid)
        return result;
 }
 
-int agent_find_mot_enable_devices()
+static gboolean _find_device_timeout_cb(gpointer data)
+{
+       int ret = -1;
+
+       if (found_device_count > 0)
+               ret = 0;
+
+       notify_device_find_finish(ret);
+
+       return false;
+}
+
+int agent_find_mot_enable_devices(int timeout)
 {
        GVariant *variant = NULL;
        int result = COMP_ERROR_NONE;
@@ -90,6 +104,8 @@ int agent_find_mot_enable_devices()
                return COMP_ERROR_IO_ERROR;
        }
 
+       found_device_count = 0;
+
        variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "disc_mot_enb_devs",
                                NULL, G_DBUS_CALL_FLAGS_NONE,  -1, NULL, &error);
        if (variant) {
@@ -101,6 +117,8 @@ int agent_find_mot_enable_devices()
                return COMP_ERROR_IO_ERROR;
        }
 
+       g_timeout_add_seconds(timeout + 1, _find_device_timeout_cb, NULL);
+
        return result;
 }
 
@@ -629,7 +647,7 @@ static void _agent_signal_handler(GDBusConnection *connection,
                g_variant_iter_free(iter);
 
                LOG_DEBUG("mot_enb_devs_cnt = %d", mot_enb_devs_cnt);
-
+               found_device_count = mot_enb_devs_cnt;
                comp_group_notify_mot_enable_device_done(mot_enb_devs_cnt);
 
        } else if (0 == g_strcmp0(signal_name, "disc_mowned_devs_done")) {
index 97c0b9f8272b9bbfb440856b1cab3e780178bba9..c6e9c854dee7aac045ea8728f8e5996bb2c3a41f 100644 (file)
                <method name="GetMyUuid">
                        <arg type="s" name="uuid" direction="out" />
                </method>
-               <method name="CreateSubgroup">
-                       <arg type="s" name="group_name" direction="in" />
+               <method name="RequestCreateGroup">
                        <arg type="s" name="uuid" direction="in" />
-                       <arg type="s" name="subgroup_name" direction="in" />
+                       <arg type="s" name="group_name" direction="in" />
                        <arg type="i" name="result" direction="out" />
                </method>
-               <method name="GetSubgroups">
+               <method name="RequestInvite">
+                       <arg type="s" name="uuid" direction="in" />
                        <arg type="s" name="group_name" direction="in" />
-                       <arg type="aa{sv}" name="groups" direction="out" />
+                       <arg type="s" name="target_uuid" direction="in" />
+                       <arg type="s" name="pin" direction="in" />
                        <arg type="i" name="result" direction="out" />
                </method>
-               <method name="AddDeviceToSubgroup">
-                       <arg type="s" name="subgroup_name" direction="in" />
+               <method name="RequestEject">
                        <arg type="s" name="uuid" direction="in" />
+                       <arg type="s" name="group_name" direction="in" />
+                       <arg type="s" name="target_uuid" direction="in" />
                        <arg type="i" name="result" direction="out" />
                </method>
-               <method name="DeleteSubgroup">
-                       <arg type="s" name="subgroup_name" direction="in" />
+               <method name="RequestDeleteGroup">
+                       <arg type="s" name="uuid" direction="in" />
+                       <arg type="s" name="group_name" direction="in" />
                        <arg type="i" name="result" direction="out" />
                </method>
                <!-- Signal (D-Bus) definitions -->