initial push to rsa
authorjungmin76.park <jungmin76.park@samsung.com>
Tue, 18 Dec 2012 03:03:12 +0000 (12:03 +0900)
committerjungmin76.park <jungmin76.park@samsung.com>
Tue, 18 Dec 2012 13:05:50 +0000 (22:05 +0900)
Change-Id: If260be1dc22e14a839195cd121097f69e934680c
Signed-off-by: jungmin76.park <jungmin76.park@samsung.com>
24 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0755]
NOTICE [new file with mode: 0755]
data/dummy.txt [new file with mode: 0644]
icons/icon.png [new file with mode: 0644]
icons/splash.png [new file with mode: 0644]
inc/FShell_Livebox.h [new file with mode: 0644]
inc/FShell_LiveboxBase.h [new file with mode: 0644]
inc/FShell_LiveboxManagerService.h [new file with mode: 0644]
inc/FShell_LiveboxManagerStub.h [new file with mode: 0644]
inc/FShell_LiveboxPopup.h [new file with mode: 0644]
inc/OspLiveboxService.h [new file with mode: 0644]
manifest.xml [new file with mode: 0644]
osp-livebox-service.manifest [new file with mode: 0644]
packaging/osp-livebox-service.spec [new file with mode: 0644]
res/screen-density-xhigh/tizen.png [new file with mode: 0644]
src/FShell_Livebox.cpp [new file with mode: 0644]
src/FShell_LiveboxBase.cpp [new file with mode: 0644]
src/FShell_LiveboxManagerService.cpp [new file with mode: 0644]
src/FShell_LiveboxManagerStub.cpp [new file with mode: 0644]
src/FShell_LiveboxPopup.cpp [new file with mode: 0644]
src/OspLiveboxService.cpp [new file with mode: 0644]
src/OspLiveboxServiceEntry.cpp [new file with mode: 0644]
system-service-export.ver [new file with mode: 0755]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..68e5a38
--- /dev/null
@@ -0,0 +1,61 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target samsung-livebox-service)
+SET (APPID 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/chromium
+       inc
+       )
+
+SET (${this_target}_SOURCE_FILES
+       src/OspLiveboxService.cpp
+       src/OspLiveboxServiceEntry.cpp
+       src/FShell_Livebox.cpp
+       src/FShell_LiveboxBase.cpp
+       src/FShell_LiveboxManagerService.cpp
+       src/FShell_LiveboxManagerStub.cpp
+       src/FShell_LiveboxPopup.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}")
+
+## 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")
+
+
+## Cory additional info
+INSTALL(TARGETS ${this_target} DESTINATION ../usr/apps/${APPID}/bin)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/manifest.xml DESTINATION ../usr/apps/${APPID}/info)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data DESTINATION ../usr/apps/${APPID})
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ../usr/apps/${APPID}/data FILES_MATCHING PATTERN "*.ini")
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100755 (executable)
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+                                 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.
diff --git a/NOTICE b/NOTICE
new file mode 100755 (executable)
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+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.
diff --git a/data/dummy.txt b/data/dummy.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/icons/icon.png b/icons/icon.png
new file mode 100644 (file)
index 0000000..8169106
Binary files /dev/null and b/icons/icon.png differ
diff --git a/icons/splash.png b/icons/splash.png
new file mode 100644 (file)
index 0000000..7474959
Binary files /dev/null and b/icons/splash.png differ
diff --git a/inc/FShell_Livebox.h b/inc/FShell_Livebox.h
new file mode 100644 (file)
index 0000000..7a01fb2
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// 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       FShell_Livebox.h
+ * @brief      This is the header file for the _Livebox class.
+ *
+ * This header file contains the declarations of the _Livebox class.
+ */
+
+#ifndef FShell_Livebox_H_
+#define FShell_Livebox_H_
+
+#include <provider.h>
+#include <provider_buffer.h>
+
+#include <FAppTypes.h>
+#include <FBaseRtTimer.h>
+#include <FBaseObject.h>
+#include <FBaseColArrayList.h>
+
+#include "FShell_LiveboxBase.h"
+
+
+#define MAX_PACKAGENAME  512
+
+
+namespace Tizen { namespace Shell  { namespace App
+{
+class _LiveboxPopup;
+
+class _Livebox
+        : public _LiveboxBase
+         ,public Tizen::Base::Runtime::ITimerEventListener
+{
+public:
+       _Livebox(const Tizen::Base::String& name, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId,
+                                               int width, int height, int period, int priority);
+       virtual ~_Livebox();
+       void OnAdded(void);
+       void OnUpdate(void);
+       void OnResize(int width, int height);
+       void OnRemoved();
+       void OnForeground();
+       void OnBackground();
+       virtual void OnPopupCreated(int width, int height);
+       virtual void OnPopupDestoyed(void);
+
+       result RequestUpdateRemote(int width, int height);
+
+       _LiveboxPopup* GetLiveboxPopup() 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);
+       result SendResizeRequest(int width, int height);
+       result SendRemoveRequest();
+
+       result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::ArrayList* pArgs);
+
+       virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+
+private:
+       _LiveboxPopup* __pLiveboxPopup;
+       Tizen::Base::Runtime::Timer __lifeDurationTimer;
+       Tizen::Base::Runtime::Timer __UpdateTimer;
+       int __UpdateMillis;
+
+};
+
+
+} } } // Tizen::Shell::App {
+
+
+#endif /* FShell_Livebox_H_ */
diff --git a/inc/FShell_LiveboxBase.h b/inc/FShell_LiveboxBase.h
new file mode 100644 (file)
index 0000000..66770d2
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * FShell_LiveboxBase.h
+ *
+ *  Created on: Oct 20, 2012
+ *      Author: jungmin76park
+ */
+
+#ifndef _FSHL_LIVEBOXBASE_H_
+#define _FSHL_LIVEBOXBASE_H_
+
+#include <provider.h>
+
+#include <FAppTypes.h>
+#include <FBaseObject.h>
+#include <FBaseColArrayList.h>
+
+#define TEST_MODE_ENABLE false // If this is enabled, appId of Livebox will be fixed to "EOE7JEjMWn.SampleLiveboxApp" for easy test
+#define LIVEBOX_PROVIDER_ID_ENABLE true
+
+typedef struct _bundle_t bundle;//TODO move code to osp-appfw
+
+namespace Tizen { namespace Shell  { namespace App
+{
+
+class _LiveboxBase:
+       public Tizen::Base::Object
+{
+public:
+       _LiveboxBase(target_type type, const Tizen::Base::String& info, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int priority);
+       virtual ~_LiveboxBase();
+
+       virtual void OnPopupCreated(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 livebox
+       int GetSharedMemId(int w, int h);
+       result ReleaseSharedMem();
+
+
+protected:
+       result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::ArrayList* pArgs);
+
+public:
+       target_type __type;
+       Tizen::Base::String __info;
+       Tizen::Base::String __appId;
+       Tizen::Base::String __providerName;
+       Tizen::Base::String __providerId;
+       Tizen::Base::String __instanceId;
+       int __width;
+       int __height;
+       int __priority;
+
+protected:
+       struct livebox_buffer *__buffer_info;
+       void *__buffer;
+       bool __isForeground;// LB only?
+       int __ipcClientId;
+
+};
+
+class _LiveboxRequestHelper
+{
+public:
+       static result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::ArrayList* pArgs);
+       static result AddStrArrayToBundle(bundle* b, const char* key, const Tizen::Base::Collection::IList* pList);
+//     static result ExtractPackageIdAndExecutableName(Tizen::App::AppId inAppId, Tizen::Base::String& outPackageId, Tizen::Base::String& outExecutableName);
+};
+
+} /* namespace App */
+} /* namespace Livebox */
+} /* namespace Samsung */
+#endif /* _FSHL_LIVEBOXBASE_H_ */
diff --git a/inc/FShell_LiveboxManagerService.h b/inc/FShell_LiveboxManagerService.h
new file mode 100644 (file)
index 0000000..ce84e40
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// 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       FShell_LiveboxManagerService.h
+ * @brief      This is the header file for the %LiveboxManagerService class.
+ *
+ * This header file contains the declarations of the %LiveboxManagerService class.
+ */
+
+#ifndef FShell_LiveboxMANAGERSERVICE_H_
+#define FShell_LiveboxMANAGERSERVICE_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseRtTimer.h>
+#include <FApp_IAppManagerEventListener.h>
+#include <FShell_Livebox.h>
+//#include <FBaseColHashMapT.h>
+#include <FBaseColArrayListT.h>
+#include "FShell_LiveboxManagerStub.h"
+
+namespace Tizen { namespace Shell  { namespace App {
+
+
+class LiveboxManagerService
+       :public Tizen::Shell::App::_LiveboxManagerStub
+        ,public Tizen::App::_IAppManagerEventListener
+        ,public Tizen::Base::Runtime::ITimerEventListener
+{
+public:
+       static LiveboxManagerService* GetInstance(void);
+       result AddLivebox(_Livebox* pLivebox);
+       result RemoveLivebox(const char* pPackageName, const char* pId, bool free);
+
+private:
+       result Construct();
+       result InitializeMasterDaemonEventReceiver(const char* pServiceExecutableName);
+       result DeinitializeMasterDaemonEventReceiver(void);
+
+       // master daemon callbacks
+       static int LiveboxConnected(struct event_arg *arg, void* data);
+       static int LiveboxDisconnected(struct event_arg *arg, void* data);
+       static int OnLiveboxCreate(struct event_arg *arg, int *width, int *height, double *priority, void* data);
+       static int OnLiveboxDestroy(struct event_arg *arg, void* data);
+       static int OnLiveboxUpdate(struct event_arg *arg, void* data);
+       static int OnLiveboxPopupCreate(struct event_arg *arg, void* data);
+       static int OnLiveboxPopupDestroy(struct event_arg *arg, void* data);
+       static int OnLivePause(struct event_arg *arg, void* data);
+       static int OnLiveboxResume(struct event_arg *arg, void* data);
+       static int OnLiveboxClick(struct event_arg *arg, void* data);
+       static int OnLiveboxResize(struct event_arg *arg, void* data);
+       static int OnLiveboxPeriodChaned(struct event_arg *arg, void* data);
+
+       // stub implementations
+       virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName);
+       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
+       LiveboxManagerService();
+       virtual ~LiveboxManagerService();
+
+       virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
+       virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
+
+       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 UpdateAllLiveboxesByAppId(const Tizen::Base::String& appId);
+
+       void StartPingTimer();
+       virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+       _Livebox* 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<_Livebox*> __liveboxes;
+       Tizen::Base::Runtime::Timer __pingTimer;
+       _TaskHandlerThread      __handlerThread;
+};
+
+} } } // Tizen::Shell::App {
+
+#endif /* FShell_LiveboxMANAGERSERVICE_H_ */
diff --git a/inc/FShell_LiveboxManagerStub.h b/inc/FShell_LiveboxManagerStub.h
new file mode 100644 (file)
index 0000000..00d8a4c
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// 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       FAppAppManager.h
+ * @brief      This is the header file for the %AppManager class.
+ *
+ * This header file contains the declarations of the %AppManager class.
+ */
+
+#ifndef _FAPP_INTERNAL_APP_MANAGER_STUB_H_
+#define _FAPP_INTERNAL_APP_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              _LiveboxManagerStub
+ * @brief              Handles IPC requests and calls real methods.
+ * @since 2.1
+ */
+class _LiveboxManagerStub
+       : 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:
+       _LiveboxManagerStub(void);
+       virtual ~_LiveboxManagerStub(void);
+
+       // handlers
+       bool OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, 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) = 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:
+       _LiveboxManagerStub(const _LiveboxManagerStub& value);
+       _LiveboxManagerStub& operator =(const _LiveboxManagerStub& source);
+
+
+protected:
+       Tizen::Io::_IpcServer *__pIpcServer;
+};     //_LiveboxManagerStub
+
+}}}
+
+#endif//_FAPP_INTERNAL_APP_MANAGER_STUB_H_
diff --git a/inc/FShell_LiveboxPopup.h b/inc/FShell_LiveboxPopup.h
new file mode 100644 (file)
index 0000000..b93d26e
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * FShell_LiveboxPopup.h
+ *
+ *  Created on: Oct 19, 2012
+ *      Author: jungmin76park
+ */
+
+#ifndef _FSHL_LiveboxPopup_H_
+#define _FSHL_LiveboxPopup_H_
+
+#include "FShell_LiveboxBase.h"
+
+namespace Tizen { namespace Shell { namespace App
+{
+
+class _LiveboxPopup
+        :public Tizen::Shell::App::_LiveboxBase
+{
+public:
+       _LiveboxPopup(const Tizen::Base::String& info, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int priority);
+       virtual ~_LiveboxPopup();
+
+       // event handler
+       void OnPopupCreated(int width, int height);
+       void OnPopupDestoyed(void);
+
+       // request to app
+       result SendPopupCreateRequest(int width, int height);
+       result SendPopupDestroyRequest();
+       virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y);
+
+       result RequestUpdateRemote();
+};
+
+
+} /* namespace App */
+} /* namespace Livebox */
+} /* namespace Samsung */
+#endif /* _FSHL_LiveboxPopup_H_ */
diff --git a/inc/OspLiveboxService.h b/inc/OspLiveboxService.h
new file mode 100644 (file)
index 0000000..695afb7
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// 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       OspLiveboxService.h
+ * @brief      This is the header file for the OspLiveboxService class.
+ *
+ * This header file contains the declarations of the OspLiveboxService class.
+ */
+
+#ifndef _OSPLIVEBOXSERVICE_H_
+#define _OSPLIVEBOXSERVICE_H_
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FSystem.h>
+//#include <FUi.h>
+
+/**
+ * [OspLiveboxService] ServiceApp must inherit from ServiceApp class
+ * which provides basic features necessary to define an ServiceApp.
+ */
+class OspLiveboxService
+//     : public Tizen::App::ServiceApp
+       : public Tizen::App::ServiceApp
+{
+public:
+
+       /**
+        * [OspLiveboxService] ServiceApp must have a factory method that creates an instance of itself.
+        */
+       static Tizen::App::ServiceApp* CreateInstance(void);
+
+public:
+
+       OspLiveboxService();
+       ~OspLiveboxService();
+
+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_
diff --git a/manifest.xml b/manifest.xml
new file mode 100644 (file)
index 0000000..a228dd4
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/06/manifest">
+    <Id>gi2qxenosh</Id>
+    <Version>1.0.0</Version>
+    <Type>C++App</Type>
+    <Vendors>
+        <Vendor Locale="eng-GB"/>
+    </Vendors>
+    <Descriptions>
+        <Description Locale="eng-GB"/>
+    </Descriptions>
+    <Url/>
+    <Requirements/>
+    <Apps>
+        <ApiVersion>2.1</ApiVersion>
+        <Secret/>
+        <Privileges>
+            <Privilege>http://tizen.org/privilege/application.launch</Privilege>
+            <Privilege>http://tizen.org/privilege/appmanager.launch</Privilege>
+        </Privileges>
+        <ServiceApp AutoRestart="False" Default="True" ExecutableName="samsung-livebox-service" LaunchOnBoot="False">
+            <Names>
+                <Name Locale="eng-GB">samsung-livebox-service</Name>
+            </Names>
+            <Icons/>
+            <AppControls/>
+            <DataControls/>
+            <LaunchConditions/>
+            <Notifications/>
+        </ServiceApp>
+    </Apps>
+</Manifest>
diff --git a/osp-livebox-service.manifest b/osp-livebox-service.manifest
new file mode 100644 (file)
index 0000000..9aadc6f
--- /dev/null
@@ -0,0 +1,12 @@
+<manifest>
+       <define>
+               <domain name="osp-livebox-service"/>
+       </define>
+       <request>
+               <domain name="osp-livebox-service"/>
+       </request>
+       <assign>
+               <filesystem path="/usr/apps/gi2qxenosh/bin/osp-livebox-service.sh" label="osp-livebox-service" exec_label="osp-livebox-service"/>
+               <filesystem path="/usr/share/license/osp-livebox-service" label="_"/>
+       </assign>
+</manifest>
diff --git a/packaging/osp-livebox-service.spec b/packaging/osp-livebox-service.spec
new file mode 100644 (file)
index 0000000..94604f6
--- /dev/null
@@ -0,0 +1,71 @@
+Name: osp-livebox-service
+Summary:       osp livebox service
+Version:       1.2.1.0
+Release:       1
+Group:         System/Libraries
+License:       TO_BE/FILLED_IN
+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
+%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 -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}
+if [ -f /usr/lib/rpm-plugins/msm.so ]
+then
+       chsmack -a %{name} /usr/apps/gi2qxenosh/bin/%{name}
+       chsmack -e %{name} /usr/apps/gi2qxenosh/bin/%{name}
+fi
+
+#%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+/usr/share/license/%{name}
+/usr/apps/*
+#/opt/apps/gi2qxenosh/*
+
+
diff --git a/res/screen-density-xhigh/tizen.png b/res/screen-density-xhigh/tizen.png
new file mode 100644 (file)
index 0000000..66cdf2f
Binary files /dev/null and b/res/screen-density-xhigh/tizen.png differ
diff --git a/src/FShell_Livebox.cpp b/src/FShell_Livebox.cpp
new file mode 100644 (file)
index 0000000..0cd59e7
--- /dev/null
@@ -0,0 +1,296 @@
+//
+// 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       FShell_Livebox.cpp
+ * @brief      This is the implementation for the Livebox 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_LiveboxManagerService.h"
+#include "FShell_LiveboxPopup.h"
+#include "FShell_LiveboxBase.h"
+#include "FShell_Livebox.h"
+
+
+namespace Tizen { namespace Shell  { namespace App
+{
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+
+const String LIVEBOX_ON_ADD(L"Livebox='event=add'");
+const String LIVEBOX_ON_REMOVE(L"Livebox='event=remove'");
+const String LIVEBOX_ON_UPDATE(L"Livebox='event=update'");
+const String LIVEBOX_ON_RESIZE(L"Livebox='event=resize'");
+const String LIVEBOX_ON_TOUCH(L"Livebox='event=touch'");
+
+const int LIVE_DURATION_MSEC= 30000;//30sec
+
+_Livebox::_Livebox(const String& info, const String& providerId, const String& instanceId, int width, int height, int period, int priority)
+:_LiveboxBase(TYPE_LB, info, providerId, instanceId, width, height, priority)
+,__pLiveboxPopup(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);
+       }
+}
+
+_Livebox::~_Livebox()
+{
+       SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+       __lifeDurationTimer.Cancel();
+       __UpdateTimer.Cancel();
+}
+
+_LiveboxPopup*
+_Livebox::GetLiveboxPopup() const
+{
+       return __pLiveboxPopup;
+}
+
+void
+_Livebox::OnAdded(void)
+{
+       SendAddRequest(__width, __height);
+}
+
+void
+_Livebox::OnRemoved()
+{
+       SendRemoveRequest();
+}
+
+void
+_Livebox::OnUpdate(void)
+{
+       SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+
+       SendUpdateRequest(__width, __height);
+}
+
+void
+_Livebox::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
+_Livebox::OnForeground()
+{
+       SysLog(NID_APP, "");
+       __isForeground = true;
+
+       __UpdateTimer.Cancel();
+       __UpdateTimer.StartAsRepeatable(__UpdateMillis);
+}
+
+void
+_Livebox::OnBackground()
+{
+       SysLog(NID_APP, "");
+       __isForeground = false;
+       __UpdateTimer.Cancel();
+}
+
+void
+_Livebox::OnPopupCreated(int width, int height)
+{
+       __pLiveboxPopup = new (std::nothrow) _LiveboxPopup(__info, __providerId, __instanceId, width, height, __priority);
+       __pLiveboxPopup->SetClientId(__ipcClientId);
+       __pLiveboxPopup->OnPopupCreated(width, height);
+
+       __lifeDurationTimer.Cancel();
+}
+
+void
+_Livebox::OnPopupDestoyed(void)
+{
+       if (__pLiveboxPopup)
+       {
+               __pLiveboxPopup->OnPopupDestoyed();
+               __pLiveboxPopup->ReleaseSharedMem();
+               delete __pLiveboxPopup;
+       }
+
+       __pLiveboxPopup = null;
+
+       RestartLifeDurationTimer();
+}
+
+result
+_Livebox::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)));
+
+       return SendRequestToApp( __appId, LIVEBOX_ON_ADD, pArgs.get());
+}
+
+result
+_Livebox::SendUpdateRequest(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)));
+
+       return SendRequestToApp( __appId, LIVEBOX_ON_UPDATE, pArgs.get());
+}
+
+result
+_Livebox::SendResizeRequest(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)));
+
+       return SendRequestToApp( __appId, LIVEBOX_ON_RESIZE, pArgs.get());
+}
+
+result
+_Livebox::SendRemoveRequest()
+{
+       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));
+
+       return SendRequestToApp( __appId, LIVEBOX_ON_REMOVE, pArgs.get());
+}
+
+result
+_Livebox::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(__providerId));
+               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, LIVEBOX_ON_TOUCH, pArgs.get());
+       }
+       else
+       {
+//             SysAssertf( Tizen::App::AppManager::GetInstance()->IsRunning(__appId) == false, "application isn't running");
+               LiveboxManagerService::GetInstance()->SendTouchEvent(__ipcClientId, __instanceId, event, timestamp, x, y);
+       }
+       return E_SUCCESS;
+}
+
+result
+_Livebox::SendRequestToApp(const AppId& appId, const String& operation, ArrayList* pArgs)
+{
+       result r = _LiveboxBase::SendRequestToApp(appId, operation, pArgs);
+       RestartLifeDurationTimer();
+
+       return r;
+}
+
+result
+_Livebox::RequestUpdateRemote(int width, int height)
+{
+       /*if( GetLiveboxPopup() != null)
+       {
+               SysLog(NID_APP, "LiveboxPopup is appeared, so livebox 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(__info));
+
+       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
+_Livebox::RestartLifeDurationTimer()
+{
+       __lifeDurationTimer.Cancel();
+       __lifeDurationTimer.Start(LIVE_DURATION_MSEC);
+       SysLog(NID_APP, "lifeDuration timer restarted (%d)msec", LIVE_DURATION_MSEC);
+}
+
+void
+_Livebox::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
+{
+       SysLog(NID_APP, "");
+
+       if( &timer == &__lifeDurationTimer)
+       {
+               SysLog(NID_APP, "lifeDuration timer is expired, so terminating livebox app(%ls)..", __providerId.GetPointer() );
+
+#if TEST_MODE_ENABLE
+               AppManager::GetInstance()->TerminateApplication(L"EOE7JEjMWn.SampleLiveboxApp");//todo remove this
+#else
+               AppManager::GetInstance()->TerminateApplication(__providerId);
+#endif
+       }
+       else if( &timer == &__UpdateTimer)
+       {
+               SysLog(NID_APP, "update timer is expired for livebox app(%ls)..", __providerId.GetPointer() );
+               OnUpdate();
+       }
+}
+
+
+} } } // Tizen::Shell::App {
+
diff --git a/src/FShell_LiveboxBase.cpp b/src/FShell_LiveboxBase.cpp
new file mode 100644 (file)
index 0000000..c328fb1
--- /dev/null
@@ -0,0 +1,335 @@
+//
+// 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       FShell_LiveboxBase.cpp
+ * @brief      This is the implementation for the Livebox 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_AppControlManager.h>
+#include <FShell_TemplateUtil.h>
+#include <FShell_LiveboxManagerImpl.h>
+
+#include "FShell_LiveboxBase.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 LiveboxHandleBufferEventCallback( 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 LIVEBOX_ON_ADD(L"Livebox='event=add'");
+const String LIVEBOX_ON_REMOVE(L"Livebox='event=remove'");
+const String LIVEBOX_ON_UPDATE(L"Livebox='event=update'");
+const String LIVEBOX_ON_RESIZE(L"Livebox='event=resize'");
+const String LIVEBOX_ON_TOUCH(L"Livebox='event=touch'");
+const String LIVEBOX_TRAY_ON_CREATE(L"LiveboxTray='event=create'");
+const String LIVEBOX_TRAY_ON_DESTROY(L"LiveboxTray='event=destroy'");
+const String LIVEBOX_TRAY_ON_TOUCH(L"LiveboxTray='event=touch'");
+
+
+_LiveboxBase::_LiveboxBase(target_type type, const String& info, const String& providerId, const String& instanceId, int width, int height, int priority)
+       :__type(type)
+       ,__info(info)
+       ,__providerId(providerId)
+       ,__instanceId(instanceId)
+       ,__width(width)
+       ,__height(height)
+       ,__priority(priority)
+       ,__buffer_info(null)
+       ,__buffer(null)  // __pEcoreEvas(null), __pEvas(null), __current(0)
+       ,__isForeground(true)
+       ,__ipcClientId(-1)
+{
+       /*providerId.IndexOf(".", 11, index);
+       providerId.SubString(0, index, __appId);
+       providerId.SubString(index+1, __providerName);*/
+       _LiveboxManagerImpl::ExtractAppIdAndProviderName(providerId, __appId, __providerName);
+
+       SysLog(NID_APP, "providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+       SysLog(NID_APP, "appId(%ls)", __appId.GetPointer());
+}
+
+_LiveboxBase::~_LiveboxBase()
+{
+       SysLog(NID_APP, "providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+}
+
+
+void
+_LiveboxBase::SetClientId(int clientId)
+{
+       __ipcClientId = clientId;
+}
+
+bool
+_LiveboxBase::HasValidClientId() const
+{
+       SysLog(NID_APP, "%d", __ipcClientId);
+       return (__ipcClientId > -1);
+}
+
+int
+_LiveboxBase::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), LiveboxHandleBufferEventCallback, 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
+_LiveboxBase::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;
+}
+
+result
+_LiveboxBase::SendRequestToApp(const AppId& appId, const String& operation, ArrayList* pArgs)
+{
+       if( __isForeground == false)
+       {
+               SysLog(NID_APP, "livebox isn't foreground, so, message skip");
+               return E_SUCCESS;
+       }
+
+#if TEST_MODE_ENABLE
+       const String sampleLiveboxAppId(L"EOE7JEjMWn.SampleLiveboxApp"); //TODO: specify appid for temporary test
+       return _LiveboxRequestHelper::SendRequestToApp(sampleLiveboxAppId, operation, pArgs);
+#else
+       return _LiveboxRequestHelper::SendRequestToApp(appId, operation, pArgs);
+#endif
+
+}
+
+result
+_LiveboxRequestHelper::SendRequestToApp(const AppId& appId, const String& operation, ArrayList* pArgs)
+{
+       SysLog(NID_APP, "operation(%ls)", operation.GetPointer());
+
+       String outAppId;
+       String execName;
+
+//     ExtractPackageIdAndExecutableName(appId, outAppId, execName);
+
+       const char OSP_K_APPCONTROL_OPERATION[] =  "__OSP_APPCONTROL_OPERATION__";
+       const char OSP_K_APPCONTROL_INTERNAL_OPERATION[] = "__OSP_APPCONTROL_INTERNAL_INTERNAL_OPERATION__";
+       const char OSP_K_ARG[] =  "__OSP_ARGS__";
+
+       _AppMessageImpl msg;
+
+       msg.AddData(OSP_K_APPCONTROL_OPERATION, operation);
+       msg.AddData(OSP_K_APPCONTROL_INTERNAL_OPERATION, L"livebox");
+       AddStrArrayToBundle(msg.GetBundle(), OSP_K_ARG, pArgs);
+
+       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
+_LiveboxRequestHelper::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
+_LiveboxRequestHelper::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 LiveboxHandleBufferEventCallback( 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::_LiveboxBase *pLiveboxBase = static_cast<Tizen::Shell::App::_LiveboxBase*>(data);
+    SysTryReturn(NID_APP, pLiveboxBase != null, 0, E_SYSTEM, "[E_SYSTEM] retrieved pLiveboxBase 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");
+       }
+
+    pLiveboxBase->SendTouchEvent(event, timestamp, x, y);
+
+    return 0;
+}
diff --git a/src/FShell_LiveboxManagerService.cpp b/src/FShell_LiveboxManagerService.cpp
new file mode 100644 (file)
index 0000000..5284069
--- /dev/null
@@ -0,0 +1,624 @@
+//
+// 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       FAppAppManager.cpp
+ * @brief      This is the implementation for the AppManager 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_Livebox.h"
+#include "FShell_LiveboxPopup.h"
+#include "FShell_LiveboxManagerStub.h"
+
+#include "FShell_LiveboxManagerService.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;
+}
+
+LiveboxManagerService::LiveboxManagerService()
+{
+}
+
+LiveboxManagerService::~LiveboxManagerService()
+{
+       __pingTimer.Cancel();
+       DeinitializeMasterDaemonEventReceiver();
+}
+
+LiveboxManagerService*
+LiveboxManagerService::GetInstance(void)
+{
+       static LiveboxManagerService* pSelf = null;
+       if( pSelf == null)
+       {
+               pSelf = new LiveboxManagerService();
+               SysTryReturn(NID_APP, pSelf != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+               result r = pSelf->Construct();
+               SysAssertf(!IsFailed(r), "Failed to construct LiveboxManagerService");
+               SysLog(NID_APP, "LiveboxManagerService is created.");
+       }
+       return pSelf;
+}
+
+result
+LiveboxManagerService::Construct()
+{
+       _AppManagerImpl::GetInstance()->AddEventListener(*this);
+
+       _LiveboxManagerStub::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("samsung-livebox-service");
+}
+
+int
+LiveboxManagerService::LiveboxConnected(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");
+       LiveboxManagerService::GetInstance()->StartPingTimer();
+
+    }
+    else
+    {
+       SysLog(NID_APP, "failed to provider_send_hello()");
+    }
+    return ret;
+}
+
+int
+LiveboxManagerService::LiveboxDisconnected(struct event_arg *arg, void* data)
+{
+       SysLog(NID_APP, "success to be disconnected with master daemon");
+//     aul_terminate_pid(getpid());
+    return 0;
+}
+
+void
+LiveboxManagerService::StartPingTimer()
+{
+       __pingTimer.Construct(*this);//, true);
+       __pingTimer.StartAsRepeatable(120000);
+}
+
+void
+LiveboxManagerService::OnTimerExpired(Timer& timer)
+{
+       SysLog(NID_APP, "provider_send_ping");
+       provider_send_ping();
+}
+
+_Livebox*
+LiveboxManagerService::Find(const String& appId, const String& instanceId) const
+{
+       for( int i = 0; i < __liveboxes.GetCount(); i++ )
+       {
+               _Livebox* pLivebox = null;
+               __liveboxes.GetAt(i, pLivebox);
+               SysLog(NID_APP, "%ls", pLivebox->__instanceId.GetPointer());
+
+               if ( pLivebox->__instanceId == instanceId )
+               {
+//                     SysAssert(pLivebox->__appId == appId)
+                       return pLivebox;
+               }
+       }
+       return null;
+}
+
+result
+LiveboxManagerService::SetClientIds(const Tizen::App::AppId& appId, int clientId)
+{
+       for( int i = 0; i < __liveboxes.GetCount(); i++ )
+       {
+               _Livebox* pLivebox = null;
+               __liveboxes.GetAt(i, pLivebox);
+               SysLog(NID_APP, "%ls", pLivebox->__instanceId.GetPointer());
+               SysLog(NID_APP, "%ls, %ls", pLivebox->__providerId.GetPointer(), appId.GetPointer());
+
+#if TEST_MODE_ENABLE
+               String sampleAppId = L"EOE7JEjMWn.SampleLiveboxApp";
+               if( sampleAppId == appId) //TODO: specify appid for temporary test
+#else
+               if ( pLivebox->__providerId == appId )
+#endif
+               {
+                       pLivebox->SetClientId(clientId);
+                       SysLog(NID_APP, "client is registered.(%d)", clientId);
+               }
+       }
+       return E_SUCCESS;
+}
+
+void
+LiveboxManagerService::OnApplicationLaunched(const AppId& appId, _AppType type)
+{
+
+}
+
+void
+LiveboxManagerService::OnApplicationTerminated(const AppId& appId, _AppType type)
+{
+       this->SetClientIds(appId, -1);
+}
+
+void
+LiveboxManagerService::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);
+
+}
+
+void
+LiveboxManagerService::OnIpcClientDisconnected(const _IpcServer& server, int clientId)
+{
+       String fullAppId = server.GetClientAppId() + "." + server.GetClientAppExecutableName();
+       SysLog(NID_APP, "(%ls)\n", fullAppId.GetPointer());
+//     SysLog(NID_APP, "(appId:%ls, pid:%d, clientId:%d)\n", server.GetClientAppId().GetPointer(), server.GetClientProcessId(), clientId);
+//     this->SetClientIds(server.GetClientAppId(), -1);
+}
+
+result
+LiveboxManagerService::AddLivebox(_Livebox* pLivebox)
+{
+       SysLog(NID_APP, "%ls, %ls, count(%d)", pLivebox->__providerId.GetPointer(), pLivebox->__instanceId.GetPointer(), __liveboxes.GetCount());
+
+       return __liveboxes.Add(pLivebox);
+}
+
+result
+LiveboxManagerService::RemoveLivebox(const char* pPackageName, const char* pId, bool free)
+{
+       SysLog(NID_APP, "%s, %s, count(%d)", pPackageName, pId, __liveboxes.GetCount());
+
+       SysTryReturn(NID_APP, ( pPackageName != null && pId != null), null, E_INVALID_ARG, "[E_INVALID_ARG]");
+       SysLog(NID_APP, "%s, %s", pPackageName, pId);
+
+       _Livebox* pLivebox = Find(pPackageName, pId);
+       SysTryReturn(NID_APP, pLivebox, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND]");
+
+       result r = __liveboxes.Remove(pLivebox);
+
+       if( __liveboxes.GetCount() == 0 )
+       {
+               SysLog(NID_APP, "No running native livebox app remains, terminating samsung livebox service...");
+               Tizen::App::App::GetInstance()->Terminate();
+       }
+
+       return r;
+}
+
+
+///////////////////////////////////////////////////////
+// MasterDaemonEventReceiver implementation
+///////////////////////////////////////////////////////
+int
+LiveboxManagerService::OnLiveboxCreate(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)", arg->pkgname, arg->id, arg->info.lb_create.content, arg->info.lb_create.cluster, arg->info.lb_create.category );
+       SysTryReturn (NID_APP, LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id) == null, -EBUSY, E_SUCCESS,"already exist");
+
+       double default_priority = 1.0f;
+       _Livebox* pLivebox = new (std::nothrow)_Livebox( 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, pLivebox, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+       LiveboxManagerService* pLiveboxService = LiveboxManagerService::GetInstance();
+       pLiveboxService->AddLivebox(pLivebox);
+       pLivebox->OnAdded();
+
+       *priority = pLivebox->__priority;
+       *height= pLivebox->__height;
+       *width = pLivebox->__width;
+
+       SysLog(NID_APP, "Exit. %d livebox(es)", pLiveboxService->__liveboxes.GetCount());
+    return 0;
+}
+
+int
+LiveboxManagerService::OnLiveboxUpdate(struct event_arg *arg, void* data)
+{
+       if( arg->id == null || strlen(arg->id) < 1)
+       {
+               SysLog(NID_APP, "updating alls");
+               LiveboxManagerService::GetInstance()->UpdateAllLiveboxesByAppId(arg->pkgname);
+       }
+       else
+       {
+               _Livebox* pLivebox = LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+               SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+               pLivebox->OnUpdate();
+       }
+
+       SysLog(NID_APP, "Exit");
+       return 0;
+}
+
+int
+LiveboxManagerService::UpdateAllLiveboxesByAppId(const String& providerId)
+{
+       for( int i = 0; i < __liveboxes.GetCount(); i++ )
+       {
+               _Livebox* pLivebox = null;
+               __liveboxes.GetAt(i, pLivebox);
+
+#if TEST_MODE_ENABLE
+               String sampleAppId = L"EOE7JEjMWn.SampleLiveboxApp";
+               if( sampleAppId == appId) //TODO: specify appid for temporary test
+#else
+               if ( pLivebox->__providerId == providerId )
+#endif
+               {
+                       pLivebox->OnUpdate();
+               }
+       }
+       return E_SUCCESS;
+}
+
+int
+LiveboxManagerService::OnLiveboxDestroy(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");
+
+       LiveboxManagerService* pLiveboxManagerService = LiveboxManagerService::GetInstance();
+
+       _Livebox* pLivebox = pLiveboxManagerService->Find(arg->pkgname, arg->id);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+    pLivebox->OnRemoved();
+    pLiveboxManagerService->RemoveLivebox( arg->pkgname, arg->id, true);
+    delete pLivebox;
+
+    SysLog(NID_APP, "Exit");
+    return 0;
+}
+
+int
+LiveboxManagerService::OnLiveboxPopupCreate(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);
+
+       SysLog(NID_APP, "Enter");
+       _Livebox* pLivebox = LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+       pLivebox->OnPopupCreated(arg->info.pd_create.w, arg->info.pd_create.h);
+
+       SysLog(NID_APP, "Exit");
+    return 0;
+}
+
+ int
+ LiveboxManagerService::OnLiveboxPopupDestroy(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), width(%d), height(%d), priority(%d)", arg->pkgname, arg->id);
+       SysLog(NID_APP, "Enter");
+
+       _Livebox* pLivebox = LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+       pLivebox->OnPopupDestoyed();
+
+        SysLog(NID_APP, "Exit");
+    return 0;
+}
+
+ int
+ LiveboxManagerService::OnLivePause(struct event_arg *arg, void* data)
+{
+        SysTryReturn(NID_APP, arg || arg->id || arg->pkgname, 0, E_SUCCESS, "arg is null!");
+        SysLog(NID_APP, "packageName(%s), id(%s)", arg->pkgname, arg->id);
+
+        _Livebox* pLivebox = LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+        SysTryReturnResult(NID_APP, pLivebox , 0, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+        pLivebox->OnBackground();
+
+    return 0;
+}
+
+int
+LiveboxManagerService::OnLiveboxResume(struct event_arg *arg, void* data)
+{
+       SysTryReturn(NID_APP, arg || arg->id || arg->pkgname, 0, E_SUCCESS, "arg is null!");
+       SysLog(NID_APP, "packageName(%s), id(%s)", arg->pkgname, arg->id);
+
+       _Livebox* pLivebox = LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+       pLivebox->OnForeground();
+    return 0;
+}
+
+int
+LiveboxManagerService::OnLiveboxClick(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
+LiveboxManagerService::OnLiveboxResize(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);
+
+       _Livebox* pLivebox = LiveboxManagerService::GetInstance()->Find(arg->pkgname, arg->id);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id);
+
+       pLivebox->OnResize(arg->info.resize.w, arg->info.resize.h);
+
+    return 0;
+}
+
+int
+LiveboxManagerService::OnLiveboxPeriodChaned(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
+LiveboxManagerService::InitializeMasterDaemonEventReceiver(const char *pServiceExecutableName)
+{
+       SysTryReturnResult(NID_APP, pServiceExecutableName != null, E_INVALID_ARG, "");
+       SysLog(NID_APP, "Enter.");
+
+       __liveboxes.Construct();
+
+       /*!
+        * \note
+        * Only for the buffer type
+        */
+    struct event_handler cbs;
+    memset(&cbs, 0, sizeof(event_handler));
+
+    cbs.connected = LiveboxConnected,
+    cbs.disconnected = LiveboxDisconnected,
+    cbs.pause = OnLivePause,
+    cbs.resume = OnLiveboxResume,
+    cbs.lb_create = OnLiveboxCreate,
+    cbs.lb_destroy = OnLiveboxDestroy,
+    cbs.update_content = OnLiveboxUpdate,
+    cbs.pd_create = OnLiveboxPopupCreate,
+    cbs.pd_destroy = OnLiveboxPopupDestroy,
+    cbs.clicked = OnLiveboxClick,
+    cbs.resize = OnLiveboxResize,
+    cbs.set_period = OnLiveboxPeriodChaned;
+    //cbs.lb_recreate = OnLiveboxRecreate,/* Recover from the fault of slave */
+    //cbs.content_event = OnLiveboxContentEvent,
+    //cbs.change_group = OnLiveboxGroupChanged;
+
+    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
+LiveboxManagerService::DeinitializeMasterDaemonEventReceiver()
+{
+       SysLog(NID_APP, "Enter.");
+    provider_fini();
+    SysLog(NID_APP, "Exit.");
+    return E_SUCCESS;
+}
+
+///////////////////////////////////////////////////////
+// stub implmentation
+///////////////////////////////////////////////////////
+
+result
+LiveboxManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName)//, const Tizen::Base::String& param)
+{
+       SysLog(NID_APP, "Enter.");
+
+       bool found = false;
+       for( int i = 0; i < __liveboxes.GetCount(); i++ )
+       {
+               _Livebox* pLivebox = null;
+               __liveboxes.GetAt(i, pLivebox);
+               SysLog(NID_APP, "%ls", pLivebox->__instanceId.GetPointer());
+
+               if ( pLivebox->__appId == appId && pLivebox->__providerName == providerName)
+               {
+                       SysLog(NID_APP, "OK");
+
+                       ArrayList* pArray = new ArrayList();
+                       SysTryReturnResult(NID_APP, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+                       pArray->Construct();
+                       pArray->Add(pLivebox);
+
+                       result r = __handlerThread.SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray);
+                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r));
+
+                       found = true;
+//                     pLivebox->OnUpdate();
+               }
+       }
+       SysLog(NID_APP, "Exit.");
+       return (found) ? E_SUCCESS : E_OBJ_NOT_FOUND;
+
+}
+
+result
+LiveboxManagerService::RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId)
+{
+       _Livebox* pLivebox = this->Find(appId, instanceId);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+       if(pLivebox->HasValidClientId() == false)
+       {
+               String fullAppId = __pIpcServer->GetClientAppId() + "." + __pIpcServer->GetClientAppExecutableName();
+               this->SetClientIds(fullAppId, __pIpcServer->GetClientId());
+       }
+
+       shmId = pLivebox->GetSharedMemId(width, height);
+       SysTryReturnResult(NID_APP, pLivebox , shmId != -1, "[E_SYSTEM] failed to GetSharedMemId for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+    return E_SUCCESS;
+}
+
+result
+LiveboxManagerService::RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId)
+{
+       _Livebox* pLivebox = this->Find(appId, instanceId);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+       _LiveboxPopup* pPd = pLivebox->GetLiveboxPopup();
+       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, pLivebox , shmId != -1, "[E_SYSTEM] failed to GetSharedMemId for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+    return E_SUCCESS;
+}
+
+result
+LiveboxManagerService::RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height)
+{
+       _Livebox* pLivebox = this->Find(appId, instanceId);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+       return pLivebox->RequestUpdateRemote(width, height);
+}
+
+result
+LiveboxManagerService::RequestSyncSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId)
+{
+       _Livebox* pLivebox = this->Find(appId, instanceId);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+       SysTryReturnResult(NID_APP, pLivebox->GetLiveboxPopup(), E_SYSTEM, "[E_SYSTEM] GetLiveboxPopup() returns null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+       return pLivebox->GetLiveboxPopup()->RequestUpdateRemote();
+}
+
+result
+LiveboxManagerService::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));
+
+       _Livebox* pLivebox = this->Find(appId, instanceId);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+       return pLivebox->ReleaseSharedMem();
+}
+
+result
+LiveboxManagerService::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));
+
+       _Livebox* pLivebox = this->Find(appId, instanceId);
+       SysTryReturnResult(NID_APP, pLivebox , E_SYSTEM, "[E_SYSTEM] pLivebox is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+       SysTryReturnResult(NID_APP, pLivebox->GetLiveboxPopup(), E_SYSTEM, "[E_SYSTEM] GetLiveboxPopup() returns null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+
+       return pLivebox->GetLiveboxPopup()->ReleaseSharedMem();
+}
+
+LiveboxManagerService::_TaskHandlerThread::~_TaskHandlerThread(void)
+{
+
+}
+
+void
+LiveboxManagerService::_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:
+       {
+               _Livebox* pLivebox = dynamic_cast<_Livebox*>( pArgs->GetAt(0) );
+               SysLog(NID_APP, "111.");
+               SysTryReturnVoidResult(NID_APP, pLivebox != null, E_INVALID_STATE, "_Livebox is null!.");
+               SysLog(NID_APP, "222.");
+               pLivebox->OnUpdate();
+               SysLog(NID_APP, "333.");
+               pArgs->RemoveAll();
+               delete pArgs;
+       }
+               break;
+
+       default:
+               SysAssertf(false, "never get here!");
+               break;
+       }
+       SysLog(NID_APP, "Exit.");
+}
+
+} } } //namespace Tizen { namespace Shell  { namespace App {
diff --git a/src/FShell_LiveboxManagerStub.cpp b/src/FShell_LiveboxManagerStub.cpp
new file mode 100644 (file)
index 0000000..761a932
--- /dev/null
@@ -0,0 +1,217 @@
+//
+// 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       FAppAppManager.cpp
+ * @brief      This is the implementation for the AppManager class.
+ */
+
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FIo_IpcServer.h>
+#include <FShell_LiveboxManagerIpcMessage.h>
+
+#include "FShell_LiveboxManagerStub.h"
+
+
+namespace Tizen { namespace Shell  { namespace App {
+
+namespace
+{
+const char IPC_SERVER_NAME[] = "osp.shell.ipcserver.liveboxmanager";
+const int INVALID_CLIENT_ID = -1;
+};
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Text;
+using namespace Tizen::Security;
+
+
+_LiveboxManagerStub::_LiveboxManagerStub(void)
+:__pIpcServer(null)
+{
+       SysLog(NID_APP, "Enter\n");
+
+       SysLog(NID_APP, "Exit\n");
+}
+
+_LiveboxManagerStub::~_LiveboxManagerStub(void)
+{
+       SysLog(NID_APP, "Enter\n");
+
+       if ( __pIpcServer != null)
+       {
+               __pIpcServer->Stop();
+               delete __pIpcServer;
+       }
+
+       SysLog(NID_APP, "Exit\n");
+}
+
+result
+_LiveboxManagerStub::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);
+       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
+_LiveboxManagerStub::OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, result* pRes)
+{
+       SysLog(NID_APP, "");
+       *pRes = RequestUpdate(appId, providerName);
+       return true;
+}
+
+bool
+_LiveboxManagerStub::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
+_LiveboxManagerStub::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
+_LiveboxManagerStub::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
+_LiveboxManagerStub::OnRequestSyncSharedMemoryForPD(const String& instanceId, result* pRes)
+{
+       SysLog(NID_APP, "(instanceId:%ls)", instanceId.GetPointer());
+
+       *pRes = RequestSyncSharedMemoryForPD(__pIpcServer->GetClientAppId(), instanceId);
+
+       return true;
+}
+
+bool
+_LiveboxManagerStub::OnRequestReleaseSharedMemory(const String& instanceId, result* pRes)
+{
+       SysLog(NID_APP, "(instanceId:%ls)", instanceId.GetPointer());
+
+       *pRes = RequestReleaseSharedMemory(__pIpcServer->GetClientAppId(), instanceId);
+
+       return true;
+}
+
+bool
+_LiveboxManagerStub::OnRequestReleaseSharedMemoryForPD(const String& instanceId, result* pRes)
+{
+       SysLog(NID_APP, "(instanceId:%ls)", instanceId.GetPointer());
+
+       *pRes = RequestReleaseSharedMemoryForPD(__pIpcServer->GetClientAppId(), instanceId);
+
+       return true;
+}
+
+bool
+_LiveboxManagerStub::SendTouchEvent(const int clientId, const String& instanceId, int eventType, double timestamp, double x, double y)
+{
+       SysLog(NID_APP,"");
+       result r = __pIpcServer->SendResponse(clientId, new LiveboxManager_SendTouchEvent(instanceId, eventType, timestamp, x, y));
+       SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+       return true;
+}
+
+bool
+_LiveboxManagerStub::SendTouchEventForPD(const int clientId, const String& instanceId, int eventType, double timestamp, double x, double y)
+{
+       SysLog(NID_APP,"");
+       result r = __pIpcServer->SendResponse(clientId, new LiveboxManager_SendTouchEventForPD(instanceId, eventType, timestamp, x, y));
+       SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
+
+       return true;
+}
+
+
+void
+_LiveboxManagerStub::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(_LiveboxManagerStub, message)
+               IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestUpdate, &server, OnRequestUpdate)
+               IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestSharedMemoryId, &server, OnRequestSharedMemoryId)
+               IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestSharedMemoryIdForPD, &server, OnRequestSharedMemoryIdForPD)
+               IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestSyncSharedMemory, &server, OnRequestSyncSharedMemory)
+               IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestSyncSharedMemoryForPD, &server, OnRequestSyncSharedMemoryForPD)
+               IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestReleaseSharedMemory, &server, OnRequestReleaseSharedMemory)
+               IPC_MESSAGE_HANDLER_EX(LiveboxManager_RequestReleaseSharedMemoryForPD, &server, OnRequestReleaseSharedMemoryForPD)
+       IPC_END_MESSAGE_MAP()
+}
+
+void
+_LiveboxManagerStub::OnIpcServerStarted(const _IpcServer& server)
+{
+       SysLog(NID_APP, "\n");
+}
+
+void
+_LiveboxManagerStub::OnIpcServerStopped(const _IpcServer& server)
+{
+       SysLog(NID_APP, "\n");
+}
+
+void
+_LiveboxManagerStub::OnIpcClientConnected(const _IpcServer& server, int clientId)
+{
+       SysLog(NID_APP, "(clientId:%d)\n", clientId);
+
+}
+
+void
+_LiveboxManagerStub::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 {
diff --git a/src/FShell_LiveboxPopup.cpp b/src/FShell_LiveboxPopup.cpp
new file mode 100644 (file)
index 0000000..c144030
--- /dev/null
@@ -0,0 +1,135 @@
+//
+// 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       FShell_Livebox.cpp
+ * @brief      This is the implementation for the Livebox 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_LiveboxManagerService.h"
+#include "FShell_LiveboxPopup.h"
+
+namespace Tizen { namespace Shell  { namespace App
+{
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+const String LIVEBOX_TRAY_ON_CREATE(L"LiveboxTray='event=create'");
+const String LIVEBOX_TRAY_ON_DESTROY(L"LiveboxTray='event=destroy'");
+const String LIVEBOX_TRAY_ON_TOUCH(L"LiveboxTray='event=touch'");
+
+_LiveboxPopup::_LiveboxPopup(const String& info, const String& appId, const String& instanceId, int width, int height, int priority)
+:_LiveboxBase(TYPE_PD, info, appId, instanceId, width, height, priority)
+{
+       SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
+}
+
+_LiveboxPopup::~_LiveboxPopup()
+{
+       SysLog(NID_APP, "appId(%ls), instanceId(%ls), width(%d), height(%d))", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
+}
+
+
+void
+_LiveboxPopup::OnPopupCreated(int width, int height)
+{
+       SysLog(NID_APP, "width(%d), height(%d)", width, height);
+       SendPopupCreateRequest(width, height);
+}
+
+void
+_LiveboxPopup::OnPopupDestoyed()
+{
+       SysLog(NID_APP, "");
+       SendPopupDestroyRequest();
+}
+
+result
+_LiveboxPopup::SendPopupCreateRequest(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)));
+
+       return SendRequestToApp( __appId, LIVEBOX_TRAY_ON_CREATE, pArgs.get());
+}
+
+result
+_LiveboxPopup::SendPopupDestroyRequest()
+{
+       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));
+
+       return SendRequestToApp( __appId, LIVEBOX_TRAY_ON_DESTROY, pArgs.get());
+}
+
+result
+_LiveboxPopup::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, LIVEBOX_TRAY_ON_TOUCH, pArgs.get());
+       }
+       else*/
+       {
+//             SysAssertf( Tizen::App::AppManager::GetInstance()->IsRunning(__appId) == false, "application isn't running");
+               LiveboxManagerService::GetInstance()->SendTouchEventForPD(__ipcClientId, __instanceId, event, timestamp, x, y);
+       }
+       return E_SUCCESS;
+}
+
+result
+_LiveboxPopup::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 {
+
diff --git a/src/OspLiveboxService.cpp b/src/OspLiveboxService.cpp
new file mode 100644 (file)
index 0000000..fb8cc5e
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// 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       OspLiveboxService.cpp
+ * @brief      This is the implementation for the OspLiveboxService class.
+ */
+
+#include "FShell_LiveboxManagerService.h"
+#include "OspLiveboxService.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::System;
+using namespace Tizen::Shell::App;
+
+
+OspLiveboxService::OspLiveboxService()
+{
+}
+
+OspLiveboxService::~OspLiveboxService()
+{
+}
+
+ServiceApp*
+OspLiveboxService::CreateInstance(void)
+{
+       // Create the instance through the constructor.
+       return new OspLiveboxService();
+}
+
+bool
+OspLiveboxService::OnAppInitializing(AppRegistry& appRegistry)
+{
+       AppLog("Enter.");
+
+       LiveboxManagerService* pSvc = LiveboxManagerService::GetInstance();
+       AppAssertf( pSvc != null, "LiveboxManagerService::GetInstance() failed.");
+
+       return true;
+}
+
+bool
+OspLiveboxService::OnAppInitialized(void)
+{
+       return true;
+}
+
+bool
+OspLiveboxService::OnAppWillTerminate(void)
+{
+       return true;
+}
+
+bool
+OspLiveboxService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+       return true;
+}
+
+void
+OspLiveboxService::OnLowMemory(void)
+{
+}
+
+void
+OspLiveboxService::OnBatteryLevelChanged(BatteryLevel batteryLevel)
+{
+}
diff --git a/src/OspLiveboxServiceEntry.cpp b/src/OspLiveboxServiceEntry.cpp
new file mode 100644 (file)
index 0000000..615a5d3
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// 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       OspLiveboxService.cpp
+ * @brief      This file contains the Tizen application entry point.
+ */
+
+#include "OspLiveboxService.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 ArrayList();
+       pArgs->Construct();
+       for (int i = 0; i < argc; i++)
+               pArgs->Add(*(new String(pArgv[i])));
+
+       start_profile();
+       r = Tizen::App::ServiceApp::Execute(OspLiveboxService::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
diff --git a/system-service-export.ver b/system-service-export.ver
new file mode 100755 (executable)
index 0000000..68c06a8
--- /dev/null
@@ -0,0 +1,6 @@
+{
+global:
+       OspMain;
+local:
+       *;
+};