diff --git a/lib/wp/session-item.c b/lib/wp/session-item.c index 2e6f9a8a..4e04e849 100644 --- a/lib/wp/session-item.c +++ b/lib/wp/session-item.c @@ -345,6 +345,40 @@ wp_session_item_get_associated_proxy_id (WpSessionItem * self, GType proxy_type) return wp_proxy_get_bound_id (proxy); } +/** + * wp_session_item_register: + * @self: (transfer full): the session item + * + * Registers the session item to its associated core + */ +void +wp_session_item_register (WpSessionItem * self) +{ + g_autoptr (WpCore) core = NULL; + + g_return_if_fail (WP_IS_SESSION_ITEM (self)); + + core = wp_object_get_core (WP_OBJECT (self)); + wp_registry_register_object (wp_core_get_registry (core), self); +} + +/** + * wp_session_item_remove: + * @self: (transfer none): the session item + * + * Removes the session item from the registry + */ +void +wp_session_item_remove (WpSessionItem * self) +{ + g_autoptr (WpCore) core = NULL; + + g_return_if_fail (WP_IS_SESSION_ITEM (self)); + + core = wp_object_get_core (WP_OBJECT (self)); + wp_registry_remove_object (wp_core_get_registry (core), self); +} + /** * wp_session_item_get_properties: * @self: the session item diff --git a/lib/wp/session-item.h b/lib/wp/session-item.h index 167ded74..c5652f97 100644 --- a/lib/wp/session-item.h +++ b/lib/wp/session-item.h @@ -90,6 +90,14 @@ WP_API guint32 wp_session_item_get_associated_proxy_id (WpSessionItem * self, GType proxy_type); +/* registry */ + +WP_API +void wp_session_item_register (WpSessionItem * self); + +WP_API +void wp_session_item_remove (WpSessionItem * self); + /* properties */ WP_API diff --git a/modules/module-lua-scripting/api.c b/modules/module-lua-scripting/api.c index d32e4042..f39c8711 100644 --- a/modules/module-lua-scripting/api.c +++ b/modules/module-lua-scripting/api.c @@ -1088,9 +1088,27 @@ session_item_configure (lua_State *L) return 1; } +static int +session_item_register (lua_State *L) +{ + WpSessionItem *si = wplua_checkobject (L, 1, WP_TYPE_SESSION_ITEM); + wp_session_item_register (g_object_ref (si)); + return 0; +} + +static int +session_item_remove (lua_State *L) +{ + WpSessionItem *si = wplua_checkobject (L, 1, WP_TYPE_SESSION_ITEM); + wp_session_item_remove (si); + return 0; +} + static const luaL_Reg session_item_methods[] = { { "reset", session_item_reset }, { "configure", session_item_configure }, + { "register", session_item_register }, + { "remove", session_item_remove }, { NULL, NULL } };