DSTizenAppinfoMgr: change into singleton and add getInstance(),releaseInstance() 00/241800/1
authorDuna Oh <duna.oh@samsung.com>
Thu, 13 Aug 2020 04:51:40 +0000 (13:51 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:10:59 +0000 (19:10 +0900)
Change-Id: Ie7b93ea027785c79d932671d5e4b116361889c71

13 files changed:
src/DSCompositor/DSCompositor.cpp
src/DSCompositor/DSCompositorPrivate.h
src/DSTizenAppinfo/DSTizenAppinfo.cpp [moved from src/DSWaylandExtension/DSTizenAppinfo.cpp with 92% similarity]
src/DSTizenAppinfo/DSTizenAppinfo.h [moved from src/DSWaylandExtension/DSTizenAppinfo.h with 98% similarity]
src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp [new file with mode: 0644]
src/DSTizenAppinfo/DSTizenAppinfoMgr.h [moved from src/DSWaylandExtension/DSTizenAppinfoMgr.h with 77% similarity]
src/DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h [new file with mode: 0644]
src/DSWaylandExtension/DSTizenAppinfoMgr.cpp [deleted file]
src/DSWaylandExtension/DSWaylandExtension.cpp
src/DSWaylandExtension/DSWaylandExtensionPrivate.h
src/DSWaylandServer/DSWaylandTizenAppinfo.cpp
src/meson.build
tests/DSTizenAppinfo-test.cpp

index 1c46a96..5e70a1b 100644 (file)
@@ -70,7 +70,8 @@ DSCompositorPrivate::DSCompositorPrivate(DSCompositor *p_ptr)
        : DSObjectPrivate(p_ptr),
          __p_ptr(p_ptr),
          __displayDevice(nullptr),
-         __canvas(nullptr)
+         __canvas(nullptr),
+         __dsAppinfoMgr(nullptr)
 
 {
        __eventLoop = DSEventLoop::getInstance();
@@ -83,6 +84,7 @@ DSCompositorPrivate::~DSCompositorPrivate()
        DSWaylandCompositor::releaseInstance();
        DSBufferManager::releaseInstance();
        DSEventLoop::releaseInstance();
+       DSTizenAppinfoMgr::releaseInstance();
 }
 
 bool DSCompositorPrivate::run()
@@ -92,6 +94,7 @@ bool DSCompositorPrivate::run()
        __initializeWlDisplay();
        __initializeOutputs();
        __initializeBufferManager();
+       __initializeTizenAppinfoMgr();
        __canvas = pub->_onInitialized();
        if (!__canvas) {
                DSLOG_ERR("Compositor", "_onInitialized() fails.");
@@ -147,4 +150,9 @@ void DSCompositorPrivate::__initializeBufferManager()
        __dsBufferManager = DSBufferManager::getInstance();
 }
 
+void DSCompositorPrivate::__initializeTizenAppinfoMgr()
+{
+       __dsAppinfoMgr = DSTizenAppinfoMgr::getInstance();
+}
+
 } // namespace display_server
index 6e21ed8..3f5dc81 100644 (file)
@@ -28,6 +28,7 @@
 #include "DSEventLoop.h"
 #include "IDSDisplayDevice.h"
 #include "DSBufferManager.h"
+#include "DSTizenAppinfoMgr.h"
 
 namespace display_server
 {
@@ -35,6 +36,7 @@ namespace display_server
 class DSSeat;
 class DSInput;
 class DSWaylandCompositor;
+class DSTizenAppinfoMgr;
 
 class DSCompositorPrivate : public DSObjectPrivate
 {
@@ -59,10 +61,12 @@ private:
        std::list<std::shared_ptr<IDSOutput>> __outputList;
        std::shared_ptr<DSCanvas> __canvas;
        DSBufferManager *__dsBufferManager;
+       DSTizenAppinfoMgr * __dsAppinfoMgr;
 
        void __initializeWlDisplay();
        void __initializeOutputs();
        void __initializeBufferManager();
+       void __initializeTizenAppinfoMgr();
 };
 
 }
similarity index 92%
rename from src/DSWaylandExtension/DSTizenAppinfo.cpp
rename to src/DSTizenAppinfo/DSTizenAppinfo.cpp
index f1b2220..905ea02 100644 (file)
 
 namespace display_server
 {
-DSTizenAppinfo::DSTizenAppinfo()
-    : __pid(-1),
-      __base_output_available(false),
-      __base_output_width(0),
-      __base_output_height(0)
-{
-}
-
 DSTizenAppinfo::DSTizenAppinfo(std::string appid)
     : __pid(-1),
       __base_output_available(false),
similarity index 98%
rename from src/DSWaylandExtension/DSTizenAppinfo.h
rename to src/DSTizenAppinfo/DSTizenAppinfo.h
index 76bae93..5eecb93 100644 (file)
@@ -32,7 +32,7 @@ namespace display_server
 class DSTizenAppinfo : public DSObject
 {
 public:
-    DSTizenAppinfo();
+    DSTizenAppinfo() = delete;
     DSTizenAppinfo(std::string appid);
     virtual ~DSTizenAppinfo();
 
diff --git a/src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp b/src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp
new file mode 100644 (file)
index 0000000..356e865
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "DSTizenAppinfoMgr.h"
+#include "DSTizenAppinfoMgrPrivate.h"
+#include "DSWaylandTizenAppinfo.h"
+#include "DSDebugLog.h"
+
+namespace display_server
+{
+
+int DSTizenAppinfoMgr::__refCount { 0 };
+std::mutex DSTizenAppinfoMgr::__mutex;
+DSTizenAppinfoMgr* DSTizenAppinfoMgr::__appinfoMgr { nullptr };
+
+DSTizenAppinfoMgrPrivate::DSTizenAppinfoMgrPrivate(DSTizenAppinfoMgr *p_ptr)
+       : DSObjectPrivate(p_ptr),
+         __p_ptr(p_ptr)
+{
+}
+
+DSTizenAppinfoMgrPrivate::~DSTizenAppinfoMgrPrivate()
+{
+}
+
+std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgrPrivate::getTizenAppinfo(std::string appId)
+{
+    auto it = __appIdMap.find(appId);
+    if (it != __appIdMap.end()) {
+        return it->second;
+    }
+    return nullptr;
+}
+
+std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgrPrivate::getTizenAppinfo(pid_t pid)
+{
+    std::shared_ptr<DSTizenAppinfo> ptr_appinfo;
+    DSTizenAppinfo * appinfo;
+
+    for (auto it = __appIdMap.begin(); it != __appIdMap.end(); it++) {
+        ptr_appinfo = it->second;
+        if (ptr_appinfo == nullptr)
+            continue;
+
+        appinfo = ptr_appinfo.get() ;
+        if ((appinfo) && (appinfo->pid() == pid)) {
+            return ptr_appinfo;
+        }
+    }
+    return nullptr;
+}
+
+std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgrPrivate::addTizenAppinfo(std::string appId)
+{
+    std::shared_ptr<DSTizenAppinfo> appinfo = nullptr;
+
+    appinfo = std::make_shared<DSTizenAppinfo>(appId);
+    if (appinfo != nullptr) {
+        __appIdMap.emplace(appId, appinfo);
+    }
+    return appinfo;
+}
+
+bool DSTizenAppinfoMgrPrivate::removeTizenAppinfo(std::string appId)
+{
+    auto it = __appIdMap.find(appId);
+    if (it != __appIdMap.end()) {
+        __appIdMap.erase(it);
+        return true;
+    }
+    return false;
+}
+
+DSTizenAppinfoMgr::DSTizenAppinfoMgr(DSObject *parent)
+    : DS_INIT_PRIVATE_PTR(DSTizenAppinfoMgr)
+{
+}
+
+DSTizenAppinfoMgr::~DSTizenAppinfoMgr()
+{
+}
+
+DSTizenAppinfoMgr *DSTizenAppinfoMgr::getInstance()
+{
+       std::lock_guard<std::mutex> tLock(__mutex);
+
+       if (!__appinfoMgr && (__refCount == 0))
+       {
+               __appinfoMgr = new DSTizenAppinfoMgr(new DSObject);
+               DSLOG_INF("DSTizenAppinfoMgr",
+                       "DSTizenAppinfoMgr instance has been created !");
+       }
+
+       ++__refCount;
+       return __appinfoMgr;
+}
+
+void DSTizenAppinfoMgr::releaseInstance()
+{
+       std::lock_guard<std::mutex> tLock(__mutex);
+
+       --__refCount;
+       if (__refCount < 0)
+               __refCount = 0;
+
+       if ((0 == __refCount) && __appinfoMgr)
+       {
+               delete __appinfoMgr;
+               __appinfoMgr = nullptr;
+               DSLOG_INF("DSTizenAppinfoMgr",
+                       "DSTizenAppinfoMgr instance has been removed !");
+       }
+}
+
+std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgr::getTizenAppinfo(std::string appId)
+{
+    DS_GET_PRIV(DSTizenAppinfoMgr);
+
+    return priv->getTizenAppinfo(appId);
+}
+
+std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgr::getTizenAppinfo(pid_t pid)
+{
+    DS_GET_PRIV(DSTizenAppinfoMgr);
+
+    return priv->getTizenAppinfo(pid);
+}
+
+std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgr::addTizenAppinfo(std::string appId)
+{
+    DS_GET_PRIV(DSTizenAppinfoMgr);
+
+    std::shared_ptr<DSTizenAppinfo> appinfo = getTizenAppinfo(appId);
+    if (appinfo == nullptr) {
+        appinfo = priv->addTizenAppinfo(appId);
+        DSLOG_INF("DSTizenAppinfoMgr", "New TizenAppinfo(apppId:%s) added", appId.c_str());
+    }
+    else
+        DSLOG_INF("DSTizenAppinfoMgr", "Adding TizenAppinfo(apppId:%s) failed..", appId.c_str());
+    return appinfo;
+}
+
+bool DSTizenAppinfoMgr::removeTizenAppinfo(std::string appId)
+{
+    DS_GET_PRIV(DSTizenAppinfoMgr);
+    bool ret = false;
+
+    ret = priv->removeTizenAppinfo(appId);
+    if (ret)
+        DSLOG_INF("DSTizenAppinfoMgr", "Removing TizenAppinfo(appId:%s) failedd..", appId.c_str());
+    else
+        DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) removed", appId.c_str());
+    return ret;
+}
+
+void DSTizenAppinfoMgr::updateTizenAppinfo(std::string appId, pid_t pid)
+{
+    std::shared_ptr<DSTizenAppinfo> ptr_appinfo;
+    DSTizenAppinfo * appinfo;
+
+    ptr_appinfo = getTizenAppinfo(appId);
+    if (ptr_appinfo == nullptr)
+        return;
+
+    appinfo = ptr_appinfo.get();
+    if (appinfo != nullptr)
+    {
+        appinfo->setPid(pid);
+        DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) set to pid:%d", appId.c_str(), pid);
+    }
+}
+
+bool DSTizenAppinfoMgr::getBaseOutputResolution(pid_t pid, int *res_w, int *res_h)
+{
+    std::shared_ptr<DSTizenAppinfo> ptr_appinfo;
+    DSTizenAppinfo * appinfo;
+
+    ptr_appinfo = getTizenAppinfo(pid);
+    if (ptr_appinfo = nullptr)
+        return false;
+
+    appinfo = ptr_appinfo.get();
+    if (appinfo == nullptr)
+        return false;
+
+    if (!appinfo->base_output_available())
+        return false;
+
+    if (res_w) *res_w = appinfo->base_output_width();
+    if (res_h) *res_h = appinfo->base_output_height();
+    return true;
+}
+
+}
similarity index 77%
rename from src/DSWaylandExtension/DSTizenAppinfoMgr.h
rename to src/DSTizenAppinfo/DSTizenAppinfoMgr.h
index fec3ece..b553a66 100644 (file)
 namespace display_server
 {
 
+class DSTizenAppinfoMgrPrivate;
+
 class DSTizenAppinfoMgr : public DSObject
 {
+DS_PIMPL_USE_PRIVATE(DSTizenAppinfoMgr);
 public:
-    DSTizenAppinfoMgr();
-    virtual ~DSTizenAppinfoMgr();
+    static DSTizenAppinfoMgr *getInstance();
+    static void releaseInstance();
 
     std::shared_ptr<DSTizenAppinfo> getTizenAppinfo(std::string appId);
     std::shared_ptr<DSTizenAppinfo> getTizenAppinfo(pid_t pid);
 
     std::shared_ptr<DSTizenAppinfo> addTizenAppinfo(std::string appId);
 
-    void removeTizenAppinfo(std::string appId);
+    bool removeTizenAppinfo(std::string appId);
 
     void updateTizenAppinfo(std::string appId, pid_t pid);
 
-    int numAppinfo()
-    {
-        return __numAppinfo;
-    };
+    bool getBaseOutputResolution(pid_t pid, int *res_w, int *res_h);
 
 private:
-    DSWaylandCompositor *__wlCompositor;
-    DSWaylandTizenAppinfo *__wlAppinfo;
-    std::unordered_map <std::string, std::shared_ptr<DSTizenAppinfo>> __appIdMap;
-    int __numAppinfo;
+    static std::mutex __mutex;
+    static DSTizenAppinfoMgr *__appinfoMgr;
+    static int __refCount;
+
+    DSTizenAppinfoMgr() = delete;
+    ~DSTizenAppinfoMgr();
+    DSTizenAppinfoMgr(DSObject *parent);
 };
 
 }
diff --git a/src/DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h b/src/DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h
new file mode 100644 (file)
index 0000000..0ac3795
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef _DS_TIZENAPPINFO_MGR_PRIVATE_H_
+#define _DS_TIZENAPPINFO_MGR_PRIVATE_H_
+
+#include "DSTizenAppinfoMgr.h"
+
+namespace display_server
+{
+
+class DSTizenAppinfoMgrPrivate : public DSObjectPrivate
+{
+    DS_PIMPL_USE_PUBLIC(DSTizenAppinfoMgr);
+public:
+    DSTizenAppinfoMgrPrivate() = delete;
+    DSTizenAppinfoMgrPrivate(DSTizenAppinfoMgr *p_ptr);
+    ~DSTizenAppinfoMgrPrivate();
+
+    std::shared_ptr<DSTizenAppinfo> getTizenAppinfo(std::string appId);
+    std::shared_ptr<DSTizenAppinfo> getTizenAppinfo(pid_t pid);
+
+    std::shared_ptr<DSTizenAppinfo> addTizenAppinfo(std::string appId);
+    bool removeTizenAppinfo(std::string appId);
+
+private:
+    std::unordered_map <std::string, std::shared_ptr<DSTizenAppinfo>> __appIdMap;
+
+};
+
+}
+
+#endif
\ No newline at end of file
diff --git a/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp b/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp
deleted file mode 100644 (file)
index c1eed07..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a
-* copy of this software and associated documentation files (the "Software"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#include "DSTizenAppinfoMgr.h"
-#include "DSWaylandTizenAppinfo.h"
-#include "DSDebugLog.h"
-
-namespace display_server
-{
-
-DSTizenAppinfoMgr::DSTizenAppinfoMgr()
-    :__numAppinfo(0)
-{
-    __wlCompositor = DSWaylandCompositor::getInstance();
-    __wlAppinfo = new DSWaylandTizenAppinfo(__wlCompositor, this);
-}
-
-DSTizenAppinfoMgr::~DSTizenAppinfoMgr()
-{
-}
-
-std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgr::getTizenAppinfo(std::string appId)
-{
-    auto it = __appIdMap.find(appId);
-    if (it != __appIdMap.end())
-    {
-        DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo returned by appId:%s", appId.c_str());
-        return it->second;
-    }
-    return nullptr;
-}
-
-std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgr::getTizenAppinfo(pid_t pid)
-{
-    std::unordered_map <std::string, std::shared_ptr<DSTizenAppinfo>>::iterator it;
-    for (it = __appIdMap.begin(); it != __appIdMap.end(); it++) {
-        std::shared_ptr<DSTizenAppinfo> ptr_appinfo = it->second;
-        DSTizenAppinfo * appinfo;
-        appinfo = ptr_appinfo.get() ;
-        if (appinfo->pid() == pid) {
-            DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo returned by pid:%d", pid);
-            return ptr_appinfo;
-        }
-    }
-    return nullptr;
-}
-
-std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgr::addTizenAppinfo(std::string appId)
-{
-    std::shared_ptr<DSTizenAppinfo> appinfo = getTizenAppinfo(appId);
-    if (appinfo == nullptr) {
-        appinfo = std::make_shared<DSTizenAppinfo>(appId);
-        if (appinfo != nullptr)
-        {
-            __appIdMap.emplace(appId, appinfo);
-            __numAppinfo++;
-            DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) added", appId.c_str());
-            return appinfo;
-        }
-    }
-    DSLOG_INF("DSTizenAppinfoMgr", "No TizenAppinfo added by apppId:%s", appId.c_str());
-    return appinfo;
-}
-
-void DSTizenAppinfoMgr::removeTizenAppinfo(std::string appId)
-{
-    auto it = __appIdMap.find(appId);
-    if (it != __appIdMap.end()) {
-        DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) removed", appId.c_str());
-        __appIdMap.erase(it);
-        --__numAppinfo;
-    }
-    return;
-}
-
-void DSTizenAppinfoMgr::updateTizenAppinfo(std::string appId, pid_t pid)
-{
-    std::shared_ptr<DSTizenAppinfo> ptr_appinfo = getTizenAppinfo(appId);
-    DSTizenAppinfo * appinfo;
-    appinfo = ptr_appinfo.get();
-    if (appinfo != nullptr)
-    {
-        appinfo->setPid(pid);
-        DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) set to pid:%d", appId.c_str(), pid);
-    }
-}
-}
index 8a103af..0c27e6c 100644 (file)
@@ -26,7 +26,7 @@
 #include "DSWaylandCompositor.h"
 #include "DSWaylandZxdgShellV6.h"
 #include "DSWaylandTizenPolicy.h"
-#include "DSTizenAppinfoMgr.h"
+#include "DSWaylandTizenAppinfo.h"
 
 
 namespace display_server
@@ -56,7 +56,7 @@ bool DSWaylandExtensionPrivate::init(DSWaylandCompositor *compositor)
        {
                __initShell();
                __initTizenPolicy();
-               __initTizenAppinfoMgr();
+               __initTizenAppinfo();
        }
        catch(const std::runtime_error& e)
        {
@@ -97,10 +97,10 @@ bool DSWaylandExtensionPrivate::__initTizenPolicy(void)
        return true;
 }
 
-bool DSWaylandExtensionPrivate::__initTizenAppinfoMgr(void)
+bool DSWaylandExtensionPrivate::__initTizenAppinfo(void)
 {
-       __tzAppinfoMgr = std::make_shared<DSTizenAppinfoMgr>();
-       if (__tzAppinfoMgr == nullptr)
+       __tzAppinfo = std::make_shared<DSWaylandTizenAppinfo>(__compositor);
+       if (__tzAppinfo == nullptr)
        {
                throw std::runtime_error(__func__);
                return false;
index 50abefd..361082b 100644 (file)
@@ -29,7 +29,7 @@ namespace display_server
 
 class DSWaylandZxdgShellV6;
 class DSWaylandTizenPolicy;
-class DSTizenAppinfoMgr;
+class DSWaylandTizenAppinfo;
 
 class DSWaylandExtensionPrivate : public DSObjectPrivate
 {
@@ -45,13 +45,13 @@ public:
 private:
        bool __initShell(void);
        bool __initTizenPolicy(void);
-       bool __initTizenAppinfoMgr(void);
+       bool __initTizenAppinfo(void);
 
 private:
        DSWaylandCompositor *__compositor;
        std::shared_ptr<DSWaylandZxdgShellV6> __zxdgShell;
        std::shared_ptr<DSWaylandTizenPolicy> __tzPolicy;
-       std::shared_ptr<DSTizenAppinfoMgr> __tzAppinfoMgr;
+       std::shared_ptr<DSWaylandTizenAppinfo> __tzAppinfo;
 
 };
 
index 805d92e..9bbd803 100644 (file)
@@ -79,13 +79,17 @@ void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_get_base_output_resoluti
 {
        DSLOG_DBG("TizenAppinfoPriv", "");
        DS_GET_PUB(DSWaylandTizenAppinfo);
+       bool result;
+       int res_w, res_h;
        if (pub->__dsAppinfoMgr == nullptr)
                return;
 
-       std::shared_ptr<DSTizenAppinfo> ptr_appinfo = pub->__dsAppinfoMgr->getTizenAppinfo(pid);
-       DSTizenAppinfo *appinfo = ptr_appinfo.get();
-       send_base_output_resolution_done(pid, appinfo->base_output_width(), appinfo->base_output_height());
-       DSLOG_DBG("TizenAppinfoPriv", "SEND base_output_resolution_done event with width(%d), height(%d)", appinfo->base_output_width(), appinfo->base_output_height());
+       result = pub->__dsAppinfoMgr->getBaseOutputResolution(pid, &res_w, &res_h);
+       if (!result) {
+               /* TODO: Read configured resolution values */
+       }
+       send_base_output_resolution_done(pid, res_w, res_h);
+       DSLOG_DBG("TizenAppinfoPriv", "SEND base_output_resolution_done event with width(%d), height(%d)", res_w, res_h);
 }
 void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_register_appid(Resource *resource, const std::string &appid)
 {
@@ -116,10 +120,10 @@ void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_ready_metadata(Resource
 DSWaylandTizenAppinfo::DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor)
        : DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo),
          __wlCompositor(wlCompositor),
-         __isCreated(false),
-         __dsAppinfoMgr(nullptr)
+         __isCreated(false)
 {
        this->initialize(__wlCompositor);
+       __dsAppinfoMgr = DSTizenAppinfoMgr::getInstance();
 }
 
 DSWaylandTizenAppinfo::DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor, DSTizenAppinfoMgr *dsAppinfoMgr)
index 0766802..c58f4d5 100644 (file)
@@ -55,10 +55,11 @@ libds_srcs = [
        'DSCore/DSStruct.h',
        'DSCore/DSCore.h',
        'DSWaylandExtension/DSWaylandExtension.cpp',
-       'DSWaylandExtension/DSTizenAppinfo.h',
-       'DSWaylandExtension/DSTizenAppinfo.cpp',
-       'DSWaylandExtension/DSTizenAppinfoMgr.h',
-       'DSWaylandExtension/DSTizenAppinfoMgr.cpp',
+       'DSTizenAppinfo/DSTizenAppinfo.h',
+       'DSTizenAppinfo/DSTizenAppinfo.cpp',
+       'DSTizenAppinfo/DSTizenAppinfoMgr.h',
+       'DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h',
+       'DSTizenAppinfo/DSTizenAppinfoMgr.cpp',
        'DSWindow/DSWindow.h',
        'DSWindow/DSWindowPrivate.h',
        'DSWindow/DSWindow.cpp',
@@ -227,6 +228,7 @@ libds_include_dirs = include_directories(
        './DSClient',
        './DSXkb',
        './DSTextInput',
+       './DSTizenAppinfo',
        )
 
 libds_lib = shared_library(
index c9bdcb1..b893611 100644 (file)
@@ -42,7 +42,8 @@ public:
 
 TEST_F(DSTizenAppinfoTest, NewTizenAppinfo)
 {
-    DSTizenAppinfo *appinfo = new DSTizenAppinfo();
+    std::string appId1{"com.appinfo.first"};
+    DSTizenAppinfo *appinfo = new DSTizenAppinfo(appId1);
     EXPECT_TRUE(appinfo != nullptr);
 
     if (appinfo)
@@ -51,19 +52,18 @@ TEST_F(DSTizenAppinfoTest, NewTizenAppinfo)
 
 TEST_F(DSTizenAppinfoTest, NewTizenAppinfoMgr)
 {
-    DSTizenAppinfoMgr *appinfoMgr = new DSTizenAppinfoMgr();
+    DSTizenAppinfoMgr *appinfoMgr = DSTizenAppinfoMgr::getInstance();
     EXPECT_TRUE(appinfoMgr != nullptr);
 
     if (appinfoMgr)
     {
         std::string appId1{"com.appinfo.first"};
-        std::string appId2{"com.appinfo.econd"};
+        std::string appId2{"com.appinfo.second"};
 
         std::shared_ptr<DSTizenAppinfo> app1 = appinfoMgr->addTizenAppinfo(appId1);
         EXPECT_TRUE(app1 != nullptr);
         std::shared_ptr<DSTizenAppinfo> app2 = appinfoMgr->addTizenAppinfo(appId2);
         EXPECT_TRUE(app2 != nullptr);
-        EXPECT_TRUE(appinfoMgr->numAppinfo() == 2);
 
         std::shared_ptr<DSTizenAppinfo> temp = appinfoMgr->getTizenAppinfo(appId2);
         EXPECT_TRUE(temp != nullptr);
@@ -74,8 +74,6 @@ TEST_F(DSTizenAppinfoTest, NewTizenAppinfoMgr)
         temp = appinfoMgr->getTizenAppinfo(pid);
         appinfoMgr->removeTizenAppinfo(temp->appId());
 
-        EXPECT_TRUE(appinfoMgr->numAppinfo() == 0);
-
-        delete appinfoMgr;
+        DSTizenAppinfoMgr::releaseInstance();
     }
 }