Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:50:33 +0000 (01:50 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:50:33 +0000 (01:50 +0900)
16 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE.APLv2 [new file with mode: 0644]
NOTICE [new file with mode: 0644]
data/dummy [new file with mode: 0644]
icons/screen-density-xhigh/mainmenu.png [new file with mode: 0644]
inc/ChannelService.h [new file with mode: 0644]
inc/FIo_MessagePortService.h [new file with mode: 0644]
inc/FIo_MessagePortStub.h [new file with mode: 0644]
manifest.xml [new file with mode: 0644]
osp-channel-service.manifest [new file with mode: 0644]
packaging/osp-channel-service.spec [new file with mode: 0755]
src/ChannelService.cpp [new file with mode: 0644]
src/ChannelServiceEntry.cpp [new file with mode: 0644]
src/FIo_MessagePortService.cpp [new file with mode: 0644]
src/FIo_MessagePortStub.cpp [new file with mode: 0644]
system-service-export.ver [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3ee79a5
--- /dev/null
@@ -0,0 +1,51 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target osp-channel-service)
+SET (APPID cp7ipabg4k)
+
+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/osp
+       /usr/include/osp/app
+       /usr/include/osp/base
+       /usr/include/osp/io
+       /usr/include/chromium
+       inc
+       )
+
+SET (${this_target}_SOURCE_FILES
+       src/ChannelService.cpp
+       src/ChannelServiceEntry.cpp
+       src/FIo_MessagePortStub.cpp
+       src/FIo_MessagePortService.cpp
+       )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -fPIE -Wall -pthread -g3" )
+
+## 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")
+
+
+## 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.APLv2 b/LICENSE.APLv2
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
@@ -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 100644 (file)
index 0000000..0e0f016
--- /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.APLv2 file for Apache License terms and conditions.
diff --git a/data/dummy b/data/dummy
new file mode 100644 (file)
index 0000000..139597f
--- /dev/null
@@ -0,0 +1,2 @@
+
+
diff --git a/icons/screen-density-xhigh/mainmenu.png b/icons/screen-density-xhigh/mainmenu.png
new file mode 100644 (file)
index 0000000..b0979b1
Binary files /dev/null and b/icons/screen-density-xhigh/mainmenu.png differ
diff --git a/inc/ChannelService.h b/inc/ChannelService.h
new file mode 100644 (file)
index 0000000..3a4b7b6
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               ChannelService.h
+ * @brief              This is the header file of the Channel service daemon.
+ */
+
+
+#ifndef _CHANNEL_SERVICE_H_
+#define _CHANNEL_SERVICE_H_
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FIo.h>
+
+
+namespace Tizen { namespace Io {
+
+class _ChannelService;
+class _ChannelServiceStub;
+
+class _MessagePortService;
+class _MessagePortStub;
+} }
+
+
+/**
+ * [ChannelService] ServiceApp must inherit from ServiceApp class
+ * which provides basic features necessary to define an ServiceApp.
+ */
+class ChannelService
+       : public Tizen::App::ServiceApp
+{
+public:
+
+       /**
+        * [ChannelService] ServiceApp must have a factory method that creates an instance of itself.
+        */
+       static Tizen::App::ServiceApp* CreateInstance(void);
+
+public:
+
+       ChannelService();
+       ~ChannelService();
+
+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);
+
+private:
+       Tizen::Io::_ChannelService*     __pChannelService;
+       Tizen::Io::_ChannelServiceStub* __pChannelServiceStub;
+
+       Tizen::Io::_MessagePortService* __pMessagePortService;
+       Tizen::Io::_MessagePortStub*    __pMessagePortStub;
+}; // ChannelService
+
+#endif // _CHANNEL_SERVICE_H_
diff --git a/inc/FIo_MessagePortService.h b/inc/FIo_MessagePortService.h
new file mode 100644 (file)
index 0000000..a9a3a58
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FIo_MessagePortService.h
+ * @brief      This is the header file for the _MessagePortService class.
+ *
+ * This file contains the declarations of _MessagePortService.
+ */
+
+#ifndef _FIO_INTERNAL_MESSAGE_PORT_SERVICE_H_
+#define _FIO_INTERNAL_MESSAGE_PORT_SERVICE_H_
+
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColHashMapT.h>
+#include <FAppTypes.h>
+
+namespace IPC
+{
+class Message;
+}
+
+namespace Tizen { namespace Io
+{
+
+class _MessagePortStub;
+
+class _MessagePortService
+{
+public:
+       _MessagePortService(void);
+
+       virtual ~_MessagePortService(void);
+
+       virtual result Construct(_MessagePortStub& stub);
+
+       virtual result RegisterMessagePort(const Tizen::Base::String& appId,
+                                                                       const Tizen::Base::String& port,
+                                                                  int clientId,
+                                                                  bool isTrusted);
+
+       virtual result RequestRemotePort(const Tizen::App::AppId& remoteAppId,
+                                                                       const Tizen::Base::String& remotePort,
+                                                                  bool isTrusted);
+
+       result UnregisterMessagePort(int clientId);
+
+       virtual result SendMessage(const Tizen::Base::String& dest,
+                                                       const Tizen::Base::String& destPort,
+                                                       bool isTrusted,
+                                                       const Tizen::Base::Collection::HashMap* pMap);
+
+       virtual result SendMessage(const Tizen::Base::String& src,
+                                                       const Tizen::Base::String& srcPort,
+                                                       bool isTrustedSrc,
+                                                       const Tizen::Base::String& dest,
+                                                       const Tizen::Base::String& destPort,
+                                                       bool isTrustedDest,
+                                                       const Tizen::Base::Collection::HashMap* pMap);
+
+private:
+       Tizen::Base::String GetKey(const Tizen::Base::String& appId, const Tizen::Base::String& port) const;
+
+       class _StringHashProvider
+               : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
+       {
+       public:
+               virtual int GetHashCode(const Tizen::Base::String& value) const
+               {
+                       return value.GetHashCode();
+               }
+       };
+
+       class _StringComparer
+               : public Tizen::Base::Collection::IComparerT<Tizen::Base::String>
+       {
+       public:
+               virtual result Compare(const Tizen::Base::String& string1, const Tizen::Base::String& string2, int& cmp) const
+               {
+                       cmp = string1.CompareTo(string2);
+                       return E_SUCCESS;
+               }
+       };
+
+private:
+       _MessagePortStub* __pStub;
+
+       Tizen::Base::Collection::HashMapT <Tizen::Base::String, int>* __pPorts;
+       Tizen::Base::Collection::HashMapT <Tizen::Base::String, int>* __pTrustedPorts;
+}; // _MessagePortService
+
+} } // Tizen::Io
+
+#endif // _FIO_INTERNAL_MESSAGE_PORT_SERVICE_H_
diff --git a/inc/FIo_MessagePortStub.h b/inc/FIo_MessagePortStub.h
new file mode 100644 (file)
index 0000000..e56693d
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FIo_MessagePortStub.h
+ * @brief      This is the header file for the _MessagePortStub class.
+ *
+ * This file contains the declarations of _MessagePortStub.
+ */
+
+
+#ifndef _FIO_INTERNAL_MESSAGE_PORT_STUB_H_
+#define _FIO_INTERNAL_MESSAGE_PORT_STUB_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColHashMap.h>
+#include <FAppTypes.h>
+
+#include <FIo_IIpcServerEventListener.h>
+
+namespace IPC
+{
+class Message;
+}
+
+namespace Tizen { namespace Io
+{
+class _IpcServer;
+
+class _MessagePortService;
+
+class _MessagePortStub
+       : public Tizen::Io::_IIpcServerEventListener
+{
+public:
+       _MessagePortStub(void);
+       virtual ~_MessagePortStub(void);
+
+       virtual result Construct(void);
+
+       result SendMessage(int clientId,
+                                               const Tizen::Base::String& destPort,
+                                               bool isTrusted,
+                                               const Tizen::Base::Collection::HashMap* pMap);
+
+       result SendMessage(int clientId,
+                                               const Tizen::Base::String& destPort,
+                                               bool isTrustedDest,
+                                               const Tizen::Base::String& src,
+                                               const Tizen::Base::String& srcPort,
+                                               bool isTrustedSrc,
+                                               const Tizen::Base::Collection::HashMap* pMap);
+
+       void SetMessagePortService(_MessagePortService& service);
+
+
+private:
+       bool OnRegisterMessagePort(const Tizen::Base::String& appId, const Tizen::Base::String& port, bool isTrusted,  int* pResult);
+
+       bool OnRequestRemotePort(const Tizen::App::AppId& remoteAppId, const Tizen::Base::String& remotePort, bool isTrusted, int* pResult);
+
+       bool OnSendMessage(const Tizen::Base::String& dest,
+                                       const Tizen::Base::String& destPort,
+                                       bool isTrusted,
+                                       const Tizen::Base::Collection::HashMap& map,
+                                       int* pResult);
+
+       bool OnSendBidirMessage(const Tizen::Base::String& src,
+                                                       const Tizen::Base::String& srcPort,
+                                                       bool isTrusted,
+                                                       const Tizen::Base::String& dest,
+                                                       const Tizen::Base::String& destPort,
+                                                       const Tizen::Base::Collection::HashMap& map,
+                                                       int* pResult);
+
+       bool OnSendTrustedBidirMessage(const Tizen::Base::String& src,
+                                                       const Tizen::Base::String& srcPort,
+                                                       bool isTrusted,
+                                                       const Tizen::Base::String& dest,
+                                                       const Tizen::Base::String& destPort,
+                                                       const Tizen::Base::Collection::HashMap& map,
+                                                       int* pResult);
+
+       virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
+
+       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);
+
+       _MessagePortStub(const _MessagePortStub& value);
+       _MessagePortStub& operator = (const _MessagePortStub& value);
+
+private:
+       Tizen::Io::_IpcServer* __pIpcServer;
+       _MessagePortService* __pService;
+
+}; // _MessagePortStub
+
+} } // Tizen::Io
+
+#endif // _FIO_INTERNAL_MESSAGE_PORT_STUB_H_
+
diff --git a/manifest.xml b/manifest.xml
new file mode 100644 (file)
index 0000000..de93d5a
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/06/manifest">
+    <Id>cp7ipabg4k</Id>
+    <Version>1.0.0</Version>
+    <Type>C++App</Type>
+    <Vendors>
+        <Vendor Locale="eng-GB">Samsung Electronics</Vendor>
+    </Vendors>
+    <Descriptions>
+        <Description Locale="eng-GB"/>
+    </Descriptions>
+    <Url/>
+    <DeviceProfile>
+        <Property Name="GLTextureFormat"/>
+    </DeviceProfile>
+    <Apps>
+        <ApiVersion>2.1</ApiVersion>
+        <Secret>9C645DDBA19C71BAD1204DA4DAA7A0B9</Secret>
+        <Privileges/>
+        <ServiceApp Default="True" ExecutableName="osp-channel-service">
+            <Names>
+                <Name Locale="eng-GB">osp-channel-service</Name>
+            </Names>
+                       <Icons/>
+            <AppControls/>
+            <DataControls/>
+            <LaunchConditions/>
+                       <Notifications/>
+        </ServiceApp>
+    </Apps>
+</Manifest>
diff --git a/osp-channel-service.manifest b/osp-channel-service.manifest
new file mode 100644 (file)
index 0000000..051ee21
--- /dev/null
@@ -0,0 +1,12 @@
+<manifest>
+       <define>
+               <domain name="osp-channel-service"/>
+       </define>
+       <request>
+               <domain name="osp-channel-service"/>
+       </request>
+       <assign>
+               <filesystem path="/usr/apps/cp7ipabg4k/bin/osp-channel-service.sh" label="osp-channel-service" exec_label="osp-channel-service"/>
+               <filesystem path="/usr/share/license/osp-channel-service" label="_"/>
+       </assign>
+</manifest>
\ No newline at end of file
diff --git a/packaging/osp-channel-service.spec b/packaging/osp-channel-service.spec
new file mode 100755 (executable)
index 0000000..8b6f0c2
--- /dev/null
@@ -0,0 +1,62 @@
+Name:          osp-channel-service
+Summary:       osp channel service
+Version:       1.2.0.0
+Release:       1
+Group:         TO_BE/FILLED_IN
+License:    Apache License, Version 2.0
+Source0:       %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(osp-appfw)
+BuildRequires: pkgconfig(chromium)
+BuildRequires:  osp-appfw-internal-devel
+
+# runtime requires
+Requires: osp-appfw 
+Requires: osp-installer
+Requires: osp-app-service
+
+Requires(post): coreutils
+
+%description
+osp channel service
+
+%prep
+%setup -q
+
+%build 
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%ifarch %{ix86}
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+%else
+CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+%endif
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2  %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post
+
+/bin/rm -fr /opt/apps/cp7ipabg4k
+
+/usr/etc/package-manager/backend/tpk -i /usr/apps/cp7ipabg4k
+cp -f %{_libdir}/osp/osp-system-service-loader /usr/apps/cp7ipabg4k/bin/osp-channel-service
+if [ -f /usr/lib/rpm-plugins/msm.so ]
+then
+       chsmack -a osp-channel-service /usr/apps/cp7ipabg4k/bin/osp-channel-service
+       chsmack -e osp-channel-service /usr/apps/cp7ipabg4k/bin/osp-channel-service
+fi
+
+#%postun -p /sbin/ldconfig
+
+%files
+%manifest osp-channel-service.manifest
+/usr/share/license/%{name}
+/usr/apps/*
diff --git a/src/ChannelService.cpp b/src/ChannelService.cpp
new file mode 100644 (file)
index 0000000..0fd9f8c
--- /dev/null
@@ -0,0 +1,172 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        ChannelService.cpp
+ * @brief      This is the implementation for the ChannelService class.
+ */
+
+#include "ChannelService.h"
+
+#include <FBaseSysLog.h>
+#include <FIo_ChannelService.h>
+#include <FIo_ChannelServiceStub.h>
+#include <FIo_ChannelServiceManager.h>
+
+#include <FIo_MessagePortStub.h>
+#include <FIo_MessagePortService.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::App;
+
+ChannelService::ChannelService()
+: __pChannelService(null)
+, __pChannelServiceStub(null)
+, __pMessagePortService(null)
+, __pMessagePortStub(null)
+{
+       SysLog(NID_IO, "Enter.");
+}
+
+ChannelService::~ChannelService()
+{
+       SysLog(NID_IO, "Exit.");
+
+       delete __pChannelService;
+       delete __pChannelServiceStub;
+
+       delete __pMessagePortService;
+       delete __pMessagePortStub;
+}
+
+ServiceApp*
+ChannelService::CreateInstance(void)
+{
+       // Create the instance through the constructor.
+       return new ChannelService();
+}
+
+bool
+ChannelService::OnAppInitializing(AppRegistry& appRegistry)
+{
+       result r = E_SUCCESS;
+
+       __pChannelServiceStub = new (std::nothrow) _ChannelServiceStub();
+       if (__pChannelServiceStub == null)
+       {
+               return false;
+       }
+
+       r = __pChannelServiceStub->Construct();
+       if (IsFailed(r))
+       {
+               delete __pChannelServiceStub;
+               __pChannelServiceStub = null;
+
+               return false;
+       }
+
+       __pChannelService = new (std::nothrow) _ChannelService;
+       if (__pChannelService == null)
+       {
+               delete __pChannelServiceStub;
+               __pChannelServiceStub = null;
+
+               return false;
+       }
+
+       r = __pChannelService->Construct(*__pChannelServiceStub);
+       if (IsFailed(r))
+       {
+               delete __pChannelService;
+               __pChannelService = null;
+
+               delete __pChannelServiceStub;
+               __pChannelServiceStub = null;
+
+               return false;
+       }
+
+       _ChannelServiceManager::GetInstance()->SetChannelService(__pChannelService);
+
+
+       // Message Port
+       __pMessagePortStub = new (std::nothrow) _MessagePortStub();
+       if (__pMessagePortStub == null)
+       {
+               return false;
+       }
+
+       r = __pMessagePortStub->Construct();
+       if (IsFailed(r))
+       {
+               delete __pMessagePortStub;
+               __pMessagePortStub = null;
+
+               return false;
+       }
+
+       __pMessagePortService = new (std::nothrow) _MessagePortService();
+       if (__pMessagePortService == null)
+       {
+               delete __pMessagePortStub;
+               __pMessagePortStub = null;
+
+               return false;
+       }
+
+       r = __pMessagePortService->Construct(*__pMessagePortStub);
+       if (IsFailed(r))
+       {
+               delete __pMessagePortService;
+               __pMessagePortService = null;
+
+               delete __pMessagePortStub;
+               __pMessagePortStub = null;
+
+               return false;
+       }
+
+       __pMessagePortStub->SetMessagePortService(*__pMessagePortService);
+
+       return true;
+}
+
+bool
+ChannelService::OnAppInitialized(void)
+{
+       return true;
+}
+
+bool
+ChannelService::OnAppWillTerminate(void)
+{
+       return true;
+}
+
+bool
+ChannelService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+       return true;
+}
+
+void
+ChannelService::OnLowMemory(void)
+{
+}
+
diff --git a/src/ChannelServiceEntry.cpp b/src/ChannelServiceEntry.cpp
new file mode 100644 (file)
index 0000000..a5fa2a8
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "ChannelService.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // __cplusplus
+
+_OSP_EXPORT_ int OspMain(int argc, char*pArgv[]);
+
+int
+OspMain(int argc, char* pArgv[])
+{
+       result r = E_SUCCESS;
+
+       AppLog("Application started.");
+       ArrayList* pArgs = new (std::nothrow) ArrayList();
+       pArgs->Construct();
+       for (int i = 0; i < argc; i++)
+       {
+               pArgs->Add(*(new (std::nothrow) String(pArgv[i])));
+       }
+
+       r = Tizen::App::ServiceApp::Execute(ChannelService::CreateInstance, pArgs);
+       if (IsFailed(r))
+       {
+               AppLogException("Application execution failed - [%s].", GetErrorMessage(r));
+               r &= 0x0000FFFF;
+       }
+
+       pArgs->RemoveAll(true);
+       delete pArgs;
+       AppLog("Application finished.");
+
+       return static_cast<int>(r);
+}
+#ifdef __cplusplus
+}
+#endif // __cplusplus
diff --git a/src/FIo_MessagePortService.cpp b/src/FIo_MessagePortService.cpp
new file mode 100644 (file)
index 0000000..5719aca
--- /dev/null
@@ -0,0 +1,238 @@
+// // Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FIo_MessagePortService.cpp
+ * @brief      This is the implementation file for the _MessagePortService class.
+ *
+ */
+
+#include <unique_ptr.h>
+
+#include <FBaseStringComparer.h>
+#include <FBaseSysLog.h>
+
+#include "FIo_MessagePortStub.h"
+#include "FIo_MessagePortService.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+using namespace Tizen::App;
+
+namespace Tizen { namespace Io
+{
+
+_MessagePortService::_MessagePortService(void)
+       : __pStub(null)
+{
+
+}
+
+_MessagePortService::~_MessagePortService(void)
+{
+
+}
+
+result
+_MessagePortService::Construct(_MessagePortStub& stub)
+{
+       static _StringHashProvider hashProvider;
+       static _StringComparer stringComparer;
+       result r = E_SUCCESS;
+
+       __pPorts = new HashMapT <String, int>();
+       __pPorts->Construct(0, 0, hashProvider, stringComparer);
+
+       __pTrustedPorts = new HashMapT <String, int>();
+       __pTrustedPorts->Construct(0, 0, hashProvider, stringComparer);
+
+       __pStub = &stub;
+
+       return E_SUCCESS;
+}
+
+result
+_MessagePortService::RegisterMessagePort(const String& appId, const String& port, int clientId, bool isTrusted)
+{
+       result r = E_SUCCESS;
+       bool out = false;
+       int id = 0;
+
+       String key = GetKey(appId, port);
+
+       if (!isTrusted)
+       {
+               __pPorts->ContainsKey(key, out);
+               SysTryReturnResult(NID_IO, !out, E_SYSTEM,  "The port (%ls) has already registered", key.GetPointer());
+
+               __pPorts->Add(key, clientId);
+       }
+       else
+       {
+               __pTrustedPorts->ContainsKey(key, out);
+               SysTryReturnResult(NID_IO, !out, E_SYSTEM,  "The trusted port (%ls) has already registered", key.GetPointer());
+
+               __pTrustedPorts->Add(key, clientId);
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_MessagePortService::RequestRemotePort(const AppId& remoteAppId, const String& remotePort, bool isTrusted)
+{
+       result r = E_SUCCESS;
+       bool out = false;
+       int id = 0;
+
+       String key = GetKey(remoteAppId, remotePort);
+
+       if (!isTrusted)
+       {
+               __pPorts->ContainsKey(key, out);
+               SysTryReturnResult(NID_IO, out, E_OBJ_NOT_FOUND,
+                               "The remote message port (%ls) is not found.", key.GetPointer());
+       }
+       else
+       {
+               __pTrustedPorts->ContainsKey(key, out);
+               SysTryReturnResult(NID_IO, out, E_OBJ_NOT_FOUND,
+                               "The trusted remote message port (%ls) is not found.", key.GetPointer());
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_MessagePortService::UnregisterMessagePort(int clientId)
+{
+       result r = E_OBJ_NOT_FOUND;
+
+       int value = 0;
+       int count = __pPorts->GetCount();
+
+       String key;
+       IListT<String>* pKeys = __pPorts->GetKeysN();
+       SysTryReturnResult(NID_IO, pKeys != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       for (int i = 0; i < count; i++)
+       {
+               pKeys->GetAt(i, key);
+               __pPorts->GetValue(key, value);
+               if (value == clientId)
+               {
+                       SysLog(NID_IO, "Unregister - key = %ls", key.GetPointer());
+
+                       __pPorts->Remove(key);
+
+                       r = E_SUCCESS;
+               }
+       }
+
+       delete pKeys;
+
+       count = __pTrustedPorts->GetCount();
+       pKeys = __pTrustedPorts->GetKeysN();
+       SysTryReturnResult(NID_IO, pKeys != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       for (int i = 0; i < count; i++)
+       {
+               pKeys->GetAt(i, key);
+               __pTrustedPorts->GetValue(key, value);
+               if (value == clientId)
+               {
+                       SysLog(NID_IO, "Unregister - key = %ls", key.GetPointer());
+
+                       __pTrustedPorts->Remove(key);
+
+                       r = E_SUCCESS;
+               }
+       }
+
+       delete pKeys;
+
+       return r;
+}
+
+result
+_MessagePortService::SendMessage(const String& dest, const String& destPort,
+                                                               bool isTrusted, const HashMap* pMap)
+{
+       result r = E_SUCCESS;
+
+       int clientId = 0;
+       String key = GetKey(dest, destPort);
+
+       if (!isTrusted)
+       {
+               __pPorts->GetValue(key, clientId);
+       }
+       else
+       {
+               __pTrustedPorts->GetValue(key, clientId);
+       }
+
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, E_OBJ_NOT_FOUND,
+                               "The destination message port is not found.");
+
+       r = __pStub->SendMessage(clientId, destPort, isTrusted, pMap);
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Failed to send a message");
+
+       return E_SUCCESS;
+}
+
+result
+_MessagePortService::SendMessage(const String& src, const String& srcPort, bool isTrustedSrc,
+                                                               const String& dest, const String& destPort, bool isTrustedDest,
+                                                               const HashMap* pMap)
+{
+       result r = E_SUCCESS;
+       int clientId = 0;
+
+       String key = GetKey(dest, destPort);
+
+       if (!isTrustedDest)
+       {
+               r = __pPorts->GetValue(key, clientId);
+       }
+       else
+       {
+               r = __pTrustedPorts->GetValue(key, clientId);
+       }
+
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, E_OBJ_NOT_FOUND,
+                               "The destination message port is not found.");
+
+       r = __pStub->SendMessage(clientId, destPort, isTrustedDest, src, srcPort, isTrustedSrc, pMap);
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Failed to send a message");
+
+       return E_SUCCESS;
+}
+
+String 
+_MessagePortService::GetKey(const String& appId, const String& port) const
+{
+       String key(appId);
+       key.Append(L':');
+       key.Append(port);
+
+       return key;
+}
+
+} } // Tizen::Io
+
diff --git a/src/FIo_MessagePortStub.cpp b/src/FIo_MessagePortStub.cpp
new file mode 100644 (file)
index 0000000..fa05a40
--- /dev/null
@@ -0,0 +1,238 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FIo_MessagePortStub.cpp
+ * @brief      This is the implementation file for the  _MessagePortStub class.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include <FIo_IpcServer.h>
+#include <FIo_MessagePortMessages.h>
+
+#include "FIo_MessagePortStub.h"
+#include "FIo_MessagePortService.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Io;
+using namespace Tizen::App;
+
+namespace Tizen { namespace Io
+{
+
+_MessagePortStub::_MessagePortStub(void)
+       : __pIpcServer(null)
+       , __pService(null)
+{
+
+}
+
+_MessagePortStub::~_MessagePortStub(void)
+{
+       delete __pIpcServer;
+}
+
+result
+_MessagePortStub::Construct(void)
+{
+       SysAssertf(__pIpcServer == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+       _IpcServer* pIpcServer = null;
+
+       pIpcServer = new (std::nothrow) _IpcServer;
+       SysTryReturnResult(NID_IO, pIpcServer != null, E_OUT_OF_MEMORY, "Not enough memory.");
+
+       r = pIpcServer->Construct("osp.io.ipcserver.messageportmanager", *this, false);
+       SysTryCatch(NID_IO, !IsFailed(r), , r, "[%s] Failed to create IPC server(MessagePort)", GetErrorMessage(r));
+
+       __pIpcServer = pIpcServer;
+
+       return E_SUCCESS;
+
+CATCH:
+       delete pIpcServer;
+
+       return r;
+}
+
+void
+_MessagePortStub::SetMessagePortService(_MessagePortService& service)
+{
+       __pService = &service;
+}
+
+bool
+_MessagePortStub::OnRegisterMessagePort(const String& appId, const String& port, bool isTrusted, int* pResult)
+{
+       SysAssertf(__pService != null, "Message port service has not been initialized.\n");
+
+       int clientId = __pIpcServer->GetClientId();
+
+       SysLog(NID_IO, "Register a message port: [%ls:%ls], client id = %d", appId.GetPointer(), port.GetPointer(), clientId);
+
+       *pResult = __pService->RegisterMessagePort(appId, port, clientId, isTrusted);
+
+       return true;
+}
+
+bool
+_MessagePortStub::OnRequestRemotePort(const AppId& remoteAppId, const String& remotePort, bool isTrusted, int* pResult)
+{
+       SysAssertf(__pService != null, "Message port service has not been initialized.\n");
+
+       int clientId = __pIpcServer->GetClientId();
+
+       SysLog(NID_IO, "Request a remote message port: [%ls:%ls]", remoteAppId.GetPointer(), remotePort.GetPointer());
+
+       *pResult = __pService->RequestRemotePort(remoteAppId, remotePort, isTrusted);
+
+       return true;
+}
+
+bool
+_MessagePortStub::OnSendMessage(const String& dest, const String& destPort,
+                                                               bool isTrusted, const HashMap& map,
+                                                               int* pResult)
+{
+       SysAssertf(__pService != null, "MessagePort service has not been initialized.\n");
+
+       SysLog(NID_IO, "Message is sent to [%ls:%ls]", dest.GetPointer(), destPort.GetPointer());
+
+       if (!isTrusted)
+       {
+               *pResult = __pService->SendMessage(dest, destPort, false, &map);
+       }
+       else
+       {
+               *pResult = __pService->SendMessage(dest, destPort, true, &map);
+       }
+
+       const_cast<HashMap*>(&map)->RemoveAll(true);
+
+       return true;
+}
+
+bool
+_MessagePortStub::OnSendBidirMessage(const String& src, const String& srcPort, bool isTrusted,
+                                                               const String& dest, const String& destPort,
+                                                               const HashMap& map, int* pResult)
+{
+       SysAssertf(__pService != null, "MessagePort service has not been initialized.\n");
+
+       SysLog(NID_IO, "[%ls:%ls] sends a message to [%ls:%ls]", src.GetPointer(), srcPort.GetPointer(), dest.GetPointer(), destPort.GetPointer());
+
+       *pResult = __pService->SendMessage(src, srcPort, isTrusted, dest, destPort, false, &map);
+
+       const_cast<HashMap*>(&map)->RemoveAll(true);
+
+       return true;
+}
+
+bool
+_MessagePortStub::OnSendTrustedBidirMessage(const String& src, const String& srcPort, bool isTrusted,
+                                                               const String& dest, const String& destPort,
+                                                               const HashMap& map, int* pResult)
+{
+       SysAssertf(__pService != null, "MessagePort service has not been initialized.\n");
+
+       SysLog(NID_IO, "[%ls:%ls] sends a message to [%ls:%ls]", src.GetPointer(), srcPort.GetPointer(), dest.GetPointer(), destPort.GetPointer());
+
+       *pResult = __pService->SendMessage(src, srcPort, isTrusted, dest, destPort, true, &map);
+
+       const_cast<HashMap*>(&map)->RemoveAll(true);
+
+       return true;
+}
+
+result
+_MessagePortStub::SendMessage(int clientId, const String& destPort, bool isTrusted, const HashMap* pMap)
+{
+       SysAssertf(__pService != null, "MessagePort service has not been initialized.\n");
+
+       SysLog(NID_IO, "Sends a message to port [%ls]", destPort.GetPointer());
+
+       if (pMap != null)
+       {
+               result r = __pIpcServer->SendResponse(clientId, new MessagePortService_sendMessageAsync(destPort, isTrusted, *pMap));
+               SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "Failed to send a response message.");
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_MessagePortStub::SendMessage(int clientId, const String& destPort, bool isTrustedDest, const String& src, const String& srcPort, bool isTrustedSrc, const HashMap* pMap)
+{
+       SysAssertf(__pService != null, "MessagePort service has not been initialized.\n");
+
+       SysLog(NID_IO, "[%ls:%ls] sends a message to port [%ls]", src.GetPointer(), srcPort.GetPointer(), destPort.GetPointer());
+
+       if (pMap != null)
+       {
+               result r = __pIpcServer->SendResponse(clientId, new MessagePortService_sendBidirMessageAsync(destPort, isTrustedDest, src, srcPort, isTrustedSrc, *pMap));
+               SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "Failed to send a response message.");
+       }
+
+       return E_SUCCESS;
+
+}
+
+void
+_MessagePortStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
+{
+       IPC_BEGIN_MESSAGE_MAP(_MessagePortStub, message)
+       IPC_MESSAGE_HANDLER_EX(MessagePortService_register, &server, OnRegisterMessagePort)
+       IPC_MESSAGE_HANDLER_EX(MessagePortService_requestRemotePort, &server, OnRequestRemotePort)
+       IPC_MESSAGE_HANDLER_EX(MessagePortService_sendMessage, &server, OnSendMessage)
+       IPC_MESSAGE_HANDLER_EX(MessagePortService_sendBidirMessage, &server, OnSendBidirMessage)
+       IPC_MESSAGE_HANDLER_EX(MessagePortService_sendTrustedBidirMessage, &server, OnSendTrustedBidirMessage)
+       IPC_END_MESSAGE_MAP_EX()
+}
+
+void
+_MessagePortStub::OnIpcServerStarted(const _IpcServer& server)
+{
+
+}
+
+void
+_MessagePortStub::OnIpcServerStopped(const _IpcServer& server)
+{
+
+}
+
+void
+_MessagePortStub::OnIpcClientConnected(const _IpcServer& server, int clientId)
+{
+
+}
+
+void
+_MessagePortStub::OnIpcClientDisconnected(const _IpcServer& server, int clientId)
+{
+       SysAssertf(__pService != null, "Channel service has not been initialized.\n");
+       SysLog(NID_IO, "Unregister - clientId =  %d", clientId);
+
+       __pService->UnregisterMessagePort(clientId);
+}
+
+} } // Tizen::Io
+
diff --git a/system-service-export.ver b/system-service-export.ver
new file mode 100644 (file)
index 0000000..68c06a8
--- /dev/null
@@ -0,0 +1,6 @@
+{
+global:
+       OspMain;
+local:
+       *;
+};