From 709ff4abb008a6c1037b6b5df44ca8057f4a4be1 Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Mon, 7 Jan 2013 22:21:56 +0900 Subject: [PATCH] apply appcontrol change Change-Id: Ia0aad8b0324ecf25d74ca1bff8f9dbbd41d6c337 Signed-off-by: jungmin76.park --- inc/FShell_Livebox.h | 2 +- inc/FShell_LiveboxBase.h | 14 +++---- inc/FShell_LiveboxPopup.h | 2 +- src/FShell_Livebox.cpp | 68 ++++++++++++++++------------------ src/FShell_LiveboxBase.cpp | 72 +++++++++++++++++++++++------------- src/FShell_LiveboxManagerService.cpp | 19 ++-------- src/FShell_LiveboxPopup.cpp | 20 ++++------ 7 files changed, 98 insertions(+), 99 deletions(-) diff --git a/inc/FShell_Livebox.h b/inc/FShell_Livebox.h index 7a01fb2..8e5ee1d 100644 --- a/inc/FShell_Livebox.h +++ b/inc/FShell_Livebox.h @@ -68,7 +68,7 @@ private: result SendResizeRequest(int width, int height); result SendRemoveRequest(); - result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::ArrayList* pArgs); + result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); diff --git a/inc/FShell_LiveboxBase.h b/inc/FShell_LiveboxBase.h index 66770d2..47aaec4 100644 --- a/inc/FShell_LiveboxBase.h +++ b/inc/FShell_LiveboxBase.h @@ -12,9 +12,8 @@ #include #include -#include +#include -#define TEST_MODE_ENABLE false // If this is enabled, appId of Livebox will be fixed to "EOE7JEjMWn.SampleLiveboxApp" for easy test #define LIVEBOX_PROVIDER_ID_ENABLE true typedef struct _bundle_t bundle;//TODO move code to osp-appfw @@ -26,7 +25,7 @@ class _LiveboxBase: public Tizen::Base::Object { public: - _LiveboxBase(target_type type, const Tizen::Base::String& info, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int priority); + _LiveboxBase(target_type type, const Tizen::Base::String& userInfo, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int priority); virtual ~_LiveboxBase(); virtual void OnPopupCreated(int width, int height) = 0; @@ -42,11 +41,12 @@ public: protected: - result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::ArrayList* pArgs); + Tizen::Base::Collection::HashMap* CreateRequestArgs(void); + result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); public: target_type __type; - Tizen::Base::String __info; + Tizen::Base::String __userInfo; Tizen::Base::String __appId; Tizen::Base::String __providerName; Tizen::Base::String __providerId; @@ -66,8 +66,8 @@ protected: class _LiveboxRequestHelper { public: - static result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::ArrayList* pArgs); - static result AddStrArrayToBundle(bundle* b, const char* key, const Tizen::Base::Collection::IList* pList); + static result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); +// static result AddStrArrayToBundle(bundle* b, const char* key, const Tizen::Base::Collection::IList* pList); // static result ExtractPackageIdAndExecutableName(Tizen::App::AppId inAppId, Tizen::Base::String& outPackageId, Tizen::Base::String& outExecutableName); }; diff --git a/inc/FShell_LiveboxPopup.h b/inc/FShell_LiveboxPopup.h index b93d26e..03f791a 100644 --- a/inc/FShell_LiveboxPopup.h +++ b/inc/FShell_LiveboxPopup.h @@ -17,7 +17,7 @@ class _LiveboxPopup :public Tizen::Shell::App::_LiveboxBase { public: - _LiveboxPopup(const Tizen::Base::String& info, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int priority); + _LiveboxPopup(const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int priority); virtual ~_LiveboxPopup(); // event handler diff --git a/src/FShell_Livebox.cpp b/src/FShell_Livebox.cpp index 181ec3d..31807b2 100644 --- a/src/FShell_Livebox.cpp +++ b/src/FShell_Livebox.cpp @@ -47,6 +47,13 @@ const String LIVEBOX_ON_UPDATE(L"Livebox='event=update'"); const String LIVEBOX_ON_RESIZE(L"Livebox='event=resize'"); const String LIVEBOX_ON_TOUCH(L"Livebox='event=touch'"); +const String ARG_KEY_WIDTH = L"_Width"; +const String ARG_KEY_HEIGHT = L"_Height"; +const String ARG_KEY_EVENT_TYPE = L"_EventType"; +const String ARG_KEY_TIME_STAMP = L"_TimeStamp"; +const String ARG_KEY_X = L"_X"; +const String ARG_KEY_Y = L"_Y"; + const int LIVE_DURATION_MSEC= 30000;//30sec _Livebox::_Livebox(const String& info, const String& providerId, const String& instanceId, int width, int height, int period, int priority) @@ -130,7 +137,7 @@ _Livebox::OnBackground() void _Livebox::OnPopupCreated(int width, int height) { - __pLiveboxPopup = new (std::nothrow) _LiveboxPopup(__info, __providerId, __instanceId, width, height, __priority); + __pLiveboxPopup = new (std::nothrow) _LiveboxPopup(__userInfo, __providerId, __instanceId, width, height, __priority); __pLiveboxPopup->SetClientId(__ipcClientId); __pLiveboxPopup->OnPopupCreated(width, height); @@ -155,13 +162,18 @@ _Livebox::OnPopupDestoyed(void) result _Livebox::SendAddRequest(int width, int height) { - std::unique_ptr pArgs (new (std::nothrow) ArrayList); +/* std::unique_ptr pArgs (new (std::nothrow) ArrayList); pArgs->Construct(); pArgs->Add(*new String(__instanceId)); pArgs->Add(*new String(__providerId)); pArgs->Add(*new String(__info)); pArgs->Add(*new String(Integer::ToString(width))); - pArgs->Add(*new String(Integer::ToString(height))); + pArgs->Add(*new String(Integer::ToString(height)));*/ + + std::unique_ptr pArgs (CreateRequestArgs() ); + + pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(width))); + pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(height))); return SendRequestToApp( __appId, LIVEBOX_ON_ADD, pArgs.get()); } @@ -169,13 +181,10 @@ _Livebox::SendAddRequest(int width, int height) result _Livebox::SendUpdateRequest(int width, int height) { - std::unique_ptr pArgs (new (std::nothrow) ArrayList); - pArgs->Construct(); - pArgs->Add(*new String(__instanceId)); - pArgs->Add(*new String(__providerId)); - pArgs->Add(*new String(__info)); - pArgs->Add(*new String(Integer::ToString(width))); - pArgs->Add(*new String(Integer::ToString(height))); + std::unique_ptr pArgs (CreateRequestArgs() ); + + pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(width))); + pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(height))); return SendRequestToApp( __appId, LIVEBOX_ON_UPDATE, pArgs.get()); } @@ -183,13 +192,10 @@ _Livebox::SendUpdateRequest(int width, int height) result _Livebox::SendResizeRequest(int width, int height) { - std::unique_ptr pArgs (new (std::nothrow) ArrayList); - pArgs->Construct(); - pArgs->Add(*new String(__instanceId)); - pArgs->Add(*new String(__providerId)); - pArgs->Add(*new String(__info)); - pArgs->Add(*new String(Integer::ToString(width))); - pArgs->Add(*new String(Integer::ToString(height))); + std::unique_ptr pArgs (CreateRequestArgs() ); + + pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(width))); + pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(height))); return SendRequestToApp( __appId, LIVEBOX_ON_RESIZE, pArgs.get()); } @@ -197,11 +203,7 @@ _Livebox::SendResizeRequest(int width, int height) result _Livebox::SendRemoveRequest() { - std::unique_ptr pArgs (new (std::nothrow) ArrayList); - pArgs->Construct(); - pArgs->Add(*new String(__instanceId)); - pArgs->Add(*new String(__providerId)); - pArgs->Add(*new String(__info)); + std::unique_ptr pArgs (CreateRequestArgs() ); return SendRequestToApp( __appId, LIVEBOX_ON_REMOVE, pArgs.get()); } @@ -212,16 +214,12 @@ _Livebox::SendTouchEvent(buffer_event event, double timestamp, double x, double SysLog(NID_APP, ""); if( HasValidClientId() == false ) { - std::unique_ptr pArgs (new (std::nothrow) ArrayList); - pArgs->Construct(); - pArgs->Add(*new String(__instanceId)); - pArgs->Add(*new String(__providerId)); - pArgs->Add(*new String(__info)); + std::unique_ptr pArgs (CreateRequestArgs() ); - pArgs->Add(*new String(Integer::ToString(event))); - pArgs->Add(*new String(Double::ToString(timestamp))); - pArgs->Add(*new String(Double::ToString(x))); - pArgs->Add(*new String(Double::ToString(y))); + pArgs->Add(new String(ARG_KEY_EVENT_TYPE), new String(Integer::ToString(event))); + pArgs->Add(new String(ARG_KEY_TIME_STAMP), new String(Double::ToString(timestamp))); + pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x))); + pArgs->Add(new String(ARG_KEY_Y), new String(Double::ToString(y))); return SendRequestToApp( __appId, LIVEBOX_ON_TOUCH, pArgs.get()); } @@ -234,7 +232,7 @@ _Livebox::SendTouchEvent(buffer_event event, double timestamp, double x, double } result -_Livebox::SendRequestToApp(const AppId& appId, const String& operation, ArrayList* pArgs) +_Livebox::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) { result r = _LiveboxBase::SendRequestToApp(appId, operation, pArgs); RestartLifeDurationTimer(); @@ -252,7 +250,7 @@ _Livebox::RequestUpdateRemote(int width, int height) }*/ std::unique_ptr packageName(_StringConverter::CopyToCharArrayN(__providerId)); std::unique_ptr id(_StringConverter::CopyToCharArrayN(__instanceId)); - std::unique_ptr content_info(_StringConverter::CopyToCharArrayN(__info)); + std::unique_ptr content_info(_StringConverter::CopyToCharArrayN(__userInfo)); int ret = provider_send_updated(packageName.get(), id.get(), width, height, __priority, content_info.get(), null); SysTryReturnResult(NID_APP, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated"); @@ -278,11 +276,7 @@ _Livebox::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) { SysLog(NID_APP, "lifeDuration timer is expired, so terminating livebox app(%ls)..", __providerId.GetPointer() ); -#if TEST_MODE_ENABLE - AppManager::GetInstance()->TerminateApplication(L"EOE7JEjMWn.SampleLiveboxApp");//todo remove this -#else AppManager::GetInstance()->TerminateApplication(__appId); -#endif } else if( &timer == &__UpdateTimer) { diff --git a/src/FShell_LiveboxBase.cpp b/src/FShell_LiveboxBase.cpp index c328fb1..f8d6916 100644 --- a/src/FShell_LiveboxBase.cpp +++ b/src/FShell_LiveboxBase.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -88,10 +89,14 @@ const String LIVEBOX_TRAY_ON_CREATE(L"LiveboxTray='event=create'"); const String LIVEBOX_TRAY_ON_DESTROY(L"LiveboxTray='event=destroy'"); const String LIVEBOX_TRAY_ON_TOUCH(L"LiveboxTray='event=touch'"); +const String ARG_KEY_INSTANCE_ID = L"_InstanceId"; +const String ARG_KEY_PROVIDER_NAME = L"_ProviderName"; +const String ARG_KEY_USER_INFO = L"_UserInfo"; -_LiveboxBase::_LiveboxBase(target_type type, const String& info, const String& providerId, const String& instanceId, int width, int height, int priority) + +_LiveboxBase::_LiveboxBase(target_type type, const String& userInfo, const String& providerId, const String& instanceId, int width, int height, int priority) :__type(type) - ,__info(info) + ,__userInfo(userInfo) ,__providerId(providerId) ,__instanceId(instanceId) ,__width(width) @@ -102,13 +107,9 @@ _LiveboxBase::_LiveboxBase(target_type type, const String& info, const String& p ,__isForeground(true) ,__ipcClientId(-1) { - /*providerId.IndexOf(".", 11, index); - providerId.SubString(0, index, __appId); - providerId.SubString(index+1, __providerName);*/ _LiveboxManagerImpl::ExtractAppIdAndProviderName(providerId, __appId, __providerName); - SysLog(NID_APP, "providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority); - SysLog(NID_APP, "appId(%ls)", __appId.GetPointer()); + SysLog(NID_APP, "appId(%ls), providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __appId.GetPointer(), __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority); } _LiveboxBase::~_LiveboxBase() @@ -182,8 +183,20 @@ _LiveboxBase::ReleaseSharedMem() return E_SUCCESS; } +Tizen::Base::Collection::HashMap* +_LiveboxBase::CreateRequestArgs(void) +{ + HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter); + pArgs->Construct(); + pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(__instanceId)); + pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(__providerName)); + pArgs->Add(new String(ARG_KEY_USER_INFO), new String(__userInfo)); + + return pArgs; +} + result -_LiveboxBase::SendRequestToApp(const AppId& appId, const String& operation, ArrayList* pArgs) +_LiveboxBase::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) { if( __isForeground == false) { @@ -191,35 +204,42 @@ _LiveboxBase::SendRequestToApp(const AppId& appId, const String& operation, Arra return E_SUCCESS; } -#if TEST_MODE_ENABLE - const String sampleLiveboxAppId(L"EOE7JEjMWn.SampleLiveboxApp"); //TODO: specify appid for temporary test - return _LiveboxRequestHelper::SendRequestToApp(sampleLiveboxAppId, operation, pArgs); -#else return _LiveboxRequestHelper::SendRequestToApp(appId, operation, pArgs); -#endif - } result -_LiveboxRequestHelper::SendRequestToApp(const AppId& appId, const String& operation, ArrayList* pArgs) +_LiveboxRequestHelper::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) { - SysLog(NID_APP, "operation(%ls)", operation.GetPointer()); + SysLog(NID_APP, "appId(%ls), operation(%ls), arg count(%d)", appId.GetPointer(), operation.GetPointer(), pArgs->GetCount() ); - String outAppId; - String execName; +/* std::unique_ptr pMapEnum(pArgs->GetMapEnumeratorN()); + SysTryReturnResult(NID_APP, pMapEnum.get(), E_SYSTEM, "failed to get GetMapEnumeratorN"); -// ExtractPackageIdAndExecutableName(appId, outAppId, execName); + while( pMapEnum->MoveNext() == E_SUCCESS) + { + const String* pKey = dynamic_cast(pMapEnum->GetKey()); + const String* pValue = dynamic_cast(pMapEnum->GetValue()); - const char OSP_K_APPCONTROL_OPERATION[] = "__OSP_APPCONTROL_OPERATION__"; - const char OSP_K_APPCONTROL_INTERNAL_OPERATION[] = "__OSP_APPCONTROL_INTERNAL_INTERNAL_OPERATION__"; - const char OSP_K_ARG[] = "__OSP_ARGS__"; + if( pKey == null) + { + SysLog(NID_APP, "key is null"); + continue; + } + if( pValue == null) + { + SysLog(NID_APP, "pValue is null"); + continue; + } + + SysLog(NID_APP, "key(%ls), value(%ls)", pKey->GetPointer(), pValue->GetPointer() ); + + }*/ _AppMessageImpl msg; - msg.AddData(OSP_K_APPCONTROL_OPERATION, operation); msg.AddData(OSP_K_APPCONTROL_INTERNAL_OPERATION, L"livebox"); - AddStrArrayToBundle(msg.GetBundle(), OSP_K_ARG, pArgs); - + // AddStrArrayToBundle(msg.GetBundle(), OSP_K_ARG, pArgs); + Tizen::App::_AppArg::AddStrMap(msg.GetBundle(), pArgs); std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId) ); std::unique_ptr pOperation(_StringConverter::CopyToCharArrayN(operation) ); @@ -244,6 +264,7 @@ _LiveboxRequestHelper::ExtractPackageIdAndExecutableName(AppId appId, AppId& out return E_SYSTEM; }*/ +/* // helper for bundle result _LiveboxRequestHelper::AddStrArrayToBundle(bundle* b, const char* key, const IList* pList) @@ -289,6 +310,7 @@ _LiveboxRequestHelper::AddStrArrayToBundle(bundle* b, const char* key, const ILi return r; } +*/ } } } // Tizen::Shell::App { diff --git a/src/FShell_LiveboxManagerService.cpp b/src/FShell_LiveboxManagerService.cpp index cdd6e43..023cee5 100644 --- a/src/FShell_LiveboxManagerService.cpp +++ b/src/FShell_LiveboxManagerService.cpp @@ -160,12 +160,7 @@ LiveboxManagerService::SetClientIds(const Tizen::App::AppId& appId, int clientId SysLog(NID_APP, "%ls", pLivebox->__instanceId.GetPointer()); SysLog(NID_APP, "%ls, %ls", pLivebox->__providerId.GetPointer(), appId.GetPointer()); -#if TEST_MODE_ENABLE - String sampleAppId = L"EOE7JEjMWn.SampleLiveboxApp"; - if( sampleAppId == appId) //TODO: specify appid for temporary test -#else if ( pLivebox->__appId == appId ) -#endif { pLivebox->SetClientId(clientId); SysLog(NID_APP, "client is registered.(%d)", clientId); @@ -295,12 +290,7 @@ LiveboxManagerService::UpdateAllLiveboxesByAppId(const String& providerId) _Livebox* pLivebox = null; __liveboxes.GetAt(i, pLivebox); -#if TEST_MODE_ENABLE - String sampleAppId = L"EOE7JEjMWn.SampleLiveboxApp"; - if( sampleAppId == appId) //TODO: specify appid for temporary test -#else if ( pLivebox->__providerId == providerId ) -#endif { pLivebox->OnUpdate(); } @@ -474,14 +464,13 @@ LiveboxManagerService::DeinitializeMasterDaemonEventReceiver() result LiveboxManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName)//, const Tizen::Base::String& param) { - SysLog(NID_APP, "Enter."); + SysLog(NID_APP, "%ls, %ls", appId.GetPointer(), providerName.GetPointer() ); bool found = false; for( int i = 0; i < __liveboxes.GetCount(); i++ ) { _Livebox* pLivebox = null; __liveboxes.GetAt(i, pLivebox); - SysLog(NID_APP, "%ls", pLivebox->__instanceId.GetPointer()); if ( pLivebox->__appId == appId && pLivebox->__providerName == providerName) { @@ -497,7 +486,6 @@ LiveboxManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tizen SysTryLog(NID_APP, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r)); found = true; -// pLivebox->OnUpdate(); } } SysLog(NID_APP, "Exit."); @@ -604,11 +592,10 @@ LiveboxManagerService::_TaskHandlerThread::OnUserEventReceivedN(RequestId reqId, case LOCAL_EVENT_REQUEST_UPDATE: { _Livebox* pLivebox = dynamic_cast<_Livebox*>( pArgs->GetAt(0) ); - SysLog(NID_APP, "111."); SysTryReturnVoidResult(NID_APP, pLivebox != null, E_INVALID_STATE, "_Livebox is null!."); - SysLog(NID_APP, "222."); + pLivebox->OnUpdate(); - SysLog(NID_APP, "333."); + pArgs->RemoveAll(); delete pArgs; } diff --git a/src/FShell_LiveboxPopup.cpp b/src/FShell_LiveboxPopup.cpp index c144030..559968b 100644 --- a/src/FShell_LiveboxPopup.cpp +++ b/src/FShell_LiveboxPopup.cpp @@ -40,6 +40,10 @@ const String LIVEBOX_TRAY_ON_CREATE(L"LiveboxTray='event=create'"); const String LIVEBOX_TRAY_ON_DESTROY(L"LiveboxTray='event=destroy'"); const String LIVEBOX_TRAY_ON_TOUCH(L"LiveboxTray='event=touch'"); +const String ARG_KEY_WIDTH = L"_Width"; +const String ARG_KEY_HEIGHT = L"_Height"; + + _LiveboxPopup::_LiveboxPopup(const String& info, const String& appId, const String& instanceId, int width, int height, int priority) :_LiveboxBase(TYPE_PD, info, appId, instanceId, width, height, priority) { @@ -69,14 +73,10 @@ _LiveboxPopup::OnPopupDestoyed() result _LiveboxPopup::SendPopupCreateRequest(int width, int height) { - std::unique_ptr pArgs (new (std::nothrow) ArrayList); - pArgs->Construct(); - pArgs->Add(*new String(__instanceId)); - pArgs->Add(*new String(__providerId)); - pArgs->Add(*new String(__info)); + std::unique_ptr pArgs (CreateRequestArgs() ); - pArgs->Add(*new String(Integer::ToString(width))); - pArgs->Add(*new String(Integer::ToString(height))); + pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(width))); + pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(height))); return SendRequestToApp( __appId, LIVEBOX_TRAY_ON_CREATE, pArgs.get()); } @@ -84,11 +84,7 @@ _LiveboxPopup::SendPopupCreateRequest(int width, int height) result _LiveboxPopup::SendPopupDestroyRequest() { - std::unique_ptr pArgs (new (std::nothrow) ArrayList); - pArgs->Construct(); - pArgs->Add(*new String(__instanceId)); - pArgs->Add(*new String(__providerId)); - pArgs->Add(*new String(__info)); + std::unique_ptr pArgs (CreateRequestArgs() ); return SendRequestToApp( __appId, LIVEBOX_TRAY_ON_DESTROY, pArgs.get()); } -- 2.7.4