--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target osp-livebox-service)
+SET (PACKAGEID gi2qxenosh)
+
+SET(CMAKE_EXECUTABLE_SUFFIX ".exe")
+SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/output")
+
+INCLUDE_DIRECTORIES (
+ /usr/include/glib-2.0
+ /usr/lib/glib-2.0/include
+ /usr/include/provider
+ /usr/include/appfw
+ /usr/include/aul
+ /usr/include/osp
+ /usr/include/osp/app
+ /usr/include/osp/base
+ /usr/include/osp/io
+ /usr/include/osp/system
+ /usr/include/osp/security
+ /usr/include/osp/shell
+ /usr/include/osp/server
+ /usr/include/chromium
+ inc
+ )
+
+SET (${this_target}_SOURCE_FILES
+ src/OspAppWidgetService.cpp
+ src/OspAppWidgetServiceEntry.cpp
+ src/FShell_AppWidgetContext.cpp
+ src/FShell_AppWidgetContextBase.cpp
+ src/FShell_AppWidgetManagerService.cpp
+ src/FShell_AppWidgetManagerStub.cpp
+ src/FShell_AppWidgetPopupContext.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE -Wall -pthread -g3" )
+#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fstack-protector -Wstack-protector" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+SET(CMAKE_SKIP_BUILD_RPATH FALSE)
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+SET(CMAKE_INSTALL_RPATH "/usr/lib/osp-server")
+SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
+
+## Create Library
+ADD_EXECUTABLE (${this_target} ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker --as-needed -pie)
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --version-script=${CMAKE_CURRENT_SOURCE_DIR}/system-service-export.ver)
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw -lchromium -lprovider -losp-shell -lbundle")
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp-server -losp-appfw-server")
+
+
+## Cory additional info
+INSTALL(TARGETS ${this_target} DESTINATION ../usr/apps/${PACKAGEID}/bin)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/manifest.xml DESTINATION ../usr/apps/${PACKAGEID}/info)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data DESTINATION ../usr/apps/${PACKAGEID})
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ../usr/apps/${PACKAGEID}/data FILES_MATCHING PATTERN "*.ini")
+
+
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
--- /dev/null
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetContext.h
+ * @brief This is the header file for the _AppWidgetContext class.
+ *
+ * This header file contains the declarations of the _AppWidgetContext class.
+ */
+
+#ifndef _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_
+#define _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_
+
+#include <provider.h>
+#include <provider_buffer.h>
+
+#include <FAppTypes.h>
+#include <FBaseRtTimer.h>
+#include <FBaseObject.h>
+#include <FBaseColArrayList.h>
+
+#include "FShell_AppWidgetContextBase.h"
+
+
+#define MAX_PACKAGENAME 512
+
+
+namespace Tizen { namespace Shell { namespace App
+{
+class _AppWidgetPopupContext;
+
+class _AppWidgetContext
+ : public _AppWidgetContextBase
+ ,public Tizen::Base::Runtime::ITimerEventListener
+{
+public:
+ _AppWidgetContext(const Tizen::Base::String& name, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId,
+ int width, int height, int period, int priority);
+ virtual ~_AppWidgetContext();
+ void OnAdded(void);
+ void OnUpdate(const Tizen::Base::String& argument);
+ void OnResize(int width, int height);
+ void OnRemoved();
+ void OnForeground();
+ void OnBackground();
+ virtual void OnPopupCreated(double x, double y, int width, int height);
+ virtual void OnPopupDestoyed(void);
+
+ result RequestUpdateRemote(int width, int height);
+
+ _AppWidgetPopupContext* GetAppWidgetPopup() const;
+ virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y);
+
+ void RestartLifeDurationTimer();
+
+private:
+ result SendAddRequest(int width, int height);
+ result SendUpdateRequest(int width, int height, const Tizen::Base::String& argument);
+ result SendResizeRequest(int width, int height);
+ result SendRemoveRequest();
+
+ 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);
+
+private:
+ _AppWidgetPopupContext* __pAppWidgetPopup;
+ Tizen::Base::Runtime::Timer __lifeDurationTimer;
+ Tizen::Base::Runtime::Timer __UpdateTimer;
+ int __UpdateMillis;
+
+};
+
+
+} } } // Tizen::Shell::App {
+
+
+#endif // _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetContextBase.h
+ * @brief This is the header file for the _AppWidgetContextBase class.
+ *
+ * This header file contains the declarations of the _AppWidgetContextBase class.
+ */
+
+#ifndef _FSHELL_INTERNAL_APPWIDGET_CONTEXT_BASE_H_
+#define _FSHELL_INTERNAL_APPWIDGET_CONTEXT_BASE_H_
+
+#include <provider.h>
+
+#include <FAppTypes.h>
+#include <FBaseObject.h>
+#include <FBaseColHashMap.h>
+
+#define APPWIDGET_PROVIDER_ID_ENABLE true
+
+typedef struct _bundle_t bundle;//TODO move code to osp-appfw
+
+namespace Tizen { namespace Shell { namespace App
+{
+
+class _AppWidgetContextBase:
+ public Tizen::Base::Object
+{
+public:
+ _AppWidgetContextBase(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 ~_AppWidgetContextBase();
+
+ virtual void OnPopupCreated(double x, double y, int width, int height) = 0;
+ virtual void OnPopupDestoyed(void) = 0;
+
+ virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y) = 0;
+
+ void SetClientId(int clientId);
+ bool HasValidClientId() const;
+ // for buffered appWidget
+ int GetSharedMemId(int w, int h);
+ result ReleaseSharedMem();
+
+
+protected:
+ 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 __userInfo;
+ Tizen::Base::String __appId;
+ Tizen::Base::String __providerName;
+ Tizen::Base::String __providerId;
+ Tizen::Base::String __instanceId;
+ int __width;
+ int __height;
+ int __priority;
+
+protected:
+ bool __isForeground;// LB only?
+ int __ipcClientId;
+
+private:
+ struct livebox_buffer *__buffer_info;
+ void *__buffer;
+};
+
+class _AppWidgetRequestHelper
+{
+public:
+ 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);
+};
+
+} /* namespace App */
+} /* namespace AppWidget */
+} /* namespace Samsung */
+#endif // _FSHELL_INTERNAL_APPWIDGET_CONTEXT_BASE_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetManagerService.h
+ * @brief This is the header file for the %AppWidgetManagerService class.
+ *
+ * This header file contains the declarations of the %AppWidgetManagerService class.
+ */
+
+#ifndef _FSHELL_INTERNAL_APPWIDGET_MANAGER_SERVICE_H_
+#define _FSHELL_INTERNAL_APPWIDGET_MANAGER_SERVICE_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseRtTimer.h>
+#include <FBaseColArrayListT.h>
+
+#include "FShell_AppWidgetContext.h"
+#include "FShell_AppWidgetManagerStub.h"
+
+namespace Tizen { namespace Shell { namespace App {
+
+
+class AppWidgetManagerService
+ :public Tizen::Shell::App::_AppWidgetManagerStub
+ ,public Tizen::Base::Runtime::ITimerEventListener
+{
+public:
+ static AppWidgetManagerService* GetInstance(void);
+ result AddAppWidget(_AppWidgetContext* pAppWidget);
+ result RemoveAppWidget(const char* pPackageName, const char* pId, bool free);
+
+private:
+ result Construct();
+ result InitializeMasterDaemonEventReceiver(const char* pServiceExecutableName);
+ result DeinitializeMasterDaemonEventReceiver(void);
+
+ // master daemon callbacks
+ static int AppWidgetConnected(struct event_arg *arg, void* data);
+ static int AppWidgetDisconnected(struct event_arg *arg, void* data);
+ static int OnAppWidgetCreate(struct event_arg *arg, int *width, int *height, double *priority, void* data);
+ static int OnAppWidgetDestroy(struct event_arg *arg, void* data);
+ static int OnAppWidgetUpdate(struct event_arg *arg, void* data);
+ static int OnAppWidgetPopupCreate(struct event_arg *arg, void* data);
+ static int OnAppWidgetPopupDestroy(struct event_arg *arg, void* data);
+ static int OnLivePause(struct event_arg *arg, void* data);
+ static int OnAppWidgetResume(struct event_arg *arg, void* data);
+ static int OnAppWidgetClick(struct event_arg *arg, void* data);
+ static int OnAppWidgetResize(struct event_arg *arg, void* data);
+ static int OnAppWidgetPeriodChaned(struct event_arg *arg, void* data);
+
+ // stub implementations
+ virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument);
+ virtual result RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument);
+ virtual result RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& shmId);
+ virtual result RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& shmId);
+ virtual result RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height);
+ virtual result RequestSyncSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId);
+ virtual result RequestReleaseSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId);
+ virtual result RequestReleaseSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId);
+
+ // internal functions
+ AppWidgetManagerService();
+ virtual ~AppWidgetManagerService();
+
+ virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
+ virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId);
+
+ // helpers
+ result SetClientIds(const Tizen::App::AppId& appId, int clientId);
+ int UpdateAllAppWidgetsByAppId(const Tizen::Base::String& appId);
+
+ void StartPingTimer();
+ virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+ _AppWidgetContext* Find(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) const;
+
+
+ class _TaskHandlerThread
+ : public Tizen::Base::Runtime::Thread
+ {
+ public:
+ virtual ~_TaskHandlerThread(void);
+ virtual void OnUserEventReceivedN(RequestId reqId, Tizen::Base::Collection::IList* pArgs);
+
+ };
+
+private:
+ Tizen::Base::Collection::ArrayListT<_AppWidgetContext*> __appWidgetContextList;
+ Tizen::Base::Runtime::Timer __pingTimer;
+ _TaskHandlerThread __handlerThread;
+};
+
+} } } // Tizen::Shell::App {
+
+#endif // _FSHELL_INTERNAL_APPWIDGET_MANAGER_SERVICE_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetManagerStub.h
+ * @brief This is the header file for the %_AppWidgetManagerStub class.
+ *
+ * This header file contains the declarations of the %_AppWidgetManagerStub class.
+ */
+
+#ifndef _FSHELL_INTERNAL_APPWIDGET_MANAGER_STUB_H_
+#define _FSHELL_INTERNAL_APPWIDGET_MANAGER_STUB_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseRtIEventListener.h>
+#include <FSystem.h>
+#include <FIo.h>
+
+#include <FIo_IIpcServerEventListener.h>
+//#include <FApp_IAppManager.h>
+
+
+namespace Tizen { namespace Shell { namespace App {
+
+/**
+ * @class _AppWidgetManagerStub
+ * @brief Handles IPC requests and calls real methods.
+ * @since 2.1
+ */
+class _AppWidgetManagerStub
+ : public Tizen::Base::Object
+ , public Tizen::Io::_IIpcServerEventListener
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+ bool SendTouchEvent(const int clientId, const Tizen::Base::String& instanceId, int eventType, double timestamp, double x, double y);
+ bool SendTouchEventForPD(const int clientId, const Tizen::Base::String& instanceId, int eventType, double timestamp, double x, double y);
+
+protected:
+ _AppWidgetManagerStub(void);
+ virtual ~_AppWidgetManagerStub(void);
+
+ // handlers
+ bool OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument, result* pRes);
+ bool OnRequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument, result* pRes);
+ bool OnRequestSharedMemoryId(const Tizen::Base::String& instanceId, int width, int height, int* pShmId);
+ bool OnRequestSharedMemoryIdForPD(const Tizen::Base::String& instanceId, int width, int height, int* pShmId);
+ bool OnRequestSyncSharedMemory(const Tizen::Base::String& instanceId, int width, int height, result* pRes);
+ bool OnRequestSyncSharedMemoryForPD(const Tizen::Base::String& instanceId, result* pRes);
+ bool OnRequestReleaseSharedMemory(const Tizen::Base::String& instanceId, result* pRes);
+ bool OnRequestReleaseSharedMemoryForPD(const Tizen::Base::String& instanceId, result* pRes);
+
+ // interface to service
+ virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument) = 0;
+ virtual result RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument) = 0;
+ virtual result RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId) = 0;
+ virtual result RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId) = 0;
+ virtual result RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height) = 0;
+ virtual result RequestSyncSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0;
+ virtual result RequestReleaseSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0;
+ virtual result RequestReleaseSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0;
+
+ // _IIpcServerEventListener
+ virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server);
+ virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server);
+ virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
+ virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId);
+ virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
+
+ result StartIpcServer(void);
+
+private:
+ _AppWidgetManagerStub(const _AppWidgetManagerStub& value);
+ _AppWidgetManagerStub& operator =(const _AppWidgetManagerStub& source);
+
+
+protected:
+ Tizen::Io::_IpcServer *__pIpcServer;
+}; //_AppWidgetManagerStub
+
+}}}
+
+#endif//_FSHELL_INTERNAL_APPWIDGET_MANAGER_STUB_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetPopupContext.h
+ * @brief This is the header file for the %_AppWidgetPopupContext class.
+ *
+ * This header file contains the declarations of the %_AppWidgetPopupContext class.
+ */
+
+#ifndef _FSHELL_INTERNAL_APPWIDGET_POPUP_CONTEXT_H_
+#define _FSHELL_INTERNAL_APPWIDGET_POPUP_CONTEXT_H_
+
+#include "FShell_AppWidgetContextBase.h"
+
+namespace Tizen { namespace Shell { namespace App
+{
+
+class _AppWidgetPopupContext
+ :public Tizen::Shell::App::_AppWidgetContextBase
+{
+public:
+ _AppWidgetPopupContext(const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int priority);
+ virtual ~_AppWidgetPopupContext();
+
+ // event handler
+ void OnPopupCreated(double x, double y, int width, int height);
+ void OnPopupDestoyed(void);
+
+ // request to app
+ result SendPopupCreateRequest(double x, double y, int width, int height);
+ result SendPopupDestroyRequest();
+ virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y);
+
+ result RequestUpdateRemote();
+};
+
+
+} /* namespace App */
+} /* namespace AppWidget */
+} /* namespace Samsung */
+#endif // _FSHELL_INTERNAL_APPWIDGET_POPUP_CONTEXT_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+/**
+ * @file OspAppWidgetService.h
+ * @brief This is the header file for the OspAppWidgetService class.
+ *
+ * This header file contains the declarations of the OspAppWidgetService class.
+ */
+
+#ifndef _OSP_APPWIDGET_SERVICE_H_
+#define _OSP_APPWIDGET_SERVICE_H_
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FSystem.h>
+
+/**
+ * [OspAppWidgetService] ServiceApp must inherit from ServiceApp class
+ * which provides basic features necessary to define an ServiceApp.
+ */
+class OspAppWidgetService
+ : public Tizen::App::ServiceApp
+{
+public:
+
+ /**
+ * [OspAppWidgetService] ServiceApp must have a factory method that creates an instance of itself.
+ */
+ static Tizen::App::ServiceApp* CreateInstance(void);
+
+public:
+
+ OspAppWidgetService();
+ ~OspAppWidgetService();
+
+public:
+
+ // Called when the ServiceApp is initializing.
+ bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
+
+ // Called when the ServiceApp initializing is finished.
+ bool OnAppInitialized(void);
+
+ // Called when the ServiceApp is requested to terminate.
+ bool OnAppWillTerminate(void);
+
+ // Called when the ServiceApp is terminating.
+ bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
+
+ // Called when the system memory is not sufficient to run the ServiceApp any further.
+ void OnLowMemory(void);
+
+ // Called when the battery level changes.
+ void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
+
+};
+
+#endif // _$(baseName_upper)_H_
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest">
+ <Id>gi2qxenosh</Id>
+ <Version>1.0.0</Version>
+ <Type>C++App</Type>
+ <Author/>
+ <Descriptions>
+ <Description Locale="eng-GB"/>
+ </Descriptions>
+ <Requirements>
+ <Feature Name="http://tizen.org/feature/platform.core.cpu.arch">x86</Feature>
+ <Feature Name="http://tizen.org/feature/platform.core.fpu.arch">vfpv3</Feature>
+ <Feature Name="http://tizen.org/feature/screen.coordinate_system.logical">Normal</Feature>
+ </Requirements>
+ <Apps>
+ <ApiVersion>2.1</ApiVersion>
+ <Privileges>
+ <Privilege>http://tizen.org/privilege/application.launch</Privilege>
+ <Privilege>http://tizen.org/privilege/appmanager.launch</Privilege>
+ <Privilege>http://tizen.org/privilege/application.kill</Privilege>
+ </Privileges>
+ <ServiceApp Name="osp-livebox-service" Main="True">
+ <DisplayNames>
+ <DisplayName Locale="eng-GB">tizen livebox service</DisplayName>
+ </DisplayNames>
+ <Icons/>
+ <DataControls/>
+ <LaunchConditions/>
+ <Notifications/>
+ </ServiceApp>
+ </Apps>
+</Manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="gi2qxenosh" policy="restricted" />
+ <request>
+ <smack request="system::homedir" type="rx"/>
+ <smack request="system::use_internet" type="r"/>
+ <smack request="system::vconf" type="rwx"/>
+ <smack request="sys-assert::core" type="rwxa"/>
+ <smack request="syslogd" type="w"/>
+ <smack request="pkgmgr::db" type="rw"/>
+ <smack request="ail::db" type="rw"/>
+ <smack request="notification::db" type="rw"/>
+ <smack request="xorg" type="w"/>
+ <smack request="isf" type="rx"/>
+ <smack request="data-provider-master" type="w"/>
+ <smack request="data-provider-master::share" type="x"/>
+ </request>
+ </define>
+ <request>
+ <domain name="gi2qxenosh"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/apps/gi2qxenosh/bin/osp-livebox-service.exe" label="gi2qxenosh" exec_label="gi2qxenosh"/>
+ <filesystem path="/usr/share/license/osp-livebox-service" label="_"/>
+ </assign>
+</manifest>
--- /dev/null
+Name: osp-livebox-service
+Summary: osp livebox service
+Version: 1.2.1.0
+Release: 1
+Group: System/Libraries
+License: Apache License, Version 2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(chromium)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(provider)
+BuildRequires: pkgconfig(osp-appfw)
+BuildRequires: pkgconfig(osp-uifw)
+BuildRequires: pkgconfig(osp-image)
+BuildRequires: pkgconfig(osp-shell)
+BuildRequires: osp-shell-internal-devel
+BuildRequires: osp-appfw-internal-devel
+
+# runtime requires
+Requires: chromium
+Requires: osp-appfw
+Requires: osp-shell
+Requires: data-provider-master
+
+%description
+osp livebox service
+
+%prep
+%setup -q
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%ifarch %{ix86}
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+%else
+CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+%endif
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post
+
+/bin/rm -fr /opt/apps/gi2qxenosh
+
+/usr/etc/package-manager/backend/tpk -i /usr/apps/gi2qxenosh
+cp -f %{_libdir}/osp/osp-system-service-loader /usr/apps/gi2qxenosh/bin/%{name}
+
+#%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+/usr/share/license/%{name}
+/usr/apps/*
+#/opt/apps/gi2qxenosh/*
+
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetContext.cpp
+ * @brief This is the implementation for the _AppWidgetContext class.
+ */
+
+#include <stdlib.h>
+#include <unique_ptr.h>
+
+#include "provider_buffer.h"
+
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+
+#include <FApp_AppControlManager.h>
+
+#include "FShell_AppWidgetManagerService.h"
+#include "FShell_AppWidgetPopupContext.h"
+#include "FShell_AppWidgetContextBase.h"
+#include "FShell_AppWidgetContext.h"
+
+
+namespace Tizen { namespace Shell { namespace App
+{
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+const char APPWIDGET_ON_ADD[] = "http://tizen.org/appcontrol/appwidget/add";
+const char APPWIDGET_ON_REMOVE[] = "http://tizen.org/appcontrol/appwidget/remove";
+const char APPWIDGET_ON_UPDATE[] = "http://tizen.org/appcontrol/appwidget/update";
+const char APPWIDGET_ON_RESIZE[] = "http://tizen.org/appcontrol/appwidget/resize";
+const char APPWIDGET_ON_TOUCH[] = "http://tizen.org/appcontrol/appwidget/touch";
+
+const String ARG_KEY_WIDTH = L"_Width";
+const String ARG_KEY_HEIGHT = L"_Height";
+const String ARG_KEY_ARGUMENT = L"_Argument";
+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
+
+_AppWidgetContext::_AppWidgetContext(const String& info, const String& providerId, const String& instanceId, int width, int height, int period, int priority)
+:_AppWidgetContextBase(TYPE_LB, info, providerId, instanceId, width, height, priority)
+,__pAppWidgetPopup(null), __UpdateMillis(period)
+{
+ SysLog(NID_APP, "period(%d)", period);
+
+ __lifeDurationTimer.Construct(*this);//, true);
+ __lifeDurationTimer.Start(LIVE_DURATION_MSEC);
+
+ SysLog(NID_APP, "period(%d)", __UpdateMillis);
+ if( __UpdateMillis > 0)
+ {
+ __UpdateTimer.Construct(*this);//, false);
+ __UpdateTimer.StartAsRepeatable(__UpdateMillis);
+ }
+}
+
+_AppWidgetContext::~_AppWidgetContext()
+{
+ SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+ __lifeDurationTimer.Cancel();
+ __UpdateTimer.Cancel();
+
+ if (__pAppWidgetPopup)
+ {
+ SysLog(NID_APP, "Destroying dangling AppWidgetPopup instance..");
+ __pAppWidgetPopup->OnPopupDestoyed();
+ delete __pAppWidgetPopup;
+ }
+}
+
+_AppWidgetPopupContext*
+_AppWidgetContext::GetAppWidgetPopup() const
+{
+ return __pAppWidgetPopup;
+}
+
+void
+_AppWidgetContext::OnAdded(void)
+{
+ SendAddRequest(__width, __height);
+}
+
+void
+_AppWidgetContext::OnRemoved()
+{
+ SendRemoveRequest();
+}
+
+void
+_AppWidgetContext::OnUpdate(const String& argument)
+{
+ SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+
+ SendUpdateRequest(__width, __height, argument);
+}
+
+void
+_AppWidgetContext::OnResize(int width, int height)
+{
+ SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+
+ __width = width;
+ __height = height;
+ SendResizeRequest(__width, __height);
+}
+
+void
+_AppWidgetContext::OnForeground()
+{
+ SysLog(NID_APP, "");
+ __isForeground = true;
+
+ __UpdateTimer.Cancel();
+ __UpdateTimer.StartAsRepeatable(__UpdateMillis);
+}
+
+void
+_AppWidgetContext::OnBackground()
+{
+ SysLog(NID_APP, "");
+ __isForeground = false;
+ __UpdateTimer.Cancel();
+}
+
+void
+_AppWidgetContext::OnPopupCreated(double x, double y, int width, int height)
+{
+ __pAppWidgetPopup = new (std::nothrow) _AppWidgetPopupContext(__userInfo, __providerId, __instanceId, width, height, __priority);
+ __pAppWidgetPopup->SetClientId(__ipcClientId);
+ __pAppWidgetPopup->OnPopupCreated(x, y, width, height);
+
+ __lifeDurationTimer.Cancel();
+}
+
+void
+_AppWidgetContext::OnPopupDestoyed(void)
+{
+ if (__pAppWidgetPopup)
+ {
+ __pAppWidgetPopup->OnPopupDestoyed();
+ delete __pAppWidgetPopup;
+ __pAppWidgetPopup = null;
+ }
+ RestartLifeDurationTimer();
+}
+
+result
+_AppWidgetContext::SendAddRequest(int width, int height)
+{
+/* std::unique_ptr<ArrayList, AllElementsDeleter> 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<HashMap, AllElementsDeleter> 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, APPWIDGET_ON_ADD, pArgs.get());
+}
+
+result
+_AppWidgetContext::SendUpdateRequest(int width, int height, const String& argument)
+{
+ std::unique_ptr<HashMap, AllElementsDeleter> 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)));
+ pArgs->Add(new String(ARG_KEY_ARGUMENT), new String(argument));
+
+ return SendRequestToApp( __appId, APPWIDGET_ON_UPDATE, pArgs.get());
+}
+
+result
+_AppWidgetContext::SendResizeRequest(int width, int height)
+{
+ std::unique_ptr<HashMap, AllElementsDeleter> 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, APPWIDGET_ON_RESIZE, pArgs.get());
+}
+
+result
+_AppWidgetContext::SendRemoveRequest()
+{
+ std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
+
+ return SendRequestToApp( __appId, APPWIDGET_ON_REMOVE, pArgs.get());
+}
+
+result
+_AppWidgetContext::SendTouchEvent(buffer_event event, double timestamp, double x, double y)
+{
+ SysLog(NID_APP, "");
+ if( HasValidClientId() == false )
+ {
+ std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
+
+ 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, APPWIDGET_ON_TOUCH, pArgs.get());
+ }
+ else
+ {
+// SysAssertf( Tizen::App::AppManager::GetInstance()->IsRunning(__appId) == false, "application isn't running");
+ AppWidgetManagerService::GetInstance()->SendTouchEvent(__ipcClientId, __instanceId, event, timestamp, x, y);
+ }
+ return E_SUCCESS;
+}
+
+result
+_AppWidgetContext::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs)
+{
+ result r = _AppWidgetContextBase::SendRequestToApp(appId, operation, pArgs);
+ RestartLifeDurationTimer();
+
+ return r;
+}
+
+result
+_AppWidgetContext::RequestUpdateRemote(int width, int height)
+{
+ /*if( GetAppWidgetPopup() != null)
+ {
+ SysLog(NID_APP, "AppWidgetPopup is appeared, so appWidget doesn't need to update");
+ return E_SUCCESS;
+ }*/
+ std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__providerId));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__instanceId));
+ std::unique_ptr<char[]> 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");
+
+ SysLog(NID_APP, "Done");
+ return E_SUCCESS;
+}
+
+void
+_AppWidgetContext::RestartLifeDurationTimer()
+{
+ __lifeDurationTimer.Cancel();
+ __lifeDurationTimer.Start(LIVE_DURATION_MSEC);
+ SysLog(NID_APP, "lifeDuration timer restarted (%d)msec", LIVE_DURATION_MSEC);
+}
+
+void
+_AppWidgetContext::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
+{
+ SysLog(NID_APP, "");
+
+ if( &timer == &__lifeDurationTimer)
+ {
+ SysLog(NID_APP, "lifeDuration timer is expired, so terminating appWidget app(%ls)..", __providerId.GetPointer() );
+
+ ReleaseSharedMem();
+ AppManager::GetInstance()->TerminateApplication(__appId);
+
+ }
+ else if( &timer == &__UpdateTimer)
+ {
+ SysLog(NID_APP, "update timer is expired for appWidget app(%ls)..", __providerId.GetPointer() );
+ OnUpdate(L"");
+ }
+}
+
+
+} } } // Tizen::Shell::App {
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetContextBase.cpp
+ * @brief This is the implementation for the _AppWidgetContextBase class.
+ */
+
+#include <stdlib.h>
+#include <unique_ptr.h>
+
+#include "provider_buffer.h"
+
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+
+#include <FApp_AppMessageImpl.h>
+#include <FApp_AppArg.h>
+#include <FApp_AppControlManager.h>
+#include <FShell_TemplateUtil.h>
+#include <FShell_AppWidgetManagerImpl.h>
+
+#include "FShell_AppWidgetContextBase.h"
+
+// provider/src/fb.c
+struct fb_info {
+ char *id;
+ int w;
+ int h;
+ int bufsz;
+ void *buffer;
+
+ int handle;
+};
+
+// provider/inc/provider_buffer_internal.h
+struct livebox_buffer {
+ enum {
+ BUFFER_CREATED = 0x00beef00,
+ BUFFER_DESTROYED = 0x00dead00,
+ } state;
+
+ enum target_type type;
+
+ union {
+ int fd; /* File handle(descriptor) */
+ int id; /* SHM handle(id) */
+ } handle;
+
+ char *pkgname;
+ char *id;
+ int width;
+ int height;
+ int pixel_size;
+
+ struct fb_info *fb;
+
+ int (*handler)(struct livebox_buffer *info, enum buffer_event event, double timestamp, double x, double y, void *data);
+ void *data;
+};
+
+static int AppWidgetHandleBufferEventCallback( struct livebox_buffer *info, enum buffer_event event,
+ double timestamp, double x, double y, void* data);
+
+namespace Tizen { namespace Shell { namespace App
+{
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+const String APPWIDGET_ON_ADD(L"AppWidget='event=add'");
+const String APPWIDGET_ON_REMOVE(L"AppWidget='event=remove'");
+const String APPWIDGET_ON_UPDATE(L"AppWidget='event=update'");
+const String APPWIDGET_ON_RESIZE(L"AppWidget='event=resize'");
+const String APPWIDGET_ON_TOUCH(L"AppWidget='event=touch'");
+const String APPWIDGET_POPUP_ON_CREATE(L"AppWidgetPopup='event=create'");
+const String APPWIDGET_POPUP_ON_DESTROY(L"AppWidgetPopup='event=destroy'");
+const String APPWIDGET_POPUP_ON_TOUCH(L"AppWidgetPopup='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";
+
+
+_AppWidgetContextBase::_AppWidgetContextBase(target_type type, const String& userInfo, const String& providerId, const String& instanceId, int width, int height, int priority)
+ :__type(type)
+ ,__userInfo(userInfo)
+ ,__providerId(providerId)
+ ,__instanceId(instanceId)
+ ,__width(width)
+ ,__height(height)
+ ,__priority(priority)
+ ,__isForeground(true)
+ ,__ipcClientId(-1)
+ ,__buffer_info(null)
+ ,__buffer(null)
+{
+ _AppWidgetManagerImpl::ExtractAppIdAndProviderName(providerId, __appId, __providerName);
+
+ SysLog(NID_APP, "appId(%ls), providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __appId.GetPointer(), __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+}
+
+_AppWidgetContextBase::~_AppWidgetContextBase()
+{
+ SysLog(NID_APP, "providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+}
+
+
+void
+_AppWidgetContextBase::SetClientId(int clientId)
+{
+ __ipcClientId = clientId;
+}
+
+bool
+_AppWidgetContextBase::HasValidClientId() const
+{
+ SysLog(NID_APP, "%d", __ipcClientId);
+ return (__ipcClientId > -1);
+}
+
+int
+_AppWidgetContextBase::GetSharedMemId(int w, int h)
+{
+ SysLog(NID_APP, "Enter");
+
+ if( __buffer_info == null)
+ {
+ std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__providerId));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__instanceId));
+
+ __buffer_info = provider_buffer_acquire(__type, packageName.get(), id.get(), w, h, sizeof(int), AppWidgetHandleBufferEventCallback, this);
+ SysTryReturnResult(NID_APP, __buffer_info , -1, "[E_SYSTEM] failed to provider_buffer_acquire");
+ SysLog(NID_APP, "provider_buffer_acquire successed");
+
+ __buffer = provider_buffer_ref(__buffer_info);
+ SysTryReturnResult(NID_APP, __buffer , -1, "[E_SYSTEM] failed to provider_buffer_ref");
+ SysLog(NID_APP, "provider_buffer_ref successed");
+ }
+
+ int bufferId = __buffer_info->fb->handle;
+
+ SysLog(NID_APP, "(%d) Exit", bufferId);
+ return bufferId;
+}
+
+result
+_AppWidgetContextBase::ReleaseSharedMem()
+{
+ SysLog(NID_APP, "Enter");
+
+ int ret;
+
+ if( __buffer)
+ {
+ ret = provider_buffer_unref(__buffer);
+ __buffer = null;
+ SysTryReturnResult(NID_APP, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_buffer_unref");
+ SysLog(NID_APP, "provider_buffer_unref successed");
+ }
+
+ if( __buffer_info)
+ {
+ ret = provider_buffer_release(__buffer_info);
+ __buffer_info = null;
+ SysTryReturnResult(NID_APP, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_buffer_release");
+ SysLog(NID_APP, "provider_buffer_release successed");
+ }
+
+ SysLog(NID_APP, "Exit.");
+
+ return E_SUCCESS;
+}
+
+Tizen::Base::Collection::HashMap*
+_AppWidgetContextBase::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
+_AppWidgetContextBase::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs)
+{
+ if( __isForeground == false)
+ {
+ SysLog(NID_APP, "appWidget isn't foreground, so, message skip");
+ return E_SUCCESS;
+ }
+
+ return _AppWidgetRequestHelper::SendRequestToApp(appId, operation, pArgs);
+}
+
+result
+_AppWidgetRequestHelper::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs)
+{
+ SysLog(NID_APP, "appId(%ls), operation(%ls), arg count(%d)", appId.GetPointer(), operation.GetPointer(), pArgs->GetCount() );
+
+ _AppMessageImpl msg;
+ msg.AddData(OSP_K_APPCONTROL_INTERNAL_OPERATION, L"livebox");
+ Tizen::App::_AppArg::AddStrMap(msg.GetBundle(), pArgs);
+
+ std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId) );
+ std::unique_ptr<char[]> pOperation(_StringConverter::CopyToCharArrayN(operation) );
+
+ return Tizen::App::_AppControlManager::GetInstance()->LaunchPkg(msg, pAppId.get(), pOperation.get(), null, null, null, null);
+}
+
+/*result
+_AppWidgetRequestHelper::ExtractPackageIdAndExecutableName(AppId appId, AppId& outPackageId, String& outExecutableName)
+{
+ const int APP_ID_LEN = 10;
+
+ if (appId.GetLength() > APP_ID_LEN)
+ {
+ result r = appId.SubString(APP_ID_LEN + 1, appId.GetLength() - (APP_ID_LEN + 1), outExecutableName);
+ SysTryReturnResult(NID_APP, !IsFailed(r), E_INVALID_ARG, "invalid AppId(%ls)", appId.GetPointer());
+
+ r = appId.SubString(0, APP_ID_LEN, outPackageId);
+ SysTryReturnResult(NID_APP, !IsFailed(r), E_INVALID_ARG, "invalid AppId(%ls)", appId.GetPointer());
+
+ return E_SUCCESS;
+ }
+ return E_SYSTEM;
+}*/
+
+/*
+// helper for bundle
+result
+_AppWidgetRequestHelper::AddStrArrayToBundle(bundle* b, const char* key, const IList* pList)
+{
+ bundle* pb = b;
+ SysTryReturnResult(NID_APP, pb != NULL, E_INVALID_ARG, "Empty bundle.");
+
+ if (pList == null || pList->GetCount() == 0)
+ {
+ SysLog(NID_APP, "No element added for bundle.");
+ return E_SUCCESS;
+ }
+
+ int i = 0;
+ const int count = pList->GetCount();
+
+ const char** pSa = new (std::nothrow) const char*[count];
+ SysTryReturnResult(NID_APP, pSa != null, E_OUT_OF_MEMORY, "Memory allocation failure with cound %d.", count);
+
+ for (i = 0; i < count; i++)
+ {
+ pSa[i] = null;
+
+ const String* pStr = static_cast<const String*>(pList->GetAt(i));
+ if (pStr)
+ {
+ pSa[i] = _StringConverter::CopyToCharArrayN(*pStr);
+ }
+ }
+
+ result r = E_SUCCESS;
+
+ int ret = bundle_add_str_array(pb, key, pSa, count);
+ SysTryReturnResult(NID_APP, ret >= 0, E_SYSTEM, "Bundle add failre with %d.", strerror(errno));
+
+//CATCH:
+ for (i = 0; i < count; i++)
+ {
+ delete[] pSa[i];
+ }
+
+ delete[] pSa;
+
+ return r;
+}
+*/
+
+} } } // Tizen::Shell::App {
+
+
+////////////////////////////////////////////
+// callback
+////////////////////////////////////////////
+static int AppWidgetHandleBufferEventCallback( struct livebox_buffer *info, enum buffer_event event,
+ double timestamp, double x, double y, void* data)
+{
+ SysLog(NID_APP, "timestamp(%f), x(%f), y(%f)", timestamp, x, y);
+
+ Tizen::Shell::App::_AppWidgetContextBase *pAppWidgetBase = static_cast<Tizen::Shell::App::_AppWidgetContextBase*>(data);
+ SysTryReturn(NID_APP, pAppWidgetBase != null, 0, E_SYSTEM, "[E_SYSTEM] retrieved pAppWidgetBase is null");
+
+// const char *pkgname = provider_buffer_pkgname(info);
+// const char *id = provider_buffer_id(info);
+// enum target_type type = provider_buffer_type(info);
+
+ if( event == BUFFER_EVENT_ENTER)
+ {
+ SysLog(NID_APP, "BUFFER_EVENT_ENTER");
+ }
+ else if( event == BUFFER_EVENT_LEAVE)
+ {
+ SysLog(NID_APP, "BUFFER_EVENT_LEAVE");
+ }
+ else if( event == BUFFER_EVENT_DOWN)
+ {
+ SysLog(NID_APP, "BUFFER_EVENT_DOWN");
+ }
+ else if( event == BUFFER_EVENT_MOVE)
+ {
+ SysLog(NID_APP, "BUFFER_EVENT_MOVE");
+ }
+ else if( event == BUFFER_EVENT_UP)
+ {
+ SysLog(NID_APP, "BUFFER_EVENT_UP");
+ }
+
+ pAppWidgetBase->SendTouchEvent(event, timestamp, x, y);
+
+ return 0;
+}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetManagerService.cpp
+ * @brief This is the implementation for the AppWidgetManagerService class.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <unique_ptr.h>
+#include <provider.h>
+#include <aul.h>
+
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FApp.h>
+#include <FApp_AppManagerImpl.h>
+#include <FIo_IpcServer.h>
+#include <FBase_StringConverter.h>
+
+#include "FShell_AppWidgetContext.h"
+#include "FShell_AppWidgetPopupContext.h"
+#include "FShell_AppWidgetManagerStub.h"
+
+#include "FShell_AppWidgetManagerService.h"
+
+namespace Tizen { namespace Shell { namespace App {
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Io;
+using namespace Tizen::System;
+using namespace Tizen::Shell::App;
+
+
+namespace
+{
+static const RequestId LOCAL_EVENT_REQUEST_UPDATE = 0;
+}
+
+AppWidgetManagerService::AppWidgetManagerService()
+{
+}
+
+AppWidgetManagerService::~AppWidgetManagerService()
+{
+ __pingTimer.Cancel();
+ DeinitializeMasterDaemonEventReceiver();
+}
+
+AppWidgetManagerService*
+AppWidgetManagerService::GetInstance(void)
+{
+ static AppWidgetManagerService* pSelf = null;
+ if( pSelf == null)
+ {
+ pSelf = new AppWidgetManagerService();
+ SysTryReturn(NID_APP, pSelf != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+ result r = pSelf->Construct();
+ SysAssertf(!IsFailed(r), "Failed to construct AppWidgetManagerService");
+ SysLog(NID_APP, "AppWidgetManagerService is created.");
+ }
+ return pSelf;
+}
+
+result
+AppWidgetManagerService::Construct()
+{
+// _AppManagerImpl::GetInstance()->AddEventListener(*this);
+
+ _AppWidgetManagerStub::StartIpcServer();
+
+ result r = __handlerThread.Construct(THREAD_TYPE_EVENT_DRIVEN);
+ SysTryReturn(NID_APP, IsFailed(r) == false, false, r, "[%s] Event thread creation failure.", GetErrorMessage(r));
+
+ r = __handlerThread.Start();
+ SysTryReturn(NID_APP, IsFailed(r) == false, false, r, "[%s] Event thread Start failure.", GetErrorMessage(r));
+
+ return InitializeMasterDaemonEventReceiver("osp-livebox-service");
+}
+
+int
+AppWidgetManagerService::AppWidgetConnected(struct event_arg *arg, void* data)
+{
+ int ret;
+ ret = provider_send_hello();
+ if (ret == 0)
+ {
+ SysLog(NID_APP, "success to be connected with master daemon");
+ AppWidgetManagerService::GetInstance()->StartPingTimer();
+
+ }
+ else
+ {
+ SysLog(NID_APP, "failed to provider_send_hello()");
+ }
+ return ret;
+}
+
+int
+AppWidgetManagerService::AppWidgetDisconnected(struct event_arg *arg, void* data)
+{
+ SysLog(NID_APP, "success to be disconnected with master daemon");
+// aul_terminate_pid(getpid());
+ return 0;
+}
+
+void
+AppWidgetManagerService::StartPingTimer()
+{
+ __pingTimer.Construct(*this);//, true);
+ __pingTimer.StartAsRepeatable(120000);
+}
+
+void
+AppWidgetManagerService::OnTimerExpired(Timer& timer)
+{
+ SysLog(NID_APP, "provider_send_ping");
+ provider_send_ping();
+}
+
+_AppWidgetContext*
+AppWidgetManagerService::Find(const String& appId, const String& instanceId) const
+{
+ for( int i = 0; i < __appWidgetContextList.GetCount(); i++ )
+ {
+ _AppWidgetContext* pAppWidgetContext = null;
+ __appWidgetContextList.GetAt(i, pAppWidgetContext);
+// SysLog(NID_APP, "%ls", pAppWidgetContext->__instanceId.GetPointer());
+
+ if ( pAppWidgetContext->__instanceId == instanceId )
+ {
+// SysAssert(pAppWidgetContext->__appId == appId)
+ return pAppWidgetContext;
+ }
+ }
+ return null;
+}
+
+result
+AppWidgetManagerService::SetClientIds(const Tizen::App::AppId& appId, int clientId)
+{
+ for( int i = 0; i < __appWidgetContextList.GetCount(); i++ )
+ {
+ _AppWidgetContext* pAppWidgetContext = null;
+ __appWidgetContextList.GetAt(i, pAppWidgetContext);
+ SysLog(NID_APP, "%ls", pAppWidgetContext->__instanceId.GetPointer());
+ SysLog(NID_APP, "%ls, %ls", pAppWidgetContext->__providerId.GetPointer(), appId.GetPointer());
+
+ if ( pAppWidgetContext->__appId == appId )
+ {
+ pAppWidgetContext->SetClientId(clientId);
+ SysLog(NID_APP, "client is registered.(%d)", clientId);
+ if( clientId == -1)
+ {
+ pAppWidgetContext->ReleaseSharedMem();
+ if(pAppWidgetContext->GetAppWidgetPopup())
+ {
+ pAppWidgetContext->OnPopupDestoyed();
+ }
+ }
+ }
+ }
+ return E_SUCCESS;
+}
+
+void
+AppWidgetManagerService::OnIpcClientConnected(const _IpcServer& server, int clientId)
+{
+ //SysLog(NID_APP, "(clientId:%d)\n", clientId);
+ String fullAppId = server.GetClientAppId() + "." + server.GetClientAppExecutableName();
+ SysLog(NID_APP, "(%ls)\n", fullAppId.GetPointer());
+// this->SetClientIds(fullAppId, clientId);//Todo
+
+}
+
+void
+AppWidgetManagerService::OnIpcClientDisconnected(const _IpcServer& server, int clientId)
+{
+ String fullAppId = server.GetClientAppId() + "." + server.GetClientAppExecutableName();
+ SysLog(NID_APP, "(%ls)\n", fullAppId.GetPointer());
+ this->SetClientIds(fullAppId, -1);
+}
+
+result
+AppWidgetManagerService::AddAppWidget(_AppWidgetContext* pAppWidgetContext)
+{
+ SysLog(NID_APP, "%ls, %ls, count(%d)", pAppWidgetContext->__providerId.GetPointer(), pAppWidgetContext->__instanceId.GetPointer(), __appWidgetContextList.GetCount());
+
+ return __appWidgetContextList.Add(pAppWidgetContext);
+}
+
+result
+AppWidgetManagerService::RemoveAppWidget(const char* pPackageName, const char* pId, bool free)
+{
+ SysLog(NID_APP, "%s, %s, count(%d)", pPackageName, pId, __appWidgetContextList.GetCount());
+
+ SysTryReturn(NID_APP, ( pPackageName != null && pId != null), null, E_INVALID_ARG, "[E_INVALID_ARG]");
+ SysLog(NID_APP, "%s, %s", pPackageName, pId);
+
+ _AppWidgetContext* pAppWidgetContext = Find(pPackageName, pId);
+ SysTryReturn(NID_APP, pAppWidgetContext, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND]");
+
+ result r = __appWidgetContextList.Remove(pAppWidgetContext);
+
+ if( __appWidgetContextList.GetCount() == 0 )
+ {
+ SysLog(NID_APP, "No running native appWidget app remains, terminating osp appWidget service...");
+ Tizen::App::App::GetInstance()->Terminate();
+ }
+
+ return r;
+}
+
+
+///////////////////////////////////////////////////////
+// MasterDaemonEventReceiver implementation
+///////////////////////////////////////////////////////
+int
+AppWidgetManagerService::OnAppWidgetCreate(struct event_arg *arg, int *width, int *height, double *priority, void* data)
+{
+ SysTryReturn(NID_APP, arg != null, EINVAL, E_INVALID_ARG, "[E_INVALID_ARG]");
+ SysTryReturn(NID_APP, arg->pkgname != null, EINVAL, E_INVALID_ARG, "[E_INVALID_ARG]");
+ SysTryReturn(NID_APP, arg->id != null, EINVAL, E_INVALID_ARG, "[E_INVALID_ARG]");
+ SysTryReturn(NID_APP, arg->type == event_arg::EVENT_NEW, -EPERM, E_SUCCESS, "invalid argument from master");
+
+ SysLog(NID_APP, "packageName(%s) id(%s) content(%s) cluster(%s) category(%s)", arg->pkgname, arg->id, arg->info.lb_create.content, arg->info.lb_create.cluster, arg->info.lb_create.category);
+ SysTryReturn (NID_APP, AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id) == null, -EBUSY, E_SUCCESS,"already exist");
+
+ double default_priority = 1.0f;
+ _AppWidgetContext* pAppWidgetContext = new (std::nothrow)_AppWidgetContext( arg->info.lb_create.content, arg->pkgname, arg->id,
+ arg->info.lb_create.width, arg->info.lb_create.height, arg->info.lb_create.period * 1000, default_priority);
+ SysTryReturn(NID_APP, pAppWidgetContext, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+ AppWidgetManagerService* pAppWidgetService = AppWidgetManagerService::GetInstance();
+ pAppWidgetService->AddAppWidget(pAppWidgetContext);
+ pAppWidgetContext->OnAdded();
+
+ *priority = pAppWidgetContext->__priority;
+ *height= pAppWidgetContext->__height;
+ *width = pAppWidgetContext->__width;
+
+ SysLog(NID_APP, "Exit. %d appWidget(es)", pAppWidgetService->__appWidgetContextList.GetCount());
+ return 0;
+}
+
+int
+AppWidgetManagerService::OnAppWidgetUpdate(struct event_arg *arg, void* data)
+{
+ if( arg->id == null || strlen(arg->id) < 1)
+ {
+ SysLog(NID_APP, "updating alls");
+ AppWidgetManagerService::GetInstance()->UpdateAllAppWidgetsByAppId(arg->pkgname);
+ }
+ else
+ {
+ _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+ pAppWidgetContext->OnUpdate(L"");
+ }
+
+ return 0;
+}
+
+int
+AppWidgetManagerService::UpdateAllAppWidgetsByAppId(const String& providerId)
+{
+ for( int i = 0; i < __appWidgetContextList.GetCount(); i++ )
+ {
+ _AppWidgetContext* pAppWidgetContext = null;
+ __appWidgetContextList.GetAt(i, pAppWidgetContext);
+
+ if ( pAppWidgetContext->__providerId == providerId )
+ {
+ pAppWidgetContext->OnUpdate(L"");
+ }
+ }
+ return E_SUCCESS;
+}
+
+int
+AppWidgetManagerService::OnAppWidgetDestroy(struct event_arg *arg, void* data)
+{
+ SysTryReturn (NID_APP, arg->type == event_arg::EVENT_DELETE, -EPERM, E_SUCCESS, "invalid argument from master");
+ SysLog(NID_APP, "Enter");
+
+ AppWidgetManagerService* pAppWidgetManagerService = AppWidgetManagerService::GetInstance();
+
+ _AppWidgetContext* pAppWidgetContext = pAppWidgetManagerService->Find(arg->pkgname, arg->id);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+ pAppWidgetContext->OnRemoved();
+ pAppWidgetManagerService->RemoveAppWidget( arg->pkgname, arg->id, true);
+ delete pAppWidgetContext;
+
+ SysLog(NID_APP, "Exit");
+ return 0;
+}
+
+int
+AppWidgetManagerService::OnAppWidgetPopupCreate(struct event_arg *arg, void* data)
+{
+ SysTryReturn (NID_APP, arg->type == event_arg::EVENT_PD_CREATE, -EPERM, E_SUCCESS, "invalid argument from master");
+ SysLog(NID_APP, "packageName(%s), id(%s), width(%d), height(%d), priority(%d)", arg->pkgname, arg->id);
+
+ _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+ /*if( pAppWidgetContext->GetAppWidgetPopup() )
+ {
+ pAppWidgetContext->OnPopupDestoyed();
+ }*/
+ pAppWidgetContext->OnPopupCreated(arg->info.pd_create.x, arg->info.pd_create.y, arg->info.pd_create.w, arg->info.pd_create.h);
+
+ return 0;
+}
+
+ int
+ AppWidgetManagerService::OnAppWidgetPopupDestroy(struct event_arg *arg, void* data)
+{
+ SysTryReturn (NID_APP, arg->type == event_arg::EVENT_PD_DESTROY, -EPERM, E_SUCCESS, "invalid argument from master");
+ SysLog(NID_APP, "packageName(%s), id(%s)", arg->pkgname, arg->id);
+ _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+ pAppWidgetContext->OnPopupDestoyed();
+
+ return 0;
+}
+
+ int
+ AppWidgetManagerService::OnLivePause(struct event_arg *arg, void* data)
+{
+ SysTryReturn(NID_APP, arg, 0, E_SUCCESS, "arg is null!");
+
+ _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , 0, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+ SysLog(NID_APP, "packageName(%s), id(%s)", arg->pkgname, arg->id);
+ pAppWidgetContext->OnBackground();
+ return 0;
+}
+
+int
+AppWidgetManagerService::OnAppWidgetResume(struct event_arg *arg, void* data)
+{
+ SysTryReturn(NID_APP, arg || arg->id || arg->pkgname, 0, E_SUCCESS, "arg is null!");
+
+ _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+ SysLog(NID_APP, "packageName(%s), id(%s)", arg->pkgname, arg->id);
+ pAppWidgetContext->OnForeground();
+ return 0;
+}
+
+int
+AppWidgetManagerService::OnAppWidgetClick(struct event_arg *arg, void* data)
+{
+ SysTryReturn (NID_APP, arg->type == event_arg::EVENT_CLICKED, -EPERM, E_SUCCESS, "invalid argument from master");
+ SysTryReturn(NID_APP, arg != null, -EPERM, E_SUCCESS, "arg is null!");
+ SysLog(NID_APP, "packageName(%s), id(%s), clicked.event(%s), clicked.x(%d), clicked.y(%d)", arg->pkgname, arg->id, arg->info.clicked.event, arg->info.clicked.x, arg->info.clicked.y);
+
+ return 0;
+}
+
+int
+AppWidgetManagerService::OnAppWidgetResize(struct event_arg *arg, void* data)
+{
+ SysTryReturn(NID_APP, arg || arg->id || arg->pkgname, 0, E_SUCCESS, "arg is null!");
+ SysTryReturn (NID_APP, arg->type == event_arg::EVENT_RESIZE, -EPERM, E_SUCCESS, "invalid argument from master");
+
+ SysLog(NID_APP, "packageName(%s), id(%s), resize.w(%d), resize.h(%d)", arg->pkgname, arg->id, arg->info.resize.w, arg->info.resize.h);
+
+ _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+ pAppWidgetContext->OnResize(arg->info.resize.w, arg->info.resize.h);
+
+ return 0;
+}
+
+int
+AppWidgetManagerService::OnAppWidgetPeriodChaned(struct event_arg *arg, void* data)
+{
+ SysTryReturn(NID_APP, arg != null, 0, E_SUCCESS, "arg is null!");
+ SysLog(NID_APP, "packageName(%s), id(%s), width(%d), height(%d), priority(%d)", arg->pkgname, arg->id);
+ return 0;
+}
+
+result
+AppWidgetManagerService::InitializeMasterDaemonEventReceiver(const char *pServiceExecutableName)
+{
+ SysTryReturnResult(NID_APP, pServiceExecutableName != null, E_INVALID_ARG, "");
+ SysLog(NID_APP, "Enter.");
+
+ __appWidgetContextList.Construct();
+
+ /*!
+ * \note
+ * Only for the buffer type
+ */
+ struct event_handler cbs;
+ memset(&cbs, 0, sizeof(event_handler));
+
+ cbs.connected = AppWidgetConnected,
+ cbs.disconnected = AppWidgetDisconnected,
+ cbs.pause = OnLivePause,
+ cbs.resume = OnAppWidgetResume,
+// cbs.lb_pause = OnLivePause,
+// cbs.lb_resume = OnAppWidgetResume,
+ cbs.lb_create = OnAppWidgetCreate,
+ cbs.lb_destroy = OnAppWidgetDestroy,
+ cbs.update_content = OnAppWidgetUpdate,
+ cbs.pd_create = OnAppWidgetPopupCreate,
+ cbs.pd_destroy = OnAppWidgetPopupDestroy,
+ cbs.clicked = OnAppWidgetClick,
+ cbs.resize = OnAppWidgetResize,
+ cbs.set_period = OnAppWidgetPeriodChaned;
+ //cbs.lb_recreate = OnAppWidgetRecreate,/* Recover from the fault of slave */
+ //cbs.content_event = OnAppWidgetContentEvent,
+ //cbs.change_group = OnAppWidgetGroupChanged;
+
+ int ret = provider_init(null, pServiceExecutableName, &cbs, this);
+ SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "provider_init failed.");
+
+ SysLog(NID_APP, "Exit.");
+ return E_SUCCESS;
+}
+
+result
+AppWidgetManagerService::DeinitializeMasterDaemonEventReceiver()
+{
+ SysLog(NID_APP, "Enter.");
+ provider_fini();
+ SysLog(NID_APP, "Exit.");
+ return E_SUCCESS;
+}
+
+///////////////////////////////////////////////////////
+// stub implmentation
+///////////////////////////////////////////////////////
+
+result
+AppWidgetManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument)
+{
+ SysLog(NID_APP, "%ls, %ls", appId.GetPointer(), providerName.GetPointer() );
+
+ bool found = false;
+ for( int i = 0; i < __appWidgetContextList.GetCount(); i++ )
+ {
+ _AppWidgetContext* pAppWidgetContext = null;
+ __appWidgetContextList.GetAt(i, pAppWidgetContext);
+
+ if ( pAppWidgetContext->__appId == appId && pAppWidgetContext->__providerName == providerName)
+ {
+ SysLog(NID_APP, "OK");
+
+ ArrayList* pArray = new (std::nothrow) ArrayList();
+ SysTryReturnResult(NID_APP, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+ pArray->Construct();
+ pArray->Add(pAppWidgetContext);
+ pArray->Add(new String(argument));
+
+ result r = __handlerThread.SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray);
+ SysTryLog(NID_APP, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r));
+
+ found = true;
+ }
+ }
+ SysLog(NID_APP, "Exit.");
+ return (found) ? E_SUCCESS : E_OBJ_NOT_FOUND;
+
+}
+
+result
+AppWidgetManagerService::RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument)
+{
+ SysLog(NID_APP, "%ls, %ls", instanceId.GetPointer(), argument.GetPointer() );
+
+ for( int i = 0; i < __appWidgetContextList.GetCount(); i++ )
+ {
+ _AppWidgetContext* pAppWidgetContext = null;
+ __appWidgetContextList.GetAt(i, pAppWidgetContext);
+
+ if ( pAppWidgetContext->__instanceId == instanceId)
+ {
+ SysLog(NID_APP, "OK");
+
+ ArrayList* pArray = new (std::nothrow) ArrayList();
+ SysTryReturnResult(NID_APP, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+ pArray->Construct();
+ pArray->Add(pAppWidgetContext);
+ pArray->Add(new String(argument));
+
+ result r = __handlerThread.SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray);
+ SysTryLog(NID_APP, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r));
+
+ return E_SUCCESS;
+ }
+ }
+ SysLog(NID_APP, "Exit.");
+ return E_OBJ_NOT_FOUND;
+}
+
+result
+AppWidgetManagerService::RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId)
+{
+ _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+ if(pAppWidgetContext->HasValidClientId() == false)
+ {
+ String fullAppId = __pIpcServer->GetClientAppId() + "." + __pIpcServer->GetClientAppExecutableName();
+ this->SetClientIds(fullAppId, __pIpcServer->GetClientId());
+ }
+
+ shmId = pAppWidgetContext->GetSharedMemId(width, height);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , shmId != -1, "[E_SYSTEM] failed to GetSharedMemId for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+ return E_SUCCESS;
+}
+
+result
+AppWidgetManagerService::RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId)
+{
+ _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+ _AppWidgetPopupContext* pPd = pAppWidgetContext->GetAppWidgetPopup();
+ SysTryReturnResult(NID_APP, pPd , E_SYSTEM, "[E_SYSTEM] pPd is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+ if(pPd->HasValidClientId() == false)
+ {
+ String fullAppId = __pIpcServer->GetClientAppId() + "." + __pIpcServer->GetClientAppExecutableName();
+ pPd->SetClientId(__pIpcServer->GetClientId());
+ }
+
+ shmId = pPd->GetSharedMemId(width, height);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , shmId != -1, "[E_SYSTEM] failed to GetSharedMemId for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+ return E_SUCCESS;
+}
+
+result
+AppWidgetManagerService::RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height)
+{
+ _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+ return pAppWidgetContext->RequestUpdateRemote(width, height);
+}
+
+result
+AppWidgetManagerService::RequestSyncSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId)
+{
+ _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+ SysTryReturnResult(NID_APP, pAppWidgetContext->GetAppWidgetPopup(), E_SYSTEM, "[E_SYSTEM] GetAppWidgetPopup() returns null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+ return pAppWidgetContext->GetAppWidgetPopup()->RequestUpdateRemote();
+}
+
+result
+AppWidgetManagerService::RequestReleaseSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId)
+{
+ std::unique_ptr<char[]> pkgname(_StringConverter::CopyToCharArrayN(appId));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(instanceId));
+
+ _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+ return pAppWidgetContext->ReleaseSharedMem();
+}
+
+result
+AppWidgetManagerService::RequestReleaseSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId)
+{
+ std::unique_ptr<char[]> pkgname(_StringConverter::CopyToCharArrayN(appId));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(instanceId));
+
+ _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId);
+ SysTryReturnResult(NID_APP, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+ SysTryReturnResult(NID_APP, pAppWidgetContext->GetAppWidgetPopup(), E_SYSTEM, "[E_SYSTEM] GetAppWidgetPopup() returns null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+// return pAppWidgetContext->GetAppWidgetPopup()->ReleaseSharedMem();
+ return E_SUCCESS;
+}
+
+AppWidgetManagerService::_TaskHandlerThread::~_TaskHandlerThread(void)
+{
+
+}
+
+void
+AppWidgetManagerService::_TaskHandlerThread::OnUserEventReceivedN(RequestId reqId, IList* pArgs)
+{
+ SysTryReturnVoidResult(NID_APP, pArgs != null, E_INVALID_STATE, "pArgs is null!.");
+
+ SysLog(NID_APP, "Enter.");
+
+ switch (reqId)
+ {
+ case LOCAL_EVENT_REQUEST_UPDATE:
+ {
+ _AppWidgetContext* pAppWidgetContext = dynamic_cast<_AppWidgetContext*>( pArgs->GetAt(0) );
+ SysTryReturnVoidResult(NID_APP, pAppWidgetContext != null, E_INVALID_STATE, "_AppWidget is null!.");
+
+ String* pArgument = dynamic_cast<String*>( pArgs->GetAt(1) );
+ SysTryReturnVoidResult(NID_APP, pArgument != null, E_INVALID_STATE, "pArgument is null!.");
+
+ pAppWidgetContext->OnUpdate(*pArgument);
+
+ delete pArgument;
+ pArgs->RemoveAll();
+ delete pArgs;
+ }
+ break;
+
+ default:
+ SysAssertf(false, "never get here!");
+ break;
+ }
+ SysLog(NID_APP, "Exit.");
+}
+
+} } } //namespace Tizen { namespace Shell { namespace App {
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetManagerStub.cpp
+ * @brief This is the implementation for the _AppWidgetManagerStub class.
+ */
+
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FIo_IpcServer.h>
+#include <FShell_AppWidgetManagerIpcMessage.h>
+
+#include "FShell_AppWidgetManagerStub.h"
+
+
+namespace Tizen { namespace Shell { namespace App {
+
+namespace
+{
+const char IPC_SERVER_NAME[] = "osp.shell.ipcserver.appwidgetmanager";
+const int INVALID_CLIENT_ID = -1;
+};
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Text;
+using namespace Tizen::Security;
+
+
+_AppWidgetManagerStub::_AppWidgetManagerStub(void)
+:__pIpcServer(null)
+{
+ SysLog(NID_APP, "Enter\n");
+
+ SysLog(NID_APP, "Exit\n");
+}
+
+_AppWidgetManagerStub::~_AppWidgetManagerStub(void)
+{
+ SysLog(NID_APP, "Enter\n");
+
+ if ( __pIpcServer != null)
+ {
+ __pIpcServer->Stop();
+ delete __pIpcServer;
+ }
+
+ SysLog(NID_APP, "Exit\n");
+}
+
+result
+_AppWidgetManagerStub::StartIpcServer(void)
+{
+ SysLog(NID_APP, "Enter.");
+ __pIpcServer = new (std::nothrow) _IpcServer();
+ SysTryReturn(NID_APP, __pIpcServer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Not enough memory.");
+
+ result r = __pIpcServer->Construct( IPC_SERVER_NAME, *this, false);
+ SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to create IPC server(%s)", GetErrorMessage(r), "osp.app.ipcserver.appmanager");
+ SysLog(NID_APP, "Exit.");
+
+ return E_SUCCESS;
+
+CATCH:
+ delete __pIpcServer;
+ __pIpcServer = null;
+ return r;
+}
+
+
+/////////////////////////////////////////////
+// handlers
+/////////////////////////////////////////////
+
+
+
+bool
+_AppWidgetManagerStub::OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument, result* pRes)
+{
+ SysLog(NID_APP, "");
+ *pRes = RequestUpdate(appId, providerName, argument);
+ return true;
+}
+
+bool
+_AppWidgetManagerStub::OnRequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument, result* pRes)
+{
+ SysLog(NID_APP, "");
+ *pRes = RequestUpdateInstance(instanceId, argument);
+ return true;
+}
+
+bool
+_AppWidgetManagerStub::OnRequestSharedMemoryId(const String& instanceId, int w, int h, int* pShmId)
+{
+ SysLog(NID_APP, "(instanceId:%d)xxx", instanceId.GetPointer());
+
+ RequestSharedMemoryId(__pIpcServer->GetClientAppId(), instanceId, w, h, *pShmId);
+
+ return true;
+}
+
+bool
+_AppWidgetManagerStub::OnRequestSharedMemoryIdForPD(const String& instanceId, int w, int h, int* pShmId)
+{
+ SysLog(NID_APP, "(instanceId:%d)", instanceId.GetPointer());
+
+ RequestSharedMemoryIdForPD(__pIpcServer->GetClientAppId(), instanceId, w, h, *pShmId);
+
+ return true;
+}
+
+bool
+_AppWidgetManagerStub::OnRequestSyncSharedMemory(const String& instanceId, int w, int h, result* pRes)
+{
+ SysLog(NID_APP, "(instanceId:%ls)", instanceId.GetPointer());
+
+ *pRes = RequestSyncSharedMemory(__pIpcServer->GetClientAppId(), instanceId, w, h);
+
+ return true;
+}
+
+bool
+_AppWidgetManagerStub::OnRequestSyncSharedMemoryForPD(const String& instanceId, result* pRes)
+{
+ SysLog(NID_APP, "(instanceId:%ls)", instanceId.GetPointer());
+
+ *pRes = RequestSyncSharedMemoryForPD(__pIpcServer->GetClientAppId(), instanceId);
+
+ return true;
+}
+
+bool
+_AppWidgetManagerStub::OnRequestReleaseSharedMemory(const String& instanceId, result* pRes)
+{
+ SysLog(NID_APP, "(instanceId:%ls)", instanceId.GetPointer());
+
+ *pRes = RequestReleaseSharedMemory(__pIpcServer->GetClientAppId(), instanceId);
+
+ return true;
+}
+
+bool
+_AppWidgetManagerStub::OnRequestReleaseSharedMemoryForPD(const String& instanceId, result* pRes)
+{
+ SysLog(NID_APP, "(instanceId:%ls)", instanceId.GetPointer());
+
+ *pRes = RequestReleaseSharedMemoryForPD(__pIpcServer->GetClientAppId(), instanceId);
+
+ return true;
+}
+
+bool
+_AppWidgetManagerStub::SendTouchEvent(const int clientId, const String& instanceId, int eventType, double timestamp, double x, double y)
+{
+ SysLog(NID_APP,"");
+ result r = __pIpcServer->SendResponse(clientId, new AppWidgetManager_SendTouchEvent(instanceId, eventType, timestamp, x, y));
+ SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+ return true;
+}
+
+bool
+_AppWidgetManagerStub::SendTouchEventForPD(const int clientId, const String& instanceId, int eventType, double timestamp, double x, double y)
+{
+ SysLog(NID_APP,"");
+ result r = __pIpcServer->SendResponse(clientId, new AppWidgetManager_SendTouchEventForPD(instanceId, eventType, timestamp, x, y));
+ SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+ return true;
+}
+
+
+void
+_AppWidgetManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
+{
+ SysLog(NID_APP, "(appId:%ls, pid:%d, clientId:%d)\n", server.GetClientAppId().GetPointer(), server.GetClientProcessId(), server.GetClientId());
+
+ IPC_BEGIN_MESSAGE_MAP(_AppWidgetManagerStub, message)
+ IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestUpdate, &server, OnRequestUpdate)
+ IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestUpdateInstance, &server, OnRequestUpdateInstance)
+ IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSharedMemoryId, &server, OnRequestSharedMemoryId)
+ IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSharedMemoryIdForPD, &server, OnRequestSharedMemoryIdForPD)
+ IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSyncSharedMemory, &server, OnRequestSyncSharedMemory)
+ IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSyncSharedMemoryForPD, &server, OnRequestSyncSharedMemoryForPD)
+ IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestReleaseSharedMemory, &server, OnRequestReleaseSharedMemory)
+ IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestReleaseSharedMemoryForPD, &server, OnRequestReleaseSharedMemoryForPD)
+ IPC_END_MESSAGE_MAP()
+}
+
+void
+_AppWidgetManagerStub::OnIpcServerStarted(const _IpcServer& server)
+{
+ SysLog(NID_APP, "\n");
+}
+
+void
+_AppWidgetManagerStub::OnIpcServerStopped(const _IpcServer& server)
+{
+ SysLog(NID_APP, "\n");
+}
+
+void
+_AppWidgetManagerStub::OnIpcClientConnected(const _IpcServer& server, int clientId)
+{
+ SysLog(NID_APP, "(clientId:%d)\n", clientId);
+
+}
+
+void
+_AppWidgetManagerStub::OnIpcClientDisconnected(const _IpcServer& server, int clientId)
+{
+ SysLog(NID_APP, "(appId:%ls, pid:%d, clientId:%d)\n", server.GetClientAppId().GetPointer(), server.GetClientProcessId(), clientId);
+}
+
+
+}}}//namespace Tizen { namespace Shell { namespace App {
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FShell_AppWidgetPopupContext.cpp
+ * @brief This is the implementation for the _AppWidgetPopupContext class.
+ */
+
+#include <stdlib.h>
+#include <unique_ptr.h>
+
+#include "provider_buffer.h"
+
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+
+#include <FApp_AppControlManager.h>
+
+#include "FShell_AppWidgetManagerService.h"
+#include "FShell_AppWidgetPopupContext.h"
+
+namespace Tizen { namespace Shell { namespace App
+{
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+const char APPWIDGET_POPUP_ON_CREATE[] = "http://tizen.org/appcontrol/appwidgetpopup/create";
+const char APPWIDGET_POPUP_ON_DESTROY[] = "http://tizen.org/appcontrol/appwidgetpopup/destroy";
+const char APPWIDGET_POPUP_ON_TOUCH[] = "http://tizen.org/appcontrol/appwidgetpopup/touch";
+
+const String ARG_KEY_X = L"_X";
+const String ARG_KEY_Y = L"_Y";
+const String ARG_KEY_WIDTH = L"_Width";
+const String ARG_KEY_HEIGHT = L"_Height";
+
+
+_AppWidgetPopupContext::_AppWidgetPopupContext(const String& info, const String& appId, const String& instanceId, int width, int height, int priority)
+:_AppWidgetContextBase(TYPE_PD, info, appId, instanceId, width, height, priority)
+{
+ SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
+}
+
+_AppWidgetPopupContext::~_AppWidgetPopupContext()
+{
+ SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d))", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
+ ReleaseSharedMem();
+}
+
+
+void
+_AppWidgetPopupContext::OnPopupCreated(double x, double y, int width, int height)
+{
+ SysLog(NID_APP, "width(%d), height(%d)", width, height);
+ SendPopupCreateRequest(x, y, width, height);
+}
+
+void
+_AppWidgetPopupContext::OnPopupDestoyed()
+{
+ SysLog(NID_APP, "");
+ SendPopupDestroyRequest();
+}
+
+result
+_AppWidgetPopupContext::SendPopupCreateRequest(double x, double y, int width, int height)
+{
+ std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
+
+ pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x)));
+ pArgs->Add(new String(ARG_KEY_Y), new String(Double::ToString(y)));
+ 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, APPWIDGET_POPUP_ON_CREATE, pArgs.get());
+}
+
+result
+_AppWidgetPopupContext::SendPopupDestroyRequest()
+{
+ std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
+
+ return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_DESTROY, pArgs.get());
+}
+
+result
+_AppWidgetPopupContext::SendTouchEvent(buffer_event event, double timestamp, double x, double y)
+{
+ SysLog(NID_APP, "");
+ /*if( HasValidClientId() == false )
+ {
+ std::unique_ptr<ArrayList, AllElementsDeleter> pArgs (new (std::nothrow) ArrayList);
+ pArgs->Construct();
+ pArgs->Add(*new String(__instanceId));
+ pArgs->Add(*new String(__info));
+ 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)));
+
+ return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_TOUCH, pArgs.get());
+ }
+ else*/
+ {
+// SysAssertf( Tizen::App::AppManager::GetInstance()->IsRunning(__appId) == false, "application isn't running");
+ AppWidgetManagerService::GetInstance()->SendTouchEventForPD(__ipcClientId, __instanceId, event, timestamp, x, y);
+ }
+ return E_SUCCESS;
+}
+
+result
+_AppWidgetPopupContext::RequestUpdateRemote()
+{
+ std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__providerId));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__instanceId));
+
+ int ret = provider_send_desc_updated(packageName.get(), id.get(), null);
+ SysTryReturnResult(NID_APP, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated");
+
+ SysLog(NID_APP, "Done");
+ return E_SUCCESS;
+}
+
+} } } // Tizen::Shell::App {
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file OspAppWidgetService.cpp
+ * @brief This is the implementation for the OspAppWidgetService class.
+ */
+
+#include "FShell_AppWidgetManagerService.h"
+#include "OspAppWidgetService.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::System;
+using namespace Tizen::Shell::App;
+
+
+OspAppWidgetService::OspAppWidgetService()
+{
+}
+
+OspAppWidgetService::~OspAppWidgetService()
+{
+}
+
+ServiceApp*
+OspAppWidgetService::CreateInstance(void)
+{
+ // Create the instance through the constructor.
+ return new (std::nothrow) OspAppWidgetService();
+}
+
+bool
+OspAppWidgetService::OnAppInitializing(AppRegistry& appRegistry)
+{
+ AppLog("Enter.");
+
+ AppWidgetManagerService* pSvc = AppWidgetManagerService::GetInstance();
+ AppAssertf( pSvc != null, "AppWidgetManagerService::GetInstance() failed.");
+
+ return true;
+}
+
+bool
+OspAppWidgetService::OnAppInitialized(void)
+{
+ return true;
+}
+
+bool
+OspAppWidgetService::OnAppWillTerminate(void)
+{
+ return true;
+}
+
+bool
+OspAppWidgetService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+ return true;
+}
+
+void
+OspAppWidgetService::OnLowMemory(void)
+{
+}
+
+void
+OspAppWidgetService::OnBatteryLevelChanged(BatteryLevel batteryLevel)
+{
+}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file OspAppWidgetService.cpp
+ * @brief This file contains the Tizen application entry point.
+ */
+
+#include "OspAppWidgetService.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // __cplusplus
+
+_EXPORT_ int OspMain(int argc, char *pArgv[]);
+#ifdef _PROFILE
+extern void start_profile (void);
+extern void end_profile (void);
+#else
+#define start_profile()
+#define end_profile()
+#endif
+
+
+/**
+ * The entry function of Tizen C++ application called by the operating system.
+ */
+int
+OspMain(int argc, char *pArgv[])
+{
+ result r = E_SUCCESS;
+
+ AppLog("Application started.");
+ ArrayList* pArgs = new (std::nothrow) ArrayList();
+ pArgs->Construct();
+ for (int i = 0; i < argc; i++)
+ pArgs->Add(*(new String(pArgv[i])));
+
+ start_profile();
+ r = Tizen::App::ServiceApp::Execute(OspAppWidgetService::CreateInstance, pArgs);
+ if (IsFailed(r))
+ {
+ AppLogException("Application execution failed-[%s].", GetErrorMessage(r));
+ }
+ end_profile();
+
+ AppLog("arg count %d", pArgs->GetCount());
+
+ for(int i =0 ; i < pArgs->GetCount(); i++)
+ {
+ AppLog("%ls", dynamic_cast<Tizen::Base::String*>(pArgs->GetAt(i)));
+ }
+ pArgs->RemoveAll(true);
+ delete pArgs;
+ AppLog("Application finished.");
+
+ return static_cast<int>(r);
+}
+#ifdef __cplusplus
+}
+#endif // __cplusplus
--- /dev/null
+{
+global:
+ OspMain;
+local:
+ *;
+};