check privilege, and prepare fix touch event prblem
authorjungmin76.park <jungmin76.park@samsung.com>
Fri, 22 Mar 2013 13:23:38 +0000 (22:23 +0900)
committerjungmin76.park <jungmin76.park@samsung.com>
Fri, 22 Mar 2013 13:49:22 +0000 (22:49 +0900)
Change-Id: I8092e15fec0158682f0483dc33fc0e939e67e5b3
Signed-off-by: jungmin76.park <jungmin76.park@samsung.com>
src/FShell_AppWidgetProviderManagerImpl.cpp
src/core/FShellNotificationManager.cpp
src/core/FShellShortcutManager.cpp
src/inc/FShell_AppWidgetProviderManagerImpl.h

index 08761cc..6df029f 100644 (file)
@@ -36,6 +36,7 @@
 #include <FApp_ServiceAppImpl.h>
 #include <FAppPkg_PackageManagerImpl.h>
 #include <FBase_StringConverter.h>
+#include <FSec_AccessController.h>
 
 #include <FShellAppWidgetProviderInfo.h>
 #include <FShellAppWidgetProvider.h>
@@ -61,6 +62,7 @@ using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::App;
 using namespace Tizen::App::Package;
+using namespace Tizen::Security;
 using namespace Tizen::Graphics;
 
 
@@ -93,6 +95,8 @@ _AppWidgetProviderManagerImpl::_AppWidgetProviderManagerImpl()
        ,__pAppWidgetPopupProviderFactory(null)
        ,__pAppWidgetPopupProvider(null)
        ,__AppWidgetPopupTouchEventListener(null)
+       ,__isAppWidgetFrameReady(false)
+       ,__pPendingTouchEvent(null)
 {
        SysLog(NID_APP, "");
 }
@@ -256,11 +260,13 @@ int AddAppWidgetCallback(int ret, int pid, void *data)
 result
 _AppWidgetProviderManagerImpl::AddAppWidget(const Tizen::App::AppId& providerAppId, const Tizen::Base::String& providerName, const Tizen::Base::String& text, const Tizen::Base::String& userInfo)
 {
+       result r = _AccessController::CheckUserPrivilege(_PRV_SHORTCUT_INSTALL);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
        SysTryReturnResult(NID_APP, providerAppId.IsEmpty()==false, E_INVALID_ARG, "The providerAppId is empty.");
        SysTryReturnResult(NID_APP, providerAppId.GetLength() < NATIVE_APP_MAX_APPID_LENGTH, E_INVALID_ARG, "The providerAppId is too long (Maximum %d bytes).", NATIVE_APP_MAX_APPID_LENGTH);
        SysTryReturnResult(NID_APP, Tizen::App::_Aul::IsInstalled(providerAppId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", providerAppId.GetPointer());
 
-       //TODO :: check privilege
        String providerId;
        if( providerAppId.StartsWith(L"com.samsung", 0) == true )
        {
@@ -280,11 +286,8 @@ _AppWidgetProviderManagerImpl::AddAppWidget(const Tizen::App::AppId& providerApp
                providerId = providerAppId + "." + providerName;
        }
 
-
-       result r = E_SUCCESS;
-
        PackageAppInfo* pPackageInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(providerAppId);
-       SysTryReturn(NID_APP, pPackageInfo != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_APP, pPackageInfo != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
 
        String iconPath = pPackageInfo->GetAppMenuIconPath();
        delete pPackageInfo;
@@ -471,7 +474,15 @@ _AppWidgetProviderManagerImpl::HandleAppWidgetRequest(const Tizen::Base::String&
                SysTryReturnResult(NID_APP, pValue, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_Y.GetPointer() );
                Double::Parse(*pValue, y);
 
-               this->ForwardTouchEvent(*pInstanceId, eventType, timeStamp, x, y);
+               if( __isAppWidgetFrameReady == false )
+               {
+                       delete __pPendingTouchEvent;
+                       __pPendingTouchEvent = new PendingTouchEvent(eventType, timeStamp, x, y);
+               }
+               else
+               {
+                       this->ForwardTouchEvent(*pInstanceId, eventType, timeStamp, x, y);
+               }
        }
        SysLog(NID_APP, "Exit");
        return E_SUCCESS;
@@ -743,7 +754,20 @@ _AppWidgetProviderManagerImpl::RequestSyncSharedMemory(const Tizen::Base::String
        _AppWidgetManagerProxy* pProxy = _AppWidgetManagerProxy::GetInstance();
        SysTryReturnResult(NID_APP, pProxy, E_SYSTEM, "Failed to get proxy instance!");
 
-       return pProxy->RequestSyncSharedMemory(instanceId, width, height);
+       result r = pProxy->RequestSyncSharedMemory(instanceId, width, height);
+
+       if( __isAppWidgetFrameReady == false)
+       {
+               __isAppWidgetFrameReady = true;
+               if( __pPendingTouchEvent)
+               {
+                       this->ForwardTouchEvent(instanceId, __pPendingTouchEvent->eventType, __pPendingTouchEvent->timeStamp, __pPendingTouchEvent->x, __pPendingTouchEvent->y);
+                       delete __pPendingTouchEvent;
+                       __pPendingTouchEvent = null;
+               }
+       }
+
+       return r;
 }
 
 result
index d566d07..e0a56dc 100644 (file)
@@ -274,12 +274,16 @@ NotificationManager::NotifyOngoingActivityByAppControl(const Tizen::Base::String
 result
 NotificationManager::AddBadgeEventListener(IBadgeEventListener& listener)
 {
+       SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
        return __pNotificationManagerImpl->AddBadgeEventListener(listener);
 }
 
 result
 NotificationManager::RemoveBadgeEventListener(IBadgeEventListener& listener)
 {
+       SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
        return __pNotificationManagerImpl->RemoveBadgeEventListener(listener);
 }
 
index 3fc18e0..dfad2fd 100644 (file)
 #include <FApp_Types.h>
 #include <FApp_AppInfo.h>
 #include <FBase_StringConverter.h>
+#include <FSec_AccessController.h>
 #include <FShell_ShortcutManagerImpl.h>
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
-
+using namespace Tizen::Security;
 
 namespace Tizen { namespace Shell
 {
@@ -76,6 +77,9 @@ ShortcutManager::Construct()
 result
 ShortcutManager::AddShortcut(const AppId& appId, const String& displayName, const String& iconFilePath, const String& uriData, bool allowDuplication)
 {
+       result r = _AccessController::CheckUserPrivilege(_PRV_SHORTCUT_INSTALL);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
        if( allowDuplication )
        {
                SysLog(NID_APP, "This feature(allowDuplication) is not yet implemented!");
index a9aaf65..cf31f3f 100644 (file)
@@ -101,6 +101,18 @@ private:
        result HandleAppWidgetRequest(const Tizen::Base::String& operationId, const Tizen::Base::Collection::IMap* pArgs);
        result HandleAppWidgetPopupRequest(const Tizen::Base::String& operationId, const Tizen::Base::Collection::IMap* pArgs);
 
+       struct PendingTouchEvent
+       {
+       public:
+               PendingTouchEvent(int eventType, double timeStamp, double       x, double       y)
+                : eventType(eventType), timeStamp(timeStamp), x(x), y(y) {  }
+
+               int eventType;
+               double  timeStamp;
+               double  x;
+               double  y;
+       };
+
 private:
        // for AppWidget
        IAppWidgetProviderFactory* __pAppWidgetFactory;
@@ -112,7 +124,8 @@ private:
        AppWidgetPopupProvider* __pAppWidgetPopupProvider;
        _IAppWidgetTouchEventListener* __AppWidgetPopupTouchEventListener;
 
-//     bool __messageReceived;
+       bool __isAppWidgetFrameReady;
+       PendingTouchEvent* __pPendingTouchEvent;
 };
 
 }} // Tizen::Shell