diff --git a/include/ccnet.h b/include/ccnet.h index 4bd41e6..ca7c1b6 100644 --- a/include/ccnet.h +++ b/include/ccnet.h @@ -30,7 +30,7 @@ GList *ccnet_get_groups_by_user (SearpcClient *client, const char *user, int return_ancestors); GList *ccnet_get_org_groups_by_user (SearpcClient *client, const char *user, int org_id); GList * -ccnet_get_group_members (SearpcClient *client, int group_id); +ccnet_get_group_members (SearpcClient *client, int group_id, int start, int limit); int ccnet_org_user_exists (SearpcClient *client, int org_id, const char *user); diff --git a/lib/ccnet-rpc-wrapper.c b/lib/ccnet-rpc-wrapper.c index ede13fb..2410b50 100644 --- a/lib/ccnet-rpc-wrapper.c +++ b/lib/ccnet-rpc-wrapper.c @@ -29,11 +29,11 @@ ccnet_get_org_groups_by_user (SearpcClient *client, const char *user, int org_id } GList * -ccnet_get_group_members (SearpcClient *client, int group_id) +ccnet_get_group_members (SearpcClient *client, int group_id, int start, int limit) { return searpc_client_call__objlist ( client, "get_group_members", CCNET_TYPE_GROUP_USER, NULL, - 1, "int", group_id); + 3, "int", group_id, "int", start, "int", limit); } int diff --git a/net/common/rpc-service.c b/net/common/rpc-service.c index 3efa3ee..74f9051 100644 --- a/net/common/rpc-service.c +++ b/net/common/rpc-service.c @@ -172,7 +172,7 @@ ccnet_start_rpc(CcnetSession *session) searpc_server_register_function ("ccnet-threaded-rpcserver", ccnet_rpc_get_group_members, "get_group_members", - searpc_signature_objlist__int()); + searpc_signature_objlist__int_int_int()); searpc_server_register_function ("ccnet-threaded-rpcserver", ccnet_rpc_get_members_with_prefix, "get_members_with_prefix", @@ -838,13 +838,17 @@ ccnet_rpc_get_group (int group_id, GError **error) GList * -ccnet_rpc_get_group_members (int group_id, GError **error) +ccnet_rpc_get_group_members (int group_id, int start, int limit, GError **error) { CcnetGroupManager *group_mgr = ((CcnetServerSession *)session)->group_mgr; GList *ret = NULL; - ret = ccnet_group_manager_get_group_members (group_mgr, group_id, error); + if (start < 0 ) { + start = 0; + } + + ret = ccnet_group_manager_get_group_members (group_mgr, group_id, start, limit, error); if (ret == NULL) return NULL; diff --git a/net/common/rpc-service.h b/net/common/rpc-service.h index fe769b4..8dc711f 100644 --- a/net/common/rpc-service.h +++ b/net/common/rpc-service.h @@ -171,7 +171,7 @@ GObject * ccnet_rpc_get_group (int group_id, GError **error); GList * -ccnet_rpc_get_group_members (int group_id, GError **error); +ccnet_rpc_get_group_members (int group_id, int start, int limit, GError **error); GList * ccnet_rpc_get_members_with_prefix(int group_id, const char *prefix, GError **error); diff --git a/net/server/group-mgr.c b/net/server/group-mgr.c index d0d162f..13d4bda 100644 --- a/net/server/group-mgr.c +++ b/net/server/group-mgr.c @@ -1020,18 +1020,35 @@ get_ccnet_groupuser_cb (CcnetDBRow *row, void *data) } GList * -ccnet_group_manager_get_group_members (CcnetGroupManager *mgr, int group_id, +ccnet_group_manager_get_group_members (CcnetGroupManager *mgr, + int group_id, + int start, + int limit, GError **error) { CcnetDB *db = mgr->priv->db; char *sql; GList *group_users = NULL; + int rc; + + if (limit == -1) { + sql = "SELECT group_id, user_name, is_staff FROM GroupUser WHERE group_id = ?"; + rc = ccnet_db_statement_foreach_row (db, sql, + get_ccnet_groupuser_cb, &group_users, + 1, "int", group_id); + } else { + sql = "SELECT group_id, user_name, is_staff FROM GroupUser WHERE group_id = ? LIMIT ? OFFSET ?"; + rc = ccnet_db_statement_foreach_row (db, sql, + get_ccnet_groupuser_cb, &group_users, + 3, "int", group_id, + "int", limit, + "int", start); - sql = "SELECT group_id, user_name, is_staff FROM GroupUser WHERE group_id = ?"; - if (ccnet_db_statement_foreach_row (db, sql, - get_ccnet_groupuser_cb, &group_users, - 1, "int", group_id) < 0) + } + + if (rc < 0) { return NULL; + } return g_list_reverse (group_users); } diff --git a/net/server/group-mgr.h b/net/server/group-mgr.h index c98a92e..b33b2ee 100644 --- a/net/server/group-mgr.h +++ b/net/server/group-mgr.h @@ -85,7 +85,10 @@ ccnet_group_manager_get_group (CcnetGroupManager *mgr, int group_id, GError **error); GList * -ccnet_group_manager_get_group_members (CcnetGroupManager *mgr, int group_id, +ccnet_group_manager_get_group_members (CcnetGroupManager *mgr, + int group_id, + int start, + int limit, GError **error); GList * diff --git a/python/ccnet/rpc.py b/python/ccnet/rpc.py index 69a8ce7..8dd6be0 100644 --- a/python/ccnet/rpc.py +++ b/python/ccnet/rpc.py @@ -157,8 +157,8 @@ class CcnetThreadedRpcClient(NamedPipeClient): def get_group(self, group_id): pass - @searpc_func("objlist", ["int"]) - def get_group_members(self, group_id): + @searpc_func("objlist", ["int", "int", "int"]) + def get_group_members(self, group_id, start, limit): pass @searpc_func("objlist", ["int", "string"])