e_server: use e_tizen_launch_appinfo 02/317502/1
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 31 Dec 2024 07:58:35 +0000 (16:58 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 2 Jan 2025 23:43:09 +0000 (08:43 +0900)
Use e_tizen_launch_appinfo instead of the code in e_policy_wl.c

Change-Id: I3782ab2ba32a07bdb74d162352557d7c7930a47c

src/bin/server/e_policy_wl.c
src/bin/server/e_server.c
src/bin/server/e_server_intern.h
src/bin/server/e_tizen_launch_appinfo.c

index b764cdd6903f6b24b1a4ca054e0893d65892c568..689d5fecc009a19f84202de57e73cfa12abfe485 100644 (file)
@@ -175,11 +175,6 @@ typedef struct _E_Policy_Wl_Dpy_Surface
    int32_t             brightness;
 } E_Policy_Wl_Dpy_Surface;
 
-typedef struct _E_Policy_Wl_Tzlaunch_Appinfo
-{
-   struct wl_resource        *res_tzlaunch_appinfo; /* tizen_launch_appinfo */
-} E_Policy_Wl_Tzlaunch_Appinfo;
-
 typedef struct _E_Policy_Wl_Tz_Indicator
 {
    struct wl_resource *res_tz_indicator;
@@ -208,8 +203,6 @@ typedef struct _E_Policy_Wl
    Eina_List       *tz_indicators;
    Eina_List       *tz_clipboards;           /* list of E_Policy_Wl_Tz_Clipboard */
 
-   /* tizen_launch_appinfo_interface */
-   Eina_List       *tzlaunch_appinfo;       /* list of E_Policy_Wl_Tzlaunch_Appinfo */
    /* tizen_ws_shell_interface ver_2 */
    Eina_List       *tzsh_extensions;           /* list of E_Policy_Wl_Tzsh_Extension */
 } E_Policy_Wl;
@@ -6580,411 +6573,6 @@ err:
    wl_client_post_no_memory(client);
 }
 
-// --------------------------------------------------------
-// tizen_launch_appinfo_interface
-// --------------------------------------------------------
-static void
-_tzlaunch_appinfo_iface_cb_register_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
-                                            uint32_t pid)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   E_Appinfo *eai = NULL;
-
-   tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
-   if (!tzlaunch_appinfo)
-     {
-        wl_resource_post_error(res_tzlaunch_appinfo,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "Invalid tzlaunch_appinfo's user data");
-        return;
-     }
-
-   if (pid <= 0)
-     {
-        ELOGF("TZ_APPINFO", "registered pid is invalid. pid:%u", NULL, pid);
-        return;
-     }
-
-   eai = e_appinfo_find_with_pid(pid);
-   if (!eai)
-     {
-        eai = e_appinfo_new();
-        EINA_SAFETY_ON_NULL_RETURN(eai);
-
-        if (!e_appinfo_pid_set(eai, pid))
-          {
-             ELOGF("TZ_APPINFO", "failed to set pid is invalid. pid:%u", NULL, pid);
-             e_appinfo_del(eai);
-             return;
-          }
-     }
-
-   e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
-}
-
-static void
-_tzlaunch_appinfo_iface_cb_deregister_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
-                                            uint32_t pid)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   E_Appinfo *eai = NULL;
-
-   tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
-   if (!tzlaunch_appinfo)
-     {
-        wl_resource_post_error(res_tzlaunch_appinfo,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "Invalid tzlaunch_appinfo's user data");
-        return;
-     }
-
-   eai = e_appinfo_find_with_pid(pid);
-   EINA_SAFETY_ON_NULL_RETURN(eai);
-
-   e_appinfo_del(eai);
-}
-
-static void
-_tzlaunch_appinfo_iface_cb_set_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
-                                      uint32_t pid, const char *appid)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   E_Appinfo *eai = NULL;
-   int width = 0;
-   int height = 0;
-
-   tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
-   if (!tzlaunch_appinfo)
-     {
-        wl_resource_post_error(res_tzlaunch_appinfo,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "Invalid tzlaunch_appinfo's user data");
-        return;
-     }
-
-   if (pid <= 0)
-     {
-        ELOGF("TZ_APPINFO", "set pid is invalid. pid:%u", NULL, pid);
-        return;
-     }
-
-   eai = e_appinfo_find_with_pid(pid);
-   EINA_SAFETY_ON_NULL_RETURN(eai);
-
-   if (!e_appinfo_appid_set(eai, appid))
-     {
-        ELOGF("TZ_APPINFO", "failed to set appid, appid:%s", NULL, appid);
-        return;
-     }
-
-   /* about base  output resolution */
-   if (e_config->configured_output_resolution.use)
-     {
-
-        // 1. send HOOK with pid
-        e_policy_wl_base_output_resolution_info_update(pid);
-        // 2. module must set the base_output_resolution.
-        if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
-          {
-             ELOGF("TZ_APPINFO", "failed to set base_output_resolution in module, pid:%u, appid:%s", NULL, pid, appid);
-             return;
-          }
-        // 3. server has to get the base_screern_resolution via e_appinfo_base_output_resolution_get.
-        //    3-1. if success, use the base_rescreen_resolution
-        //    3-2. if fail, get the base_output_resolution from the E_Comp_Wl_Output.
-
-        // 4. send output.
-        if (!e_comp_wl_pid_output_configured_resolution_send(pid, width, height))
-          {
-             ELOGF("TZ_APPINFO", "failed to send output_configured_resolution, pid:%u, appid:%s", NULL, pid, appid);
-             return;
-          }
-     }
-
-   return;
-}
-
-static void
-_tzlaunch_appinfo_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo)
-{
-   wl_resource_destroy(res_tzlaunch_appinfo);
-}
-
-static void
-_tzlaunch_appinfo_iface_cb_get_base_output_resolution(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
-                                    uint32_t pid)
-{
-   E_Appinfo *eai = NULL;
-   int width = 0, height = 0;
-
-   if (pid <= 0)
-     {
-        ELOGF("TZ_APPINFO", "requested pid is invalid. pid:%u", NULL, pid);
-        goto err;
-     }
-
-   eai = e_appinfo_find_with_pid(pid);
-   if (!eai)
-     {
-        ELOGF("TZ_APPINFO", "cannot find pid. pid:%u", NULL, pid);
-        goto err;
-     }
-
-   if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
-     {
-        ELOGF("TZ_APPINFO", "cannot read size. pid:%u", NULL, pid);
-        goto err;
-     }
-
-   tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
-   ELOGF("TZ_APPINFO", "send Output base_output_resolution size(%d, %d) : pid(%u)", NULL, width, height, pid);
-
-   return;
-
-err:
-   width = e_config->configured_output_resolution.w;
-   height = e_config->configured_output_resolution.h;
-   ELOGF("TZ_APPINFO", "send Output base_output_resolution size(%d, %d) : pid(%u)", NULL, width, height, pid);
-   tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
-
-   return;
-}
-
-static void
-_tzlaunch_appinfo_iface_cb_register_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
-                                          const char *appid)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   E_Appinfo *eai = NULL;
-
-   tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
-   if (!tzlaunch_appinfo)
-     {
-        wl_resource_post_error(res_tzlaunch_appinfo,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "Invalid tzlaunch_appinfo's user data");
-        return;
-     }
-
-   if ((eai = e_appinfo_find_with_appid(appid)))
-     {
-        ELOGF("TZ_APPINFO", "appid:%s is already registered!", NULL, appid);
-        return;
-     }
-
-   eai = e_appinfo_new();
-   EINA_SAFETY_ON_NULL_RETURN(eai);
-
-   if (!e_appinfo_appid_set(eai, appid))
-     {
-        ELOGF("TZ_APPINFO", "Failed to register appid:%s", NULL, appid);
-        e_appinfo_del(eai);
-        return;
-     }
-
-   e_appinfo_owner_set(eai, E_APPINFO_OWNER_CLIENT);
-}
-
-static void
-_tzlaunch_appinfo_iface_cb_deregister_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
-                                            const char *appid)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   E_Appinfo *eai = NULL;
-
-   tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
-   if (!tzlaunch_appinfo)
-     {
-        wl_resource_post_error(res_tzlaunch_appinfo,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "Invalid tzlaunch_appinfo's user data");
-        return;
-     }
-
-   eai = e_appinfo_find_with_appid(appid);
-   EINA_SAFETY_ON_NULL_RETURN(eai);
-
-   e_appinfo_del(eai);
-}
-
-static void
-_tzlaunch_appinfo_iface_cb_set_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
-                                   const char *appid, uint32_t pid)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   E_Appinfo *eai = NULL;
-
-   tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
-   if (!tzlaunch_appinfo)
-     {
-        wl_resource_post_error(res_tzlaunch_appinfo,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "Invalid tzlaunch_appinfo's user data");
-        return;
-     }
-
-   eai = e_appinfo_find_with_appid(appid);
-   EINA_SAFETY_ON_NULL_RETURN(eai);
-
-   if (!e_appinfo_pid_set(eai, pid))
-     {
-        ELOGF("TZ_APPINFO", "Failed to set pid:%u for appid:%s", NULL, pid, appid);
-        return;
-     }
-}
-
-static void
-_tzlaunch_appinfo_iface_cb_ready_metadata(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
-                                          const char *appid, uint32_t pid)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   E_Appinfo *eai = NULL;
-   int width = 0, height = 0;
-
-   tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
-   if (!tzlaunch_appinfo)
-     {
-        wl_resource_post_error(res_tzlaunch_appinfo,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "Invalid tzlaunch_appinfo's user data");
-        return;
-     }
-
-   eai = e_appinfo_find_with_appid(appid);
-   EINA_SAFETY_ON_NULL_RETURN(eai);
-
-   e_appinfo_ready_metadata(eai, pid);
-
-   /* about base  output resolution */
-   if (e_config->configured_output_resolution.use)
-     {
-        // 1. send HOOK with pid
-        e_policy_wl_base_output_resolution_info_update(pid);
-        // 2. module must set the base_output_resolution.
-        if (!e_appinfo_base_output_resolution_get(eai, &width, &height))
-          {
-             ELOGF("TZ_APPINFO", "failed to set base_output_resolution in module, pid:%u, appid:%s", NULL, pid, appid);
-             return;
-          }
-        // 3. server has to get the base_screern_resolution via e_appinfo_base_output_resolution_get.
-        //    3-1. if success, use the base_rescreen_resolution
-        //    3-2. if fail, get the base_output_resolution from the E_Comp_Wl_Output.
-
-        // 4. send output.
-        if (!e_comp_wl_pid_output_configured_resolution_send(pid, width, height))
-          {
-             ELOGF("TZ_APPINFO", "failed to send output_configured_resolution, pid:%u, appid:%s", NULL, pid, appid);
-             return;
-          }
-     }
-}
-
-static void
-_tzlaunch_appinfo_iface_cb_set_auto_placement(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
-                                              uint32_t pid)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   E_Appinfo *eai = NULL;
-
-   tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
-   if (!tzlaunch_appinfo)
-     {
-        wl_resource_post_error(res_tzlaunch_appinfo,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "Invalid tzlaunch_appinfo's user data");
-        return;
-     }
-
-   eai = e_appinfo_find_with_pid(pid);
-   EINA_SAFETY_ON_NULL_RETURN(eai);
-
-   ELOGF("TZ_APPINFO", "Set auto placement. pid(%d)", NULL, pid);
-   e_appinfo_auto_placement_set(eai, EINA_TRUE);
-}
-
-static const struct tizen_launch_appinfo_interface _tzlaunch_appinfo_iface =
-{
-   _tzlaunch_appinfo_iface_cb_destroy,
-   _tzlaunch_appinfo_iface_cb_register_pid,
-   _tzlaunch_appinfo_iface_cb_deregister_pid,
-   _tzlaunch_appinfo_iface_cb_set_appid,
-   _tzlaunch_appinfo_iface_cb_get_base_output_resolution,
-   _tzlaunch_appinfo_iface_cb_register_appid,
-   _tzlaunch_appinfo_iface_cb_deregister_appid,
-   _tzlaunch_appinfo_iface_cb_set_pid,
-   _tzlaunch_appinfo_iface_cb_ready_metadata,
-   _tzlaunch_appinfo_iface_cb_set_auto_placement,
-};
-
-static void
-_tzlaunch_appinfo_del(E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo)
-{
-   EINA_SAFETY_ON_NULL_RETURN(tzlaunch_appinfo);
-
-   polwl->tzlaunch_appinfo = eina_list_remove(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
-
-   memset(tzlaunch_appinfo, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Appinfo));
-   E_FREE(tzlaunch_appinfo);
-}
-
-static E_Policy_Wl_Tzlaunch_Appinfo *
-_tzlaunch_appinfo_add(struct wl_resource *res_tzlaunch_appinfo)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo;
-
-   tzlaunch_appinfo = E_NEW(E_Policy_Wl_Tzlaunch_Appinfo, 1);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_appinfo, NULL);
-
-   tzlaunch_appinfo->res_tzlaunch_appinfo = res_tzlaunch_appinfo;
-
-   polwl->tzlaunch_appinfo = eina_list_append(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
-
-   return tzlaunch_appinfo;
-}
-
-static void
-_tzlaunch_appinfo_cb_unbind(struct wl_resource *res_tzlaunch_appinfo)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   Eina_List *l, *ll;
-
-   EINA_LIST_FOREACH_SAFE(polwl->tzlaunch_appinfo, l, ll, tzlaunch_appinfo)
-     {
-        if (tzlaunch_appinfo->res_tzlaunch_appinfo != res_tzlaunch_appinfo) continue;
-        _tzlaunch_appinfo_del(tzlaunch_appinfo);
-        break;
-     }
-}
-
-static void
-_tzlaunch_appinfo_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
-{
-   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
-   struct wl_resource *res_tzlaunch_appinfo;
-
-   EINA_SAFETY_ON_NULL_GOTO(polwl, err);
-
-   res_tzlaunch_appinfo = wl_resource_create(client,
-                                     &tizen_launch_appinfo_interface,
-                                     ver,
-                                     id);
-   EINA_SAFETY_ON_NULL_GOTO(res_tzlaunch_appinfo, err);
-
-   tzlaunch_appinfo = _tzlaunch_appinfo_add(res_tzlaunch_appinfo);
-   EINA_SAFETY_ON_NULL_GOTO(tzlaunch_appinfo, err);
-
-   wl_resource_set_implementation(res_tzlaunch_appinfo,
-                                  &_tzlaunch_appinfo_iface,
-                                  tzlaunch_appinfo,
-                                  _tzlaunch_appinfo_cb_unbind);
-
-   return;
-
-err:
-   ERR("Could not create tizen_launch_appinfo_interface res: %m");
-   wl_client_post_no_memory(client);
-}
-
 EINTERN void
 e_policy_wl_base_output_resolution_info_update(pid_t pid)
 {
@@ -7840,26 +7428,7 @@ e_policy_wl_aux_hint_init(void)
 EINTERN Eina_Bool
 e_policy_wl_defer_job(void)
 {
-   struct wl_global *global = NULL;
-   E_Comp_Wl_Data *comp_wl;
-
-   EINA_SAFETY_ON_NULL_GOTO(polwl, err);
-
-   comp_wl = e_comp_wl_get();
-
-   global = wl_global_create(comp_wl->wl.disp,
-                             &tizen_launch_appinfo_interface,
-                             2,
-                             NULL,
-                             _tzlaunch_appinfo_cb_bind);
-   EINA_SAFETY_ON_NULL_GOTO(global, err);
-
-   polwl->globals = eina_list_append(polwl->globals, global);
-
    return EINA_TRUE;
-
-err:
-   return EINA_FALSE;
 }
 
 EINTERN Eina_Bool
index 0dd2a095892ce097fdc5ec3d5febef90233585dd..6c4aa4c93b0523119a867a543977f5c44e7c8669 100644 (file)
@@ -25,6 +25,7 @@
 #include "e_keyrouter_wl_intern.h"
 #include "e_video_shell_intern.h"
 #include "e_tizen_launch_effect_intern.h"
+#include "e_tizen_launch_appinfo_intern.h"
 
 typedef struct _E_Server E_Server;
 
@@ -62,6 +63,7 @@ struct _E_Server
         Dummy_Handle *tizen_keyrouter_handle;
         Dummy_Handle *tizen_video_shell;
         E_Tizen_Launch_Effect *tizen_launch_effect;
+        E_Tizen_Launch_Appinfo *tizen_launch_appinfo;
     } handles; // feature handles
 };
 
@@ -132,6 +134,7 @@ e_server_init(void)
    e_server_feature_register(E_SERVER_FEATURE_TIZEN_DEVICEMGR, e_devicemgr_wl_init(comp_wl->wl.disp));
    e_server_feature_register(E_SERVER_FEATURE_TIZEN_KEYROUTER, e_keyrouter_wl_init(comp_wl->wl.disp));
    e_server_feature_register(E_SERVER_FEATURE_TIZEN_LAUNCH_EFFECT, e_tizen_launch_effect_init(comp_wl->wl.disp));
+   e_server_feature_register(E_SERVER_FEATURE_TIZEN_LAUNCH_APPINFO, e_tizen_launch_appinfo_init(comp_wl->wl.disp));
 
    return EINA_TRUE;
 }
@@ -139,6 +142,7 @@ e_server_init(void)
 EINTERN void
 e_server_shutdown(void)
 {
+   e_tizen_launch_appinfo_shutdown();
    e_tizen_launch_effect_shutdown();
    e_keyrouter_wl_shutdown();
    e_devicemgr_wl_shutdown();
@@ -257,6 +261,9 @@ e_server_feature_register(E_SERVER_FEATURE feature, void *handle)
        case E_SERVER_FEATURE_TIZEN_LAUNCH_EFFECT:
          g_server->handles.tizen_launch_effect = handle;
          break;
+       case E_SERVER_FEATURE_TIZEN_LAUNCH_APPINFO:
+         g_server->handles.tizen_launch_appinfo = handle;
+         break;
        default:
          ERR("Unknown feature(%d) and handle(%p)", feature, handle);
          break;
@@ -350,6 +357,9 @@ e_server_feature_handle_get(E_SERVER_FEATURE feature)
        case E_SERVER_FEATURE_TIZEN_LAUNCH_EFFECT:
          handle = g_server->handles.tizen_launch_effect;
          break;
+       case E_SERVER_FEATURE_TIZEN_LAUNCH_APPINFO:
+         handle = g_server->handles.tizen_launch_appinfo;
+         break;
        default:
          ERR("Unknown feature(%d)", feature);
          break;
@@ -362,8 +372,13 @@ EINTERN void
 e_server_deferred_job(void)
 {
   E_Tizen_Launch_Effect *tizen_launch_effect;
+  E_Tizen_Launch_Appinfo *tizen_launch_appinfo;
 
   tizen_launch_effect = (E_Tizen_Launch_Effect *)e_server_feature_handle_get(E_SERVER_FEATURE_TIZEN_LAUNCH_EFFECT);
   if (tizen_launch_effect)
     e_tizen_launch_effect_defer_job(tizen_launch_effect);
+
+  tizen_launch_appinfo = (E_Tizen_Launch_Appinfo *)e_server_feature_handle_get(E_SERVER_FEATURE_TIZEN_LAUNCH_APPINFO);
+  if (tizen_launch_appinfo)
+    e_tizen_launch_appinfo_defer_job(tizen_launch_appinfo);
 }
index 39065fb9a2e5839b8825b2c7055846042d18af78..0672407919a95d9199aa3dc8f673e931969f9f74 100644 (file)
@@ -30,6 +30,7 @@ typedef enum _E_SERVER_FEATURE {
     E_SERVER_FEATURE_TIZEN_KEYROUTER,
     E_SERVER_FEATURE_TIZEN_VIDEO_SHELL,
     E_SERVER_FEATURE_TIZEN_LAUNCH_EFFECT,
+    E_SERVER_FEATURE_TIZEN_LAUNCH_APPINFO,
     E_SERVER_FEATURE_MAX
 } E_SERVER_FEATURE;
 
index 29c1a32adb269cfca63b53502b203ea3fc30918b..8e1b093cd1e76bf8816dbf148393b6cbc6b0308b 100644 (file)
@@ -416,6 +416,9 @@ _e_tizen_launch_appinfo_cb_bind(struct wl_client *client, void *data EINA_UNUSED
                                   &_e_tizen_launch_appinfo_iface,
                                   tzlaunch_appinfo,
                                   _e_tizen_launch_appinfo_cb_unbind);
+
+return;
+
 err:
    ERR("Could not create tizen_launch_appinfo_interface res: %m");
    wl_client_post_no_memory(client);